123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823 |
- using LYFZ.ComponentLibrary;
- using LYFZ.Software.MainBusiness.DoorCityProcess;
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Windows.Forms;
- namespace LYFZ.Software.MainBusiness.StatisticalInquiry
- {
- public partial class FrmMonthFinance : LYFZ.Software.UI.StatisticalInquiry.FrmMonthFinance
- {
- private delegate void UpdateControl();
- public string DateTimeDay = "";
- LYFZ.BLL.BLL_ErpOrder orbll = new BLL.BLL_ErpOrder();
- LYFZ.BLL.BLL_ErpPayment ptbll = new BLL.BLL_ErpPayment();
- LYFZ.BLL.BLL_AllViewSet avsbll = new BLL.BLL_AllViewSet();
- LYFZ.BLL.BLL_ErpWagesSet wbsll = new BLL.BLL_ErpWagesSet();
- LYFZ.BLL.BLL_ErpSystemCategory scbll = new BLL.BLL_ErpSystemCategory();
- public FrmMonthFinance()
- {
- this.btnQuery.Click += btnQuery_Click;
- }
- /// <summary>
- /// 窗体加载事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- protected override void FrmMonthFinance_Shown(object sender, EventArgs e)
- {
- try
- {
- //this.Isbl = false;
- if (!string.IsNullOrEmpty(DateTimeDay))
- {
- this.dtpStart.DateValue = DateTimeDay + "-01";
- this.dtpEnd.DateValue = Convert.ToDateTime(this.dtpStart.DateValue).AddMonths(1).AddSeconds(-1).ToString();
- }
- else
- {
- this.dtpStart.DateValue = SDateTime.Now.ToString("yyyy-MM") + "-01";
- this.dtpEnd.DateValue = Convert.ToDateTime(this.dtpStart.DateValue).AddMonths(1).AddSeconds(-1).ToString();
- }
- this.dgvMonth.Rows.Clear();
- //获取订单数
- this.GetTodayMumberOrders();
- #region 获取支付方式
- this.cmbPay_PaymentMethod.TreeView.Nodes.Clear();
- DataTable tbl = orbll.GetView_Custom("tb_ErpSystemCategory", StrWhere: "", ShowColumnName: "ID,Sc_ClassCode,Sc_ClassName,Sc_ClassParentID", filedOrder: "ID desc").Tables[0];
- tbl.PrimaryKey = new DataColumn[] { tbl.Columns["Sc_ClassCode"] };
- DataRow dtRow = tbl.Rows.Find("BEBACCAFCCEAGAIHH");
- if (dtRow != null)
- {
- DataRow[] dtRow1 = tbl.Select("Sc_ClassParentID='" + dtRow["ID"].ToString().Trim() + "'");
- TreeNode root = null;
- for (int i = 0; i < dtRow1.Length; i++)
- {
- root = new TreeNode();
- if (i == 0)
- {
- root = new TreeNode(" ");
- this.cmbPay_PaymentMethod.TreeView.Nodes.Add(root);
- }
- root = new TreeNode(dtRow1[i]["Sc_ClassName"].ToString());
- root.Tag = dtRow1[i]["Sc_ClassCode"].ToString();
- this.CreateTreeViewShop(root.Nodes, dtRow1[i]["ID"].ToString(), tbl);
- this.cmbPay_PaymentMethod.TreeView.Nodes.Add(root);
- }
- }
- #endregion
- //获取文本框金额
- this.BindTotal();
- //获取每日绑定报表
- this.Bind();
- this.cmbProjectSearch.SelectedIndex = 0;
- this.btnExPort.Enabled = LYFZ.BLL.BLL_ErpUser.GetRights(LYFZ.BLL.BLL_ErpUser.CurrentUserRights.MonthFinanceCompetence, CustomAttributes.OperatingAuthority.DataExport);
- // 打印
- this.btnPrint.Enabled = LYFZ.BLL.BLL_ErpUser.GetRights(LYFZ.BLL.BLL_ErpUser.CurrentUserRights.MonthFinanceCompetence, CustomAttributes.OperatingAuthority.Print);
- // 财务支出
- if (!LYFZ.BLL.BLL_ErpUser.GetRights(LYFZ.BLL.BLL_ErpUser.CurrentUserRights.DayFinanceCompetence, CustomAttributes.OperatingAuthority.FinancialExpenses))
- { this.cmbProjectSearch.Items.RemoveAt(8); }
- //this.Isbl = true;
- }
- catch (Exception ex)
- { MessageBoxCustom.Show(ex.Message); }
- }
- /// <summary>
- /// 获取订单数
- /// </summary>
- public void GetTodayMumberOrders()
- {
- #region 滕工
- string ExecuteSql = orbll.GetView_CustomReturnExecuteSql("tb_ErpOrder", StrWhere: PublicCodeClasses.GetDateTime("Ord_CreateDateTime", this.dtpStart.DateValue, this.dtpEnd.DateValue, DateAddDays: 0, ConnectWord: ""), ShowColumnName: "Ord_Type,Ord_Class");
- ExecuteSql += ";" + orbll.GetView_CustomReturnExecuteSql("tb_ErpPayment Left Join tb_ErpOrder on Ord_Number = Pay_OrdNumber and Pay_Type = '0'", StrWhere: PublicCodeClasses.GetDateTime("Pay_CreateDatetime", this.dtpStart.DateValue, this.dtpEnd.DateValue, DateAddDays: 0, ConnectWord: "") + " and Ord_Type is not null", ShowColumnName: "sum( Pay_AmountOf) as SumAmount ,Ord_Type", StrGroupBy: "Ord_Type");
- DataSet dtSet = orbll.GetView_Custom(ExecuteSql);
- DataTable tbl1 = dtSet.Tables["ds"];
- DataRow[] dtRow = tbl1.Select("Ord_Type = '0'");
- DataRow[] dtRow1 = tbl1.Select("Ord_Type = '1'");
- DataRow[] dtRow2 = tbl1.Select("Ord_Type = '2'");
- DataRow[] dtRow3 = tbl1.Select("Ord_Type = '3'");
- DataRow[] dtRow4 = tbl1.Select("Ord_Type = '4'");
- DataRow[] dtRow5 = tbl1.Select("Ord_Class = '0'");
- this.lblCount.Text = " 订单数:婚纱:" + dtRow.Length + " 儿童:" + dtRow1.Length + " 写真:" + dtRow2.Length + " 服务:" + dtRow3.Length + " 婚庆:" + dtRow4.Length + " 其中意向:" + dtRow5.Length;
- DataTable tbl2 = dtSet.Tables["ds1"];
- tbl2.PrimaryKey = new DataColumn[] { tbl2.Columns["Ord_Type"] };
- DataRow dtRowA = tbl2.Rows.Find("0");
- string StrText = "";
- if (dtRowA != null)
- { StrText += "婚纱:" + dtRowA["SumAmount"] + " "; }
- DataRow dtRowA1 = tbl2.Rows.Find("1");
- if (dtRowA1 != null)
- { StrText += "儿童:" + dtRowA1["SumAmount"] + " "; }
- DataRow dtRowA2 = tbl2.Rows.Find("2");
- if (dtRowA2 != null)
- { StrText += "写真:" + dtRowA2["SumAmount"] + " "; }
- DataRow dtRowA3 = tbl2.Rows.Find("3");
- if (dtRowA3 != null)
- { StrText += "服务:" + dtRowA3["SumAmount"] + " "; }
- DataRow dtRowA4 = tbl2.Rows.Find("4");
- if (dtRowA4 != null)
- { StrText += "婚庆:" + dtRowA4["SumAmount"] + " "; }
- this.lblCount.Text += "\r\n收款金额:" + StrText;
- #endregion
- }
- /// <summary>
- /// 获取下拉订单后期收入/其它消费收入
- /// </summary>
- public void CmbBindOrderLateRevenue()
- {
- this.CtvTsorder_Name.Visible = true;
- this.CtvTsorder_Name.TreeView.Nodes.Clear();
- DataTable tbl = scbll.GetList("Sc_ClassCode='BEBACDAJDFDDEACGJ'").Tables[0];
- tbl = scbll.GetList(" Sc_ClassParentID='" + tbl.Rows[0]["ID"].ToString() + "' and Sc_ClassCode!='BEBCADBFBCDFBGJHC' and Sc_ClassCode!='BEBCADBFBDDEGGABF' and Sc_ClassCode!='BEBCBFBICGDHCGBEJ' and Sc_ClassCode!='BEBCABBAAICBDHDHI' and Sc_ClassCode!='BEBCABBAAICJAAGDG' and Sc_ClassCode!='BEBCBFBICFCECBHFF' ").Tables[0];
- if (tbl.Rows.Count > 0)
- {
- TreeNode root = null;
- for (int i = 0; i < tbl.Rows.Count; i++)
- {
- root = new TreeNode();
- if (i == 0)
- {
- root = new TreeNode("全部");
- this.CtvTsorder_Name.TreeView.Nodes.Add(root);
- }
- root = new TreeNode(tbl.Rows[i]["Sc_ClassName"].ToString());
- root.Tag = tbl.Rows[i]["Sc_ClassCode"].ToString();
- this.CtvTsorder_Name.TreeView.Nodes.Add(root);
- }
- }
- }
- public void CmbBindCashExpenditure()
- {
- this.CtvTsorder_Name.Visible = true;
- this.CtvTsorder_Name.TreeView.Nodes.Clear();
- DataTable tbl = orbll.GetView_Custom("tb_ErpSystemCategory", StrWhere: "", ShowColumnName: "ID,Sc_ClassCode,Sc_ClassName,Sc_ClassParentID", filedOrder: "ID desc").Tables[0];
- tbl.PrimaryKey = new DataColumn[] { tbl.Columns["Sc_ClassCode"] };
- DataRow dtRow = tbl.Rows.Find("BEBACIAFBEDIGJJFE");
- if (dtRow != null)
- {
- DataRow[] dtRow1 = tbl.Select("Sc_ClassParentID='" + dtRow["ID"].ToString().Trim() + "'");
- TreeNode root = null;
- for (int i = 0; i < dtRow1.Length; i++)
- {
- root = new TreeNode();
- if (i == 0)
- {
- root = new TreeNode("全部");
- this.CtvTsorder_Name.TreeView.Nodes.Add(root);
- }
- root = new TreeNode(dtRow1[i]["Sc_ClassName"].ToString());
- root.Tag = dtRow1[i]["Sc_ClassCode"].ToString();
- this.CreateTreeViewShop(root.Nodes, dtRow1[i]["ID"].ToString(), tbl);
- this.CtvTsorder_Name.TreeView.Nodes.Add(root);
- }
- }
- }
- /// <summary>
- /// 绑定第三级二销名称
- /// </summary>
- /// <param name="nodes">TreeView的节点集合</param>
- /// <param name="dataSource">数据源</param>
- /// <param name="parentid"></param>
- private void CreateTreeViewShop(TreeNodeCollection nodes, string ClassCode, DataTable tbl)
- {
- if (ClassCode != "")
- {
- DataRow[] dtRow = tbl.Select("Sc_ClassParentID='" + ClassCode + "'");
- TreeNode node;
- for (int i = 0; i < dtRow.Length; i++)
- {
- node = new TreeNode();
- node.Text = dtRow[i]["Sc_ClassName"].ToString();
- node.Tag = dtRow[i]["Sc_ClassCode"].ToString();
- nodes.Add(node);
- }
- }
- }
- /// <summary>
- /// 获取每日绑定报表
- /// </summary>
- public void Bind()
- {
- this.dgvMonth.Rows.Clear();
- string time = PublicCodeClasses.GetDateTime("Pay_CreateDatetimes", this.dtpStart.DateValue, this.dtpEnd.DateValue, DateAddDays: 0, ConnectWord: "");// Convert.ToDateTime(this.numYear.Value + "-" + this.numMonth.Value).ToString("yyyy-MM");
- LYFZ.ComponentLibrary.FrmLoadHandling.LoadDoWorkMethod(delegate(object obj, BackgroundWorker backgroundWorker)
- {
- #region 获取月报表
- DataTable dt = avsbll.Vw_MonthlyReport(time).Tables[0];
- //DataTable dt = avsbll.Vw_MonthlyReport("convert(varchar,Pay_CreateDatetimes,120) like '%" + time + "%'").Tables[0];
- if (dt.Rows.Count > 0)
- {
- this.Invoke(new UpdateControl(delegate()
- {
- for (int t = 0; t < dt.Rows.Count; t++)
- {
- //日订单收入
- decimal DayOrdersIncome = dt.Rows[t]["DayOrdersIncome"].ToString() == "" ? 0 : Convert.ToDecimal(dt.Rows[t]["DayOrdersIncome"]);
- //日补款收入
- decimal DayReplenishmentIncome = dt.Rows[t]["DayReplenishmentIncome"].ToString() == "" ? 0 : Convert.ToDecimal(dt.Rows[t]["DayReplenishmentIncome"]);
- //日后期收入
- decimal DayLateStageIncome = dt.Rows[t]["DayLateStageIncome"].ToString() == "" ? 0 : Convert.ToDecimal(dt.Rows[t]["DayLateStageIncome"]);
- //日其它收入
- decimal DayOtherIncome = dt.Rows[t]["DayOtherIncome"].ToString() == "" ? 0 : Convert.ToDecimal(dt.Rows[t]["DayOtherIncome"]);
- //日会员充值
- decimal DayMemberIncome = dt.Rows[t]["DayMemberIncome"].ToString() == "" ? 0 : Convert.ToDecimal(dt.Rows[t]["DayMemberIncome"]);
- //日服务卡充值
- decimal DayMemberCardPaymentIncome = dt.Rows[t]["DayMemberCardPaymentIncome"].ToString() == "" ? 0 : Convert.ToDecimal(dt.Rows[t]["DayMemberCardPaymentIncome"]);
- //日前期业绩
- decimal DayEarlyPerformance = dt.Rows[t]["DayEarlyPerformance"].ToString() == "" ? 0 : Convert.ToDecimal(dt.Rows[t]["DayEarlyPerformance"]);
- //日后期业绩(加挑商品+其它消费)
- //加挑商品
- decimal DayPluslatepickPerformance = dt.Rows[t]["DayPluslatepickPerformance"].ToString() == "" ? 0 : Convert.ToDecimal(dt.Rows[t]["DayPluslatepickPerformance"]);
- decimal DayOtherPerformance = dt.Rows[t]["DayOtherPerformance"].ToString() == "" ? 0 : Convert.ToDecimal(dt.Rows[t]["DayOtherPerformance"]);
- //日店面支出
- decimal DayExpenditure = dt.Rows[t]["DayExpenditure"].ToString() == "" ? 0 : Convert.ToDecimal(dt.Rows[t]["DayExpenditure"]);
- //日财务支出
- decimal DayExpenditure2 = dt.Rows[t]["DayExpenditure2"].ToString() == "" ? 0 : Convert.ToDecimal(dt.Rows[t]["DayExpenditure2"]);
- #region 获取月报表
- DataGridViewRow dgvr = new DataGridViewRow();
- DataGridViewCell cell = null;
- //日期
- cell = new DataGridViewTextBoxCell();
- cell.Value = dt.Rows[t]["Pay_CreateDatetimes"].ToString();
- dgvr.Cells.Add(cell);
- //日总收入
- cell = new DataGridViewTextBoxCell();
- cell.Value = (DayOrdersIncome + DayReplenishmentIncome + DayLateStageIncome + DayOtherIncome + DayMemberIncome + DayMemberCardPaymentIncome).ToString();
- dgvr.Cells.Add(cell);
- //日订单收入
- cell = new DataGridViewTextBoxCell();
- cell.Value = DayOrdersIncome.ToString();
- dgvr.Cells.Add(cell);
- //日补款收入
- cell = new DataGridViewTextBoxCell();
- cell.Value = DayReplenishmentIncome.ToString();
- dgvr.Cells.Add(cell);
- //日后期收入
- cell = new DataGridViewTextBoxCell();
- cell.Value = DayLateStageIncome.ToString();
- dgvr.Cells.Add(cell);
- //日其它收入
- cell = new DataGridViewTextBoxCell();
- cell.Value = DayOtherIncome.ToString();
- dgvr.Cells.Add(cell);
- //日会员充值
- cell = new DataGridViewTextBoxCell();
- cell.Value = DayMemberIncome.ToString();
- dgvr.Cells.Add(cell);
- //日服务卡充值
- cell = new DataGridViewTextBoxCell();
- cell.Value = DayMemberCardPaymentIncome.ToString();
- dgvr.Cells.Add(cell);
- //日前期业绩
- cell = new DataGridViewTextBoxCell();
- cell.Value = DayEarlyPerformance.ToString();
- dgvr.Cells.Add(cell);
- //日后期业绩
- cell = new DataGridViewTextBoxCell();
- cell.Value = (DayPluslatepickPerformance + DayOtherPerformance).ToString();
- dgvr.Cells.Add(cell);
- //日总业绩
- cell = new DataGridViewTextBoxCell();
- cell.Value = (DayEarlyPerformance + DayPluslatepickPerformance + DayOtherPerformance).ToString();
- dgvr.Cells.Add(cell);
- //日总支出
- cell = new DataGridViewTextBoxCell();
- cell.Value = (DayExpenditure + DayExpenditure2).ToString();
- dgvr.Cells.Add(cell);
- this.dgvMonth.Rows.Add(dgvr);
- #endregion
- }
- this.dgvMonth.ClearSelection();
- }));
- }
- #endregion
- });
- }
- #region 获取收入/营业收入/支出/订单前期/后期等金额
- /// <summary>
- /// 总押金
- /// </summary>
- /// <returns></returns>
- decimal Deposit()
- {
- decimal sum = wbsll.GetDressDepositSum();
- return sum;
- }
- /// <summary>
- /// 总欠款
- /// </summary>
- /// <returns></returns>
- decimal Arrears()
- {
- decimal sum = ptbll.GetSumArrears();
- return sum;
- }
- /// <summary>
- /// 获取订单前期
- /// </summary>
- /// <returns></returns>
- decimal OrderEarly()
- {
- decimal sum = 0;
- DataTable dt = wbsll.GetTwoPieSum(PublicCodeClasses.GetDateTime("convert(datetime,Pay_CreateDatetime)", this.dtpStart.DateValue, this.dtpEnd.DateValue, DateAddDays: 0, ConnectWord: "") + " and Pay_Category!='后期收款' and (Pay_PaymentMethod!='BEBACCAFEGECFBJFD' and Pay_PaymentMethod!='BEBCABAJBDFBBJGID')").Tables[0];
- //DataTable dt = wbsll.GetTwoPieSum(" convert(varchar,Pay_CreateDatetime,120) like '%" + time + "%' and Pay_Category!='后期收款' and (Pay_PaymentMethod!='BEBACCAFEGECFBJFD' and Pay_PaymentMethod!='BEBCABAJBDFBBJGID')").Tables[0];
- if (!string.IsNullOrEmpty(dt.Rows[0]["Pay_AmountOf"].ToString()))
- { sum = Convert.ToDecimal(dt.Rows[0]["Pay_AmountOf"]); }
- return sum;
- }
- /// <summary>
- /// 获取订单后期
- /// </summary>
- /// <returns></returns>
- decimal OrderLate()
- {
- decimal sum = 0;
- DataTable dt = wbsll.GetTwoPieSum(PublicCodeClasses.GetDateTime("convert(datetime,Pay_CreateDatetime)", this.dtpStart.DateValue, this.dtpEnd.DateValue, DateAddDays: 0, ConnectWord: "") + " and Pay_Category='后期收款' and (Pay_Type=0) and (Pay_PaymentMethod!='BEBACCAFEGECFBJFD' and Pay_PaymentMethod!='BEBCABAJBDFBBJGID')").Tables[0];
- //DataTable dt = wbsll.GetTwoPieSum("convert(varchar,Pay_CreateDatetime,120) like '%" + time + "%' and Pay_Category='后期收款' and (Pay_Type=0) and (Pay_PaymentMethod!='BEBACCAFEGECFBJFD' and Pay_PaymentMethod!='BEBCABAJBDFBBJGID')").Tables[0];
- if (!string.IsNullOrEmpty(dt.Rows[0]["Pay_AmountOf"].ToString()))
- { sum = Convert.ToDecimal(dt.Rows[0]["Pay_AmountOf"]); }
- return sum;
- }
- /// <summary>
- /// 获取收款记录金额
- /// </summary>
- /// <param name="Symbol"></param>
- /// <returns></returns>
- decimal TotalRevenueSun(string Symbol)
- {
- StringBuilder str = new StringBuilder();
- str.Append(Symbol);
- //str.Append("" + Symbol + " convert(varchar,Pay_CreateDatetime,120) like '%" + time + "%' ");
- str.Append(PublicCodeClasses.GetDateTime("convert(datetime,Pay_CreateDatetime)", this.dtpStart.DateValue, this.dtpEnd.DateValue, DateAddDays: 0, ConnectWord: ""));
- if (!string.IsNullOrEmpty(this.cmbPay_PaymentMethod.Text) && this.cmbPay_PaymentMethod.Tag != null)
- { str.Append(" and Pay_PaymentMethod='" + this.cmbPay_PaymentMethod.Tag.ToString() + "'"); }
- if (this.cmbProjectSearch.Text.Trim() != "全部")
- {
- //订单前期
- if (this.cmbProjectSearch.Text.Trim() == "订单前期收入")
- {
- if (string.IsNullOrEmpty(this.CtvTsorder_Name.Text) || this.CtvTsorder_Name.Text == "全部")
- { str.Append(" and Pay_Category!='后期收款'"); }
- else
- { str.Append(" and Pay_Category='" + this.CtvTsorder_Name.Text.ToString() + "'"); }
- }
- //订单后期收入
- if (this.cmbProjectSearch.Text.Trim() == "订单后期收入")
- {
- if (string.IsNullOrEmpty(this.CtvTsorder_Name.Text) || this.CtvTsorder_Name.Text == "全部")
- { str.Append(" and Pay_Category='后期收款' and Pay_Type=0"); }
- else
- { str.Append("and Pay_Category='后期收款' and Pay_Type=0 and Pay_TwoPinsCategory='" + this.CtvTsorder_Name.Tag.ToString() + "'"); }
- }
- //其它消费收入
- if (this.cmbProjectSearch.Text.Trim() == "其它消费收入")
- {
- if (string.IsNullOrEmpty(this.CtvTsorder_Name.Text) || this.CtvTsorder_Name.Text == "全部")
- { str.Append(" and Pay_Category='后期收款' and Pay_Type=1"); }
- else
- { str.Append("and Pay_Category='后期收款' and Pay_Type=1 and Pay_TwoPinsCategory='" + this.CtvTsorder_Name.Tag.ToString() + "'"); }
- }
- //礼服租售收入
- if (this.cmbProjectSearch.Text.Trim() == "礼服租售收入")
- {
- if (string.IsNullOrEmpty(this.CtvTsorder_Name.Text) || this.CtvTsorder_Name.Text == "全部")
- { str.Append(" and Pay_Category='后期收款' and Pay_Type=2"); }
- else
- { str.Append("and Pay_Category='后期收款' and Pay_Type=2 and Pay_ReceivableProject='" + this.CtvTsorder_Name.Text.ToString() + "'"); }
- }
- }
- DataTable dt = wbsll.GetTwoPieSum(str.ToString()).Tables[0];
- decimal sum = 0;
- if (!string.IsNullOrEmpty(dt.Rows[0]["Pay_AmountOf"].ToString()))
- { sum = Convert.ToDecimal(dt.Rows[0]["Pay_AmountOf"]); }
- return sum;
- }
- /// <summary>
- /// 获取其它收入金额
- /// </summary>
- /// <returns></returns>
- decimal OtherIncomeSum()
- {
- decimal sum = 0;
- StringBuilder str = new StringBuilder();
- str.Append("Oiae_Type='收入' " + PublicCodeClasses.GetDateTime("convert(datetime,Oiae_IEDatetime)", this.dtpStart.DateValue, this.dtpEnd.DateValue, DateAddDays: 0));
- if (!string.IsNullOrEmpty(this.cmbPay_PaymentMethod.Text) && this.cmbPay_PaymentMethod.Tag != null)
- { str.Append(" and Oiae_PaymentMethod='" + this.cmbPay_PaymentMethod.Tag.ToString() + "'"); }
- DataTable dt = wbsll.GetOtherIncomeSum(str.ToString()).Tables[0];
- if (!string.IsNullOrEmpty(dt.Rows[0]["Oiae_Money"].ToString()))
- { sum = Convert.ToDecimal(dt.Rows[0]["Oiae_Money"]); }
- return sum;
- }
- /// <summary>
- /// 获取会员充值金额
- /// </summary>
- /// <returns></returns>
- decimal MembersRechargeSum()
- {
- decimal sum = 0;
- StringBuilder str = new StringBuilder();
- str.Append(PublicCodeClasses.GetDateTime("convert(datetime,Mcrr_CreateDatetime)", this.dtpStart.DateValue, this.dtpEnd.DateValue, DateAddDays: 0, ConnectWord: ""));
- if (!string.IsNullOrEmpty(this.cmbPay_PaymentMethod.Text) && this.cmbPay_PaymentMethod.Tag != null)
- { str.Append(" and Mcrr_PaymentMethod='" + this.cmbPay_PaymentMethod.Tag.ToString() + "'"); }
- DataTable dt = wbsll.GetMembersRechargeSum(str.ToString()).Tables[0];
- if (!string.IsNullOrEmpty(dt.Rows[0]["Mcrr_RechargeAmount"].ToString()))
- { sum = Convert.ToDecimal(dt.Rows[0]["Mcrr_RechargeAmount"]); }
- return sum;
- }
- /// <summary>
- /// 获取服务卡消费充值金额
- /// </summary>
- /// <returns></returns>
- decimal MemberCardPayment()
- {
- decimal sum = 0;
- StringBuilder str = new StringBuilder();
- str.Append(PublicCodeClasses.GetDateTime("convert(datetime,创建日期)", this.dtpStart.DateValue, this.dtpEnd.DateValue, DateAddDays: 0));
- if (!string.IsNullOrEmpty(this.cmbPay_PaymentMethod.Text) && this.cmbPay_PaymentMethod.Tag != null)
- { str.Append(" and 付款方式编号='" + this.cmbPay_PaymentMethod.Tag.ToString() + "'"); }
- DataTable dt = avsbll.GetMemberCardPaymentSum(str.ToString()).Tables[0];
- if (!string.IsNullOrEmpty(dt.Rows[0]["收款金额"].ToString()))
- { sum = Convert.ToDecimal(dt.Rows[0]["收款金额"]); }
- return sum;
- }
- /// <summary>
- /// 现金支出金额
- /// </summary>
- /// <returns></returns>
- decimal ExpenditureSum()
- {
- decimal sum = 0;
- StringBuilder str = new StringBuilder();
- str.Append(" Oiae_Type='支出' " + PublicCodeClasses.GetDateTime("convert(datetime,Oiae_IEDatetime)", this.dtpStart.DateValue, this.dtpEnd.DateValue, DateAddDays: 0));
- if (!string.IsNullOrEmpty(this.cmbPay_PaymentMethod.Text) && this.cmbPay_PaymentMethod.Tag != null)
- {
- str.Append("and Oiae_PaymentMethod='" + this.cmbPay_PaymentMethod.Tag.ToString() + "'");
- //if (cmbPay_PaymentMethod.Text != "现金")
- //{ return 0; }
- }
- if (this.cmbProjectSearch.Text != "全部")
- {
- //现金支出
- if (this.cmbProjectSearch.Text == "店面支出")
- {
- if (string.IsNullOrEmpty(this.CtvTsorder_Name.Text) || this.CtvTsorder_Name.Text == "全部")
- { str.Append(" "); }
- else
- { str.Append("and Oiae_ProjectName='" + this.CtvTsorder_Name.Text.ToString() + "'"); }
- }
- }
- DataTable dt = wbsll.GetOtherIncomeSum(str.ToString()).Tables[0];
- if (!string.IsNullOrEmpty(dt.Rows[0]["Oiae_Money"].ToString()))
- { sum = Convert.ToDecimal(dt.Rows[0]["Oiae_Money"]); }
- return sum;
- }
- /// <summary>
- /// 财务支出金额
- /// </summary>
- /// <param name="Time"></param>
- /// <returns></returns>
- decimal FinancialExpensesSum()
- {
- decimal sum = 0;
- StringBuilder str = new StringBuilder();
- str.Append(" Oiae_Type='财务支出' " + PublicCodeClasses.GetDateTime("convert(datetime,Oiae_IEDatetime)", this.dtpStart.DateValue, this.dtpEnd.DateValue, DateAddDays: 0));
- if (!string.IsNullOrEmpty(this.cmbPay_PaymentMethod.Text) && this.cmbPay_PaymentMethod.Tag != null)
- {
- str.Append("and Oiae_PaymentMethod='" + this.cmbPay_PaymentMethod.Tag.ToString() + "'");
- // if (cmbPay_PaymentMethod.Text != "现金")
- // { return 0; }
- }
- if (this.cmbProjectSearch.Text != "全部")
- {
- //现金支出
- if (this.cmbProjectSearch.Text == "财务支出")
- {
- if (string.IsNullOrEmpty(this.CtvTsorder_Name.Text) || this.CtvTsorder_Name.Text == "全部")
- { str.Append(" "); }
- else
- { str.Append("and Oiae_ProjectName='" + this.CtvTsorder_Name.Text.ToString() + "'"); }
- }
- }
- DataTable dt = wbsll.GetOtherIncomeSum(str.ToString()).Tables[0];
- if (!string.IsNullOrEmpty(dt.Rows[0]["Oiae_Money"].ToString()))
- { sum = Convert.ToDecimal(dt.Rows[0]["Oiae_Money"]); }
- return sum;
- }
- /// <summary>
- /// 文本框合计获取值
- /// </summary>
- public void BindTotal()
- {
- //string time = Convert.ToDateTime(this.numYear.Value + "-" + this.numMonth.Value).ToString("yyyy-MM");
- if (this.cmbProjectSearch.Text == "全部")
- {
- //收入
- this.txtTotalRevenue.Text = (this.TotalRevenueSun("(Pay_PaymentMethod!='BEBACCAFEGECFBJFD' and Pay_PaymentMethod!='BEBCABAJBDFBBJGID') and ") + this.OtherIncomeSum()).ToString();
- //营业收入
- this.txtOperatingIncome.Text = (this.TotalRevenueSun("") + this.MembersRechargeSum() + this.MemberCardPayment()).ToString();
- //总支出
- this.txtTotalExpenditure.Text = (this.ExpenditureSum() + this.FinancialExpensesSum()).ToString();
- //净收入
- this.txtNetIncome.Text = (Convert.ToDecimal(this.txtTotalRevenue.Text) - Convert.ToDecimal(this.txtTotalExpenditure.Text)).ToString();
- }
- else if (this.cmbProjectSearch.Text == "订单前期收入")
- {
- //收入
- this.txtTotalRevenue.Text = this.TotalRevenueSun("(Pay_PaymentMethod!='BEBACCAFEGECFBJFD' and Pay_PaymentMethod!='BEBCABAJBDFBBJGID') and ").ToString();
- //营业收入
- this.txtOperatingIncome.Text = this.TotalRevenueSun("").ToString();
- //总支出
- this.txtTotalExpenditure.Text = "0";
- //净收入
- this.txtNetIncome.Text = (Convert.ToDecimal(this.txtTotalRevenue.Text) - Convert.ToDecimal(this.txtTotalExpenditure.Text)).ToString();
- }
- else if (this.cmbProjectSearch.Text == "订单后期收入")
- {
- //收入
- this.txtTotalRevenue.Text = this.TotalRevenueSun("(Pay_PaymentMethod!='BEBACCAFEGECFBJFD' and Pay_PaymentMethod!='BEBCABAJBDFBBJGID') and ").ToString();
- //营业收入
- this.txtOperatingIncome.Text = this.TotalRevenueSun("").ToString();
- //总支出
- this.txtTotalExpenditure.Text = "0";
- //净收入
- this.txtNetIncome.Text = (Convert.ToDecimal(this.txtTotalRevenue.Text) - Convert.ToDecimal(this.txtTotalExpenditure.Text)).ToString();
- }
- else if (this.cmbProjectSearch.Text == "其它消费收入")
- {
- //收入
- this.txtTotalRevenue.Text = this.TotalRevenueSun("(Pay_PaymentMethod!='BEBACCAFEGECFBJFD' and Pay_PaymentMethod!='BEBCABAJBDFBBJGID') and ").ToString();
- //营业收入
- this.txtOperatingIncome.Text = this.TotalRevenueSun("").ToString();
- //总支出
- this.txtTotalExpenditure.Text = "0";
- //净收入
- this.txtNetIncome.Text = (Convert.ToDecimal(this.txtTotalRevenue.Text) - Convert.ToDecimal(this.txtTotalExpenditure.Text)).ToString();
- }
- else if (this.cmbProjectSearch.Text == "其它收入")
- {
- //收入
- this.txtTotalRevenue.Text = this.OtherIncomeSum().ToString();
- //营业收入
- this.txtOperatingIncome.Text = "0";
- //总支出
- this.txtTotalExpenditure.Text = "0";
- //净收入
- this.txtNetIncome.Text = (Convert.ToDecimal(this.txtTotalRevenue.Text) - Convert.ToDecimal(this.txtTotalExpenditure.Text)).ToString();
- }
- else if (this.cmbProjectSearch.Text == "会员充值收入")
- {
- //收入
- this.txtTotalRevenue.Text = "0";// Convert.ToDecimal(Convert.ToDecimal(MembersRechargeSum(time))).ToString();
- //营业收入
- this.txtOperatingIncome.Text = this.MembersRechargeSum().ToString();
- //总支出
- this.txtTotalExpenditure.Text = "0";
- //净收入
- this.txtNetIncome.Text = (Convert.ToDecimal(this.txtTotalRevenue.Text) - Convert.ToDecimal(this.txtTotalExpenditure.Text)).ToString();
- }
- else if (this.cmbProjectSearch.Text == "服务卡消费收入")
- {
- //收入
- this.txtTotalRevenue.Text = "0";// Convert.ToDecimal(Convert.ToDecimal(MemberCardPayment(time))).ToString();
- //营业收入
- this.txtOperatingIncome.Text = this.MemberCardPayment().ToString();
- //总支出
- this.txtTotalExpenditure.Text = "0";
- //净收入
- this.txtNetIncome.Text = (Convert.ToDecimal(this.txtTotalRevenue.Text) - Convert.ToDecimal(this.txtTotalExpenditure.Text)).ToString();
- }
- else if (this.cmbProjectSearch.Text == "礼服租售收入")
- {
- //收入
- this.txtTotalRevenue.Text = this.TotalRevenueSun("(Pay_PaymentMethod!='BEBACCAFEGECFBJFD' and Pay_PaymentMethod!='BEBCABAJBDFBBJGID') and ").ToString();
- //营业收入
- this.txtOperatingIncome.Text = this.TotalRevenueSun("").ToString();
- //总支出
- this.txtTotalExpenditure.Text = "0";
- //净收入
- this.txtNetIncome.Text = (Convert.ToDecimal(this.txtTotalRevenue.Text) - Convert.ToDecimal(this.txtTotalExpenditure.Text)).ToString();
- }
- else if (this.cmbProjectSearch.Text == "店面支出")
- {
- //收入
- this.txtTotalRevenue.Text = "0";
- //营业收入
- this.txtOperatingIncome.Text = "0";
- //总支出
- this.txtTotalExpenditure.Text = this.ExpenditureSum().ToString();
- //净收入
- this.txtNetIncome.Text = (Convert.ToDecimal(this.txtTotalRevenue.Text) - Convert.ToDecimal(this.txtTotalExpenditure.Text)).ToString();
- }
- else if (this.cmbProjectSearch.Text == "财务支出")
- {
- //收入
- this.txtTotalRevenue.Text = "0";
- //营业收入
- this.txtOperatingIncome.Text = "0";
- //总支出
- this.txtTotalExpenditure.Text = this.FinancialExpensesSum().ToString();
- //净收入
- this.txtNetIncome.Text = (Convert.ToDecimal(this.txtTotalRevenue.Text) - Convert.ToDecimal(this.txtTotalExpenditure.Text)).ToString();
- }
- else if (this.cmbProjectSearch.Text == "押金")
- {
- //收入
- this.txtTotalRevenue.Text = "0";
- //营业收入
- this.txtOperatingIncome.Text = "0";
- //总支出
- this.txtTotalExpenditure.Text = "0";
- //净收入
- this.txtNetIncome.Text = "0";
- }
- //订单前期
- this.txtPreliminaryResults.Text = OrderEarly().ToString();
- //订单后期
- this.txtLateResults.Text = OrderLate().ToString();
- }
- #endregion
- /// <summary>
- /// 项目查询
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- protected override void cmbProjectSearch_SelectedValueChanged(object sender, EventArgs e)
- {
- try
- {
- this.CtvTsorder_Name.Text = "";
- if (this.cmbProjectSearch.Text == "全部")
- { this.CtvTsorder_Name.Visible = false; }
- else if (this.cmbProjectSearch.Text == "订单前期收入")
- {
- this.CtvTsorder_Name.Visible = true;
- this.CtvTsorder_Name.TreeView.Nodes.Clear();
- this.CtvTsorder_Name.Nodes.Add("全部");
- this.CtvTsorder_Name.Nodes.Add("预约收款");
- this.CtvTsorder_Name.Nodes.Add("预约补款");
- this.CtvTsorder_Name.Nodes.Add("全款");
- }
- else if (this.cmbProjectSearch.Text == "订单后期收入")
- { this.CmbBindOrderLateRevenue(); }
- else if (this.cmbProjectSearch.Text == "其它消费收入")
- { this.CmbBindOrderLateRevenue(); }
- else if (this.cmbProjectSearch.Text == "其它收入")
- { this.CtvTsorder_Name.Visible = false; }
- else if (this.cmbProjectSearch.Text == "会员充值收入")
- { this.CtvTsorder_Name.Visible = false; }
- else if (this.cmbProjectSearch.Text == "服务卡消费收入")
- { this.CtvTsorder_Name.Visible = false; }
- else if (this.cmbProjectSearch.Text == "礼服租售收入")
- {
- this.CtvTsorder_Name.Visible = true;
- this.CtvTsorder_Name.TreeView.Nodes.Clear();
- this.CtvTsorder_Name.Nodes.Add("全部");
- this.CtvTsorder_Name.Nodes.Add("礼服出租");
- this.CtvTsorder_Name.Nodes.Add("礼服出售");
- }
- else if (this.cmbProjectSearch.Text == "店面支出")
- { this.CmbBindCashExpenditure(); }
- else if (this.cmbProjectSearch.Text == "财务支出")
- {
- this.CtvTsorder_Name.Visible = true;
- this.CtvTsorder_Name.TreeView.Nodes.Clear();
- DataTable tbl = orbll.GetView_Custom("tb_ErpSystemCategory", StrWhere: "", ShowColumnName: "ID,Sc_ClassCode,Sc_ClassName,Sc_ClassParentID", filedOrder: "ID desc").Tables[0];
- tbl.PrimaryKey = new DataColumn[] { tbl.Columns["Sc_ClassCode"] };
- DataRow dtRow = tbl.Rows.Find("BFAGBGBAEJBACEEHJ");
- if (dtRow != null)
- {
- DataRow[] dtRow1 = tbl.Select("Sc_ClassParentID='" + dtRow["ID"].ToString().Trim() + "'");
- TreeNode root = null;
- for (int i = 0; i < dtRow1.Length; i++)
- {
- root = new TreeNode();
- if (i == 0)
- {
- root = new TreeNode("全部");
- this.CtvTsorder_Name.TreeView.Nodes.Add(root);
- }
- root = new TreeNode(dtRow1[i]["Sc_ClassName"].ToString());
- root.Tag = dtRow1[i]["Sc_ClassCode"].ToString();
- this.CreateTreeViewShop(root.Nodes, dtRow1[i]["ID"].ToString(), tbl);
- this.CtvTsorder_Name.TreeView.Nodes.Add(root);
- }
- }
- }
- else if (this.cmbProjectSearch.Text == "押金")
- { this.CtvTsorder_Name.Visible = false; }
- //获取文本框金额
- this.BindTotal();
- }
- catch (Exception ex)
- { MessageBoxCustom.Show(ex.Message); }
- }
- /// <summary>
- /// 项目名称
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- protected override void CtvTsorder_Name_ComboBoxTreeViewEx_TextChanged(object sender, TreeViewEventArgs e)
- { this.BindTotal(); }
- /// <summary>
- /// 选择支付方式
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- protected override void cmbPay_PaymentMethod_ComboBoxTreeViewEx_TextChanged(object sender, TreeViewEventArgs e)
- { this.BindTotal(); }
- /// <summary>
- /// 查询
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- void btnQuery_Click(object sender, EventArgs e)
- {
- this.GetTodayMumberOrders();
- this.BindTotal();
- this.Bind();
- }
- /// <summary>
- /// 导出
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- protected override void btnExPort_Click(object sender, EventArgs e)
- { this.dgvMonth.ExportDataTable(); }
- /// <summary>
- /// 关闭
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- protected override void btnClose_Click(object sender, EventArgs e)
- { this.Close(); }
- /// <summary>
- /// 查询明细
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- protected override void dgvMonth_DoubleClick(object sender, EventArgs e)
- {
- try
- {
- if (this.dgvMonth.SelectedRows.Count == 0)
- { MessageBoxCustom.Show("请选择你要修改的数据!"); return; }
- LYFZ.Software.MainBusiness.StatisticalInquiry.FrmDayFinance frm = new FrmDayFinance();
- frm.StartPosition = System.Windows.Forms.FormStartPosition.Manual;
- frm.Location = new Point(LYFZ.EnumPublic.FormLocation_X, LYFZ.EnumPublic.FormLocation_Y);
- frm.Size = new Size(LYFZ.EnumPublic.FormSize_Width, LYFZ.EnumPublic.FormSize_Height);
- frm.DateTimeDay = this.dgvMonth.CurrentRow.Cells["DayNumber"].Value.ToString();
- frm.Show();
- }
- catch (Exception ex)
- { MessageBoxCustom.Show(ex.Message); }
- }
- /// <summary>
- /// 打印
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- protected override void btnPrint_Click(object sender, EventArgs e)
- {
- try
- {
- string StrDateWeek = this.dtpStart.DateValue + " — " + this.dtpEnd.DateValue;// Convert.ToDateTime(this.numYear.Value + "-" + this.numMonth.Value).ToString("yyyy年MM月");
- object StrText = "总收入:" + this.txtTotalRevenue.Text.Trim() + " 营业收入:" + this.txtOperatingIncome.Text.Trim() + " 总支出:" + this.txtTotalExpenditure.Text.Trim();
- StrText += "\r\n净收入:" + this.txtNetIncome.Text.Trim() + " 前期业绩:" + this.txtPreliminaryResults.Text.Trim() + " 后期业绩:" + this.txtLateResults.Text.Trim();
- StrText += "\r\n" + this.lblCount.Text.Trim();
- Hashtable htData = new Hashtable();
- htData["dgvData"] = this.dgvMonth;
- htData["StrText"] = StrText;
- htData["StrDateWeek"] = StrDateWeek;
- LYFZ.Software.MainBusiness.ReportPrint.ReportFixedFormat.PrintFixedFormat(EnumPublic.PrintTypeEnum.财务报表月, htData);
- }
- catch (Exception ex)
- { MessageBoxCustom.Show(ex.Message); }
- }
- /// <summary>
- /// 查看详情
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- protected override void btnSeeDetails_Click(object sender, EventArgs e)
- {
- LYFZ.Software.MainBusiness.StatisticalInquiry.MonthFinance.FrmMonthFinanceSeeDetails frm = new MonthFinance.FrmMonthFinanceSeeDetails();
- frm.StartPosition = System.Windows.Forms.FormStartPosition.Manual;
- frm.Location = new Point(LYFZ.EnumPublic.FormLocation_X, LYFZ.EnumPublic.FormLocation_Y);
- frm.Size = new Size(LYFZ.EnumPublic.FormSize_Width, LYFZ.EnumPublic.FormSize_Height);
- frm.StrDateStart = this.dtpStart.DateValue;
- frm.StrDateEnd = this.dtpEnd.DateValue;
- frm.ShowDialog();
- }
- }
- }
|