123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104 |
- using LYFZ.Model;
- 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.DecisionAssistant
- {
- public partial class AnalyzedEmployeePerformanceFormMain : LYFZ.Software.UI.DecisionAssistant.AnalyzedEmployeePerformanceFormMain
- {
- LYFZ.BLL.BLL_ErpOrder orbll = new BLL.BLL_ErpOrder();
- List<ModelImagePostionAction> actionList = new List<ModelImagePostionAction>();
- public AnalyzedEmployeePerformanceFormMain()
- {
- this.Load += AnalyzedEmployeePerformanceFormMain_Load;
- this.Shown += AnalyzedEmployeePerformanceFormMain_Shown;
- this.PictImage.Click += PictImage_Click;
- this.chkComparedStartUp.Click += chkComparedStartUp_Click;
- this.btnQuery.Click += btnQuery_Click;
- this.btnQueryCompared.Click += btnQueryCompared_Click;
- this.dtDataTimeStart.Leave += dtDataTimeStart_Leave;
- this.dtDataTimeStartCompared.Leave += dtDataTimeStartCompared_Leave;
- //this.cmbtreevItmes.ComboBoxTree_NodeMouseClick += cmbtreevItmes_ComboBoxTree_NodeMouseClick;
- this.btnSaveAs.Click += btnSaveAs_Click;
- this.btnClose.Click += btnClose_Click;
- this.Resize += AnalyzedEmployeePerformanceFormMain_Resize;
- this.PictImage.MouseDoubleClick += PictImage_MouseDoubleClick;
- this.cmbtreevItmes.AfterCheck += TreeView_AfterCheck;
- //this.cmbtreevItmes.TreeView.NodeMouseClick += TreeView_NodeMouseClick;//TreeView_NodeMouseClick;
- }
-
- void TreeView_AfterCheck(object sender, TreeViewEventArgs e)
- {
- string strNode = "";
- foreach(TreeNode node in this.cmbtreevItmes.Nodes)
- {
- if(node.Checked)
- {
- if(strNode!="")
- {
- strNode += ",";
- }
- strNode += node.Text;
- }
- }
- this.cmbtreevItmes.Text = strNode;
- }
- /// <summary>
- /// 图片双击事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- void PictImage_MouseDoubleClick(object sender, MouseEventArgs e)
- {
- ModelImagePostionAction action = actionList.Find(p => p.MouseX <= e.Location.X && e.Location.X <= (p.MouseX + p.MouseWidth)
- &&
- p.MouseY <= e.Location.Y && e.Location.Y <= (p.MouseY + p.MouseHeight));
- if (action != null)
- {
- LYFZ.Software.MainBusiness.DecisionAssistant.SetSmallForm.AnalyzedOrderDetailSmallForm detailForm = new SetSmallForm.AnalyzedOrderDetailSmallForm();
- detailForm.BindDataGridView2(action);
- detailForm.ShowDialog();
- //MessageBox.Show("内容!");
- }
- }
- bool IsFristLoad = true;
- /// <summary>
- /// 窗体加载事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- void AnalyzedEmployeePerformanceFormMain_Load(object sender, EventArgs e)
- {
- this.panelComparedColor.Visible = false;
- this.lblComparedColor.Visible = false;
- this.panelCurrentColor.BackColor = Color.Red;
- this.panelComparedColor.BackColor = Color.Blue;
- this.panelPaidColor.BackColor = Color.Green;
- this.panelEx10.Visible = false;
- this.dtDataTimeStart.DateValue = SDateTime.Now.ToString("yyyy-MM") + "-01";
- this.dtDataTimeEnd.DateValue = Convert.ToDateTime(this.dtDataTimeStart.DateValue).AddMonths(1).AddSeconds(-1).ToString("yyyy-MM-dd");
- LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.BindComboBoxTreeView_StoreDepartment(this.cmbtreevDepartment, true, "全部");
- LYFZ.BLL.BLL_ErpCompanyInfo companyBll = new BLL.BLL_ErpCompanyInfo();
- DataTable companyList = companyBll.GetAllList().Tables[0];
- List<string> sIDList = LYFZ.BLL.BLL_ErpUser.GetGroupRights("stA10", "stA19");
- try
- {
- foreach (DataRow dr in companyList.Rows)
- {
- if (!sIDList.Contains(dr["Company_DividedShop"].ToString()))
- {
- foreach (TreeNode node in this.cmbtreevDepartment.Nodes)
- {
- try
- {
- if (node != null)
- {
- if (dr["Company_DividedShop"].ToString() == node.Tag.ToString())
- {
- this.cmbtreevDepartment.Nodes.Remove(node);
- }
- }
- }
- catch (Exception ex)
- {
- Console.WriteLine(ex.Message);
- }
- }
- }
- }
- }
- catch (Exception ex){
- MessageBoxCustom.Show("加载门店数据出错:"+ex.Message);
- }
- this.cmbtreevDepartment.TextFindTag("全部");
- this.cmbtreevItmes.CheckBoxes = true;
- TreeNode root = new TreeNode();
- //root.Text = "全部";
- //root.Tag = "";
- //root.Name = "";
- //this.cmbtreevItmes.Nodes.Add(root);
- root = new TreeNode();
- root.Text = "订单前期";
- root.Tag = "订单前期";
- root.Name = "订单前期";
- this.cmbtreevItmes.Nodes.Add(root);
- LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.BindComboBoxTreeView_SystemCategory("BEBACDAJDFDDEACGJ", this.cmbtreevItmes, IsFirstNodeNull: false, StrWhere: "Sc_ClassCode != 'AAAAABZ' and Sc_ClassCode!='BEBCADBFBCDFBGJHC' and Sc_ClassCode!='BEBCADBFBDDEGGABF' and Sc_ClassCode!='BEBCBFBICGDHCGBEJ' and Sc_ClassCode!='BEBCABBAAICBDHDHI' and Sc_ClassCode!='BEBCABBAAICJAAGDG' and Sc_ClassCode!='BEBCBFBICFCECBHFF'", IsClearNodes: false);
- //if (cmbtreevDepartment.GetNodeItem_TextToTag("门市部") == null)
- //{ this.cmbtreevDepartment.TextFindTag(this.cmbtreevDepartment.Nodes[0].Text.Trim()); }
- //else
- //{ this.cmbtreevDepartment.TextFindTag("门市部"); }
- //this.cmbtreevItmes.TextFindTag("全部");
- foreach (TreeNode node in this.cmbtreevItmes.Nodes)
- {
- node.Checked = true;
- }
- TreeView_AfterCheck(null, null);
- }
- /// <summary>
- /// 窗体加载事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- void AnalyzedEmployeePerformanceFormMain_Shown(object sender, EventArgs e)
- {
- bool b = LYFZ.Software.MainBusiness.VersionControl.StaticVersion.UIFunctionVersion(VersionControl.VersionFunctionEnum.决策助手员工业绩);
- if (!b)
- {
- this.Close();
- return;
- }
- this.PublicFunctionRows();
- this.IsFristLoad = false;
-
-
- }
- /// <summary>
- /// 图片控件点击事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- void PictImage_Click(object sender, EventArgs e)
- {
- this.PictImage.Focus();
- }
- /// <summary>
- /// 启用对比
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- void chkComparedStartUp_Click(object sender, EventArgs e)
- {
-
- if (this.chkComparedStartUp.Checked)
- {
- this.panelEx10.Visible = true;
- this.panelComparedColor.Visible = true;
- this.lblComparedColor.Visible = true;
- this.cbo_CheckYear.SelectedItem = (Convert.ToInt32(this.cbo_Year.Text.Replace("年", ""))-1)+"年";
- rdo_Day_Click(null, null);
- if (!string.IsNullOrEmpty(this.dtDataTimeStart.DateValue.Trim()) &&
- !string.IsNullOrEmpty(this.dtDataTimeEnd.DateValue.Trim()) &&
- !string.IsNullOrEmpty(this.dtDataTimeStartCompared.DateValue.Trim()) &&
- !string.IsNullOrEmpty(this.dtDateTimeEndCompared.DateValue.Trim()) &&
- !string.IsNullOrEmpty(this.cmbtreevDepartment.Text.Trim()) &&
- !string.IsNullOrEmpty(this.cmbtreevItmes.Text.Trim()))
- {
- }
- else
- {
- rdo_Day_Click(null, null);
- return;
- }
- }
- else
- {
- rdo_Day_Click(null, null);
- this.panelEx10.Visible = false;
- this.panelComparedColor.Visible = false;
- this.lblComparedColor.Visible = false;
- }
-
- this.PublicFunctionRows();
- }
-
- /// <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 dtDataTimeStart_Leave(object sender, EventArgs e)
- {
- if(this.rdo_Stage.Checked)
- {
- this.dtDataTimeEnd.DateValue = Convert.ToDateTime(this.dtDataTimeStart.DateValue).AddMonths(1).AddSeconds(-1).ToString("yyyy-MM-dd");
- }
- else if(this.rdo_Day.Checked)
- {
- this.dtDataTimeEnd.DateValue = Convert.ToDateTime(this.dtDataTimeStart.DateValue).ToString("yyyy-MM-dd");
- }
- }
- /// <summary>
- /// 日期离开事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- void dtDataTimeStartCompared_Leave(object sender, EventArgs e)
- {
- if (this.rdo_Stage.Checked)
- {
- this.dtDateTimeEndCompared.DateValue = Convert.ToDateTime(this.dtDataTimeStartCompared.DateValue).AddMonths(1).AddSeconds(-1).ToString("yyyy-MM-dd");
- }
- else if (this.rdo_Day.Checked)
- {
- this.dtDateTimeEndCompared.DateValue = Convert.ToDateTime(this.dtDataTimeStartCompared.DateValue).ToString("yyyy-MM-dd");
- }
- }
- /// <summary>
- /// 项目选择事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- void cmbtreevItmes_ComboBoxTree_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e)
- {
- //TreeView_AfterCheck(null, null);
- this.PublicFunctionRows();
- }
- /// <summary>
- /// 另存为
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- void btnSaveAs_Click(object sender, EventArgs e)
- {
- //+ this.cmbtreevItmes.Text.Trim()
- string StrFilleName = Convert.ToDateTime(this.dtDataTimeStart.DateValue).ToString("yyyy年MM月dd日") + " — " + Convert.ToDateTime(this.dtDataTimeEnd.DateValue).ToString("yyyy年MM月dd日") + " " + this.cmbtreevDepartment.Text.Trim() + "分析表";
- if (this.chkComparedStartUp.Checked)
- { StrFilleName = this.dtDataTimeStart.DateValue.Trim() + "—" + this.dtDataTimeEnd.DateValue.Trim() + " 与 " + this.dtDataTimeStartCompared.DateValue.Trim() + "—" + this.dtDateTimeEndCompared.DateValue.Trim() + " " + this.cmbtreevDepartment.Text.Trim() + "分析表"; }
- LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.DownloadSaveAs(this.PictImage.Image, StrFilleName: StrFilleName);
- }
- /// <summary>
- /// 关闭
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- void btnClose_Click(object sender, EventArgs e)
- {
- this.Close();
- }
- /// <summary>
- /// 窗体大小发生变化
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- void AnalyzedEmployeePerformanceFormMain_Resize(object sender, EventArgs e)
- {
- if (this.IsFristLoad)
- {
- this.panelEx1.Width = this.Width - 10;
- this.panelEx1.Height = this.Height - 60;
- }
- }
- void SetPostionData(string ordType, string columType, Rectangle rectangle, string where, string startTime, string endTime)
- {
- ModelImagePostionAction actionModel = null;
- string SqlSelect = @"";
- string StrItemName = this.cmbtreevItmes.Text.Trim();
- string sqlWhere = " " + LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.GetDateTime("CreateDateTime", startTime, endTime, ConnectWord: "");
- if (StrItemName != "全部")
- { sqlWhere += " And 项目 in ('" + string.Join("','",StrItemName.Split(',')) + "') "; }
- string TwoSaleOrderSql = "";
- TwoSaleOrderSql =
- @"select
- Tsorder_Number as 订单号,
- Tsorder_Money as 套系金额,
- Tsorder_Name as 项目内容,
- Tsorder_OpenSingle as OrdersPerson,
- Pay_AmountOf as 实收金额
- from
- Vw_TwoSalesOrder left join tb_erpPayment on tb_erpPayment.pay_ordNumber = Vw_TwoSalesOrder.Tsorder_Number
- where
- " + LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.GetDateTime("Tsorder_CreateDatetime", startTime, endTime, ConnectWord: "") +
- (StrItemName != "全部" ? " and Tsorder_Name = '" + StrItemName + "' " : "") + " and Tsorder_OpenSingle = '" + columType + "' " +
- @" ;
- ";
- SqlSelect = "with tt AS \r\n" +
- "( \r\n" +
- "select ord_Number, SeriesPrice,OrdersPerson,CreateDateTime,项目,实收金额,客户名称, 联系电话,套系名称, \r\n" +
- "case ((select Cp_Proportion from tb_ErpCommissionPercentage where Cp_ProportionCode='MainStoreProportion') + (select Cp_Proportion from tb_ErpCommissionPercentage where Cp_ProportionCode='DeputyStoreProportion')) when 0 then 0 else \r\n" +
- "(case (len(rtrim(ltrim(OrdersPerson))) - len(rtrim(ltrim(replace(OrdersPerson,',',''))))) when 0 then SeriesPrice else cast((SeriesPrice / ((select Cp_Proportion from tb_ErpCommissionPercentage where Cp_ProportionCode='MainStoreProportion') + (select Cp_Proportion from tb_ErpCommissionPercentage where Cp_ProportionCode='DeputyStoreProportion') * (len(rtrim(ltrim(OrdersPerson))) - len(rtrim(ltrim(replace(OrdersPerson,',','')))))) ) * (select Cp_Proportion from tb_ErpCommissionPercentage where Cp_ProportionCode='MainStoreProportion') as numeric(9,2)) end) end as 主门市金额,\r\n" +
- "case ((select Cp_Proportion from tb_ErpCommissionPercentage where Cp_ProportionCode='MainStoreProportion') + (select Cp_Proportion from tb_ErpCommissionPercentage where Cp_ProportionCode='DeputyStoreProportion')) when 0 then 0 else \r\n" +
- "(case (len(rtrim(ltrim(OrdersPerson))) - len(rtrim(ltrim(replace(OrdersPerson,',',''))))) when 0 then 0 else cast((SeriesPrice / ((select Cp_Proportion from tb_ErpCommissionPercentage where Cp_ProportionCode='MainStoreProportion') + (select Cp_Proportion from tb_ErpCommissionPercentage where Cp_ProportionCode='DeputyStoreProportion') * (len(rtrim(ltrim(OrdersPerson))) - len(rtrim(ltrim(replace(OrdersPerson,',','')))))) ) * (select Cp_Proportion from tb_ErpCommissionPercentage where Cp_ProportionCode='DeputyStoreProportion') as numeric(9,2)) end) end as 副门市金额,\r\n" +
- "case ((select Cp_Proportion from tb_ErpCommissionPercentage where Cp_ProportionCode='MainStoreProportion') + (select Cp_Proportion from tb_ErpCommissionPercentage where Cp_ProportionCode='DeputyStoreProportion')) when 0 then 0 else \r\n" +
- "(case (len(rtrim(ltrim(OrdersPerson))) - len(rtrim(ltrim(replace(OrdersPerson,',',''))))) when 0 then 实收金额 else cast((实收金额 / ((select Cp_Proportion from tb_ErpCommissionPercentage where Cp_ProportionCode='MainStoreProportion') + (select Cp_Proportion from tb_ErpCommissionPercentage where Cp_ProportionCode='DeputyStoreProportion') * (len(rtrim(ltrim(OrdersPerson))) - len(rtrim(ltrim(replace(OrdersPerson,',','')))))) ) * (select Cp_Proportion from tb_ErpCommissionPercentage where Cp_ProportionCode='MainStoreProportion') as numeric(9,2)) end) end as 主门市实收,\r\n" +
- "case ((select Cp_Proportion from tb_ErpCommissionPercentage where Cp_ProportionCode='MainStoreProportion') + (select Cp_Proportion from tb_ErpCommissionPercentage where Cp_ProportionCode='DeputyStoreProportion')) when 0 then 0 else \r\n" +
- "(case (len(rtrim(ltrim(OrdersPerson))) - len(rtrim(ltrim(replace(OrdersPerson,',',''))))) when 0 then 0 else cast((实收金额 / ((select Cp_Proportion from tb_ErpCommissionPercentage where Cp_ProportionCode='MainStoreProportion') + (select Cp_Proportion from tb_ErpCommissionPercentage where Cp_ProportionCode='DeputyStoreProportion') * (len(rtrim(ltrim(OrdersPerson))) - len(rtrim(ltrim(replace(OrdersPerson,',','')))))) ) * (select Cp_Proportion from tb_ErpCommissionPercentage where Cp_ProportionCode='DeputyStoreProportion') as numeric(9,2)) end) end as 副门市实收,\r\n" +
- "(case LEFT(OrdersPerson,charindex(',',OrdersPerson,1)) when '' then OrdersPerson else LEFT(OrdersPerson,charindex(',',OrdersPerson,1)-1) end)as '主门市' \r\n" +
- "from (\r\n" +
- "select ord_Number, Ord_SeriesPrice AS SeriesPrice,Ord_CreateDateTime AS CreateDateTime,'订单前期' AS 项目,\r\n" +
- "(select stuff((select ',' + OrdPe_OrdersPerson from tb_ErpOrdersPerson where OrdPe_OrderNumber = Ord_Number for xml path('')),1,1,'')) as OrdersPerson,\r\n" +
- "isnull((select Sum(Pay_AmountOf) from tb_ErpPayment where Pay_Category in ('全款','预约收款','预约补款') And Pay_OrdNumber = Ord_Number),0) AS 实收金额,Cus_Name as '客户名称',Cus_Telephone as '联系电话',Ord_SeriesName as '套系名称' \r\n" +
- "from tb_ErpOrder inner join tempTB_AggregationCustomer on GP_OrderNumber=Ord_Number where ord_class=1) AS t \r\n" +
- "UNION ALL \r\n" +
- "select Plu_OrdNumber as ord_Number , SeriesPrice,OrdersPerson,CreateDateTime,项目,实收金额,客户名称, 联系电话,套系名称,\r\n" +
- "(case (len(rtrim(ltrim(Plu_OpenSingle))) - len(rtrim(ltrim(replace(Plu_OpenSingle,',',''))))) when 0 then SeriesPrice else cast((SeriesPrice / ((select Cp_Proportion from tb_ErpCommissionPercentage where Cp_ProportionCode='MainStoreProportion') + (select Cp_Proportion from tb_ErpCommissionPercentage where Cp_ProportionCode='DeputyStoreProportion') * (len(rtrim(ltrim(Plu_OpenSingle))) - len(rtrim(ltrim(replace(Plu_OpenSingle,',','')))))) ) * (select Cp_Proportion from tb_ErpCommissionPercentage where Cp_ProportionCode='MainStoreProportion') as numeric(9,2)) end) as 主门市金额,\r\n" +
- "(case (len(rtrim(ltrim(Plu_OpenSingle))) - len(rtrim(ltrim(replace(Plu_OpenSingle,',',''))))) when 0 then 0 else cast((SeriesPrice / ((select Cp_Proportion from tb_ErpCommissionPercentage where Cp_ProportionCode='MainStoreProportion') + (select Cp_Proportion from tb_ErpCommissionPercentage where Cp_ProportionCode='DeputyStoreProportion') * (len(rtrim(ltrim(Plu_OpenSingle))) - len(rtrim(ltrim(replace(Plu_OpenSingle,',','')))))) ) * (select Cp_Proportion from tb_ErpCommissionPercentage where Cp_ProportionCode='DeputyStoreProportion') as numeric(9,2)) end) as 副门市金额,\r\n" +
- "(case (len(rtrim(ltrim(OrdersPerson))) - len(rtrim(ltrim(replace(OrdersPerson,',',''))))) when 0 then 实收金额 else cast((实收金额 / ((select Cp_Proportion from tb_ErpCommissionPercentage where Cp_ProportionCode='MainStoreProportion') + (select Cp_Proportion from tb_ErpCommissionPercentage where Cp_ProportionCode='DeputyStoreProportion') * (len(rtrim(ltrim(OrdersPerson))) - len(rtrim(ltrim(replace(OrdersPerson,',','')))))) ) * (select Cp_Proportion from tb_ErpCommissionPercentage where Cp_ProportionCode='MainStoreProportion') as numeric(9,2)) end) as 主门市实收,\r\n" +
- "(case (len(rtrim(ltrim(OrdersPerson))) - len(rtrim(ltrim(replace(OrdersPerson,',',''))))) when 0 then 0 else cast((实收金额 / ((select Cp_Proportion from tb_ErpCommissionPercentage where Cp_ProportionCode='MainStoreProportion') + (select Cp_Proportion from tb_ErpCommissionPercentage where Cp_ProportionCode='DeputyStoreProportion') * (len(rtrim(ltrim(OrdersPerson))) - len(rtrim(ltrim(replace(OrdersPerson,',','')))))) ) * (select Cp_Proportion from tb_ErpCommissionPercentage where Cp_ProportionCode='DeputyStoreProportion') as numeric(9,2)) end) as 副门市实收,\r\n" +
- "(case LEFT(Plu_OpenSingle,charindex(',',Plu_OpenSingle,1)) when '' then Plu_OpenSingle else LEFT(Plu_OpenSingle,charindex(',',Plu_OpenSingle,1)-1) end)as '主门市' \r\n" +
- "from (\r\n" +
- "select Plu_OrdNumber, Plu_Amount AS SeriesPrice,Plu_OpenSingle AS OrdersPerson,Plu_CreateTime AS CreateDateTime,Sc_ClassName AS 项目,Plu_OpenSingle,\r\n" +
- "isnull((select Sum(Pay_AmountOf) from tb_ErpPayment where Pay_PlusPickNumber = Plu_Number And Pay_OrdNumber = Plu_OrdNumber),0) AS 实收金额,Cus_Name as '客户名称',Cus_Telephone as '联系电话',Ord_SeriesName as '套系名称'\r\n " +
- "from tb_ErpPlusPickItems left join tb_ErpOrder on Plu_OrdNumber = ord_Number inner join tempTB_AggregationCustomer on GP_OrderNumber=Ord_Number Left Join tb_ErpSystemCategory on Sc_ClassCode = Plu_TwoPinsCategory) AS t \r\n" +
- ")\r\n" +
- "select ord_Number as 订单号,SeriesPrice as 套系金额,项目 as 项目内容,实收金额,主门市金额,副门市金额,主门市实收,副门市实收,OrdersPerson,套系名称,联系电话,客户名称 from tt \r\n";
- sqlWhere += " and OrdersPerson like '%" + columType + "%' ";
- actionModel = new ModelImagePostionAction()
- {
- OrdType = ordType,
- ColumType = columType,
- MouseX = rectangle.X,
- MouseY = rectangle.Y,
- MouseWidth = rectangle.Width,
- MouseHeight = rectangle.Height,
- SqlData = SqlSelect + " where " + sqlWhere + ";" + TwoSaleOrderSql,
-
- };
- actionModel.OrdTitle = this.UcNavigationTool.LabTitle;
- if (actionModel != null)
- {
- actionList.Add(actionModel);
- }
- }
- /// <summary>
- /// 创建行
- /// </summary>
- private void PublicFunctionRows()
- {
- actionList.Clear();
- #region 处理数据前判断
- if (this.chkComparedStartUp.Checked)
- {
- if (string.IsNullOrEmpty(this.dtDataTimeStart.DateValue.Trim()) && string.IsNullOrEmpty(this.dtDataTimeEnd.DateValue.Trim()))
- { MessageBoxCustom.Show("对比前时间段不能为空"); return; }
- if (Convert.ToDateTime(this.dtDataTimeEnd.DateValue) < Convert.ToDateTime(this.dtDataTimeStart.DateValue))
- { MessageBoxCustom.Show("对比前开始日期不能大于结束日期"); return; }
- if (string.IsNullOrEmpty(this.dtDataTimeStartCompared.DateValue.Trim()) && string.IsNullOrEmpty(this.dtDateTimeEndCompared.DateValue.Trim()))
- { MessageBoxCustom.Show("对比后时间段不能为空"); return; }
- if (Convert.ToDateTime(this.dtDateTimeEndCompared.DateValue) < Convert.ToDateTime(this.dtDataTimeStartCompared.DateValue))
- { MessageBoxCustom.Show("对比后开始日期不能大于结束日期"); return; }
- if (Convert.ToDateTime(this.dtDateTimeEndCompared.DateValue.Trim()) > Convert.ToDateTime(this.dtDataTimeStart.DateValue.Trim()))
- { MessageBoxCustom.Show("对比后的结束日期不能大于对比前的开始日期"); return; }
- }
- else
- {
- if (string.IsNullOrEmpty(this.dtDataTimeStart.DateValue.Trim()) && string.IsNullOrEmpty(this.dtDataTimeEnd.DateValue.Trim()))
- { MessageBoxCustom.Show("时间段不能为空"); return; }
- if (Convert.ToDateTime(this.dtDataTimeEnd.DateValue) < Convert.ToDateTime(this.dtDataTimeStart.DateValue))
- { MessageBoxCustom.Show("开始日期不能大于结束日期"); return; }
- }
- //if (string.IsNullOrEmpty(this.cmbtreevDepartment.Tag.ToString().Trim()))
- //{ MessageBoxCustom.Show("部门不能为空"); return; }
- if (string.IsNullOrEmpty(this.cmbtreevItmes.Text.Trim()))
- { MessageBoxCustom.Show("项目不能为空"); return; }
- this.IsFristLoad = true;
- this.AnalyzedEmployeePerformanceFormMain_Resize(this, null);
- this.IsFristLoad = false;
- #endregion
- this.actionList.Clear();
- Brush b = Brushes.Black;
- Pen p = new Pen(Brushes.Black, 1);
- Font ft12 = new Font("微软雅黑", 12);
- Font ft11 = new Font("微软雅黑", 11);
- Font ft15 = new Font("微软雅黑", 15);
- #region 数据连接获取数据
- string StrTimeStrat = this.dtDataTimeStart.DateValue.Trim();
- string StrTimeEnd = this.dtDataTimeEnd.DateValue.Trim();
- string StrTimeStratDb = this.dtDataTimeStartCompared.DateValue.Trim();
- string StrTimeEndDb = this.dtDateTimeEndCompared.DateValue.Trim();
- string StrItemName = this.cmbtreevItmes.Text.Trim();
- string StrWhere = "where " + LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.GetDateTime("CreateDateTime", StrTimeStrat, StrTimeEnd, ConnectWord: "");
- if (StrItemName != "全部")
- { StrWhere += " And 项目 in ('" + string.Join("','", StrItemName.Split(',')) + "') "; }
- string TwoSaleOrderSql = "";
- TwoSaleOrderSql =
- @"select
- Tsorder_OpenSingle as EmployeeID,
- sum(Tsorder_Money) as Price,
- sum(Pay_AmountOf) as PayPrice
- from
- Vw_TwoSalesOrder left join tb_erpPayment on tb_erpPayment.pay_ordNumber = Vw_TwoSalesOrder.Tsorder_Number
- where
- " + LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.GetDateTime("Tsorder_CreateDatetime", StrTimeStrat, StrTimeEnd, ConnectWord: "") +
- (StrItemName != "全部" ? " and Tsorder_Name = '" + StrItemName + "' " : "") +
- @" group by Tsorder_OpenSingle ;
- ";
- string ExecuteSql = "with tt AS " +
- "( " +
- "select SeriesPrice,OrdersPerson,CreateDateTime,项目,实收金额,'订单' as 类型," +
- "case ((select Cp_Proportion from tb_ErpCommissionPercentage where Cp_ProportionCode='MainStoreProportion') + (select Cp_Proportion from tb_ErpCommissionPercentage where Cp_ProportionCode='DeputyStoreProportion')) when 0 then 0 else "+
- "(case (len(rtrim(ltrim(OrdersPerson))) - len(rtrim(ltrim(replace(OrdersPerson,',',''))))) when 0 then SeriesPrice else cast((SeriesPrice / ((select Cp_Proportion from tb_ErpCommissionPercentage where Cp_ProportionCode='MainStoreProportion') + (select Cp_Proportion from tb_ErpCommissionPercentage where Cp_ProportionCode='DeputyStoreProportion') * (len(rtrim(ltrim(OrdersPerson))) - len(rtrim(ltrim(replace(OrdersPerson,',','')))))) ) * (select Cp_Proportion from tb_ErpCommissionPercentage where Cp_ProportionCode='MainStoreProportion') as numeric(9,2)) end) end as 主门市金额," +
- "case ((select Cp_Proportion from tb_ErpCommissionPercentage where Cp_ProportionCode='MainStoreProportion') + (select Cp_Proportion from tb_ErpCommissionPercentage where Cp_ProportionCode='DeputyStoreProportion')) when 0 then 0 else "+
- "(case (len(rtrim(ltrim(OrdersPerson))) - len(rtrim(ltrim(replace(OrdersPerson,',',''))))) when 0 then 0 else cast((SeriesPrice / ((select Cp_Proportion from tb_ErpCommissionPercentage where Cp_ProportionCode='MainStoreProportion') + (select Cp_Proportion from tb_ErpCommissionPercentage where Cp_ProportionCode='DeputyStoreProportion') * (len(rtrim(ltrim(OrdersPerson))) - len(rtrim(ltrim(replace(OrdersPerson,',','')))))) ) * (select Cp_Proportion from tb_ErpCommissionPercentage where Cp_ProportionCode='DeputyStoreProportion') as numeric(9,2)) end) end as 副门市金额," +
- "case ((select Cp_Proportion from tb_ErpCommissionPercentage where Cp_ProportionCode='MainStoreProportion') + (select Cp_Proportion from tb_ErpCommissionPercentage where Cp_ProportionCode='DeputyStoreProportion')) when 0 then 0 else "+
- "(case (len(rtrim(ltrim(OrdersPerson))) - len(rtrim(ltrim(replace(OrdersPerson,',',''))))) when 0 then 实收金额 else cast((实收金额 / ((select Cp_Proportion from tb_ErpCommissionPercentage where Cp_ProportionCode='MainStoreProportion') + (select Cp_Proportion from tb_ErpCommissionPercentage where Cp_ProportionCode='DeputyStoreProportion') * (len(rtrim(ltrim(OrdersPerson))) - len(rtrim(ltrim(replace(OrdersPerson,',','')))))) ) * (select Cp_Proportion from tb_ErpCommissionPercentage where Cp_ProportionCode='MainStoreProportion') as numeric(9,2)) end) end as 主门市实收,"+
- "case ((select Cp_Proportion from tb_ErpCommissionPercentage where Cp_ProportionCode='MainStoreProportion') + (select Cp_Proportion from tb_ErpCommissionPercentage where Cp_ProportionCode='DeputyStoreProportion')) when 0 then 0 else "+
- "(case (len(rtrim(ltrim(OrdersPerson))) - len(rtrim(ltrim(replace(OrdersPerson,',',''))))) when 0 then 0 else cast((实收金额 / ((select Cp_Proportion from tb_ErpCommissionPercentage where Cp_ProportionCode='MainStoreProportion') + (select Cp_Proportion from tb_ErpCommissionPercentage where Cp_ProportionCode='DeputyStoreProportion') * (len(rtrim(ltrim(OrdersPerson))) - len(rtrim(ltrim(replace(OrdersPerson,',','')))))) ) * (select Cp_Proportion from tb_ErpCommissionPercentage where Cp_ProportionCode='DeputyStoreProportion') as numeric(9,2)) end) end as 副门市实收," +
- "(case LEFT(OrdersPerson,charindex(',',OrdersPerson,1)) when '' then OrdersPerson else LEFT(OrdersPerson,charindex(',',OrdersPerson,1)-1) end)as '主门市' " +
- "from (" +
- "select Ord_SeriesPrice AS SeriesPrice,Ord_CreateDateTime AS CreateDateTime,'订单前期' AS 项目," +
- "(select stuff((select ',' + OrdPe_OrdersPerson from tb_ErpOrdersPerson where OrdPe_OrderNumber = Ord_Number for xml path('')),1,1,'')) as OrdersPerson," +
- "isnull((select Sum(Pay_AmountOf) from tb_ErpPayment where Pay_Category in ('全款','预约收款','预约补款') And Pay_OrdNumber = Ord_Number),0) AS 实收金额 " +
- "from tb_ErpOrder where ord_class=1) AS t " +
- "UNION ALL " +
- "select SeriesPrice,OrdersPerson,CreateDateTime,项目,实收金额,'加挑' as 类型," +
- "(case (len(rtrim(ltrim(Plu_OpenSingle))) - len(rtrim(ltrim(replace(Plu_OpenSingle,',',''))))) when 0 then SeriesPrice else cast((SeriesPrice / ((select Cp_Proportion from tb_ErpCommissionPercentage where Cp_ProportionCode='MainStoreProportion') + (select Cp_Proportion from tb_ErpCommissionPercentage where Cp_ProportionCode='DeputyStoreProportion') * (len(rtrim(ltrim(Plu_OpenSingle))) - len(rtrim(ltrim(replace(Plu_OpenSingle,',','')))))) ) * (select Cp_Proportion from tb_ErpCommissionPercentage where Cp_ProportionCode='MainStoreProportion') as numeric(9,2)) end) as 主门市金额," +
- "(case (len(rtrim(ltrim(Plu_OpenSingle))) - len(rtrim(ltrim(replace(Plu_OpenSingle,',',''))))) when 0 then 0 else cast((SeriesPrice / ((select Cp_Proportion from tb_ErpCommissionPercentage where Cp_ProportionCode='MainStoreProportion') + (select Cp_Proportion from tb_ErpCommissionPercentage where Cp_ProportionCode='DeputyStoreProportion') * (len(rtrim(ltrim(Plu_OpenSingle))) - len(rtrim(ltrim(replace(Plu_OpenSingle,',','')))))) ) * (select Cp_Proportion from tb_ErpCommissionPercentage where Cp_ProportionCode='DeputyStoreProportion') as numeric(9,2)) end) as 副门市金额," +
- "(case (len(rtrim(ltrim(OrdersPerson))) - len(rtrim(ltrim(replace(OrdersPerson,',',''))))) when 0 then 实收金额 else cast((实收金额 / ((select Cp_Proportion from tb_ErpCommissionPercentage where Cp_ProportionCode='MainStoreProportion') + (select Cp_Proportion from tb_ErpCommissionPercentage where Cp_ProportionCode='DeputyStoreProportion') * (len(rtrim(ltrim(OrdersPerson))) - len(rtrim(ltrim(replace(OrdersPerson,',','')))))) ) * (select Cp_Proportion from tb_ErpCommissionPercentage where Cp_ProportionCode='MainStoreProportion') as numeric(9,2)) end) as 主门市实收," +
- "(case (len(rtrim(ltrim(OrdersPerson))) - len(rtrim(ltrim(replace(OrdersPerson,',',''))))) when 0 then 0 else cast((实收金额 / ((select Cp_Proportion from tb_ErpCommissionPercentage where Cp_ProportionCode='MainStoreProportion') + (select Cp_Proportion from tb_ErpCommissionPercentage where Cp_ProportionCode='DeputyStoreProportion') * (len(rtrim(ltrim(OrdersPerson))) - len(rtrim(ltrim(replace(OrdersPerson,',','')))))) ) * (select Cp_Proportion from tb_ErpCommissionPercentage where Cp_ProportionCode='DeputyStoreProportion') as numeric(9,2)) end) as 副门市实收," +
- "(case LEFT(Plu_OpenSingle,charindex(',',Plu_OpenSingle,1)) when '' then Plu_OpenSingle else LEFT(Plu_OpenSingle,charindex(',',Plu_OpenSingle,1)-1) end)as '主门市' " +
- "from (" +
- "select Plu_Amount AS SeriesPrice,Plu_OpenSingle AS OrdersPerson,Plu_CreateTime AS CreateDateTime,Sc_ClassName AS 项目,Plu_OpenSingle," +
- "isnull((select Sum(Pay_AmountOf) from tb_ErpPayment where Pay_PlusPickNumber = Plu_Number And Pay_OrdNumber = Plu_OrdNumber and Plu_TwoPinsCategory = Pay_TwoPinsCategory),0) AS 实收金额 " +
- "from tb_ErpPlusPickItems Left Join tb_ErpSystemCategory on Sc_ClassCode = Plu_TwoPinsCategory) AS t " +
- @" union all
- select
- SeriesPrice,Tsorder_OpenSingle,CreateDateTime, 项目,实收金额,'二销' as 类型,
- (case (len(rtrim(ltrim(Tsorder_OpenSingle))) - len(rtrim(ltrim(replace(Tsorder_OpenSingle,',',''))))) when 0 then SeriesPrice
- else cast((SeriesPrice / ((select Cp_Proportion from tb_ErpCommissionPercentage where Cp_ProportionCode='MainLaterOtherTwoSales') + (select Cp_Proportion from tb_ErpCommissionPercentage where Cp_ProportionCode='DeputyLaterOtherTwoSales') *
- (len(rtrim(ltrim(Tsorder_OpenSingle))) - len(rtrim(ltrim(replace(Tsorder_OpenSingle,',','')))))) ) * (select Cp_Proportion from tb_ErpCommissionPercentage where Cp_ProportionCode='MainLaterOtherTwoSales') as numeric(9,2)) end) as 主门市金额,
- (case (len(rtrim(ltrim(Tsorder_OpenSingle))) - len(rtrim(ltrim(replace(Tsorder_OpenSingle,',',''))))) when 0 then 0 else cast((SeriesPrice / ((select Cp_Proportion from tb_ErpCommissionPercentage where Cp_ProportionCode='MainLaterOtherTwoSales') +
- (select Cp_Proportion from tb_ErpCommissionPercentage where Cp_ProportionCode='DeputyLaterOtherTwoSales') * (len(rtrim(ltrim(Tsorder_OpenSingle))) - len(rtrim(ltrim(replace(Tsorder_OpenSingle,',','')))))) ) *
- (select Cp_Proportion from tb_ErpCommissionPercentage where Cp_ProportionCode='DeputyLaterOtherTwoSales') as numeric(9,2)) end) as 副门市金额,
- (case (len(rtrim(ltrim(OrdersPerson))) - len(rtrim(ltrim(replace(OrdersPerson,',',''))))) when 0 then 实收金额 else
- cast((实收金额 / ((select Cp_Proportion from tb_ErpCommissionPercentage where Cp_ProportionCode='MainLaterOtherTwoSales') +
- (select Cp_Proportion from tb_ErpCommissionPercentage where Cp_ProportionCode='DeputyLaterOtherTwoSales') * (len(rtrim(ltrim(OrdersPerson))) - len(rtrim(ltrim(replace(OrdersPerson,',','')))))) ) *
- (select Cp_Proportion from tb_ErpCommissionPercentage where Cp_ProportionCode='MainLaterOtherTwoSales') as numeric(9,2)) end) as 主门市实收,
- (case (len(rtrim(ltrim(OrdersPerson))) - len(rtrim(ltrim(replace(OrdersPerson,',',''))))) when 0 then 0 else
- cast((实收金额 / ((select Cp_Proportion from tb_ErpCommissionPercentage where Cp_ProportionCode='MainLaterOtherTwoSales') + (select Cp_Proportion from tb_ErpCommissionPercentage where Cp_ProportionCode='DeputyLaterOtherTwoSales') *
- (len(rtrim(ltrim(OrdersPerson))) - len(rtrim(ltrim(replace(OrdersPerson,',','')))))) ) * (select Cp_Proportion from tb_ErpCommissionPercentage where Cp_ProportionCode='DeputyLaterOtherTwoSales') as numeric(9,2)) end) as 副门市实收,
- (case LEFT(Tsorder_OpenSingle,charindex(',',Tsorder_OpenSingle,1)) when '' then Tsorder_OpenSingle else LEFT(Tsorder_OpenSingle,charindex(',',Tsorder_OpenSingle,1)-1) end)as '主门市'
- from (select Tsorder_Money AS SeriesPrice,Tsorder_OpenSingle AS OrdersPerson,Tsorder_CreateDatetime AS CreateDateTime,Tsorder_CategoryName AS 项目,Tsorder_OpenSingle,isnull((select Sum(Pay_AmountOf) from tb_ErpPayment where Pay_OrdNumber = Tsorder_Number and Tsorder_Category = Pay_TwoPinsCategory),0) AS 实收金额
- from Vw_TwoSalesOrder ) AS t " +
- ")" +
- "select * from tt " + StrWhere + "; ";
- if (this.chkComparedStartUp.Checked)
- {
- string StrTimeStratCompared = this.dtDataTimeStartCompared.DateValue.Trim();
- string StrTimeEndCompared = this.dtDateTimeEndCompared.DateValue.Trim();
- StrWhere = "where " + LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.GetDateTime("CreateDateTime", StrTimeStratCompared, StrTimeEndCompared, ConnectWord: "");
- if (StrItemName != "全部")
- { StrWhere += " And 项目 = '" + StrItemName + "'"; }
- TwoSaleOrderSql +=
- @"select
- Tsorder_OpenSingle as EmployeeID,
- sum(Tsorder_Money) as Price,
- sum(Pay_AmountOf) as PayPrice
- from
- Vw_TwoSalesOrder left join tb_erpPayment on tb_erpPayment.pay_ordNumber = Vw_TwoSalesOrder.Tsorder_Number
- where
- " + LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.GetDateTime("Tsorder_CreateDatetime", StrTimeStratCompared, StrTimeEndCompared, ConnectWord: "") +
- (StrItemName != "全部" ? " and Tsorder_Name = '" + StrItemName + "' " : "") +
- @" group by Tsorder_OpenSingle ;
- ";
- ExecuteSql += "with tt AS " +
- "( " +
- "select SeriesPrice,OrdersPerson,CreateDateTime,项目,实收金额,'订单' as 类型, " +
- "case ((select Cp_Proportion from tb_ErpCommissionPercentage where Cp_ProportionCode='MainStoreProportion') + (select Cp_Proportion from tb_ErpCommissionPercentage where Cp_ProportionCode='DeputyStoreProportion')) when 0 then 0 else "+
- "(case (len(rtrim(ltrim(OrdersPerson))) - len(rtrim(ltrim(replace(OrdersPerson,',',''))))) when 0 then SeriesPrice else cast((SeriesPrice / ((select Cp_Proportion from tb_ErpCommissionPercentage where Cp_ProportionCode='MainStoreProportion') + (select Cp_Proportion from tb_ErpCommissionPercentage where Cp_ProportionCode='DeputyStoreProportion') * (len(rtrim(ltrim(OrdersPerson))) - len(rtrim(ltrim(replace(OrdersPerson,',','')))))) ) * (select Cp_Proportion from tb_ErpCommissionPercentage where Cp_ProportionCode='MainStoreProportion') as numeric(9,2)) end) end as 主门市金额," +
- "case ((select Cp_Proportion from tb_ErpCommissionPercentage where Cp_ProportionCode='MainStoreProportion') + (select Cp_Proportion from tb_ErpCommissionPercentage where Cp_ProportionCode='DeputyStoreProportion')) when 0 then 0 else "+
- "(case (len(rtrim(ltrim(OrdersPerson))) - len(rtrim(ltrim(replace(OrdersPerson,',',''))))) when 0 then 0 else cast((SeriesPrice / ((select Cp_Proportion from tb_ErpCommissionPercentage where Cp_ProportionCode='MainStoreProportion') + (select Cp_Proportion from tb_ErpCommissionPercentage where Cp_ProportionCode='DeputyStoreProportion') * (len(rtrim(ltrim(OrdersPerson))) - len(rtrim(ltrim(replace(OrdersPerson,',','')))))) ) * (select Cp_Proportion from tb_ErpCommissionPercentage where Cp_ProportionCode='DeputyStoreProportion') as numeric(9,2)) end) end as 副门市金额," +
- "case ((select Cp_Proportion from tb_ErpCommissionPercentage where Cp_ProportionCode='MainStoreProportion') + (select Cp_Proportion from tb_ErpCommissionPercentage where Cp_ProportionCode='DeputyStoreProportion')) when 0 then 0 else "+
- "(case (len(rtrim(ltrim(OrdersPerson))) - len(rtrim(ltrim(replace(OrdersPerson,',',''))))) when 0 then 实收金额 else cast((实收金额 / ((select Cp_Proportion from tb_ErpCommissionPercentage where Cp_ProportionCode='MainStoreProportion') + (select Cp_Proportion from tb_ErpCommissionPercentage where Cp_ProportionCode='DeputyStoreProportion') * (len(rtrim(ltrim(OrdersPerson))) - len(rtrim(ltrim(replace(OrdersPerson,',','')))))) ) * (select Cp_Proportion from tb_ErpCommissionPercentage where Cp_ProportionCode='MainStoreProportion') as numeric(9,2)) end) end as 主门市实收,"+
- "case ((select Cp_Proportion from tb_ErpCommissionPercentage where Cp_ProportionCode='MainStoreProportion') + (select Cp_Proportion from tb_ErpCommissionPercentage where Cp_ProportionCode='DeputyStoreProportion')) when 0 then 0 else "+
- "(case (len(rtrim(ltrim(OrdersPerson))) - len(rtrim(ltrim(replace(OrdersPerson,',',''))))) when 0 then 0 else cast((实收金额 / ((select Cp_Proportion from tb_ErpCommissionPercentage where Cp_ProportionCode='MainStoreProportion') + (select Cp_Proportion from tb_ErpCommissionPercentage where Cp_ProportionCode='DeputyStoreProportion') * (len(rtrim(ltrim(OrdersPerson))) - len(rtrim(ltrim(replace(OrdersPerson,',','')))))) ) * (select Cp_Proportion from tb_ErpCommissionPercentage where Cp_ProportionCode='DeputyStoreProportion') as numeric(9,2)) end) end as 副门市实收," +
- "(case LEFT(OrdersPerson,charindex(',',OrdersPerson,1)) when '' then OrdersPerson else LEFT(OrdersPerson,charindex(',',OrdersPerson,1)-1) end)as '主门市' " +
- "from (" +
- "select Ord_SeriesPrice AS SeriesPrice,Ord_CreateDateTime AS CreateDateTime,'订单前期' AS 项目," +
- "(select stuff((select ',' + OrdPe_OrdersPerson from tb_ErpOrdersPerson where OrdPe_OrderNumber = Ord_Number for xml path('')),1,1,'')) as OrdersPerson," +
- "isnull((select Sum(Pay_AmountOf) from tb_ErpPayment where Pay_Category in ('全款','预约收款','预约补款') And Pay_OrdNumber = Ord_Number),0) AS 实收金额 " +
- "from tb_ErpOrder where ord_class=1) AS t " +
- "UNION ALL " +
- "select SeriesPrice,OrdersPerson,CreateDateTime,项目,实收金额,'加挑' as 类型," +
- "(case (len(rtrim(ltrim(Plu_OpenSingle))) - len(rtrim(ltrim(replace(Plu_OpenSingle,',',''))))) when 0 then SeriesPrice else cast((SeriesPrice / ((select Cp_Proportion from tb_ErpCommissionPercentage where Cp_ProportionCode='MainLaterOtherTwoSales') + (select Cp_Proportion from tb_ErpCommissionPercentage where Cp_ProportionCode='DeputyLaterOtherTwoSales') * (len(rtrim(ltrim(Plu_OpenSingle))) - len(rtrim(ltrim(replace(Plu_OpenSingle,',','')))))) ) * (select Cp_Proportion from tb_ErpCommissionPercentage where Cp_ProportionCode='MainLaterOtherTwoSales') as numeric(9,2)) end) as 主门市金额," +
- "(case (len(rtrim(ltrim(Plu_OpenSingle))) - len(rtrim(ltrim(replace(Plu_OpenSingle,',',''))))) when 0 then 0 else cast((SeriesPrice / ((select Cp_Proportion from tb_ErpCommissionPercentage where Cp_ProportionCode='MainLaterOtherTwoSales') + (select Cp_Proportion from tb_ErpCommissionPercentage where Cp_ProportionCode='DeputyLaterOtherTwoSales') * (len(rtrim(ltrim(Plu_OpenSingle))) - len(rtrim(ltrim(replace(Plu_OpenSingle,',','')))))) ) * (select Cp_Proportion from tb_ErpCommissionPercentage where Cp_ProportionCode='DeputyLaterOtherTwoSales') as numeric(9,2)) end) as 副门市金额," +
- "(case (len(rtrim(ltrim(OrdersPerson))) - len(rtrim(ltrim(replace(OrdersPerson,',',''))))) when 0 then 实收金额 else cast((实收金额 / ((select Cp_Proportion from tb_ErpCommissionPercentage where Cp_ProportionCode='MainLaterOtherTwoSales') + (select Cp_Proportion from tb_ErpCommissionPercentage where Cp_ProportionCode='DeputyLaterOtherTwoSales') * (len(rtrim(ltrim(OrdersPerson))) - len(rtrim(ltrim(replace(OrdersPerson,',','')))))) ) * (select Cp_Proportion from tb_ErpCommissionPercentage where Cp_ProportionCode='MainLaterOtherTwoSales') as numeric(9,2)) end) as 主门市实收," +
- "(case (len(rtrim(ltrim(OrdersPerson))) - len(rtrim(ltrim(replace(OrdersPerson,',',''))))) when 0 then 0 else cast((实收金额 / ((select Cp_Proportion from tb_ErpCommissionPercentage where Cp_ProportionCode='MainLaterOtherTwoSales') + (select Cp_Proportion from tb_ErpCommissionPercentage where Cp_ProportionCode='DeputyLaterOtherTwoSales') * (len(rtrim(ltrim(OrdersPerson))) - len(rtrim(ltrim(replace(OrdersPerson,',','')))))) ) * (select Cp_Proportion from tb_ErpCommissionPercentage where Cp_ProportionCode='DeputyLaterOtherTwoSales') as numeric(9,2)) end) as 副门市实收," +
- "(case LEFT(Plu_OpenSingle,charindex(',',Plu_OpenSingle,1)) when '' then Plu_OpenSingle else LEFT(Plu_OpenSingle,charindex(',',Plu_OpenSingle,1)-1) end)as '主门市' " +
- "from (" +
- "select Plu_Amount AS SeriesPrice,Plu_OpenSingle AS OrdersPerson,Plu_CreateTime AS CreateDateTime,Sc_ClassName AS 项目,Plu_OpenSingle," +
- "isnull((select Sum(Pay_AmountOf) from tb_ErpPayment where Pay_PlusPickNumber = Plu_Number And Pay_OrdNumber = Plu_OrdNumber and Plu_TwoPinsCategory = Pay_TwoPinsCategory),0) AS 实收金额 " +
- "from tb_ErpPlusPickItems Left Join tb_ErpSystemCategory on Sc_ClassCode = Plu_TwoPinsCategory) AS t " +
- @" union all
- select
- SeriesPrice,Tsorder_OpenSingle,CreateDateTime, 项目,实收金额,'二销' as 类型,
- (case (len(rtrim(ltrim(Tsorder_OpenSingle))) - len(rtrim(ltrim(replace(Tsorder_OpenSingle,',',''))))) when 0 then SeriesPrice
- else cast((SeriesPrice / ((select Cp_Proportion from tb_ErpCommissionPercentage where Cp_ProportionCode='MainLaterOtherTwoSales') + (select Cp_Proportion from tb_ErpCommissionPercentage where Cp_ProportionCode='DeputyLaterOtherTwoSales') *
- (len(rtrim(ltrim(Tsorder_OpenSingle))) - len(rtrim(ltrim(replace(Tsorder_OpenSingle,',','')))))) ) * (select Cp_Proportion from tb_ErpCommissionPercentage where Cp_ProportionCode='MainLaterOtherTwoSales') as numeric(9,2)) end) as 主门市金额,
- (case (len(rtrim(ltrim(Tsorder_OpenSingle))) - len(rtrim(ltrim(replace(Tsorder_OpenSingle,',',''))))) when 0 then 0 else cast((SeriesPrice / ((select Cp_Proportion from tb_ErpCommissionPercentage where Cp_ProportionCode='MainLaterOtherTwoSales') +
- (select Cp_Proportion from tb_ErpCommissionPercentage where Cp_ProportionCode='DeputyLaterOtherTwoSales') * (len(rtrim(ltrim(Tsorder_OpenSingle))) - len(rtrim(ltrim(replace(Tsorder_OpenSingle,',','')))))) ) *
- (select Cp_Proportion from tb_ErpCommissionPercentage where Cp_ProportionCode='DeputyLaterOtherTwoSales') as numeric(9,2)) end) as 副门市金额,
- (case (len(rtrim(ltrim(OrdersPerson))) - len(rtrim(ltrim(replace(OrdersPerson,',',''))))) when 0 then 实收金额 else
- cast((实收金额 / ((select Cp_Proportion from tb_ErpCommissionPercentage where Cp_ProportionCode='MainLaterOtherTwoSales') +
- (select Cp_Proportion from tb_ErpCommissionPercentage where Cp_ProportionCode='DeputyLaterOtherTwoSales') * (len(rtrim(ltrim(OrdersPerson))) - len(rtrim(ltrim(replace(OrdersPerson,',','')))))) ) *
- (select Cp_Proportion from tb_ErpCommissionPercentage where Cp_ProportionCode='MainLaterOtherTwoSales') as numeric(9,2)) end) as 主门市实收,
- (case (len(rtrim(ltrim(OrdersPerson))) - len(rtrim(ltrim(replace(OrdersPerson,',',''))))) when 0 then 0 else
- cast((实收金额 / ((select Cp_Proportion from tb_ErpCommissionPercentage where Cp_ProportionCode='MainLaterOtherTwoSales') + (select Cp_Proportion from tb_ErpCommissionPercentage where Cp_ProportionCode='DeputyLaterOtherTwoSales') *
- (len(rtrim(ltrim(OrdersPerson))) - len(rtrim(ltrim(replace(OrdersPerson,',','')))))) ) * (select Cp_Proportion from tb_ErpCommissionPercentage where Cp_ProportionCode='DeputyLaterOtherTwoSales') as numeric(9,2)) end) as 副门市实收,
- (case LEFT(Tsorder_OpenSingle,charindex(',',Tsorder_OpenSingle,1)) when '' then Tsorder_OpenSingle else LEFT(Tsorder_OpenSingle,charindex(',',Tsorder_OpenSingle,1)-1) end)as '主门市'
- from (select Tsorder_Money AS SeriesPrice,Tsorder_OpenSingle AS OrdersPerson,Tsorder_CreateDatetime AS CreateDateTime,Tsorder_CategoryName AS 项目,Tsorder_OpenSingle,isnull((select Sum(Pay_AmountOf) from tb_ErpPayment where Pay_OrdNumber = Tsorder_Number and Tsorder_Category = Pay_TwoPinsCategory),0) AS 实收金额
- from Vw_TwoSalesOrder ) AS t " +
- ")" +
- "select * from tt " + StrWhere + "; ";
- }
- DataSet dsData = orbll.GetView_Custom(ExecuteSql);
- //DataSet dsTowOrderData = orbll.GetView_Custom(TwoSaleOrderSql);
- //DataTable towOrderCount = dsTowOrderData.Tables["ds"];
- //DataTable towOrderCountCompared = dsTowOrderData.Tables["ds1"];
- string sql = " select * from tb_ErpCommissionPercentage where Cp_ProportionType in(1,5) ";
- DataTable PerDt = orbll.GetView_Custom(sql).Tables[0];
- List<DataRow> drList = PerDt.AsEnumerable().Where(q => q.Field<int>("Cp_ProportionType") == 1).ToList();
- DataRow mainDr = PerDt.NewRow();
- DataRow deputyDr = PerDt.NewRow();
- if (drList.Count > 0)
- {
- mainDr = drList.Where(q => q.Field<string>("Cp_ProportionCode") == "MainStoreProportion").First();
- deputyDr = drList.Where(q => q.Field<string>("Cp_ProportionCode") == "DeputyStoreProportion").First();
- }
- drList = PerDt.AsEnumerable().Where(q => q.Field<int>("Cp_ProportionType") == 5).ToList();
- DataRow mainTwoSalesDr= PerDt.NewRow();
- DataRow deputyTwoSalesDr = PerDt.NewRow();
- if (drList.Count > 0)
- {
- mainTwoSalesDr = drList.Where(q => q.Field<string>("Cp_ProportionCode") == "MainLaterOtherTwoSales").First();
- deputyTwoSalesDr = drList.Where(q => q.Field<string>("Cp_ProportionCode") == "DeputyLaterOtherTwoSales").First();
- }
-
-
- DataTable dtOrderCount = dsData.Tables["ds"];
- List<DataRow> drOrderList = dtOrderCount.AsEnumerable().Where(p1 => p1.Field<decimal?>("主门市金额") == null).ToList();
- foreach(DataRow dr in drOrderList)
- {
- string OrdersPerson = dr["OrdersPerson"].ToString_s();
- string[] personList = OrdersPerson.Split(',');
- if(personList.Length>1)
- {
- dr["主门市金额"] = dr["实收金额"];
- dr["副门市金额"] = dr["实收金额"];
- dr["主门市实收"] = dr["实收金额"];
- dr["副门市实收"] = dr["实收金额"];
- }
- else
- {
- dr["主门市金额"] = dr["实收金额"];
- dr["副门市金额"] = 0;
- dr["主门市实收"] = dr["实收金额"];
- dr["副门市实收"] = 0;
- }
- }
- DataTable dtOrderCountCompared = dsData.Tables["ds1"];
- DataTable dt = orbll.GetView_Custom("tb_ErpUser", StrWhere: "User_Department in (" + GetStoreTreeViewByStoreList() + ") And User_Status != '离职'", ShowColumnName: "User_EmployeeID,User_Name").Tables[0];
- #region 计算图片高度
- int ForTopLoad = 15;
- int RowHeight = 240 / 7;
- int DownHeight = 55 * dt.Rows.Count;
- int panelEx3Height = this.panelEx3.Height - 6;
- if (this.chkComparedStartUp.Checked)
- {
- panelEx3Height -= this.panelEx2.Height;
- DownHeight = 95 * dt.Rows.Count;
- }
- int TotalHeight = panelEx3Height;
- if (DownHeight > panelEx3Height)
- {
- TotalHeight = DownHeight + 20;
- this.PictImage.Dock = DockStyle.None;
- this.PictImage.Height = TotalHeight;
- this.PictImage.Width = this.panelEx3.Width - 20;
- this.panelEx3.AutoScroll = true;
- }
- else
- {
- this.PictImage.Dock = DockStyle.Fill;
- }
- #endregion
- Bitmap newBmp = new Bitmap(this.PictImage.Width, TotalHeight);
- Graphics g = Graphics.FromImage(newBmp);
- g.Clear(System.Drawing.Color.White);
- int LeftWidth = 30;
- int TableWidth = newBmp.Width - LeftWidth * 2;
- int ColumnWidth1 = 30;
- int ColumnWidth2 = 80;
- int ColumnWidth3 = TableWidth - ColumnWidth1 - ColumnWidth2;
- #endregion
- #region 从高到低排序
- Hashtable htData = new Hashtable();
- Hashtable htDataPaid = new Hashtable();
- for (int i = 0; i < dt.Rows.Count; i++)
- {
- if (dt.Rows[i]["User_EmployeeID"].ToString().Trim() == "20180128180834992")
- {
- string txt = "";
- }
- DataRow[] dtRow = dtOrderCount.Select("OrdersPerson like '%" + dt.Rows[i]["User_EmployeeID"].ToString().Trim() + "%'");
- //DataRow[] towDataRow = towOrderCount.Select(" EmployeeID like '%" + dt.Rows[i]["User_EmployeeID"].ToString().Trim() + "%' ");
- decimal decOrdSeriesPrice = 0;
- decimal decOrdSeriesPaid = 0;
- for (int j = 0; j < dtRow.Length; j++)
- {
- if (dtRow[j]["OrdersPerson"].ToString().Trim().Length != dtRow[j]["OrdersPerson"].ToString().Trim().Replace(",", "").Length)
- {
- string[] StrArrayPerson = dtRow[j]["OrdersPerson"].ToString().Trim().Split(',');
- if (StrArrayPerson[0].Trim() == dt.Rows[i]["User_EmployeeID"].ToString().Trim())
- {
- if(dtRow[j]["类型"].ToString_s()== "订单")
- {
- decOrdSeriesPrice += GetAchievement(Convert.ToDecimal(dtRow[j]["SeriesPrice"]), dtRow[j]["OrdersPerson"].ToString(), dt.Rows[i]["User_EmployeeID"].ToString().Trim(), mainDr, deputyDr);
- }
- else
- {
- decOrdSeriesPrice += GetAchievement(Convert.ToDecimal(dtRow[j]["SeriesPrice"]), dtRow[j]["OrdersPerson"].ToString(), dt.Rows[i]["User_EmployeeID"].ToString().Trim(), mainTwoSalesDr, deputyTwoSalesDr);
- }
- //decOrdSeriesPrice += Convert.ToDecimal(dtRow[j]["主门市金额"]);
- decOrdSeriesPaid += Convert.ToDecimal(dtRow[j]["主门市实收"]);
- }
- else
- {
- if (dtRow[j]["类型"].ToString_s() == "订单")
- {
- decOrdSeriesPrice += GetAchievement(Convert.ToDecimal(dtRow[j]["SeriesPrice"]), dtRow[j]["OrdersPerson"].ToString(), dt.Rows[i]["User_EmployeeID"].ToString().Trim(), mainDr, deputyDr);
- }
- else
- {
- decOrdSeriesPrice += GetAchievement(Convert.ToDecimal(dtRow[j]["SeriesPrice"]), dtRow[j]["OrdersPerson"].ToString(), dt.Rows[i]["User_EmployeeID"].ToString().Trim(), mainTwoSalesDr, deputyTwoSalesDr);
- }
- //decOrdSeriesPrice += Convert.ToDecimal(dtRow[j]["副门市金额"]);
- decOrdSeriesPaid += Convert.ToDecimal(dtRow[j]["副门市实收"]);
- }
- }
- else
- {
- if (dtRow[j]["类型"].ToString_s() == "订单")
- {
- decOrdSeriesPrice += GetAchievement(Convert.ToDecimal(dtRow[j]["SeriesPrice"]), dtRow[j]["OrdersPerson"].ToString(), dt.Rows[i]["User_EmployeeID"].ToString().Trim(), mainDr, deputyDr);
- }
- else
- {
- decOrdSeriesPrice += GetAchievement(Convert.ToDecimal(dtRow[j]["SeriesPrice"]), dtRow[j]["OrdersPerson"].ToString(), dt.Rows[i]["User_EmployeeID"].ToString().Trim(), mainTwoSalesDr, deputyTwoSalesDr);
- }
- //decOrdSeriesPrice += Convert.ToDecimal(dtRow[j]["主门市金额"]);
- decOrdSeriesPaid += Convert.ToDecimal(dtRow[j]["主门市实收"]);
- }
- }
- //for (int j = 0; j < towDataRow.Length; j++)
- //{
- // DataRow dr = towDataRow[j];
- // if(dr["EmployeeID"].ToString().Contains(dt.Rows[i]["User_EmployeeID"].ToString().Trim()))
- // {
- // decOrdSeriesPrice += Convert.ToDecimal(dr["Price"]);
- // decOrdSeriesPaid += Convert.ToDecimal(dr["PayPrice"]);
- // }
- //}
- htData[dt.Rows[i]["User_EmployeeID"].ToString().Trim()] = decOrdSeriesPrice;
- htDataPaid[dt.Rows[i]["User_EmployeeID"].ToString().Trim()] = decOrdSeriesPaid;
- }
- string[] arrKey = new string[htData.Count]; //暂存 Hashtable 的键
- decimal[] arrValue = new decimal[htData.Count];//暂存 Hashtable 的值
- htData.Keys.CopyTo(arrKey, 0);
- htData.Values.CopyTo(arrValue, 0);
- Array.Sort(arrValue, arrKey); //按 HashTable 的值排序
- #endregion
- if (!this.chkComparedStartUp.Checked)
- {
- // StrItemName +
- #region 无启动对比
- string StrValue = Convert.ToDateTime(this.dtDataTimeStart.DateValue).ToString("yyyy年MM月dd日") + " — " + Convert.ToDateTime(this.dtDataTimeEnd.DateValue).ToString("yyyy年MM月dd日") + " " + this.cmbtreevDepartment.Text.Trim() + "分析表";
- SizeF sizef = g.MeasureString(StrValue, ft15);
- int FtHeigth = Convert.ToInt32(sizef.Height);
- int FtWidth = Convert.ToInt32(sizef.Width) + 1;
- Rectangle rec = new Rectangle(TableWidth / 2 - FtWidth / 2, ForTopLoad, FtWidth, FtHeigth);
- g.DrawString(StrValue, ft15, b, rec);//画消费法规
- ForTopLoad = rec.Y + rec.Height + 30;
- float ProgressWidth = float.Parse((newBmp.Width - 200).ToString());
- float WidthRatio = 0;
- int forint = 1;
- for (int i = arrKey.Length - 1; i >= 0; i--)
- {
- Rectangle rec1 = new Rectangle(LeftWidth, ForTopLoad, ColumnWidth1, RowHeight);
- g.DrawString(forint.ToString().Trim(), ft11, b, rec1);
- string StrUserName = "";
- DataRow[] dtRowUser = dt.Select("User_EmployeeID = '" + arrKey[i].ToString().Trim() + "'");
- if (dtRowUser.Length > 0)
- { StrUserName = dtRowUser[0]["User_Name"].ToString().Trim(); }
- Rectangle rec2 = new Rectangle(rec1.X + rec1.Width + 5, rec1.Y, ColumnWidth2, RowHeight);
- g.DrawString(StrUserName.Trim(), ft11, b, rec2);
- if (forint == 1)
- {
- if (float.Parse(arrValue[i].ToString()) > 0)
- { WidthRatio = ProgressWidth / float.Parse(arrValue[i].ToString()); }
- }
- int intValue = Convert.ToInt32(WidthRatio * float.Parse(arrValue[i].ToString()));
- Rectangle rec3 = new Rectangle(rec2.X + rec2.Width + 5, rec1.Y, intValue, 20);
- g.FillRectangle(Brushes.Red, rec3);
- SetPostionData(StrUserName, arrKey[i].ToString().Trim(), rec3, "", StrTimeStrat, StrTimeEnd);
- string StrPaid = htDataPaid[arrKey[i].ToString().Trim()].ToString().Trim();
- int intValuePaid = Convert.ToInt32(WidthRatio * float.Parse(StrPaid));
- if (intValuePaid > intValue)
- {
- if (Convert.ToDecimal(StrPaid) > Convert.ToDecimal(arrValue[arrKey.Length - 1]))
- { intValuePaid = Convert.ToInt32(WidthRatio * float.Parse(arrValue[arrKey.Length - 1].ToString())); }
- }
- Rectangle rec3Paid = new Rectangle(rec2.X + rec2.Width + 5, rec1.Y, intValuePaid, 20);
- g.FillRectangle(Brushes.Green, rec3Paid);
- int rec4LocationY = rec1.Y;
- if (intValue > 0 || intValuePaid > 0)
- { rec4LocationY -= 20; }
- string StrStatisticsText = "业绩:" + LYFZ.BLL.OtherCommonModel.RemoveLastExcessZero(arrValue[i]) + " 实收:" + LYFZ.BLL.OtherCommonModel.RemoveLastExcessZero(StrPaid) + " 欠款:" + LYFZ.BLL.OtherCommonModel.RemoveLastExcessZero(Convert.ToDecimal(arrValue[i]) - Convert.ToDecimal(StrPaid));
- sizef = g.MeasureString(StrStatisticsText, ft11);
- FtWidth = Convert.ToInt32(sizef.Width) + 1;
- FtHeigth = Convert.ToInt32(sizef.Height);
- Rectangle rec4 = new Rectangle(rec3.X, rec4LocationY, FtWidth, FtHeigth);
- g.DrawString(StrStatisticsText, ft11, b, rec4);
- ForTopLoad += rec1.Height + 20;
- forint++;
- }
- #endregion
- }
- else
- {
- #region 启动对比
- Hashtable htData2 = new Hashtable();
- Hashtable htDataPaid2 = new Hashtable();
- for (int i = 0; i < dt.Rows.Count; i++)
- {
- DataRow[] dtRow = dtOrderCountCompared.Select("OrdersPerson like '%" + dt.Rows[i]["User_EmployeeID"].ToString().Trim() + "%'");
- //DataRow[] towDataRow = towOrderCountCompared.Select(" EmployeeID like '%" + dt.Rows[i]["User_EmployeeID"].ToString().Trim() + "%' ");
- decimal decOrdSeriesPrice = 0;
- decimal decOrdSeriesPaid = 0;
- for (int j = 0; j < dtRow.Length; j++)
- {
- if (dtRow[j]["OrdersPerson"].ToString().Trim().Length != dtRow[j]["OrdersPerson"].ToString().Trim().Replace(",", "").Length)
- {
- string[] StrArrayPerson = dtRow[j]["OrdersPerson"].ToString().Trim().Split(',');
- if (StrArrayPerson[0].Trim() == dt.Rows[i]["User_EmployeeID"].ToString().Trim())
- {
- if (dtRow[j]["类型"].ToString_s() == "订单")
- {
- decOrdSeriesPrice += GetAchievement(Convert.ToDecimal(dtRow[j]["SeriesPrice"]), dtRow[j]["OrdersPerson"].ToString(), dt.Rows[i]["User_EmployeeID"].ToString().Trim(), mainDr, deputyDr);
- }
- else
- {
- decOrdSeriesPrice += GetAchievement(Convert.ToDecimal(dtRow[j]["SeriesPrice"]), dtRow[j]["OrdersPerson"].ToString(), dt.Rows[i]["User_EmployeeID"].ToString().Trim(), mainTwoSalesDr, deputyTwoSalesDr);
- }
- //decOrdSeriesPrice += Convert.ToDecimal(dtRow[j]["主门市金额"]);
- decOrdSeriesPaid += Convert.ToDecimal(dtRow[j]["主门市实收"]);
- }
- else
- {
- if (dtRow[j]["类型"].ToString_s() == "订单")
- {
- decOrdSeriesPrice += GetAchievement(Convert.ToDecimal(dtRow[j]["SeriesPrice"]), dtRow[j]["OrdersPerson"].ToString(), dt.Rows[i]["User_EmployeeID"].ToString().Trim(), mainDr, deputyDr);
- }
- else
- {
- decOrdSeriesPrice += GetAchievement(Convert.ToDecimal(dtRow[j]["SeriesPrice"]), dtRow[j]["OrdersPerson"].ToString(), dt.Rows[i]["User_EmployeeID"].ToString().Trim(), mainTwoSalesDr, deputyTwoSalesDr);
- }
- //decOrdSeriesPrice += Convert.ToDecimal(dtRow[j]["副门市金额"]);
- decOrdSeriesPaid += Convert.ToDecimal(dtRow[j]["副门市实收"]);
- }
- }
- else
- {
- if (dtRow[j]["类型"].ToString_s() == "订单")
- {
- decOrdSeriesPrice += GetAchievement(Convert.ToDecimal(dtRow[j]["SeriesPrice"]), dtRow[j]["OrdersPerson"].ToString(), dt.Rows[i]["User_EmployeeID"].ToString().Trim(), mainDr, deputyDr);
- }
- else
- {
- decOrdSeriesPrice += GetAchievement(Convert.ToDecimal(dtRow[j]["SeriesPrice"]), dtRow[j]["OrdersPerson"].ToString(), dt.Rows[i]["User_EmployeeID"].ToString().Trim(), mainTwoSalesDr, deputyTwoSalesDr);
- }
- //decOrdSeriesPrice += Convert.ToDecimal(dtRow[j]["主门市金额"]);
- decOrdSeriesPaid += Convert.ToDecimal(dtRow[j]["主门市实收"]);
- }
- //decOrdSeriesPrice += Convert.ToDecimal(dtRow[j]["SeriesPrice"]);
- }
- //for (int j = 0; j < towDataRow.Length; j++)
- //{
- // DataRow dr = towDataRow[j];
- // if (dr["EmployeeID"].ToString().Contains(dt.Rows[i]["User_EmployeeID"].ToString().Trim()))
- // {
- // decOrdSeriesPrice += Convert.ToDecimal(dr["Price"]);
- // decOrdSeriesPaid += Convert.ToDecimal(dr["PayPrice"]);
- // }
- //}
- htData2[dt.Rows[i]["User_EmployeeID"].ToString().Trim()] = decOrdSeriesPrice;
- htDataPaid2[dt.Rows[i]["User_EmployeeID"].ToString().Trim()] = decOrdSeriesPaid;
- }
- string[] arrKey2 = new string[htData2.Count]; //暂存 Hashtable 的键
- decimal[] arrValue2 = new decimal[htData2.Count];//暂存 Hashtable 的值
- htData2.Keys.CopyTo(arrKey2, 0);
- htData2.Values.CopyTo(arrValue2, 0);
- Array.Sort(arrValue2, arrKey2); //按 HashTable 的值排序 + StrItemName
- string StrValue = StrTimeStrat + "—" + StrTimeEnd + " 与 " + StrTimeStratDb + "—" + StrTimeEndDb + " " + this.cmbtreevDepartment.Text.Trim() + "分析表";
- SizeF sizef = g.MeasureString(StrValue, ft15);
- int FtHeigth = Convert.ToInt32(sizef.Height);
- int FtWidth = Convert.ToInt32(sizef.Width) + 1;
- Rectangle rec = new Rectangle(TableWidth / 2 - FtWidth / 2, ForTopLoad, FtWidth, FtHeigth);
- g.DrawString(StrValue, ft15, b, rec);//画消费法规
- ForTopLoad = rec.Y + rec.Height + 30;
- float ProgressWidth = float.Parse((newBmp.Width - 200).ToString());
- float WidthRatio = 0;
- int forint = 1;
- for (int i = arrKey.Length - 1; i >= 0; i--)
- {
- Rectangle rec1 = new Rectangle(LeftWidth, ForTopLoad, ColumnWidth1, RowHeight);
- g.DrawString(forint.ToString().Trim(), ft11, b, rec1);
- string StrUserName = "";
- DataRow[] dtRowUser = dt.Select("User_EmployeeID = '" + arrKey[i].ToString().Trim() + "'");
- if (dtRowUser.Length > 0)
- { StrUserName = dtRowUser[0]["User_Name"].ToString().Trim(); }
- Rectangle rec2 = new Rectangle(rec1.X + rec1.Width + 5, rec1.Y, ColumnWidth2, RowHeight);
- g.DrawString(StrUserName, ft11, b, rec2);
- decimal StrValue1 = Convert.ToDecimal(arrValue[i]);
- if (forint == 1)
- {
- if (arrValue.Length > 0 && arrValue2.Length > 0)
- {
- if (float.Parse(arrValue[i].ToString()) >= float.Parse(arrValue2[arrValue2.Length - 1].ToString()))
- {
- if (Convert.ToDecimal(arrValue[i]) > 0)
- { WidthRatio = ProgressWidth / float.Parse(arrValue[i].ToString()); }
- }
- else
- {
- if (Convert.ToDecimal(arrValue2[arrValue2.Length - 1]) > 0)
- { WidthRatio = ProgressWidth / float.Parse(arrValue2[arrValue2.Length - 1].ToString()); }
- }
- }
- else if (arrValue.Length > 0 && arrValue2.Length == 0)
- {
- if (Convert.ToDecimal(arrValue[i]) > 0)
- { WidthRatio = ProgressWidth / float.Parse(arrValue[i].ToString()); }
- }
- else if (arrValue.Length == 0 && arrValue2.Length > 0)
- {
- if (Convert.ToDecimal(arrValue2[arrValue2.Length - 1]) > 0)
- { WidthRatio = ProgressWidth / float.Parse(arrValue2[arrValue2.Length - 1].ToString()); }
- }
- }
- int intValue1 = Convert.ToInt32(WidthRatio * float.Parse(arrValue[i].ToString()));
- Rectangle rec3 = new Rectangle(rec2.X + rec2.Width + 5, rec1.Y - 10, intValue1, 20);
- g.FillRectangle(Brushes.Red, rec3);
- SetPostionData(StrUserName, arrKey[i].ToString().Trim(), rec3, "", StrTimeStrat, StrTimeEnd);
- string StrPaid = htDataPaid[arrKey[i].ToString().Trim()].ToString().Trim();
- int intValuePaid = Convert.ToInt32(WidthRatio * float.Parse(StrPaid));
- if (intValuePaid > intValue1)
- {
- if (Convert.ToDecimal(StrPaid) > Convert.ToDecimal(arrValue[arrKey.Length - 1]))
- { intValuePaid = Convert.ToInt32(WidthRatio * float.Parse(arrValue[arrKey.Length - 1].ToString())); }
- }
- Rectangle rec3Paid = new Rectangle(rec3.X, rec3.Y, intValuePaid, 20);
- g.FillRectangle(Brushes.Green, rec3Paid);
- string StrStatisticsText = "业绩:" + LYFZ.BLL.OtherCommonModel.RemoveLastExcessZero(StrValue1) + " 实收:" + LYFZ.BLL.OtherCommonModel.RemoveLastExcessZero(StrPaid) + " 欠款:" + LYFZ.BLL.OtherCommonModel.RemoveLastExcessZero(Convert.ToDecimal(StrValue1) - Convert.ToDecimal(StrPaid));
- sizef = g.MeasureString(StrStatisticsText, ft11);
- FtWidth = Convert.ToInt32(sizef.Width) + 1;
- FtHeigth = Convert.ToInt32(sizef.Height);
- int rec4LocationY = rec3.Y;
- if (intValue1 > 0 || intValuePaid > 0)
- { rec4LocationY -= FtHeigth; }
- Rectangle rec4 = new Rectangle(rec3.X, rec4LocationY, FtWidth, FtHeigth);
- g.DrawString(StrStatisticsText, ft11, b, rec4);
- int intValue2 = 0;
- decimal StrValue2 = 0;
- if (htData2.ContainsKey(arrKey[i].ToString().Trim()))
- {
- if (Convert.ToDecimal(htData2[arrKey[i].ToString().Trim()]) > 0)
- {
- intValue2 = Convert.ToInt32(WidthRatio * float.Parse(htData2[arrKey[i].ToString().Trim()].ToString()));
- StrValue2 = Convert.ToDecimal(htData2[arrKey[i].ToString().Trim()]);
- }
- }
- Rectangle rec5 = new Rectangle(rec2.X + rec2.Width + 5, rec3.Y + rec3.Height + 1, intValue2, 20);
- g.FillRectangle(Brushes.Blue, rec5);
- SetPostionData(StrUserName, arrKey[i].ToString().Trim(), rec5, "", StrTimeStratDb, StrTimeEndDb);
- string StrPaid5 = htDataPaid2[arrKey[i].ToString().Trim()].ToString().Trim();
- int intValuePaid5 = Convert.ToInt32(WidthRatio * float.Parse(StrPaid5));
- if (intValuePaid5 > intValue1)
- {
- if (Convert.ToDecimal(StrPaid5) > Convert.ToDecimal(arrValue2[arrKey.Length - 1]))
- { intValuePaid5 = Convert.ToInt32(WidthRatio * float.Parse(arrValue2[arrKey.Length - 1].ToString())); }
- }
- Rectangle rec5Paid = new Rectangle(rec5.X, rec5.Y, intValuePaid5, 20);
- g.FillRectangle(Brushes.Green, rec5Paid);
- int rec4LocationY2 = rec5.Y;
- if (intValue2 > 0 || intValuePaid5 > 0)
- { rec4LocationY2 += rec5.Height; }
- StrStatisticsText = "业绩:" + LYFZ.BLL.OtherCommonModel.RemoveLastExcessZero(StrValue2) + " 实收:" + LYFZ.BLL.OtherCommonModel.RemoveLastExcessZero(StrPaid5) + " 欠款:" + LYFZ.BLL.OtherCommonModel.RemoveLastExcessZero(Convert.ToDecimal(StrValue2) - Convert.ToDecimal(StrPaid5));
- sizef = g.MeasureString(StrStatisticsText, ft11);
- FtWidth = Convert.ToInt32(sizef.Width) + 1;
- FtHeigth = Convert.ToInt32(sizef.Height);
- Rectangle rec6 = new Rectangle(rec3.X, rec4LocationY2, FtWidth, FtHeigth);
- g.DrawString(StrStatisticsText, ft11, b, rec6);
- string StrPercentage = "";
- if (StrValue2 != StrValue1)
- {
- if (StrValue1 > 0)
- {
- StrPercentage = LYFZ.BLL.OtherCommonModel.RemoveLastExcessZero(LYFZ.Command.Command_Validate.GetIsNotRoundedString((StrValue1 - StrValue2) / StrValue1));
- if (StrValue1 > StrValue2)
- { StrPercentage = "同比上涨 " + StrPercentage.Replace("-", ""); }
- else
- { StrPercentage = "同比下降 " + StrPercentage.Replace("-", ""); }
- }
- else
- { StrPercentage = "同比下降 " + LYFZ.BLL.OtherCommonModel.RemoveLastExcessZero(StrValue2 - StrValue1); }
- }
- if (!string.IsNullOrEmpty(StrPercentage))
- { StrPercentage += "%"; }
- sizef = g.MeasureString(StrPercentage, ft11);
- FtWidth = Convert.ToInt32(sizef.Width) + 1;
- FtHeigth = Convert.ToInt32(sizef.Height);
- Rectangle rec7 = new Rectangle(rec4.X + rec4.Width + 30, rec4.Y, FtWidth, FtHeigth);
- g.DrawString(StrPercentage, ft11, b, rec7);
- ForTopLoad += rec1.Height + 60;
- forint++;
- }
- #endregion
- }
- this.PictImage.Image = newBmp;
- }
- string GetStoreTreeViewByStoreList()
- {
- string strDepartment = "";
- List<string> department = new List<string>();
- if( this.cmbtreevDepartment.Tag.ToString()=="")
- {
- foreach(TreeNode treeNode in this.cmbtreevDepartment.TreeView.Nodes)
- {
- department.AddRange(GetStoreTreeViewByDepartmentList(treeNode));
- }
- }
- else if (this.cmbtreevDepartment.SelectedNode.Nodes.Count>0)
- {
- department.AddRange(GetStoreTreeViewByDepartmentList(this.cmbtreevDepartment.SelectedNode));
- }
- else
- {
- department.Add(this.cmbtreevDepartment.SelectedNode.Tag.ToString());
- }
- strDepartment ="'" + string.Join("','", department.ToArray()) + "'";
- return strDepartment;
- }
- List<string> GetStoreTreeViewByDepartmentList(TreeNode treeNode)
- {
- List<string> department = new List<string>();
- foreach (TreeNode node in treeNode.Nodes)
- {
- department.Add(node.Tag.ToString());
- }
- return department;
- }
- decimal GetAchievement(decimal totalValue, string personData, string EmployeeName, DataRow mainDr, DataRow deputyDr)
- {
- string[] personList = personData.Split(',');
- if (personList.Length > 1)
- {
- for (int i = 0; i < personList.Length; i++)
- {
- if (personList[i] == EmployeeName)
- {
- if (i == 0)
- {
- if (mainDr["Cp_Enabled"].ToString() == "1")
- {
- return totalValue / (Convert.ToInt32(mainDr["Cp_Proportion"]) + Convert.ToInt32(deputyDr["Cp_Proportion"]) * (personList.Length - 1)) * Convert.ToInt32(mainDr["Cp_Proportion"]);
- }
- else
- {
- return totalValue;
- }
- }
- else
- {
- if (deputyDr["Cp_Enabled"].ToString() == "1")
- {
- return totalValue / (Convert.ToInt32(mainDr["Cp_Proportion"]) + Convert.ToInt32(deputyDr["Cp_Proportion"]) * (personList.Length - 1)) * Convert.ToInt32(deputyDr["Cp_Proportion"]);
- }
- else
- {
- return totalValue;
- }
- }
- }
- }
- }
- return totalValue;
- }
- }
- }
|