Exemplo n.º 1
0
        MonthlyReportData CalcRevenue(int month)
        {
            int year = Revenue.Year;

            if (month < 1 || month > 12)
            {
                MessageBox.Show("所選月份不對!");
                return(null);
            }
            Message("計算 " + month.ToString() + "月營業額");
            if (RevenueCache[month - 1] != null)
            {
                return(RevenueCache[month - 1]);
            }
            int count = MyFunction.DayCountOfMonth(month);

            progressBar1.Minimum = 0;
            progressBar1.Maximum = count;
            progressBar1.Value   = 0;
            progressBar1.Visible = true;
            List <MonthlyReportData> list = new List <MonthlyReportData>();

            for (int i = 1; i <= count; i++)
            {
                if (Revenue.LoadData(m_OrderSet, month, i))
                {
                    list.Add(Revenue.Statics(m_OrderSet));
                }
                progressBar1.Value = i;
                Application.DoEvents();
            }
            progressBar1.Visible = false;
            MonthlyReportData total = new MonthlyReportData();

            foreach (MonthlyReportData d in list)
            {
                total.Revenue    += d.Revenue;
                total.OrderCount += d.OrderCount;
                total.Cash       += d.Cash;
                total.CreditCard += d.CreditCard;
            }
            RevenueCache[month - 1] = total;       // 存到Cache裏
            return(total);
        }
Exemplo n.º 2
0
        // RevenueCalc需要Header.Date 己經在FormLoad時給值
        MonthlyReportData CalcRevenue(int month, out List <MonthlyReportData> reportList)
        {
            int year = m_Revenue.Year;

            reportList = null;
            if (month < 1 || month > 12)
            {
                MessageBox.Show("所選月份不對!");
                return(null);
            }
            labelMessage.Text = "計算 " + month.ToString() + "月營業額";
            //if (RevenueCache[month - 1] != null)    // 不能用Cache了
            //    return RevenueCache[month - 1];
            int count = MyFunction.DayCountOfMonth(month);

            progressBar1.Minimum = 0;
            progressBar1.Maximum = count;
            progressBar1.Value   = 0;
            progressBar1.Visible = true;
            List <MonthlyReportData> list = new List <MonthlyReportData>();

            for (int i = 1; i <= count; i++)
            {
                if (m_Revenue.LoadData(damaiDataSet, month, i))
                {
                    list.Add(m_Revenue.Statics(damaiDataSet));
                }
                progressBar1.Value = i;
                Application.DoEvents();
            }
            progressBar1.Visible = false;
            MonthlyReportData total = new MonthlyReportData();

            foreach (MonthlyReportData d in list)
            {
                total.Revenue    += d.Revenue;
                total.OrderCount += d.OrderCount;
                total.Cash       += d.Cash;
                total.CreditCard += d.CreditCard;
                total.Alipay     += d.Alipay;
            }
            reportList = list;
            return(total);
        }
Exemplo n.º 3
0
        void Calc()
        {
            int year  = Revenue.Year;
            int month = comboBoxMonth.SelectedIndex + 1;

            if (month < 1 || month > 12)
            {
                MessageBox.Show("所選月份不對!");
                return;
            }
            comboBoxMonth.Enabled = false;  // 為避免計算時間過長,使用者重複選取. Reentrant會出錯
//            Application.DoEvents();
            int count = MyFunction.DayCountOfMonth(month);

            progressBar1.Minimum = 0;
            progressBar1.Maximum = count;
            progressBar1.Value   = 0;
            progressBar1.Visible = true;
            List <MonthlyReportData> list = new List <MonthlyReportData>();

            for (int i = 1; i <= count; i++)
            {
                if (Revenue.LoadData(m_DataSet, month, i))
                {
                    list.Add(Revenue.Statics(m_DataSet));
                }
                progressBar1.Value = i;
                Application.DoEvents();
            }
            dgViewMonthly.DataSource = list;
            progressBar1.Visible     = false;
            MonthlyReportData total = new MonthlyReportData();

            foreach (MonthlyReportData d in list)
            {
                total.Revenue        += d.Revenue;
                total.OrderCount     += d.OrderCount;
                total.Cash           += d.Cash;
                total.CreditCard     += d.CreditCard;
                total.CreditFee      += d.CreditFee;
                total.CreditNet      += d.CreditNet;
                total.Alipay         += d.Alipay;
                total.Wxpay          += d.Wxpay;
                total.CouponA        += d.CouponA;
                total.CouponB        += d.CouponB;
                total.DeletedCount   += d.DeletedCount;
                total.DeletedMoney   += d.DeletedMoney;
                total.TwentyPDCount  += d.TwentyPDCount;
                total.TwentyPDMoney  += d.TwentyPDMoney;
                total.FifteenPDCount += d.FifteenPDCount;
                total.FifteenPDMoney += d.FifteenPDMoney;
                total.TenPDCount     += d.TenPDCount;
                total.TenPDMoney     += d.TenPDMoney;
            }
            try
            {
                //if (total.Coupond == 0)
                //{
                //    dgViewMonthly.Columns["Coupond"].Visible = false;
                //}
                if (total.DeletedCount == 0)
                {
                    dgViewMonthly.Columns["DeletedCount"].Visible = false;
                    dgViewMonthly.Columns["DeletedMoney"].Visible = false;
                }
                if (total.TwentyPDCount == 0)
                {
                    dgViewMonthly.Columns["TwentyPDCount"].Visible = false;
                    dgViewMonthly.Columns["TwentyPDMoney"].Visible = false;
                }
                if (total.FifteenPDCount == 0)
                {
                    dgViewMonthly.Columns["FifteenPDCount"].Visible = false;
                    dgViewMonthly.Columns["FifteenPDMoney"].Visible = false;
                }
                if (total.TenPDCount == 0)
                {
                    dgViewMonthly.Columns["TenPDCount"].Visible = false;
                    dgViewMonthly.Columns["TenPDMoney"].Visible = false;
                }
            }
            catch { }
            labelCash.Text        = total.Cash.ToString();
            labelCredit.Text      = total.CreditCard.ToString();
            labelOrderCount.Text  = total.OrderCount.ToString();
            labelRevenue.Text     = total.Revenue.ToString();
            labelCreditFee.Text   = total.CreditFee.ToString();
            labelCreditNet.Text   = total.CreditNet.ToString();
            comboBoxMonth.Enabled = true;
        }