private void Query(HttpContext context) { var teachName = context.Request["name"].Trim(); var school = context.Request["sch"].Trim(); var gender = context.Request["gender"].Trim(); var title = context.Request["title"].Trim(); var idno = context.Request["idno"].Trim(); var ds = new DataSet(); var teaBll = new BLL.Teacher(); var strWhere = ""; if (!string.IsNullOrEmpty(teachName)) { strWhere = string.Format(" TeacherName like '%" + teachName + "%' "); } if (!string.IsNullOrEmpty(school)) { if (!string.IsNullOrEmpty(strWhere)) { strWhere += string.Format(" and Dept like '%" + school + "%' "); } else { strWhere = string.Format(" Dept like '%" + school + "%' "); } } if (!string.IsNullOrEmpty(gender)&&gender!="0") { if (!string.IsNullOrEmpty(strWhere)) { strWhere += string.Format(" and Gender like '%" + gender + "%' "); } else { strWhere = string.Format(" Gender like '%" + gender + "%' "); } } if (!string.IsNullOrEmpty(title)) { if (!string.IsNullOrEmpty(strWhere)) { strWhere += string.Format(" and Title like '%" + title + "%' "); } else { strWhere = string.Format(" Title like '%" + title + "%' "); } } if (!string.IsNullOrEmpty(idno)) { if (!string.IsNullOrEmpty(strWhere)) { strWhere += string.Format(" and IdentityNo like '%" + idno + "%' "); } else { strWhere = string.Format(" IdentityNo like '%" + idno + "%' "); } } // ds = teaBll.GetList(strWhere); var page = Convert.ToInt32(context.Request["page"]); var rows = Convert.ToInt32(context.Request["rows"]); var sort = string.IsNullOrEmpty(context.Request["sort"]) ? "TeacherName" : context.Request["sort"]; var order = string.IsNullOrEmpty(context.Request["order"]) ? "asc" : context.Request["order"]; if (sort == "GenderName") { sort = "Gender"; } var startIndex = (page - 1) * rows + 1; var endIndex = startIndex + rows - 1; var num = teaBll.GetRecordCount(strWhere); ds = teaBll.GetListByPage(strWhere, sort, startIndex, endIndex,order); var str = JsonConvert.SerializeObject(new { total = num, rows = ds.Tables[0] }); context.Response.Write(str); }
private string GetData(HttpContext context) { var ds = new DataSet(); var teaBll = new BLL.Teacher(); var page = Convert.ToInt32(context.Request["page"]); var rows = Convert.ToInt32(context.Request["rows"]); var sort = string.IsNullOrEmpty(context.Request["sort"]) ? "TeacherName" : context.Request["sort"]; var order = string.IsNullOrEmpty(context.Request["order"]) ? "asc" : context.Request["order"]; if (sort == "GenderName") { sort = "Gender"; } var startIndex = (page - 1) * rows + 1; var endIndex = startIndex + rows - 1; var num = teaBll.GetRecordCount(""); ds = teaBll.GetListByPage("", sort, startIndex, endIndex,order); var str = JsonConvert.SerializeObject(new { total = num, rows = ds.Tables[0] }); return str; }