Пример #1
0
        private void Query(HttpContext context)
        {
            var stuName = context.Request["name"];
            var school = context.Request["sch"];
            var ds = new DataSet();
            var sysUserBll = new BLL.SysUser();
            var strWhere = "";
            if (!string.IsNullOrEmpty(stuName))
            {
                strWhere = string.Format(" UserName like '%" + stuName + "%' ");
            }
            if (!string.IsNullOrEmpty(school))
            {
                if (!string.IsNullOrEmpty(strWhere))
                {
                    strWhere += string.Format(" and  UserRole=" + school + " ");
                }
                else
                {
                    strWhere = string.Format(" UserRole=" + school + " ");
                }
            }
              //  ds = sysUserBll.GetList(strWhere);

            var page = Convert.ToInt32(context.Request["page"]);
            var rows = Convert.ToInt32(context.Request["rows"]);
            var startIndex = (page - 1) * rows + 1;
            var endIndex = startIndex + rows - 1;
            var sort = string.IsNullOrEmpty(context.Request["sort"]) ? "UserName" : context.Request["sort"];
            var order = string.IsNullOrEmpty(context.Request["order"]) ? "asc" : context.Request["order"];

            if (sort == "UserRoleName")
            {
                sort = "UserRole";
            }

            var num = sysUserBll.GetRecordCount(strWhere);
            ds = sysUserBll.GetListByPage(strWhere, sort, startIndex, endIndex,order);

            var str = JsonConvert.SerializeObject(new { total = num, rows = ds.Tables[0] });
            context.Response.Write(str);
        }
Пример #2
0
        private string GetData(HttpContext context)
        {
            var ds = new DataSet();
            var sysUserBll = new BLL.SysUser();

            var page = Convert.ToInt32(context.Request["page"]);
            var rows = Convert.ToInt32(context.Request["rows"]);
            var sort = string.IsNullOrEmpty(context.Request["sort"]) ? "UserName" : context.Request["sort"];
            var order = string.IsNullOrEmpty(context.Request["order"]) ? "asc" : context.Request["order"];

            if (sort == "UserRoleName")
            {
                sort = "UserRole";
            }

            var startIndex = (page - 1) * rows + 1;
            var endIndex = startIndex + rows - 1;

            var num = sysUserBll.GetRecordCount("");
            ds = sysUserBll.GetListByPage("", sort, startIndex, endIndex,order);

            var str = JsonConvert.SerializeObject(new { total =  num, rows = ds.Tables[0] });
            return str;
        }