private void Query(HttpContext context) { var corName = context.Request["name"].Trim(); var teaName = context.Request["teaName"].Trim(); var teaplace = context.Request["teaplace"].Trim(); var teaTime = context.Request["teaTime"].Trim(); var ds = new DataSet(); var courBll = new BLL.Course(); var strWhere = ""; if (!string.IsNullOrEmpty(corName)) { strWhere = string.Format(" CourseName like '%" + corName + "%' "); } if (!string.IsNullOrEmpty(teaName)) { if (!string.IsNullOrEmpty(strWhere)) { strWhere += string.Format(" and TeacherName like '%" + teaName + "%' "); } else { strWhere = string.Format(" TeacherName like '%" + teaName + "%' "); } } if (!string.IsNullOrEmpty(teaplace)) { if (!string.IsNullOrEmpty(strWhere)) { strWhere += string.Format(" and TeachPlace like '%" + teaplace + "%' "); } else { strWhere = string.Format(" TeachPlace like '%" + teaplace + "%' "); } } if (!string.IsNullOrEmpty(teaTime)) { if (!string.IsNullOrEmpty(strWhere)) { strWhere += string.Format(" and TeachTime like '%" + teaTime + "%' "); } else { strWhere = string.Format(" TeachTime like '%" + teaTime + "%' "); } } var page = Convert.ToInt32(context.Request["page"]); var rows = Convert.ToInt32(context.Request["rows"]); var sort = string.IsNullOrEmpty(context.Request["sort"]) ? "TeachTime" : context.Request["sort"]; var order = string.IsNullOrEmpty(context.Request["order"]) ? "asc" : context.Request["order"]; var startIndex = (page - 1)*rows + 1; var endIndex = startIndex + rows - 1; var num = courBll.GetRecordCount(strWhere); ds = courBll.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 courBll = new BLL.Course(); var page = Convert.ToInt32(context.Request["page"]); var rows = Convert.ToInt32(context.Request["rows"]); var sort = string.IsNullOrEmpty(context.Request["sort"]) ? "TeachTime" : context.Request["sort"]; var order = string.IsNullOrEmpty(context.Request["order"]) ? "desc" : context.Request["order"]; var startIndex = (page - 1) * rows + 1; var endIndex = startIndex + rows - 1; var num = courBll.GetRecordCount(""); ds = courBll.GetListByPage("", sort, startIndex, endIndex,order); var str = JsonConvert.SerializeObject(new { total = num, rows = ds.Tables[0] }); return str; }