public HttpResponseMessage GetWorksPage() { ReturnHelper rh = new ReturnHelper(200, null, 0, ""); string key = HttpContext.Current.Request["key"]; string limit = HttpContext.Current.Request["limit"]; string page = HttpContext.Current.Request["page"]; try { if (string.IsNullOrEmpty(limit) || string.IsNullOrEmpty(page)) { rh.msg = "缺少分页参数"; rh.code = 300; } else { Works obj = new Works(); string strWhere = " 1=1"; if (!string.IsNullOrEmpty(key)) { strWhere += string.Format(" and (Work_Type like '%{0}%' or Work_Title like '%{0}%')", key); } int begin = (Convert.ToInt32(page) - 1) * Convert.ToInt32(limit); int end = Convert.ToInt32(page) * Convert.ToInt32(limit); DataTable dt = obj.GetPage("*", "Report_Time desc", strWhere, begin, end); if (dt.Rows.Count > 0) { rh.totals = SqlHelper.Count(string.Format("select count(*) from Works where {0}", strWhere), SqlHelper.CreateConn()); rh.data = dt; rh.msg = "获取成功"; } } } catch (Exception e) { rh.code = 500; rh.msg = "处理错误"; } return(ReturnJson(JsonConvert.SerializeObject(rh))); }