/// <summary> /// 获取非包月付费用户数数据列表 /// </summary> /// <returns></returns> public ExtentionNBP GetNBPList(int PageSize, int PageIndex, out int totalCount, NBPParam pra) { var query = from s in _db.Admin_NBPAccumulative orderby s.CountTime select new Admin_NBPAccumulative { CountTime=s.CountTime,CpName=s.CpName,NBPCount=s.NBPCount,Province=s.Province,ID=s.ID}; #region 查询条件过滤 //cp名称 if (!string.IsNullOrEmpty(pra.cpName))//关键词非空 { query = query.Where(s => s.CpName.Contains(pra.cpName)); } //选择时间 if (pra.seltime != new DateTime(1970, 1, 1)) { query = query.Where(s => s.CountTime == pra.seltime); } #endregion totalCount = query.Count(); var cbag = new ExtentionNBP(); if (PageIndex < 0 || PageSize < 0) { return null; } if (PageIndex == 1 && PageSize > totalCount) { cbag.list = query.ToList<Admin_NBPAccumulative>(); } else if (PageIndex == 1 && PageSize > 0) { cbag.list = query.Take(PageSize).ToList(); } else { cbag.list = query.Skip((PageIndex - 1) * PageSize).Take(PageSize).ToList(); } cbag.par = pra; return cbag; }
public ActionResult NBPManage(FormCollection form) { ExtentionNBP cbag = new ExtentionNBP(); if (form.Count != 0 || Request.QueryString.Count != 0)//有选择条件 { NBPParam pra = new NBPParam(); //post请求 if (Request.HttpMethod.Equals("POST", StringComparison.OrdinalIgnoreCase)) { if (form["SelTime"] != "" && form["SelTime"] != null) { pra.seltime = Convert.ToDateTime(form["SelTime"]); } else { pra.seltime = new DateTime(1970, 1, 1); } } else if (DTRequest.GetQueryString("seltime") != "") { pra.seltime = Convert.ToDateTime(DTRequest.GetQueryString("seltime")); } else { pra.seltime = new DateTime(1970, 1, 1); } //post请求 if (Request.HttpMethod.Equals("POST", StringComparison.OrdinalIgnoreCase)) { if (form["selCPName"] != "" && form["selCPName"] != null) { pra.cpName = form["selCPName"]; } else { pra.cpName = ""; } } else if (DTRequest.GetQueryString("selCPName") != "") { pra.cpName = DTRequest.GetQueryString("selCPName"); } else { pra.cpName = ""; } this.pageSize = GetPageSize(25); //每页数量 //post请求,点击查询返回第一页 if (Request.HttpMethod.Equals("POST", StringComparison.OrdinalIgnoreCase)) { this.page = 1; } else { this.page = DTRequest.GetQueryInt("page", 1); } ViewBag.txtKeywords = this.keywords; cbag = new Admin_NBPAccumulativeLogic().GetNBPList(this.pageSize, this.page, out this.totalCount, pra); //绑定页码 ViewBag.txtPageNum = this.pageSize.ToString(); string pageUrl = Utils.CombUrlTxt("../admin/NBPManage", "SelTime={0}&selOpusName={1}&selCPName={2}&page={3}", pra.seltime.ToString(), pra.cpName, pra.cpName, "__id__"); ViewBag.PageContent = Utils.OutPageList(this.pageSize, this.page, this.totalCount, pageUrl, 8); return View(cbag); } else { NBPParam pra = new NBPParam(); pra.seltime = form["SelTime"] == "" || form["SelTime"] == null ? new DateTime(1970, 1, 1) : Convert.ToDateTime(form["SelTime"]); pra.cpName = ""; this.pageSize = GetPageSize(25); //每页数量 this.page = DTRequest.GetQueryInt("page", 1); ViewBag.txtKeywords = this.keywords; cbag = new Admin_NBPAccumulativeLogic().GetNBPList(this.pageSize, this.page, out this.totalCount, pra); //绑定页码 ViewBag.txtPageNum = this.pageSize.ToString(); string pageUrl = Utils.CombUrlTxt("../admin/NBPManage", "SelTime={0}&selOpusName={1}&selCPName={2}&page={3}", pra.seltime.ToString(), pra.cpName, pra.cpName, "__id__"); ViewBag.PageContent = Utils.OutPageList(this.pageSize, this.page, this.totalCount, pageUrl, 8); return View(cbag); } }