/// <summary> ///用户列表JSON /// </summary> /// <param name="keyword">模糊查询</param> /// <returns></returns> public ActionResult OptionUserJson(string keyword) { BaseUserBll userBLL = new BaseUserBll(); DataTable ListData = userBLL.OptionUserList(keyword); StringBuilder sb = new StringBuilder(); sb.Append("["); if (!DataHelper.IsExistRows(ListData)) { foreach (DataRow item in ListData.Rows) { sb.Append("{"); sb.Append("\"id\":\"" + item["userid"] + "\","); sb.Append("\"text\":\"" + item["realname"] + "(" + item["account"] + ")\","); sb.Append("\"account\":\"" + item["account"] + "\","); sb.Append("\"code\":\"" + item["code"] + "\","); sb.Append("\"realname\":\"" + item["realname"] + "\","); string Genderimg = "user_female.png"; if (item["Gender"].ToString() == "男") { Genderimg = "user_green.png"; } sb.Append("\"img\":\"/Content/Images/Icon16/" + Genderimg + "\","); sb.Append("\"isexpand\":true,"); sb.Append("\"hasChildren\":false"); sb.Append("},"); } sb = sb.Remove(sb.Length - 1, 1); } sb.Append("]"); return(Content(sb.ToString())); }
/// <summary> /// 查询前面50条用户信息(返回JSON) /// </summary> /// <param name="keywords">查询关键字</param> /// <returns></returns> public ActionResult Autocomplete(string keywords) { DataTable ListData = base_userbll.OptionUserList(keywords); return(Content(ListData.ToJson())); }