类别:程序开发
日期:2020-02-25 浏览:2095 评论:0
/// <summary> /// 数据分页 /// </summary> /// <param name="viewName">表名</param> /// <param name="fieldName">字段</param> /// <param name="pageSize">默认20</param> /// <param name="pageNo">页数</param> /// <param name="orderString">排序</param> /// <param name="whereString">可选</param> /// <param name="recordTotal">总数</param> /// <returns></returns> public DataTable GetDataPager(string viewName, string fieldName, int pageSize, int pageNo, string orderString, string whereString, ref int recordTotal) { using (DbContext Entities = GetDbContext()) { DataSet ds = new DataSet(); string connectionString = Entities.Database.Connection.ConnectionString; SqlConnection conn = new System.Data.SqlClient.SqlConnection(); conn.ConnectionString = connectionString; if (conn.State != ConnectionState.Open) { conn.Open(); } try { SqlCommand cmd = new SqlCommand(); cmd.Connection = conn; cmd.CommandText = "usp_DataPager"; cmd.CommandType = CommandType.StoredProcedure; SqlParameter[] paras = new SqlParameter[7]; paras[0] = new SqlParameter("viewName", viewName); paras[1] = new SqlParameter("fieldName", fieldName); paras[2] = new SqlParameter("pageSize", pageSize); paras[3] = new SqlParameter("pageNo", pageNo); paras[4] = new SqlParameter("orderString", orderString); if (whereString.Trim() == "") { whereString = " 1=1 "; } paras[5] = new SqlParameter("whereString", whereString); paras[5].Size = Int32.MaxValue; paras[6] = new SqlParameter("recordTotal", recordTotal); paras[6].Direction = ParameterDirection.Output; cmd.Parameters.AddRange(paras); SqlDataAdapter adapter = new SqlDataAdapter(cmd); adapter.Fill(ds); recordTotal = Int32.Parse(paras[6].Value == null ? "0" : paras[6].Value.ToString()); return ds.Tables[0]; } catch (Exception ex) { throw ex; } finally { conn.Close(); } } } public DataTable GetInquireListByPage(ref int pageCount, string sortCode = "", string baseName = "", int page = 1, int pageSize = 15) { string strSql = " RL_InquireResource resourc inner join RL_InquireSort sort on resourc.InquireSortCode=sort.InquireSortCode "; string strWhere = " 1=1 and resourc.Del='0'"; if (!string.IsNullOrEmpty(sortCode)) { strWhere += string.Format(" And sort.InquireSortCode={0}", sortCode); } if (!string.IsNullOrEmpty(baseName)) { strWhere += string.Format(" and (resourc.DoctorQuestion like '%{0}%' or resourc.keyword like '%{0}%' or resourc.KeywordSpelling like '%{0}%')", baseName); } return new RL_InquireResourceB().GetDataPager(strSql, " resourc.*,sort.InquireSortName ", pageSize, page, " HealthExamItemNum ", strWhere, ref pageCount); } GetResource: function (sortCode) { tempmodel.page.pageindex = 1; var baseName = $("#txtSearch").val(); $.getJSON("/API/FTAPI.ashx", { "Action": "GETHEALTHEXAMPAGE", "ParamData": sortCode, "baseName": baseName, "pageIndex": tempmodel.page.pageindex, "pageCount": tempmodel.page.pageCount }, function (msg) { tempmodel.resourceData.clear(); tempmodel.resourceData.pushArray(msg.Result); tempmodel.page.total = msg.Result1; laypage({ cont: "pageDiv", pages: Math.ceil(parseInt(msg.Result1) / parseInt(tempmodel.page.pageCount)), curr: tempmodel.page.pageindex, skin: 'molv', jump: function (e) { if (e.curr != tempmodel.page.pageindex) { $.getJSON("/API/FTAPI.ashx", { "Action": "GETHEALTHEXAMPAGE", "ParamData": sortCode, "baseName": baseName, "pageIndex": e.curr, "pageCount": tempmodel.page.pageCount }, function (msg) { tempmodel.resourceData.clear(); tempmodel.resourceData.pushArray(msg.Result); }); } tempmodel.page.pageindex = e.curr; } }) }) } 分页: <div id="pageDiv"></div>
本文标题:laypage这个分页插件怎么用?
本文链接:https://vtzw.com/post/27.html
版权声明:本文不使用任何协议授权,您可以任何形式自由转载或使用。
发表评论 / 取消回复