public Models.Hwc.Page ShowDing(string name = "", int PageSize = 3, int PageCurrent = 1) { using (IDbConnection db = new SqlConnection(conn)) { string sql = $"select * from LMS_Client l join LMS_Ding d on l.SName=d.DName join LMS_DState e on d.DSzt=e.Id where d.dName='{name}'"; var list = db.Query <Client>(sql).ToList(); if (PageCurrent < 1) { PageCurrent = 1; } int count = list.Count(); int index = 0; if (count % PageSize == 0) { index = count / PageSize; } else { index = count / PageSize + 1; } if (PageCurrent > index) { PageCurrent = index; } Models.Hwc.Page p = new Models.Hwc.Page(); p.List1 = list.Skip((PageCurrent - 1) * PageSize).Take(PageSize).ToList(); p.PageCurrent = PageCurrent; p.PageCount = count; p.PageIndex = index; return(p); } }
public Models.Hwc.Page GetLoanorders(string name = "", int PageSize = 3, int PageCurrent = 1) { using (IDbConnection db = new SqlConnection(conn))//select * from LMS_Client l join LMS_Ding d on l.SName=d.DName join LMS_DState e on d.DSzt=e.Id where Id between 10 and 17 and not Id=10 and not Id=14 and not Id=15 and not Id=16 { string sql = $"select * from LMS_Client l join LMS_Ding d on l.SName=d.DName join LMS_DState e on d.DSzt=e.Id where Id between 10 and 17 and not Id=10 and not Id=14 and not Id=15 and not Id=16"; var list = db.Query <Client>(sql).ToList(); if (!string.IsNullOrEmpty(name)) { list = db.Query <Client>(sql).Where(m => m.DName.Contains(name)).ToList(); } else { list = db.Query <Client>(sql).ToList(); } if (PageCurrent < 1) { PageCurrent = 1; } int count = list.Count(); int index = 0; if (count % PageSize == 0) { index = count / PageSize; } else { index = count / PageSize + 1; } if (PageCurrent > index) { PageCurrent = index; } Models.Hwc.Page p = new Models.Hwc.Page(); p.List1 = list.Skip((PageCurrent - 1) * PageSize).Take(PageSize).ToList(); p.PageCurrent = PageCurrent; p.PageCount = count; p.PageIndex = index; return(p); } }