
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.ServiceModel.Activation;
using System.ServiceModel.Web;
using System.Text;
using System.Data.SqlClient;
using System.Data;

namespace ResMangSys
{
    [ServiceContract(Namespace = "")]
    [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
    public class GetBaStaNames
    {
        // 要使用 HTTP GET，请添加 [WebGet] 特性。(默认 ResponseFormat 为 WebMessageFormat.Json)
        // 要创建返回 XML 的操作，
        //     请添加 [WebGet(ResponseFormat=WebMessageFormat.Xml)]，
        //     并在操作正文中包括以下行:
        //         WebOperationContext.Current.OutgoingResponse.ContentType = "text/xml";
        [OperationContract]
        public void DoWork()
        {
            // 在此处添加操作实现
            return;
        }

        [OperationContract]
        public string[] GetBaStaNameList(string prefixText, int count, string contextkey)
        {
            if (prefixText.Trim() != "")
            {
                return GetList.GetDataList("select top 10 BaStaName from T_NetResLedg where BaStaName like '%" + prefixText.Trim() + "%'", "BaStaName");
            }
            return null;
            //SqlConnection conn;
            //SqlCommand cmd;
            //string cmdString = "select top 10 BaStaName from T_NetResLedg where BaStaName like '%" + prefixText + "%'";
            //conn = new SqlConnection(@"Data Source=.;Initial Catalog=ResMang;Integrated Security=True");
            //cmd = new SqlCommand(cmdString, conn);
            //conn.Open();
            //SqlDataReader myReader;
            //List<string> returnData = new List<string>();
            //myReader = cmd.ExecuteReader(CommandBehavior.CloseConnection);
            //while (myReader.Read())
            //{
            //    returnData.Add(myReader["BaStaName"].ToString());
            //}
            //return returnData.ToArray();
        }

        // 在此处添加更多操作并使用 [OperationContract] 标记它们
    }
}
