Exemplo n.º 1
0
        public void UpdateRecordAndReport(DayliyReport dayReport, SPClientChannelSettingEntity spClientChannelSettingEntity, int newIntercept)
        {
            if (newIntercept < 0)
            {
                return;
            }
            if (newIntercept > dayReport.TotalCount)
            {
                return;
            }

            int newCount = dayReport.InterceptCount - newIntercept;

            if (newCount == 0)
            {
                return;
            }

            string sql = "";

            if (newCount < 0)
            {
                sql = string.Format("Update SPPaymentInfo set IsIntercept = 1 where ID In (select Top {0} id from dbo.SPPaymentInfo where ChannleClientID = {1} and CreateDate > '{2}' and CreateDate < '{3}' and IsIntercept = 0)", newCount * -1, spClientChannelSettingEntity.Id, dayReport.ReportDate.Date, dayReport.ReportDate.Date.AddDays(1));
            }
            else
            {
                sql = string.Format("Update SPPaymentInfo set IsIntercept = 0 where ID In (select Top {0} id from dbo.SPPaymentInfo where ChannleClientID = {1} and CreateDate > '{2}' and CreateDate < '{3}' and IsIntercept = 1)", newCount, spClientChannelSettingEntity.Id, dayReport.ReportDate.Date, dayReport.ReportDate.Date.AddDays(1));
            }

            this.AdoNetDb.ExecuteNoQuery(sql, CommandType.Text);

            if (dayReport.ReportDate.Date < System.DateTime.Now.Date)
            {
                SPDayReportEntity spDayReportEntity =
                    this.DataObjectsContainerIocID.SPDayReportDataObjectInstance.FindReportByChannelIDChannelIDAndDate(spClientChannelSettingEntity.ChannelID.Id, spClientChannelSettingEntity.ClinetID.Id, dayReport.ReportDate.Date);

                if (spDayReportEntity == null)
                {
                    return;
                }

                spDayReportEntity.InterceptTotalCount = newIntercept;
                spDayReportEntity.DownTotalCount      = dayReport.TotalCount - newIntercept;
                this.DataObjectsContainerIocID.SPDayReportDataObjectInstance.Update(spDayReportEntity);
            }
        }
        public void ChangeInterceptCount(string dateTime, int clientID, string newIntercept)
        {
            try
            {
                SPClientWrapper clientWrapper = SPClientWrapper.FindById(clientID);

                int newInterceptCount = Convert.ToInt32(newIntercept);

                DateTime date = Convert.ToDateTime(dateTime);

                DayliyReport dayReport = clientWrapper.GetDayReport(date);

                if (newInterceptCount < 0)
                {
                    ScriptManager.AjaxSuccess      = false;
                    ScriptManager.AjaxErrorMessage = "扣量不得小于0";
                    return;
                }

                if (newInterceptCount > dayReport.TotalCount)
                {
                    ScriptManager.AjaxSuccess      = false;
                    ScriptManager.AjaxErrorMessage = "扣量不得大于当日总量:" + dayReport.TotalCount.ToString();
                    return;
                }


                //ScriptManager.AjaxSuccess = false;
                //ScriptManager.AjaxErrorMessage = string.Format("日期{0} 总量:{1} 点播 {2} 扣量 {3} 同步 {4}", dateTime, dayReport.TotalCount, dayReport.DownCount, dayReport.InterceptCount, dayReport.SycnCount);
                //return;



                SPPaymentInfoWrapper.UpdateRecordAndReport(dayReport, clientWrapper, newInterceptCount);

                ScriptManager.AjaxSuccess = true;
            }
            catch (Exception ex)
            {
                ScriptManager.AjaxSuccess      = false;
                ScriptManager.AjaxErrorMessage = string.Format(ex.Message);
                return;
            }
        }