/// <summary>
        /// 获取包月数据列表
        /// </summary>
        /// <returns></returns>
        public ExtentionMonthBag GetMonthList(int PageSize, int PageIndex, out int totalCount, MonthParam pra)
        {
            var query = from s in _db.Admin_ExcelResourceForMonth
                        join p in _db.Admin_CPcompany on s.CPid equals p.ID
                        where s.IsDelete == false
                        orderby s.StatisticsTime
                        select new Admin_ExcelResourceForMonth
                            {
                                RowNumber = s.RowNumber,
                                Cpname = p.CPname,
                                StatisticsTime = s.StatisticsTime,
                                SingleOpusName = s.SingleOpusName,
                                NotBaoyuePlayNum = s.NotBaoyuePlayNum,
                                BaoyuePlayNum = s.BaoyuePlayNum,
                                PayBillPlayNum = s.PayBillPlayNum,
                                FreePlayNum = s.FreePlayNum,
                                NotBaoyuePayBillPlayNum = s.NotBaoyuePayBillPlayNum,
                                CPid = s.CPid,
                                SourceLevel = s.SourceLevel,
                                AddTime = s.AddTime
                            };

            #region 查询条件过滤
            //cp名称
            if (!string.IsNullOrEmpty(pra.selCPName))//关键词非空
            {
                query = query.Where(s => s.Cpname.Contains(pra.selCPName));
            }
            //作品名称
            if (!string.IsNullOrEmpty(pra.selOpusName))
            {
                query = query.Where(s => s.SingleOpusName.Contains(pra.selOpusName));
            }
            //选择时间
            if (pra.seltime != new DateTime(1970, 1, 1))
            {
                query = query.Where(s => s.StatisticsTime == pra.seltime);
            }
            #endregion
            totalCount = query.Count();
            var cbag = new ExtentionMonthBag();
            if (PageIndex < 0 || PageSize < 0)
            {
                return null;
            }
            if (PageIndex == 1 && PageSize > totalCount)
            {
                cbag.list = query.ToList();
            }
            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;
        }
Example #2
0
        public ActionResult MonthManage(FormCollection form)
        {
            ExtentionMonthBag cbag = new ExtentionMonthBag();
            if (form.Count != 0 || Request.QueryString.Count != 0)//有选择条件
            {
                MonthParam pra = new MonthParam();
                //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["selOpusName"] != "" && form["selOpusName"] != null)
                    {
                        pra.selOpusName = form["selOpusName"];
                    }
                    else
                    {
                        pra.selOpusName = "";
                    }
                }
                else if (DTRequest.GetQueryString("selOpusName") != "")
                {
                    pra.selOpusName = DTRequest.GetQueryString("selOpusName");
                }
                else
                {
                    pra.selOpusName = "";
                }

                //post请求
                if (Request.HttpMethod.Equals("POST", StringComparison.OrdinalIgnoreCase))
                {
                    if (form["selCPName"] != "" && form["selCPName"] != null)
                    {
                        pra.selCPName = form["selCPName"];
                    }
                    else
                    {
                        pra.selCPName = "";
                    }
                }
                else if (DTRequest.GetQueryString("selCPName") != "")
                {
                    pra.selCPName = DTRequest.GetQueryString("selCPName");
                }
                else
                {
                    pra.selCPName = "";
                }

                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_ExcelResourceForMonthLogic().GetMonthList(this.pageSize, this.page, out this.totalCount, pra);
                //绑定页码
                ViewBag.txtPageNum = this.pageSize.ToString();
                string pageUrl = Utils.CombUrlTxt("../admin/MonthManage", "SelTime={0}&selOpusName={1}&selCPName={2}&page={3}", pra.seltime.ToString(), pra.selOpusName, pra.selCPName, "__id__");
                ViewBag.PageContent = Utils.OutPageList(this.pageSize, this.page, this.totalCount, pageUrl, 8);
                return View(cbag);
            }
            else
            {
                MonthParam pra = new MonthParam();
                pra.seltime = form["SelTime"] == "" || form["SelTime"] == null ? new DateTime(1970, 1, 1) : Convert.ToDateTime(form["SelTime"]);
                pra.selOpusName = "";
                pra.selCPName = "";

                this.pageSize = GetPageSize(25); //每页数量
                this.page = DTRequest.GetQueryInt("page", 1);
                ViewBag.txtKeywords = this.keywords;
                cbag = new Admin_ExcelResourceForMonthLogic().GetMonthList(this.pageSize, this.page, out this.totalCount, pra);
                //绑定页码
                ViewBag.txtPageNum = this.pageSize.ToString();
                string pageUrl = Utils.CombUrlTxt("../admin/MonthManage", "SelTime={0}&selOpusName={1}&selCPName={2}&page={3}", pra.seltime.ToString(), pra.selOpusName, pra.selCPName, "__id__");
                ViewBag.PageContent = Utils.OutPageList(this.pageSize, this.page, this.totalCount, pageUrl, 8);
                return View(cbag);
            }
        }