/// <summary> /// 数据库分页 /// </summary> /// <param name="Q"></param> /// <returns></returns> public ActionResult GetIndexQuesData(QueryModel Q) { String ResultJson = ""; Q.StrWhere=Q.StrWhere == null ? "" : Q.StrWhere; int BeginIndex = Q.CurrenPageIndex == 0 ? 0 : Q.CurrenPageIndex * Q.PageSize + 1; int Endindex = BeginIndex + Q.PageSize - (Q.CurrenPageIndex == 0 ? 0 : 1); QuesIndex QI = SqlStr_Process.GetListByPro(Q.StrWhere, "am_ID", BeginIndex, Endindex); int TotalRecords = QI.Total; int TotalPages = TotalRecords / Q.PageSize + (TotalRecords % Q.PageSize == 0 ? 0 : 1); ResultJson = "{\"Data\":" + JsonTool.DtToJson(QI.Data) + ", \"TotalRecords\":" + TotalRecords + ",\"TotalPages\":" + TotalPages + "}"; return Content(ResultJson.ToString()); }
public ActionResult ShowAccountListByPage(QueryModel Q) { String ResultJson = ""; string StrWhere = ""; if(!string.IsNullOrEmpty(Q.StrWhere)) { StrWhere = "am_LoginUser like '%" + Q.StrWhere + "%' or am_Email like '%" + Q.StrWhere + "%'"; } int BeginIndex = Q.CurrenPageIndex == 0 ?0 : Q.CurrenPageIndex * Q.PageSize+1; int Endindex = BeginIndex + Q.PageSize - (Q.CurrenPageIndex == 0 ? 0 : 1); DataTable dt = SqlStr_Process.GetListByPage("[SXNU_Questionnaire].[dbo].[AccountManage]", StrWhere, "am_ID", BeginIndex, Endindex); int TotalRecords = SqlStr_Process.GetTotalRecord("[SXNU_Questionnaire].[dbo].[AccountManage]", StrWhere); int TotalPages = TotalRecords / Q.PageSize + (TotalRecords % Q.PageSize == 0 ? 0 : 1); ResultJson = "{\"Data\":" + JsonTool.DtToJson(dt) + ", \"TotalRecords\":" + TotalRecords + ",\"TotalPages\":" + TotalPages + "}"; return Content(ResultJson.ToString()); }
public ActionResult GetUserInfos(QueryModel Q) { //String ResultJson = "" ; //int BeginIndex = Q.CurrenPageIndex == 0 ? 0 : Q.CurrenPageIndex * Q.PageSize + 1; //int Endindex = BeginIndex + Q.PageSize - (Q.CurrenPageIndex == 0 ? 0 : 1); //DataTable dt =SqlStr_Process.GetListByPage("[Test].[dbo].[user_info]", "", "id", BeginIndex, Endindex); //int TotalRecords = SqlStr_Process.GetTotalRecord("[dbo].[user_info]", ""); //int TotalPages = TotalRecords / Q.PageSize + ( TotalRecords % Q.PageSize == 0 ? 0 : 1); //ResultJson = "{\"Data\":" + JsonTool.DtToJson(dt) + ", \"TotalRecords\":" + TotalRecords + ",\"TotalPages\":" + TotalPages + "}"; //return Content(ResultJson.ToString()); String ResultJson = ""; int BeginIndex = Q.CurrenPageIndex == 1 ? 1 : Q.CurrenPageIndex * Q.PageSize; int Endindex = BeginIndex + Q.PageSize - (Q.CurrenPageIndex == 1 ? 1 : 0); DataTable dt = SqlStr_Process.GetListByPage("[Test].[dbo].[user_info]", "", "id", BeginIndex, Endindex); int TotalRecords = SqlStr_Process.GetTotalRecord("[dbo].[user_info]", ""); int TotalPages = TotalRecords / Q.PageSize + (TotalRecords % Q.PageSize == 0 ? 0 : 1); ResultJson = "{\"Data\":" + JsonTool.DtToJson(dt) + ", \"TotalRecords\":" + TotalRecords + ",\"TotalPages\":" + TotalPages + "}"; return Content(ResultJson.ToString()); }