123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415 |
- using System;
- 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.DecisionAssistant
- {
- public partial class AnalyzedOrderFinanceOutlayFormMain : LYFZ.Software.UI.DecisionAssistant.AnalyzedOrderFinanceOutlayFormMain
- {
- LYFZ.BLL.BLL_ErpOrder orbll = new BLL.BLL_ErpOrder();
- public AnalyzedOrderFinanceOutlayFormMain()
- {
- this.Load += AnalyzedOrderFinanceOutlayFormMain_Load;
- this.Shown += AnalyzedOrderFinanceOutlayFormMain_Shown;
- this.chkComparedStartUp.Click += chkComparedStartUp_Click;
- this.btnQuery.Click += btnQuery_Click;
- this.btnQueryCompared.Click += btnQueryCompared_Click;
- this.btnSaveAs.Click += btnSaveAs_Click;
- this.btnCloseed.Click += btnCloseed_Click;
- this.Resize += AnalyzedOrderFinanceOutlayFormMain_Resize;
- }
- /// <summary>
- /// 窗体加载事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- void AnalyzedOrderFinanceOutlayFormMain_Load(object sender, EventArgs e)
- {
- this.numYear.Value = SDateTime.Now.Year;
- this.numYearCompared.Value = SDateTime.Now.Year - 1;
- LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.BindComboBoxTreeView_SystemCategory("BFAGBGBAEJBACEEHJ", this.cmbtreevItmes, IsFirstNodeNull: true, IsFirstNodeName: "全部");
- this.cmbtreevItmes.TextFindTag("全部");
- LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.BindGroupStoreName(this.cmbtreevStoreName, StrGroupKeyCode: "stA10", StrKeyCode: "stA20", IsShowAllText: false);
- this.panelQueryCompared.Visible = false;
- }
- /// <summary>
- /// 窗体加载事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- void AnalyzedOrderFinanceOutlayFormMain_Shown(object sender, EventArgs e)
- {
- bool b = LYFZ.Software.MainBusiness.VersionControl.StaticVersion.UIFunctionVersion(VersionControl.VersionFunctionEnum.决策助手年财务支出);
- if (!b)
- {
- this.Close();
- return;
- }
-
- this.PublicFunctionRows();
-
- }
- /// <summary>
- /// 启用对比
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- void chkComparedStartUp_Click(object sender, EventArgs e)
- {
- if (this.chkComparedStartUp.Checked)
- {
- this.panelCloseed.Visible = false;
- this.panelSaveAs.Visible = false;
- this.panelEx4.Visible = true;
- this.panelQueryCompared.Visible = true;
- this.panelSaveAs.Visible = true;
- this.panelCloseed.Visible = true;
- if (!string.IsNullOrEmpty(this.numYear.Value.ToString().Trim()) && !string.IsNullOrEmpty(this.numYearCompared.Value.ToString().Trim()))
- { this.PublicFunctionRows(); }
- else
- { return; }
- }
- else
- {
- this.panelQueryCompared.Visible = false;
- this.panelEx4.Visible = false;
- }
- }
- /// <summary>
- /// 查询
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- void btnQuery_Click(object sender, EventArgs e)
- {
- this.PublicFunctionRows();
- }
- /// <summary>
- /// 查询对比
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- void btnQueryCompared_Click(object sender, EventArgs e)
- {
- this.PublicFunctionRows();
- }
- /// <summary>
- /// 另存为
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- void btnSaveAs_Click(object sender, EventArgs e)
- {
- Bitmap bitmap = new Bitmap(this.panelEx5.Width, this.panelEx5.Height);
- this.panelEx5.DrawToBitmap(bitmap, new Rectangle(0, 0, this.panelEx5.Width, this.panelEx5.Height));
- string StrYearValue = this.numYear.Value.ToString().Trim();
- string StrYearValueDb = this.numYearCompared.Value.ToString().Trim();
- string StrItemText = this.cmbtreevItmes.Text.Trim().Trim();
- if (StrItemText.Trim() == "全部")
- { StrItemText = ""; }
- string StrFilleName = StrYearValue + "年" + StrItemText + " 财务支出总览";
- if (this.chkComparedStartUp.Checked)
- { StrFilleName = StrYearValue + "年 与 " + StrYearValueDb + "年 财务支出总览"; }
- LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.DownloadSaveAs(bitmap, StrFilleName: "AAA");
- }
- /// <summary>
- /// 关闭
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- void btnCloseed_Click(object sender, EventArgs e)
- {
- this.Close();
- }
- /// <summary>
- /// 窗体大小 发生变化
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- void AnalyzedOrderFinanceOutlayFormMain_Resize(object sender, EventArgs e)
- {
- switch (this.panelCloseed.Location.Y)
- {
- case 1: this.flowLayoutPanel1.Height = 35; break;
- case 35: this.flowLayoutPanel1.Height = 70; break;
- }
- }
- /// <summary>
- /// 创建行
- /// </summary>
- void PublicFunctionRows()
- {
-
- if (this.chkComparedStartUp.Checked)
- {
- if (Convert.ToInt32(this.numYearCompared.Value.ToString().Trim()) >= Convert.ToInt32(this.numYear.Value.ToString().Trim()))
- { MessageBoxCustom.Show("对比后的年份不能大于对比前的年份"); return; }
- }
- this.AnalyzedOrderFinanceOutlayFormMain_Resize(this, null);
- this.panelEx5.Controls.Clear();
- if ((this.panelEx3.Width - 6) > 930)
- {
- this.panelEx5.Size = new Size(this.panelEx3.Width - 6, this.panelEx3.Height - 6);
- }
- Bitmap newBmp = new Bitmap(this.panelEx5.Width, this.panelEx5.Height);
- Graphics g = Graphics.FromImage(newBmp);
- Font ft15 = new Font("微软雅黑", 15);
- Font ft12b = new Font("微软雅黑", 11, FontStyle.Bold);
- Font ft12 = new Font("微软雅黑", 10);
- string StrYearValue = this.numYear.Value.ToString().Trim();
- string StrYearValueDb = this.numYearCompared.Value.ToString().Trim();
- string StrItemText = this.cmbtreevItmes.Text.Trim().Trim();
- if (StrItemText.Trim() == "全部")
- { StrItemText = ""; }
- int BitmapWidth = this.panelEx5.Width;
- LYFZ.ComponentLibrary.PanelEx panel = null;
- LYFZ.ComponentLibrary.LabelEx label = null;
- int Location_X = 40;
- int Location_Y = this.panelEx5.Height - 50;
- int SingleWidht = (this.panelEx5.Width - 110) / 11;
- #region 标题
- label = new ComponentLibrary.LabelEx();
- label.Font = new Font("微软雅黑", 15);
- if (this.chkComparedStartUp.Checked)
- { label.Text = StrYearValue + "年 与 " + StrYearValueDb + "年 " + StrItemText + "财务支出分析"; }
- else
- { label.Text = StrYearValue + "年" + StrItemText + "财务支出对比分析"; }
- SizeF sizef = g.MeasureString(label.Text.Trim(), ft15);
- int FtHeigth = Convert.ToInt32(sizef.Height);
- int FtWidth = Convert.ToInt32(sizef.Width) + 1;
- label.Width = 300;
- label.Location = new Point((this.panelEx5.Width - FtWidth) / 2, 30);
- this.panelEx5.Controls.Add(label);
- #endregion
- string StrTimeStrat = StrYearValue + "-01-01";
- string StrTimeEnd = Convert.ToDateTime(StrTimeStrat).AddYears(1).ToString("yyyy-MM-dd");
- string StrTimeStratDb = StrYearValueDb + "-01-01";
- string StrTimeEndDb = Convert.ToDateTime(StrTimeStratDb).AddYears(1).ToString("yyyy-MM-dd");
- string StrWhere = LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.GetDateTime("Oiae_IEDatetime", StrTimeStrat, StrTimeEnd, DateAddDays: 0);
- StrWhere += LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.GetGroupQueryWhere(this.cmbtreevStoreName, "Oiae_DividedShop");
- if (!string.IsNullOrEmpty(StrItemText) && StrItemText.Trim() != "全部")
- { StrWhere += " And Oiae_ProjectName = '" + StrItemText + "'"; }
- string ExecuteSql = "select Sum(Oiae_Money) AS 金额,CONVERT(varchar(7),dbo.fn_CheckDateTime(Oiae_IEDatetime), 120) AS 月份 from tb_ErpOtherIncomeAndExpenses where Oiae_Type = '财务支出' " + StrWhere + " Group By CONVERT(varchar(7),dbo.fn_CheckDateTime(Oiae_IEDatetime), 120);";
- if (this.chkComparedStartUp.Checked)
- {
- StrWhere = LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.GetDateTime("Oiae_IEDatetime", StrTimeStratDb, StrTimeEndDb, DateAddDays: 0) + "";
- StrWhere += LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.GetGroupQueryWhere(this.cmbtreevStoreName, "Oiae_DividedShop");
- ExecuteSql += "select Sum(Oiae_Money) AS 金额,CONVERT(varchar(7),dbo.fn_CheckDateTime(Oiae_IEDatetime), 120) AS 月份 from tb_ErpOtherIncomeAndExpenses where Oiae_Type = '财务支出' " + StrWhere + " Group By CONVERT(varchar(7),dbo.fn_CheckDateTime(Oiae_IEDatetime), 120);";
- }
- DataSet dsData = orbll.GetView_Custom(ExecuteSql);
- DataTable dtOrderCount = dsData.Tables["ds"];
- DataTable dtOrderCountCompared = dsData.Tables["ds1"];
- decimal MaxAmount = 0;
- for (int i = 0; i < dtOrderCount.Rows.Count; i++)
- {
- if (Convert.ToDecimal(dtOrderCount.Rows[i]["金额"]) > MaxAmount)
- { MaxAmount = Convert.ToDecimal(dtOrderCount.Rows[i]["金额"]); }
- }
- if (this.chkComparedStartUp.Checked)
- {
- for (int i = 0; i < dtOrderCountCompared.Rows.Count; i++)
- {
- if (Convert.ToDecimal(dtOrderCountCompared.Rows[i]["金额"]) > MaxAmount)
- { MaxAmount = Convert.ToDecimal(dtOrderCountCompared.Rows[i]["金额"]); }
- }
- }
- float WidthRatio = 0;
- if (float.Parse(MaxAmount.ToString()) > 0)
- { WidthRatio = (Location_Y - 100) / float.Parse(MaxAmount.ToString()); }
- if (!this.chkComparedStartUp.Checked)
- {
- #region 不启用对比
- for (int i = 1; i <= 12; i++)
- {
- string StrMonth = StrYearValue + "-" + i.ToString("d2");
- DataRow[] dtRow = dtOrderCount.Select("月份 = '" + StrMonth + "'");
- decimal decAmount = 0;
- int intValue = 0;
- if (dtRow.Length > 0)
- {
- intValue = Convert.ToInt32(WidthRatio * float.Parse(dtRow[0]["金额"].ToString().Trim()));
- decAmount = Convert.ToDecimal(dtRow[0]["金额"]);
- }
- panel = new ComponentLibrary.PanelEx();
- panel.BackColor = Color.Red;
- panel.Tag = StrYearValue + "-" + i.ToString("d2");
- panel.Size = new Size(20, intValue);
- panel.Location = new Point(Location_X, Location_Y - panel.Height);
- panel.MouseDoubleClick += panel_MouseDoubleClick;
- this.panelEx5.Controls.Add(panel);
- sizef = g.MeasureString(i + "月", ft12b);
- FtHeigth = Convert.ToInt32(sizef.Height);
- FtWidth = Convert.ToInt32(sizef.Width) + 4;
- label = new ComponentLibrary.LabelEx();
- label.Tag = StrYearValue + "-" + i.ToString("d2");
- label.Font = ft12b;
- label.Text = i + "月";
- label.Size = new System.Drawing.Size(FtWidth, FtHeigth);
- label.Location = new Point(panel.Location.X + panel.Width / 2 - FtWidth / 2, panel.Location.Y + panel.Height + 5);
- label.Click += label_MouseDoubleClick;
- this.panelEx5.Controls.Add(label);
- sizef = g.MeasureString(LYFZ.BLL.OtherCommonModel.RemoveLastExcessZero(decAmount), ft12);
- FtHeigth = Convert.ToInt32(sizef.Height);
- FtWidth = Convert.ToInt32(sizef.Width) + 10;
- label = new ComponentLibrary.LabelEx();
- label.Tag = StrYearValue + "-" + i.ToString("d2");
- label.Font = ft12;
- label.Text = LYFZ.BLL.OtherCommonModel.RemoveLastExcessZero(decAmount);
- label.Size = new System.Drawing.Size(FtWidth, FtHeigth);
- label.Location = new Point(panel.Location.X + 10 - (FtWidth / 2), panel.Location.Y - FtHeigth - 5);
- label.MouseDoubleClick += label_MouseDoubleClick;
- this.panelEx5.Controls.Add(label);
- Location_X += SingleWidht;
- }
- #endregion
- }
- else
- {
- #region 启用对比
- for (int i = 1; i <= 12; i++)
- {
- string StrMonth = StrYearValue + "-" + i.ToString("d2");
- DataRow[] dtRow = dtOrderCount.Select("月份 = '" + StrMonth + "'");
- string StrMonth2 = StrYearValueDb + "-" + i.ToString("d2");
- DataRow[] dtRow2 = dtOrderCountCompared.Select("月份 = '" + StrMonth2 + "'");
- decimal decAmount = 0;
- int intValue = 0;
- if (dtRow.Length > 0)
- {
- intValue = Convert.ToInt32(WidthRatio * float.Parse(dtRow[0]["金额"].ToString().Trim()));
- decAmount = Convert.ToDecimal(dtRow[0]["金额"]);
- }
- decimal decAmount2 = 0;
- int intValue2 = 0;
- if (dtRow2.Length > 0)
- {
- intValue2 = Convert.ToInt32(WidthRatio * float.Parse(dtRow2[0]["金额"].ToString().Trim()));
- decAmount2 = Convert.ToDecimal(dtRow2[0]["金额"]);
- }
- panel = new ComponentLibrary.PanelEx();
- panel.BackColor = Color.Red;
- panel.Tag = StrYearValue + "-" + i.ToString("d2") + "|" + StrYearValueDb + "-" + i.ToString("d2");
- panel.Size = new Size(20, intValue);
- panel.Location = new Point(Location_X, Location_Y - panel.Height);
- panel.MouseDoubleClick += panel_MouseDoubleClick;
- this.panelEx5.Controls.Add(panel);
- int panelLocationX = panel.Location.X;
- sizef = g.MeasureString(i + "月", ft12b);
- FtHeigth = Convert.ToInt32(sizef.Height);
- FtWidth = Convert.ToInt32(sizef.Width) + 4;
- label = new ComponentLibrary.LabelEx();
- label.BackColor = Color.Transparent;
- label.Tag = StrYearValue + "-" + i.ToString("d2") + "|" + StrYearValueDb + "-" + i.ToString("d2");
- label.Font = ft12b;
- label.Text = i + "月";
- label.Size = new System.Drawing.Size(FtWidth, FtHeigth);
- //label.Location = new Point(panel.Location.X - LessWidth, panel.Location.Y + panel.Height + 5);
- label.Location = new Point(panel.Location.X + panel.Width - FtWidth / 2, panel.Location.Y + panel.Height + 5);
- label.Click += label_MouseDoubleClick;
- this.panelEx5.Controls.Add(label);
- if (decAmount != 0)
- {
- sizef = g.MeasureString(LYFZ.BLL.OtherCommonModel.RemoveLastExcessZero(decAmount), ft12);
- FtHeigth = Convert.ToInt32(sizef.Height);
- FtWidth = Convert.ToInt32(sizef.Width) + 1;
- label = new ComponentLibrary.LabelEx();
- label.BackColor = Color.Transparent;
- label.Tag = StrYearValue + "-" + i.ToString("d2") + "|" + StrYearValueDb + "-" + i.ToString("d2");
- label.Font = ft12;
- label.ForeColor = Color.Red;
- label.Size = new System.Drawing.Size(FtWidth, FtHeigth);
- label.Text = LYFZ.BLL.OtherCommonModel.RemoveLastExcessZero(decAmount);
- label.Location = new Point(panel.Location.X - FtWidth / 2, panel.Location.Y - FtHeigth);
- label.MouseDoubleClick += label_MouseDoubleClick;
- this.panelEx5.Controls.Add(label);
- }
- panel = new ComponentLibrary.PanelEx();
- panel.BackColor = Color.Blue;
- panel.Tag = StrYearValue + "-" + i.ToString("d2") + "|" + StrYearValueDb + "-" + i.ToString("d2");
- panel.Size = new Size(20, intValue2);
- panel.Location = new Point(panelLocationX + panel.Width, Location_Y - panel.Height);
- panel.MouseDoubleClick += panel_MouseDoubleClick;
- this.panelEx5.Controls.Add(panel);
- if (decAmount2 != 0)
- {
- sizef = g.MeasureString(LYFZ.BLL.OtherCommonModel.RemoveLastExcessZero(decAmount2), ft12);
- FtHeigth = Convert.ToInt32(sizef.Height);
- label = new ComponentLibrary.LabelEx();
- label.Tag = StrYearValue + "-" + i.ToString("d2") + "|" + StrYearValueDb + "-" + i.ToString("d2");
- label.Font = ft12;
- label.ForeColor = Color.Blue;
- label.Size = new System.Drawing.Size(FtWidth, FtHeigth);
- label.Text = LYFZ.BLL.OtherCommonModel.RemoveLastExcessZero(decAmount2);
- label.Location = new Point(panel.Location.X, panel.Location.Y - FtHeigth - 18);
- label.MouseDoubleClick += label_MouseDoubleClick;
- label.BackColor = Color.Transparent;
- this.panelEx5.Controls.Add(label);
- }
- Location_X += SingleWidht;
- }
- #endregion
- }
- }
- /// <summary>
- /// 双击柱状
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- void panel_MouseDoubleClick(object sender, EventArgs e)
- {
- LYFZ.ComponentLibrary.PanelEx panel = (LYFZ.ComponentLibrary.PanelEx)sender;
- if (panel.Tag != null)
- { this.DoubleClickGoForm(panel.Tag.ToString().Trim()); }
- }
- /// <summary>
- /// 双击月份、金额
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- void label_MouseDoubleClick(object sender, EventArgs e)
- {
- LYFZ.ComponentLibrary.LabelEx lable = (LYFZ.ComponentLibrary.LabelEx)sender;
- if (lable.Tag != null)
- { this.DoubleClickGoForm(lable.Tag.ToString().Trim()); }
- }
- /// <summary>
- /// 双击跳转到详情
- /// </summary>
- /// <param name="StrValue"></param>
- void DoubleClickGoForm(string StrValue)
- {
- LYFZ.Software.MainBusiness.DecisionAssistant.AnalyzedOrderFinanceOutlayDetailFormMain frm = new AnalyzedOrderFinanceOutlayDetailFormMain();
- frm.StrGoFormDateTime = StrValue;
- frm.StrStoreName = this.cmbtreevStoreName.Tag.ToString().Trim();
- 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.Show();
- }
- }
- }
|