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 FinanceMonthReportSmallForm : LYFZ.Software.UI.StatisticalInquiry.FinanceMonthReportSmallForm
{
LYFZ.BLL.BLL_ErpOrder orbll = new BLL.BLL_ErpOrder();
public FinanceMonthReportSmallForm()
{
this.Load += FinanceMonthReportSmallForm_Load;
this.Shown += FinanceMonthReportSmallForm_Shown;
this.btnQuery.Click += btnQuery_Click;
this.btnExport.Click += btnExport_Click;
this.btnPrint.Click += btnPrint_Click;
this.btnViewDetail.Click += btnViewDetail_Click;
this.btnClose.Click += btnClose_Click;
this.cmbtreevPaymentMethod.ComboBoxTree_NodeMouseClick += cmbtreevPaymentMethod_ComboBoxTree_NodeMouseClick;
this.cmbtreevQueryItem.ComboBoxTree_NodeMouseClick += cmbtreevQueryItem_ComboBoxTree_NodeMouseClick;
this.cmbtreevSecondOption.ComboBoxTree_NodeMouseClick += cmbtreevSecondOption_ComboBoxTree_NodeMouseClick;
this.cmbtreevStoreName.ComboBoxTree_NodeMouseClick += cmbtreevStoreName_ComboBoxTree_NodeMouseClick;
this.cmbtreevOrderType.ComboBoxTree_NodeMouseClick += cmbtreevOrderType_ComboBoxTree_NodeMouseClick;
this.dgvData.MouseDoubleClick += dgvData_MouseDoubleClick;
this.Resize += FinanceMonthReportSmallForm_Resize;
this.dtpStart.Leave += dtpStart_Leave;
this.cmbtreevOrderClass.ComboBoxTree_NodeMouseClick += cmbtreevOrderType_ComboBoxTree_NodeMouseClick;
}
void BindOrderClassData()
{
LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.BindComboBoxTreeView_SystemCategory("BFAGAHBFDGCABAJIH", this.cmbtreevOrderClass, true);
}
public string StrDateTime = "";
///
/// 需要的分店编号(用于月报跳转过来)
///
public string DataTimeStoreName = "";
///
/// 是否有财务支出权限
///
private bool IsFinancialOutlay = false;
///
/// 分店编号
///
private string _StrStoreWhere;
///
/// 分店编号
///
public string StrStoreWhere
{
get
{
this.Invoke(new LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.UpdateControl(delegate()
{
_StrStoreWhere = LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.GetGroupQueryWhere(this.cmbtreevStoreName, "分店编号", ConnectWord: "");
}));
return _StrStoreWhere;
}
set { _StrStoreWhere = value; }
}
///
/// 窗体加载事件
///
///
///
void FinanceMonthReportSmallForm_Load(object sender, EventArgs e)
{
LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.BindGroupStoreName(this.cmbtreevStoreName, StrGroupKeyCode: "st0240", StrKeyCode: "st026", StrDefaultStoreText: DataTimeStoreName);
LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.BindFinanceOrderType(this.cmbtreevOrderType);
BindOrderClassData();
string StrColumns = "日期, 总收入, 总支出, 总净收, 优惠金额, 订单定金, 订单补款, 后期收入, 其它收入, 会员充值, 服务卡充值, 摄友会收款, 总业绩, 前期业绩, 后期业绩";
this.dgvData.DataColumns(StrColumns);
this.dgvData.FillLastColumn(true);
}
///
/// 窗体加载事件
///
///
///
void FinanceMonthReportSmallForm_Shown(object sender, EventArgs e)
{
//this.cmbtreevSecondOption.Visible = false;
if (string.IsNullOrEmpty(StrDateTime))
{ this.dtpStart.DateValue = SDateTime.Now.Year + "-" + SDateTime.Now.Month + "-01"; }
else
{ this.dtpStart.DateValue = StrDateTime + "-01"; }
this.dtpEnd.DateValue = Convert.ToDateTime(this.dtpStart.DateValue).AddMonths(1).AddSeconds(-1).ToString("yyyy-MM-dd");
LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.BindComboxTreeView(this.cmbtreevSecondOption, "全部,收入,支出,押金,退押金,报损");
this.cmbtreevSecondOption.TextFindTag("全部");
LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.BindComboBoxTreeView_PaymentMethod(this.cmbtreevPaymentMethod, IsShowAll: true, IsFirstNodeNull: true, IsFirstNodeName: "全部");
this.cmbtreevPaymentMethod.TextFindTag("全部");
this.PublicFunctionRights();
this.btnQuery_Click(this, null);
this.FinanceMonthReportSmallForm_Resize(this, null);
}
///
/// 查询
///
///
///
void btnQuery_Click(object sender, EventArgs e)
{
if (string.IsNullOrEmpty(this.dtpStart.DateValue.Trim()))
{ MessageBoxCustom.Show("开始日期不能为空"); return; }
if (string.IsNullOrEmpty(this.dtpEnd.DateValue.Trim()))
{ MessageBoxCustom.Show("结束日期不能为空"); return; }
this.dgvData.Rows.Clear();
string StrDateTimeStart = this.dtpStart.DateValue.Trim();
string StrDateTimeEnd = this.dtpEnd.DateValue.Trim();
string StrItemQueryText = this.cmbtreevQueryItem.Text.Trim();
string StrSecondOption = this.cmbtreevSecondOption.Text.Trim();
string StrPaymentMethod = this.cmbtreevPaymentMethod.Text.Trim();
string StrOrderType = this.cmbtreevOrderType.Text.Trim();
string StrOrderClass = this.cmbtreevOrderClass.Text.Trim();
LYFZ.ComponentLibrary.FrmLoadHandling.LoadDoWorkMethod(delegate(object obj, BackgroundWorker backgroundWorker)
{
LYFZ.BLL.GetFinancialReportModel frmodel = orbll.Funt_GetFinanceMonthReport(StrItemQueryText: StrItemQueryText, StrSecondOption: StrSecondOption, StrPaymentMethod: StrPaymentMethod, StrDateTimeStart: StrDateTimeStart, StrDateTimeEnd: StrDateTimeEnd, IsFinancialOutlay: this.IsFinancialOutlay, IsOrderStatistic: true, StrStoreWhere: this.StrStoreWhere);
LYFZ.BLL.GetFinancialReportModel frmodel2 = orbll.Funt_GetFinanceDayReport(StrItemQueryText: StrItemQueryText, StrSecondOption: StrSecondOption, StrPaymentMethod: StrPaymentMethod, StrOrderType: StrOrderType, StrDateTimeStart: StrDateTimeStart, StrDateTimeEnd: StrDateTimeEnd, IsFinancialOutlay: IsFinancialOutlay, IsGetArrearsOrDeposits: false, StrStoreWhere: this.StrStoreWhere, StrOrderClass: StrOrderClass);
DataTable dt = frmodel2.dtFinance_Statistic;
DataTable dt2 = frmodel.dtFinance_DataList;
string StrPaymentStatistic = frmodel.StrFinance_PaymentStatistic;
string StrOrderCountStatistic = frmodel.StrFinance_OrderCountStatistic;
this.Invoke(new LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.UpdateControl(delegate()
{
this.lblCount.Text = StrOrderCountStatistic;
this.lblPaymentStatistic.Text = StrPaymentStatistic;
if (dt != null)
{
for (int i = 0; i < dt.Rows.Count; i++)
{
this.txtTotalIncome.Text = dt.Rows[i]["总收入"].ToString().Trim();
this.txtOperatingIncome.Text = dt.Rows[i]["营业收入"].ToString().Trim();
this.txtNetIncome.Text = dt.Rows[i]["净收入"].ToString().Trim();
this.txtOrderEarly.Text = dt.Rows[i]["订单前期"].ToString().Trim();
this.txtOrderLate.Text = dt.Rows[i]["订单后期"].ToString().Trim();
this.txtTotalOutlay.Text = dt.Rows[i]["支出"].ToString().Trim();
this.txtVoucher.Text = dt.Rows[i]["代金券"].ToString().Trim();
}
}
if (dt2 != null)
{
for (int i = 0; i < dt2.Rows.Count; i++)
{
DataGridViewRow dgvr = new DataGridViewRow();
DataGridViewCell cell = null;
for (int j = 0; j < dt2.Columns.Count; j++)
{
cell = new DataGridViewTextBoxCell();
cell.Value = dt2.Rows[i][j].ToString().Trim();
dgvr.Cells.Add(cell);
}
this.dgvData.Rows.Add(dgvr);
}
}
}));
});
}
///
/// 导出
///
///
///
void btnExport_Click(object sender, EventArgs e)
{
this.dgvData.ExportDataTable(StrFileName: "月财务详情");
}
///
/// 打印
///
///
///
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.txtTotalIncome.Text.Trim() + " 营业收入:" + this.txtOperatingIncome.Text.Trim() + " 总支出:" + this.txtTotalOutlay.Text.Trim();
StrText += "\r\n净收入:" + this.txtNetIncome.Text.Trim() + " 前期业绩:" + this.txtOrderEarly.Text.Trim() + " 后期业绩:" + this.txtOrderLate.Text.Trim();
StrText += "\r\n" + this.lblCount.Text.Trim();
Hashtable htData = new Hashtable();
htData["dgvData"] = this.dgvData;
htData["StrText"] = StrText;
htData["StrDateWeek"] = StrDateWeek;
LYFZ.Software.MainBusiness.ReportPrint.ReportFixedFormat.PrintFixedFormat(EnumPublic.PrintTypeEnum.财务报表月, htData);
}
catch (Exception ex)
{ MessageBoxCustom.Show(ex.Message); }
}
///
/// 详情
///
///
///
void btnViewDetail_Click(object sender, EventArgs e)
{
LYFZ.Software.MainBusiness.StatisticalInquiry.FinanceDayReportSmallForm frm = new FinanceDayReportSmallForm();
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.DateTimeStart = this.dtpStart.DateValue;
frm.DateTimeEnd = this.dtpEnd.DateValue;
frm.DataTimeStoreName = this.cmbtreevStoreName.Text.Trim();
frm.ShowDialog();
}
///
/// 关闭
///
///
///
void btnClose_Click(object sender, EventArgs e)
{
this.Close();
}
///
/// 付款方式
///
///
///
void cmbtreevPaymentMethod_ComboBoxTree_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e)
{
this.cmbtreevSecondOption_ComboBoxTree_NodeMouseClick(this, null);
}
///
/// 项目查询
///
///
///
void cmbtreevQueryItem_ComboBoxTree_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e)
{
this.cmbtreevSecondOption.Nodes.Clear();
//this.cmbtreevSecondOption.Visible = false;
if (this.cmbtreevQueryItem.Text == "全部")
{
this.cmbtreevSecondOption.Visible = true;
LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.BindComboxTreeView(this.cmbtreevSecondOption, "全部,收入,支出,押金,退押金,报损");
}
else if (this.cmbtreevQueryItem.Text == "订单前期收入")
{
this.cmbtreevSecondOption.Visible = true;
LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.BindComboxTreeView(this.cmbtreevSecondOption, "全部,预约收款,预约补款,全款");
}
else if (this.cmbtreevQueryItem.Text == "订单后期收入" || this.cmbtreevQueryItem.Text == "散客消费收入")
{
this.cmbtreevSecondOption.Visible = true;
LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.BindComboBoxTreeView_SystemCategory("BEBACDAJDFDDEACGJ", this.cmbtreevSecondOption, IsFirstNodeNull: true, IsFirstNodeName: "全部");
}
else if (this.cmbtreevQueryItem.Text == "其它收入")
{ }
else if (this.cmbtreevQueryItem.Text == "会员充值")
{ }
else if (this.cmbtreevQueryItem.Text == "服务卡消费")
{ }
else if (this.cmbtreevQueryItem.Text == "摄友会收款")
{
this.cmbtreevSecondOption.Visible = true;
LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.BindComboxTreeView(this.cmbtreevSecondOption, "全部,摄友会升级,摄友会返还款");
}
else if (this.cmbtreevQueryItem.Text == "礼服租售收入")
{
this.cmbtreevSecondOption.Visible = true;
LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.BindComboxTreeView(this.cmbtreevSecondOption, "全部,礼服出租,礼服出售,礼服押金,退押金,报损");
}
else if (this.cmbtreevQueryItem.Text == "会员返现")
{ }
else if (this.cmbtreevQueryItem.Text == "店面支出")
{
this.cmbtreevSecondOption.Visible = true;
LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.BindComboBoxTreeView_SystemCategory("BEBACIAFBEDIGJJFE", this.cmbtreevSecondOption, IsFirstNodeNull: true, IsFirstNodeName: "全部");
}
else if (this.cmbtreevQueryItem.Text == "财务支出")
{
this.cmbtreevSecondOption.Visible = true;
LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.BindComboBoxTreeView_SystemCategory("BFAGBGBAEJBACEEHJ", this.cmbtreevSecondOption, IsFirstNodeNull: true, IsFirstNodeName: "全部");
}
//else if (this.cmbtreevQueryItem.Text == "押金")
//{ }
if (this.cmbtreevSecondOption.Visible)
{ this.cmbtreevSecondOption.TextFindTag("全部"); }
if (!this.cmbtreevSecondOption.Visible)
{ this.panelQueryItem.Width = 240; }
else
{ this.panelQueryItem.Width = 370; }
this.cmbtreevSecondOption_ComboBoxTree_NodeMouseClick(this, null);
}
///
/// 第二选项选择事件
///
///
///
void cmbtreevSecondOption_ComboBoxTree_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e)
{
if (string.IsNullOrEmpty(this.dtpStart.DateValue.Trim()))
{ MessageBoxCustom.Show("开始日期不能为空"); return; }
if (string.IsNullOrEmpty(this.dtpEnd.DateValue.Trim()))
{ MessageBoxCustom.Show("结束日期不能为空"); return; }
string StrDateTimeStart = this.dtpStart.DateValue.Trim();
string StrDateTimeEnd = this.dtpEnd.DateValue.Trim();
string StrItemQueryText = this.cmbtreevQueryItem.Text.Trim();
string StrSecondOption = this.cmbtreevSecondOption.Text.Trim();
string StrPaymentMethod = this.cmbtreevPaymentMethod.Text.Trim();
string StrOrderType = this.cmbtreevOrderType.Text.Trim();
string StrOrderClass = this.cmbtreevOrderClass.Text.Trim();
LYFZ.ComponentLibrary.FrmLoadHandling.LoadDoWorkMethod(delegate(object obj, BackgroundWorker backgroundWorker)
{
LYFZ.BLL.GetFinancialReportModel frmodel2 = orbll.Funt_GetFinanceDayReport(StrItemQueryText: StrItemQueryText, StrSecondOption: StrSecondOption, StrPaymentMethod: StrPaymentMethod, StrOrderType: StrOrderType, StrDateTimeStart: StrDateTimeStart, StrDateTimeEnd: StrDateTimeEnd, IsFinancialOutlay: IsFinancialOutlay, IsGetArrearsOrDeposits: false, StrStoreWhere: this.StrStoreWhere, StrOrderClass: StrOrderClass);
DataTable dt = frmodel2.dtFinance_Statistic;
this.Invoke(new LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.UpdateControl(delegate()
{
if (dt != null)
{
for (int i = 0; i < dt.Rows.Count; i++)
{
this.txtTotalIncome.Text = dt.Rows[i]["总收入"].ToString().Trim();
this.txtOperatingIncome.Text = dt.Rows[i]["营业收入"].ToString().Trim();
this.txtNetIncome.Text = dt.Rows[i]["净收入"].ToString().Trim();
this.txtOrderEarly.Text = dt.Rows[i]["订单前期"].ToString().Trim();
this.txtOrderLate.Text = dt.Rows[i]["订单后期"].ToString().Trim();
this.txtTotalOutlay.Text = dt.Rows[i]["支出"].ToString().Trim();
this.txtVoucher.Text = dt.Rows[i]["代金券"].ToString().Trim();
}
}
}));
});
}
///
/// 选择分店
///
///
///
void cmbtreevStoreName_ComboBoxTree_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e)
{
this.PublicFunctionRights();
this.btnQuery_Click(this, null);
}
///
/// 选择订单类型
///
///
///
void cmbtreevOrderType_ComboBoxTree_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e)
{
this.cmbtreevSecondOption_ComboBoxTree_NodeMouseClick(this, null);
}
///
/// 选择分店获取权限
///
void PublicFunctionRights()
{
LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.BindComboxTreeView(this.cmbtreevQueryItem, "全部,订单前期收入,订单后期收入,散客消费收入,其它收入,礼服租售收入,会员充值,服务卡消费,摄友会收款,会员返现,店面支出,财务支出");//,押金
this.cmbtreevQueryItem.TextFindTag("全部");
this.btnExport.Enabled = LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.GetGroupStoreRights(this.cmbtreevStoreName, "MonthFinanceCompetence", CustomAttributes.OperatingAuthority.DataExport);
this.btnPrint.Enabled = LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.GetGroupStoreRights(this.cmbtreevStoreName, "MonthFinanceCompetence", CustomAttributes.OperatingAuthority.Print);
this.IsFinancialOutlay = LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.GetGroupStoreRights(this.cmbtreevStoreName, "DayFinanceCompetence", CustomAttributes.OperatingAuthority.FinancialExpenses);
if (!this.IsFinancialOutlay)
{ this.cmbtreevQueryItem.Nodes.Remove(this.cmbtreevQueryItem.GetNodeItem_TextToTag("财务支出")); }
this.panelNetIncome.Visible = this.IsFinancialOutlay;
}
///
/// 列表双击事件
///
///
///
void dgvData_MouseDoubleClick(object sender, MouseEventArgs e)
{
try
{
if (e.Location.Y > this.dgvData.ColumnHeadersHeight)
{
if (this.dgvData.SelectedRows.Count == 0)
{ MessageBoxCustom.Show("请选择你要修改的数据!"); return; }
LYFZ.Software.MainBusiness.StatisticalInquiry.FinanceDayReportSmallForm frm = new FinanceDayReportSmallForm();
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.dgvData.CurrentRow.Cells["日期"].Value.ToString();
frm.DataTimeStoreName = this.cmbtreevStoreName.Text.Trim();
frm.Show();
}
}
catch (Exception ex)
{ MessageBoxCustom.Show(ex.Message); }
}
///
/// 窗体大小发生变化
///
///
///
void FinanceMonthReportSmallForm_Resize(object sender, EventArgs e)
{
int LocationY = 0;
if (this.panelOrderType.Visible)
{ LocationY = this.panelOrderType.Location.Y; }
else
{ LocationY = this.panelStoreName.Location.Y; }
switch (LocationY)
{
case 0: this.flowLayoutPanel1.Height = 28; break;
case 27: this.flowLayoutPanel1.Height = 55; break;
case 54: this.flowLayoutPanel1.Height = 82; break;
case 81: this.flowLayoutPanel1.Height = 109; break;
}
this.panelEx2.Height = this.flowLayoutPanel1.Height + 50;
}
///
/// 开始时间离开事件
///
///
///
void dtpStart_Leave(object sender, EventArgs e)
{
this.dtpEnd.DateValue = Convert.ToDateTime(this.dtpStart.DateValue.Trim()).AddMonths(1).AddSeconds(-1).ToString("yyyy-MM-dd");
}
}
}