using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;
using BLL;
using System.Data;
namespace ComResProSystem
{
    /// <summary>
    /// FindUser 的摘要说明
    /// </summary>
    [WebService(Namespace = "http://tempuri.org/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    [System.ComponentModel.ToolboxItem(false)]
    // 若要允许使用 ASP.NET AJAX 从脚本中调用此 Web 服务，请取消对下行的注释。
    [System.Web.Script.Services.ScriptService]
    public class FindUser : System.Web.Services.WebService
    {
        UserBll bll = new UserBll();
        [WebMethod]
        public List<string> Users(string prefixText,int count)
        {
            List<string> list = new List<string>();
            string sql = "SELECT  TOP 10  UserName FROM Users WHERE UserName LIKE '"+prefixText+"%'";
            DataTable dt = bll.gettable(sql);
            for(int i=0;i<dt.Rows.Count;i++)
            {
                list.Add(dt.Rows[i]["UserName"].ToString());
            }
            return list;
        }
         [WebMethod]
        public List<string> Recipients(string prefixText, int count)
        {
            List<string> list = new List<string>();
            string sql = "SELECT  TOP 10  Recipients FROM mail WHERE Recipients LIKE '" + prefixText + "%'";
            DataTable dt = bll.gettable(sql);
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                list.Add(dt.Rows[i]["Recipients"].ToString());
            }
            return list;
        }
    }
}
