public void ProcessRequest(HttpContext context) { HPCBusinessLogic.NguoidungDAL _NguoidungDAL = new NguoidungDAL(); DataTable dt = new DataTable(); string sqlselect = string.Empty; string type = context.Request.QueryString["type"].Split('?').GetValue(0).ToString(); string searchText = context.Request.QueryString["term"]; Collection <AutoCompleteDTO> collection; collection = new Collection <AutoCompleteDTO>(); AutoCompleteDTO dto; if (type == "1") { sqlselect = "select top 20 Ma_Nguoidung, LTRIM(RTRIM(TenDaydu))+case when Loai=1 then ' -- (CTV)' when Loai=0 then '' end as Ten_Dangnhap from T_Nguoidung where (Trangthai_Xoa=0 or Trangthai_Xoa is null) and TenDaydu LIKE N'%" + searchText.Trim() + "%' and Ten_Dangnhap is not null"; dt = Ulti.ExecSqlDataSet(sqlselect).Tables[0]; for (int i = 0; i < dt.Rows.Count; i++) { dto = new AutoCompleteDTO(); dto.value = dto.label = (string)dt.Rows[i]["Ten_Dangnhap"]; dto.id = Convert.ToString(dt.Rows[i]["Ma_Nguoidung"]); collection.Add(dto); } } if (type == "2") { string _where = "IsDeleted = 0 and UserFullName LIKE N'%" + searchText.Trim() + "%'"; dt = _NguoidungDAL.GetT_User_Dynamic(_where).Tables[0]; for (int i = 0; i < dt.Rows.Count; i++) { dto = new AutoCompleteDTO(); dto.value = dto.label = (string)dt.Rows[i]["UserFullName"]; dto.id = Convert.ToString(dt.Rows[i]["UserID"]); collection.Add(dto); } } JavaScriptSerializer serializer = new JavaScriptSerializer(); string jsonString = serializer.Serialize(collection); context.Response.Write(jsonString); }
private void LoadCombo() { //UltilFunc.BindCombox(ddlTenTruyCap, "UserID", "UserFullName", "T_U", " 1=1 Order by Ten_Dangnhap ASC", CommonLib.ReadXML("lblTatca")); ddlTraCuu.Items.Insert(0, new ListItem(CommonLib.ReadXML("lblTatca"), "0")); ddlTraCuu.Items.Insert(1, new ListItem("Tra cứu tin nguồn", "1")); ddlTraCuu.Items.Insert(2, new ListItem("Tra cứu tin tư liệu", "2")); ddlTraCuu.Items.Insert(3, new ListItem("Tra cứu ảnh", "3")); ddlTraCuu.SelectedIndex = 0; string _where = string.Empty; _where = " IsDeleted = 0 and UserActive=1 "; DataTable _dt = _userDAL.GetT_User_Dynamic(_where).Tables[0]; ddlTenTruyCap.DataSource = _dt; ddlTenTruyCap.DataTextField = "UserFullName"; ddlTenTruyCap.DataValueField = "UserID"; ddlTenTruyCap.DataBind(); ddlTenTruyCap.Items.Insert(0, "---All---"); }
public DataTable GetRecords(string prefixText, string contextKey) { DataTable _dt = new DataTable(); HPCBusinessLogic.NguoidungDAL _NguoidungDAL = new NguoidungDAL(); string _sql = string.Empty; _user = _NguoidungDAL.GetUserByUserName(HPCSecurity.CurrentUser.Identity.Name); UltilFunc ulti = new UltilFunc(); if (int.Parse(contextKey) != 3) { _sql = "select top 20 Ma_Nguoidung, LTRIM(RTRIM(TenDaydu))+case when Loai=1 then ' -- (CTV)' when Loai=0 then '' end as Ten_Dangnhap from T_Nguoidung where (Trangthai_Xoa=0 or Trangthai_Xoa is null) and TenDaydu LIKE N'%" + prefixText.Trim() + "%' and Ten_Dangnhap is not null "; _dt = ulti.ExecSqlDataSet(_sql).Tables[0]; } else { string _where = " IsDeleted = 0 and UserFullName LIKE N'%" + prefixText.Trim() + "%'"; _dt = _NguoidungDAL.GetT_User_Dynamic(_where).Tables[0]; } return(_dt); }