コード例 #1
0
        public void BindGrid(int paramPageIndex, int paramPageSize)
        {
            if (string.IsNullOrEmpty(txtLogStartTime.Value) || string.IsNullOrEmpty(txtLogEndTime.Value))
            {
                base.ShowMessage("请选择开始时间和结束时间!");
                return;
            }
            if (Convert.ToDateTime(txtLogStartTime.Value) > Convert.ToDateTime(txtLogEndTime.Value))
            {
                base.ShowMessage("开始日期不能大于结束日期,请重新选择!");
                return;
            }
            var nickField = base.XMNickIncludeAdveringFieldService.GetXMNickIncludeAdvertingFieldByNickID(this.NickID);

            if (nickField == null)
            {
                base.ShowMessage("请先设置广告费字段!");
                return;
            }
            //默认插入相关数据
            string   min     = txtLogStartTime.Value;
            string   max     = txtLogEndTime.Value;
            string   nid     = this.NickID.ToString();
            DateTime minDate = DateTime.Parse(min);
            DateTime maxDate = DateTime.Parse(max);
            TimeSpan ts      = maxDate - minDate;
            var      XMAdvertisingFeeList = base.XMAdvertisingFeeService.GetXMAdvertisingFeeList();

            if (!string.IsNullOrEmpty(nid))
            {
                XMAdvertisingFeeList = XMAdvertisingFeeList.Where(p => p.NickId == Convert.ToInt16(nid) && p.Feedate >= minDate && p.Feedate <= maxDate).ToList();
            }
            var iminDate = minDate;

            if (XMAdvertisingFeeList.Count < (ts.Days + 1))
            {
                while (iminDate <= maxDate)
                {
                    var tj = base.XMAdvertisingFeeService.GetXMByIdmin(this.NickID, iminDate);
                    if (tj.Count == 0)
                    {
                        XMAdvertisingFee ps = new XMAdvertisingFee();
                        ps.NickId      = Convert.ToInt32(nid);
                        ps.Feedate     = iminDate;
                        ps.Fee         = 0;
                        ps.CreatorID   = HozestERPContext.Current.User.CustomerID;
                        ps.CreatorTime = DateTime.Now;
                        ps.UpdatorID   = HozestERPContext.Current.User.CustomerID;
                        ps.UpdateTime  = DateTime.Now;
                        base.XMAdvertisingFeeService.InsertXMAdvertisingFee(ps);
                        //插入从表数据
                        InsertAdvertingFeeDetailData(ps.Id);
                    }
                    iminDate = iminDate.AddDays(1);
                }
            }
            if ((int)Session["isEdit"] == 1)
            {
                //更新主表fee字段数值
                UpdateAdvertingFieldData(nid);
            }
            var newList  = base.XMAdvertisingFeeService.GetXMAdvertisingFeeList().Where(p => p.NickId == Convert.ToInt16(nid) && p.Feedate >= minDate && p.Feedate <= maxDate).ToList();
            var pageList = new PagedList <XMAdvertisingFee>(newList, paramPageIndex, paramPageSize, this.Master.GridViewSortField, this.Master.GridViewSortDir.ToString());

            this.Master.BindData(this.grdvCWPlatformSpendingDetails, pageList);
        }
コード例 #2
0
        public void BindGrid(int paramPageIndex, int paramPageSize)
        {

            //根据项目店铺查询广告费用 项目说明
            string min = this.DateTimeMin.ToString();
            string max = DateTime.Parse(this.DateTimeMax).AddDays(1).AddSeconds(-1).ToString();
            string pid = this.ProjectId.ToString();
            string nid = this.NickId.ToString();
            TimeSpan ts = DateTime.Parse(this.DateTimeMax) -  DateTime.Parse(this.DateTimeMin);
            //店铺集合
            List<int> nickIdList = new List<int>();
            #region 店铺条件查询集合 处理
            //选择某项目  
            if (pid != "-1")
            {
                if (nid == "-1")//项目下的所有店铺
                {
                    var nickList = base.XMNickService.GetXMNickListByProjectId(Convert.ToInt32(pid), 362);

                    // var NickListNew = nickList.Where(p => p.nick_id != 16 && p.nick_id != 17 && p.nick_id != 18).ToList();

                    if (nickList.Count > 0)
                    {
                        nickIdList = nickList.Select(p => p.nick_id).ToList();
                    }
                }
                else
                {

                    nickIdList.Add(Convert.ToInt32(nid));
                }
            }
            else
            {
                if (nid == "-1")
                {
                    var NickList = base.XMNickService.GetXMNickListByProjectId(Convert.ToInt32(pid), 362);

                    //var NickListNew = NickList.Where(p => p.nick_id != 16 && p.nick_id != 17 && p.nick_id != 18).ToList();

                    nickIdList = NickList.Select(a => a.nick_id).ToList();
                }
                else
                {
                    nickIdList.Add(Convert.ToInt32(nid));
                }

            }
            #endregion
            var XMAdvertisingFeeList = base.XMAdvertisingFeeService.GetXMXMAdvertisingFeeByDetails(nickIdList, DateTime.Parse(min), DateTime.Parse(max));

            if (XMAdvertisingFeeList.Count == 0 || (ts.Days * nickIdList.Count) > XMAdvertisingFeeList.Count)
            {
                foreach (var b in nickIdList)
                {
                    var imin = min;
                    while (DateTime.Parse(imin) <= DateTime.Parse(max))
                    {
                        var tj2 = base.XMAdvertisingFeeService.GetXMByIdmin(0, DateTime.Parse(imin));
                        if (tj2.Count != nickIdList.Count)
                        {
                            var tj = base.XMAdvertisingFeeService.GetXMByIdmin(b, DateTime.Parse(imin));
                            if (tj.Count == 0)
                            {
                                XMAdvertisingFee ps = new XMAdvertisingFee();
                                ps.NickId = Convert.ToInt32(b);
                                ps.Feedate = DateTime.Parse(imin);
                                ps.Fee = 0;
                                ps.CreatorID = HozestERPContext.Current.User.CustomerID;
                                ps.CreatorTime = DateTime.Now;
                                ps.UpdatorID = HozestERPContext.Current.User.CustomerID;
                                ps.UpdateTime = DateTime.Now;
                                base.XMAdvertisingFeeService.InsertXMAdvertisingFee(ps);
                            }
                        }
                        imin = DateTime.Parse(imin).AddDays(1).ToString();
                    }

                }
                XMAdvertisingFeeList = base.XMAdvertisingFeeService.GetXMXMAdvertisingFeeByDetails(nickIdList, DateTime.Parse(min), DateTime.Parse(max));
            }
            var pageList = new PagedList<XMAdvertisingFee>(XMAdvertisingFeeList, paramPageIndex, paramPageSize, this.Master.GridViewSortField, this.Master.GridViewSortDir.ToString());

            this.Master.BindData(this.grdvCWPlatformSpendingDetails, pageList);
        }