⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 autocompletedservice.cs

📁 很好的技术
💻 CS
字号:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;
using System.Data.Linq.SqlClient;
using System.Data.Linq;

/// <summary>
/// Summary description for AutoCompletedService
/// </summary>
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
// To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line. 
[System.Web.Script.Services.ScriptService]
public class AutoCompletedService : System.Web.Services.WebService {

    public AutoCompletedService () {

        //Uncomment the following line if using designed components 
        //InitializeComponent(); 
    }

    [WebMethod]
    public string[] GetUnitCodeList(string prefixText, int count)
    {
        Pub_paraDataContext db = new Pub_paraDataContext();
        //Table<UNIT> unittable = db.GetTable<UNIT>();
        var resultQuery = from c in db.UNITs
                          where SqlMethods.Like(c.UNIT_CODE, "%" + prefixText + "%")
                          select c;
        int len = resultQuery.ToArray<UNIT>().Length;
        if (len > count)
        {
            len = count;
        }
        List<string> items = new List<string>(len);

        foreach (UNIT u in resultQuery)
        {
            items.Add(AjaxControlToolkit.AutoCompleteExtender.CreateAutoCompleteItem(u.UNIT_NAME, u.UNIT_CODE));
        }
        return items.ToArray();

    }
    [WebMethod]
    public string[] GetCountryCodeList(string prefixText, int count)
    {
        Pub_paraDataContext db = new Pub_paraDataContext();
        //Table<UNIT> unittable = db.GetTable<UNIT>();
        var resultQuery = from c in db.COUNTRies
                          where SqlMethods.Like(c.COUNTRY_CO,  prefixText + "%")
                          select c;
        
        int len = resultQuery.ToArray<COUNTRY>().Length;
        //int len = 10;
        if (len > count)
        {
            len = count;
        }
        List<string> items = new List<string>(len);

        foreach (COUNTRY u in resultQuery)
        {
            items.Add(AjaxControlToolkit.AutoCompleteExtender.CreateAutoCompleteItem(u.COUNTRY_NA, u.COUNTRY_CO));
        }
        return items.ToArray();

    }
    [WebMethod]
    public string[] GetCurrCodeList(string prefixText, int count)
    {
        Pub_paraDataContext db = new Pub_paraDataContext();
        //Table<UNIT> unittable = db.GetTable<UNIT>();
        var resultQuery = from c in db.CURRs
                          where SqlMethods.Like(c.CURR_CODE, "%" + prefixText + "%")
                          select c;
        int len = resultQuery.ToArray<CURR>().Length;
        if (len > count)
        {
            len = count;
        }
        List<string> items = new List<string>(len);

        foreach (CURR u in resultQuery)
        {
            items.Add(AjaxControlToolkit.AutoCompleteExtender.CreateAutoCompleteItem(u.CURR_NAME, u.CURR_CODE));
        }
        return items.ToArray();

    }
    
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -