// OrderItemAdapter m_OrderItemAdapter = new OrderItemAdapter(); void Calc() { int year = Revenue.Year; int month = comboBoxMonth.SelectedIndex + 1; if (month < 1 || month > 12) { MessageBox.Show("所選月份不對!"); return; } 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(basicDataSet1, year, month, i, checkBoxUse12.Checked)) { list.Add(Revenue.Statics(basicDataSet1)); } 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.TwentyPDCount += d.TwentyPDCount; total.TwentyPDMoney += d.TwentyPDMoney; } 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(); }
// 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); }
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); }
public MonthlyReportData Statics(BasicDataSet basicDataSet1) { decimal cash = 0, credit = 0, deduct = 0; int people = 0; MonthlyReportData data = new MonthlyReportData(); foreach (BasicDataSet.OrderRow row in basicDataSet1.Order) { if (row.IsCreditIDNull() || row.CreditID == 0) { cash += row.Income; } else { credit += row.Income; } if (!row.IsPeopleNoNull()) { people += row.PeopleNo; } if (!row.IsDeductNull()) { deduct += row.Deduct; } } data.OrderCount = basicDataSet1.Order.Count; data.Cash = Math.Round(cash); data.Date = m_WorkingDay.Date; data.CreditCard = Math.Round(credit); data.CreditFee = Math.Round(FeeRate * data.CreditCard, 2); data.CreditNet = data.CreditCard - data.CreditFee; data.Deduct = Math.Round(deduct); if (people != 0) { data.AvePerPerson = Math.Round((cash + credit) / people, 1); } data.Revenue = Math.Round(cash + credit); return(data); }
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; }
public MonthlyReportData Statics(BakeryOrderSet orderSet) #endif { decimal cash = 0, credit = 0, deduct = 0, alipay = 0, couponA = 0, couponB = 0, wxpay = 0; decimal deletedMoney = 0, returnedMoney = 0, TwentyPDMoney = 0, FifteenPDMoney = 0, TenPDMoney = 0; int orderCount = 0, deletedCount = 0, returnedCount = 0, TwentyPDCount = 0, FifteenPDCount = 0, TenPDCount = 0; MonthlyReportData data = new MonthlyReportData(); foreach (var row in orderSet.Order) { decimal income; if (row.IsIncomeNull()) { income = 0m; } else { income = row.Income; } if (!row.IsDeletedNull() && row.Deleted) { deletedMoney += income; deletedCount++; continue; } if (row.IsPayByNull() || row.PayBy == "A") // A現金 B刷卡 C支付宝 D券 { cash += income; } else if (row.PayBy == "B") { credit += income; } else if (row.PayBy == "C") { alipay += income; } else if (row.PayBy == "E") { wxpay += income; } else if (row.PayBy == "D") { if (!row.IsCashIncomeNull()) { cash += row.CashIncome; } if (!row.IsCouponIncomeNull()) { if (row.CouponIncome > income) { couponA += income; // 收券大於應收,只計應收 } else { couponA += row.CouponIncome; } } } else if (row.PayBy == "F") { if (!row.IsCashIncomeNull()) { cash += row.CashIncome; } if (!row.IsCouponIncomeNull()) { if (row.CouponIncome > income) { couponB += income; // 收券大於應收,只計應收 } else { couponB += row.CouponIncome; } } } if (!row.IsDeductNull()) { deduct += row.Deduct; } if (income >= 0) // 退貨的不計入單數 { orderCount++; // 一單一人 } else { returnedMoney += income; returnedCount++; } if (!row.IsDiscountRateNull()) { if (row.DiscountRate == (decimal)0.80) { TwentyPDMoney += income; TwentyPDCount++; } if (row.DiscountRate == (decimal)0.85) { FifteenPDMoney += income; FifteenPDCount++; } if (row.DiscountRate == (decimal)0.90) { TenPDMoney += income; TenPDCount++; } } } data.OrderCount = orderCount; data.Cash = Math.Round(cash); data.Alipay = Math.Round(alipay); data.Wxpay = Math.Round(wxpay); data.CouponA = Math.Round(couponA); data.CouponB = Math.Round(couponB); data.Deduct = Math.Round(deduct); data.Date = m_WorkingDay.Date; data.CreditCard = Math.Round(credit); data.CreditFee = Math.Round(FeeRate * data.CreditCard, 2); data.CreditNet = data.CreditCard - data.CreditFee; if (orderCount != 0) { data.AvePerPerson = Math.Round((cash + credit + alipay + wxpay + couponA + couponB) / orderCount, 1); } data.Revenue = Math.Round(cash + credit + alipay + wxpay + couponA + couponB); data.DeletedCount = deletedCount; data.DeletedMoney = Math.Round(deletedMoney); data.ReturnedCount = returnedCount; data.ReturnedMoney = Math.Round(returnedMoney); data.TwentyPDCount = TwentyPDCount; data.TwentyPDMoney = Math.Round(TwentyPDMoney); return(data); }