12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711 |
- 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.StatisticalInquiry
- {
- public partial class FrmIndividualPerformance : LYFZ.Software.UI.StatisticalInquiry.FrmIndividualPerformance
- {
- LYFZ.BLL.BLL_ErpOrder orbll = new BLL.BLL_ErpOrder();
- public FrmIndividualPerformance()
- {
- btn_Export.Click += Btn_Export_Click;
- this.cmbEmployeeName.Enabled = LYFZ.BLL.BLL_ErpUser.GetRights(LYFZ.BLL.BLL_ErpUser.CurrentUserRights.IndividualPerformanceCompetence, CustomAttributes.OperatingAuthority.ViewAll);
-
- }
-
- private void Btn_Export_Click(object sender, EventArgs e)
- {
- this.dgv.ExportDataTable();
- }
- /// <summary>
- /// 窗体加载事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- protected override void FrmIndividualPerformance_Shown(object sender, EventArgs e)
- {
- this.txtTimeStart.Text = SDateTime.Now.ToString("yyyy-MM-") + "01";
- this.txtTimeEnd.Text = Convert.ToDateTime(this.txtTimeStart.Text).AddMonths(1).AddSeconds(-1).ToString("yyyy-MM-dd");
- //部门人员绑定
- LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.BindComboBoxTreeView_DepartmentAndEmployee(this.cmbEmployeeName, IsFirstNodeNull: true, IsFirstNodeName: "全部", IsShowAdmin: true);
- //项目类别
- LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.BindComboxTreeView(this.cmbItemCategory, "订单前期,订单后期,其它消费,礼服租售,会员充值,会员服务充值", IsFirstNodeNull: true);//会员充值,服务卡充值
- //套系类别
- LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.BindComboBoxTreeView_SystemCategory("BFAGAHBFDGCABAJIH", this.CtvPak_Name, IsFirstNodeNull: true);
- LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.BindComboBoxTreeView_SystemCategory("BEBACCAFCCEAGAIHH", this.cbx_PaymentType, IsFirstNodeNull: true);
- this.cmbEmployeeName.Enabled = LYFZ.BLL.BLL_ErpUser.GetRights(LYFZ.BLL.BLL_ErpUser.CurrentUserRights.IndividualPerformanceCompetence, CustomAttributes.OperatingAuthority.ViewAll);
-
-
- if (LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.LoginUserModel.User_Account != LYFZ.AuthorizeUserName.AdministratorsName)
- {
- this.cmbEmployeeName.Tag = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.LoginUserModel.User_EmployeeID;
- this.cmbEmployeeName.Text = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.LoginUserModel.User_Name;
- //CmbEmployeeName_SelectedIndexChanged(null, null);
- }
- this.cmbEmployeeName.ComboBoxTreeViewEx_TextChanged += CmbEmployeeName_SelectedIndexChanged;
- this.cbx_PaymentType.ComboBoxTreeViewEx_TextChanged += Cbx_PaymentType_ComboBoxTreeViewEx_TextChanged;
- //this.cmbEmployeeName.TextFindTag("全部");
- this.cmbEmployeeName.TagFindText(LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.LoginUserModel.User_EmployeeID);
- this.BindPerformance(this.txtTimeStart.DateValue.ToString().Trim(), this.txtTimeEnd.DateValue.ToString().Trim(),
- GetEmployeeDataInfo());
- }
- private void Cbx_PaymentType_ComboBoxTreeViewEx_TextChanged(object sender, TreeViewEventArgs e)
- {
- this.BindCalculate();
- }
- private void CmbEmployeeName_SelectedIndexChanged(object sender, EventArgs e)
- {
- this.cmbEmployeeName_ComboBoxTree_NodeMouseClick(null, null);
- }
- /// <summary>
- /// 绑定业绩列表查询方法1(订单前期)
- /// </summary>
- public string BindSelect1()
- {
- StringBuilder str = new StringBuilder();
- if (!string.IsNullOrEmpty(this.CtvPak_Name.Text) && this.CtvPak_Name.Tag != null)
- { str.Append(" and Ord_OrderClass='" + this.CtvPak_Name.Text + "'"); }
- if (!string.IsNullOrEmpty(this.cmbItemCategory.Text.Trim()))
- {
- if (cmbItemCategory.Text != "订单前期")
- { str.Append(" and tb_ErpOrder.id=-3"); }
- }
- return str.ToString();
- }
- /// <summary>
- /// 绑定业绩列表查询方法2(订单后期)
- /// </summary>
- public string BindSelect2()
- {
- StringBuilder str = new StringBuilder();
- if (!string.IsNullOrEmpty(this.CtvPak_Name.Text.Trim()))
- { str.Append(" and 套系类别='" + this.CtvPak_Name.Text.ToString() + "'"); }
- if (!string.IsNullOrEmpty(this.cmbItemCategory.Text.Trim()))
- {
- if (this.cmbItemCategory.Text == "订单后期")
- {
- if (!string.IsNullOrEmpty(this.cmbProjectTitle.Text))
- { str.Append(" and 二销类别编号='" + this.cmbProjectTitle.Tag.ToString() + "'"); }
- }
- else
- { str.Append(" and id=-3"); }
- }
- return str.ToString();
- }
- /// <summary>
- /// 绑定业绩列表查询方法3(订单后期)
- /// </summary>
- public string BindSelect3()
- {
- StringBuilder str = new StringBuilder();
- if (!string.IsNullOrEmpty(this.CtvPak_Name.Text.Trim()))
- { str.Append(" and Vw_TwoSalesOrder.id=-3"); }
- if (!string.IsNullOrEmpty(this.cmbItemCategory.Text.Trim()))
- {
- if (this.cmbItemCategory.Text == "其它消费")
- {
- if (!string.IsNullOrEmpty(this.cmbProjectTitle.Text))
- { str.Append(" and Tsorder_Category='" + this.cmbProjectTitle.Tag.ToString() + "'"); }
- }
- else
- { str.Append(" and Vw_TwoSalesOrder.id=-3"); }
- }
- return str.ToString();
- }
- /// <summary>
- /// 绑定业绩列表查询方法4(计件提成)
- /// </summary>
- public string BindSelect4()
- {
- StringBuilder str = new StringBuilder();
- if (!string.IsNullOrEmpty(this.CtvPak_Name.Text.Trim()))
- { str.Append(" and id=-3"); }
- if (!string.IsNullOrEmpty(this.cmbItemCategory.Text.Trim()))
- {
- if (this.cmbItemCategory.Text == "计件提成")
- {
- if (!string.IsNullOrEmpty(this.cmbProjectTitle.Text))
- { str.Append(" and Pcr_CompletionContents='" + this.cmbProjectTitle.Tag + "'"); }
- }
- else
- { str.Append("and id=-3"); }
- }
- return str.ToString();
- }
- /// <summary>
- /// 绑定业绩列表查询方法4(计件提成)
- /// </summary>
- public string BindSelect5()
- {
- StringBuilder str = new StringBuilder();
- if (!string.IsNullOrEmpty(this.CtvPak_Name.Text.Trim()))
- { str.Append(" and id=-3"); }
- if (!string.IsNullOrEmpty(this.cmbItemCategory.Text.Trim()))
- {
- if (this.cmbItemCategory.Text == "礼服租售")
- {
- if (!string.IsNullOrEmpty(this.cmbProjectTitle.Text))
- {
- if (this.cmbProjectTitle.Text == "礼服出租")
- { str.Append(" and Dsro_Type=0"); }
- if (this.cmbProjectTitle.Text == "礼服出售")
- { str.Append(" and Dsro_Type=1"); }
- }
- }
- else
- { str.Append(" and id=-3"); }
- }
- return str.ToString();
- }
- /// <summary>
- /// 绑定业绩列表查询方法6(员工奖罚)
- /// </summary>
- public string BindSelect6()
- {
- StringBuilder str = new StringBuilder();
- if (!string.IsNullOrEmpty(this.CtvPak_Name.Text.Trim()))
- { str.Append(" and id=-3"); }
- if (!string.IsNullOrEmpty(this.cmbItemCategory.Text.Trim()))
- {
- if (this.cmbItemCategory.Text == "员工奖罚")
- {
- if (!string.IsNullOrEmpty(this.cmbProjectTitle.Text.Trim()))
- { str.Append(" and Rp_Type='" + this.cmbProjectTitle.Text.Trim() + "'"); }
- }
- else
- { str.Append(" and id=-3"); }
- }
- return str.ToString();
- }
- /// <summary>
- /// 绑定业绩列表查询方法7(员工支出)
- /// </summary>礼服租售数据
- public string BindSelect7()
- {
- StringBuilder str = new StringBuilder();
- if (!string.IsNullOrEmpty(this.CtvPak_Name.Text.Trim()))
- { str.Append(" and id=-3"); }
- if (!string.IsNullOrEmpty(this.cmbItemCategory.Text.Trim()))
- {
- if (this.cmbItemCategory.Text != "员工支出")
- { str.Append(" and id=-3"); }
- }
- return str.ToString();
- }
- public string BindSelect8()
- {
- StringBuilder str = new StringBuilder();
- if (!string.IsNullOrEmpty(this.CtvPak_Name.Text.Trim()))
- { str.Append(" and [tb_ErpMemberCardRechargeRecord].id=-3"); }
- if (!string.IsNullOrEmpty(this.cmbItemCategory.Text.Trim()))
- {
- if (this.cmbItemCategory.Text != "会员充值")
- { str.Append(" and [tb_ErpMemberCardRechargeRecord].id=-3"); }
- }
- return str.ToString();
- }
- public string BindSelect9()
- {
- StringBuilder str = new StringBuilder();
- if (!string.IsNullOrEmpty(this.CtvPak_Name.Text.Trim()))
- { str.Append(" and tb_ErpMemberCardPayment.id=-3"); }
- if (!string.IsNullOrEmpty(this.cmbItemCategory.Text.Trim()))
- {
- if (this.cmbItemCategory.Text != "会员服务充值")
- { str.Append(" and tb_ErpMemberCardPayment.id=-3"); }
- }
- return str.ToString();
- }
- /// <summary>
- /// 获取所有业绩列表
- /// </summary>
- public decimal BindPerformance(string StartTime, string EndTime, string EmployeeName)
- {
- decimal Sum = 0;
- this.dgv.Rows.Clear();
- string s = "";
- LYFZ.BLL.BLL_AllViewSet AllViewSetbll = new BLL.BLL_AllViewSet();
- LYFZ.BLL.BLL_ErpOrder Orderbll = new BLL.BLL_ErpOrder();
- LYFZ.BLL.BLL_ErpOrdersPhotography OrdersPhotographybll = new BLL.BLL_ErpOrdersPhotography();
- DataTable dt = new DataTable();
- ///订单前期
- DataTable preOrder = new DataTable();
- ///订单后期
- DataTable lastOrder = new DataTable();
- ///获取其它消费
- DataTable otherOrder = new DataTable();
- ///获取计件提成
- DataTable pieceworkOrder = new DataTable();
- ///获取礼服租售
- DataTable dressOrder = new DataTable();
- ///获取员工奖罚
- DataTable rewardOrder = new DataTable();
- ///获取员工支出
- DataTable paymentOrder = new DataTable();
- ///付款方式
- DataTable payData = new DataTable();
- ///会员充值
- DataTable mamberOrder = new DataTable();
- ///会员服务充值
- DataTable mamberServiceOrder = new DataTable();
- ///礼服租售充值
- DataTable dressServiceOrder = new DataTable();
- StringBuilder str = new StringBuilder();
- Dictionary<string, Dictionary<string, List<dynamic>>> dyUserList = new Dictionary<string, Dictionary<string, List<dynamic>>>();
- string sql = " select * from tb_ErpCommissionPercentage where Cp_ProportionType in(1,5) ";
- DataTable PerDt = orbll.GetView_Custom(sql).Tables[0];
- LYFZ.ComponentLibrary.FrmLoadHandling.LoadDoWorkMethod(delegate (object obj, BackgroundWorker backgroundWorker)
- {
- try
- {
- ///订单付款
- List<string> perOrderList = new List<string>();
- List<string> lastOrderList = new List<string>();
- string strWhereTime = " Pay_CreateDatetime>='" + StartTime + "' and Pay_CreateDatetime<='" + EndTime + " 23:59:59.000' ";
- if(!string.IsNullOrEmpty(cbx_PaymentType.Text.Trim()))
- {
- strWhereTime += " and Pay_PaymentMethod = '" + cbx_PaymentType.Tag + "'";
- }
- if (EmployeeName != null && !string.IsNullOrEmpty(EmployeeName))
- {
- string[] userNumbers = EmployeeName.Split(',');
- string strOpenWhere = "";
- string strCommissionRatio = "";
- foreach (string employeeKey in userNumbers)
- {
- if (!string.IsNullOrEmpty(strOpenWhere))
- {
- strOpenWhere += " or ";
- }
- strOpenWhere += " Pay_OpenSingle like '%" + employeeKey.Replace("'", "") + "%' ";
- }
- foreach (string employeeKey in userNumbers)
- {
- if (!string.IsNullOrEmpty(strCommissionRatio))
- {
- strCommissionRatio += " or ";
- }
- strCommissionRatio += " Pay_CommissionRatio like '%" + employeeKey.Replace("'", "") + "%' ";
- }
- strWhereTime += (" and ((" + strOpenWhere + ") or ("+ strCommissionRatio + ") )");
- //str.Append(" and Pay_OpenSingle in (" + EmployeeName + ")");
- }
- //if (EmployeeName != null && !string.IsNullOrEmpty(EmployeeName))
- //{
- // //str.Append(" and 销售人员编号 in (" + EmployeeName + ")");
- // strWhereTime += " and (Pay_OpenSingle like '%" + EmployeeName + "%' or Pay_CommissionRatio like '%" + EmployeeName + "%' ) ";
- //}
- string paySql = @"SELECT
- Pay_OrdNumber,
- Pay_Category,
- c2.Sc_ClassName,
- Pay_TwoPinsCategory,
- Pay_OpenSingle,
- c1.Sc_ClassName as Sc_ClassName1,
- Pay_AmountOf,
- Pay_CreateDatetime,
- Pay_ThePayee,
- Pay_ReceivableProject,
- Pay_CommissionRatio
- FROM [tb_ErpPayment] inner join tb_ErpSystemCategory c1 on Pay_PaymentMethod = c1.Sc_ClassCode
- left join tb_ErpSystemCategory c2 on Pay_TwoPinsCategory = c2.Sc_ClassCode
- where "+ strWhereTime;
- payData = Orderbll.GetView_Custom(paySql).Tables[0];
- perOrderList = payData.AsEnumerable().Where(p => p.Field<string> ("Pay_Category").IndexOf("后期") == -1).Select(p=>p.Field<string>("Pay_OrdNumber")).Distinct().ToList();
- lastOrderList = payData.AsEnumerable().Where(p => p.Field<string>("Pay_Category").IndexOf("后期") != -1).Select(p => p.Field<string>("Pay_OrdNumber")).Distinct().ToList();
-
- ///订单前期
- if (perOrderList.Count > 0)
- {
- str.Append("( Ord_Number in ('" + string.Join("','", perOrderList.ToArray()) + "') )");
- }
- else
- {
- str.Append("( Ord_Number in ('-1') )");
- }
- //if (EmployeeName != null && !string.IsNullOrEmpty(EmployeeName))
- //{
- // string[] userNumbers = EmployeeName.Split(',');
- // string strWhere = "";
- // foreach(string employeeKey in userNumbers)
- // {
- // if(!string.IsNullOrEmpty(strWhere))
- // {
- // strWhere += " or ";
- // }
- // strWhere += " Ord_OrderPersonNumber like '%" + employeeKey.Replace("'","") + "%' ";
- // }
- // str.Append(" and ("+ strWhere + ")");
- // //str.Append(" and Pay_OpenSingle in (" + EmployeeName + ")");
- //}
- s = BindSelect1();
- preOrder = orbll.GetView_Custom("tb_ErpOrder Left Join tempTB_AggregationCustomer on GP_OrderNumber = Ord_Number ", StrWhere: str.ToString() + s.ToString(), ShowColumnName: "Ord_Number,Ord_SinceOrderNumber,Ord_OrderPersonName,Ord_OrderPersonNumber,Cus_Name,Cus_Telephone,Ord_SeriesPrice,Ord_CreateDatetime,Ord_PhotographyCategory,Ord_SeriesName").Tables[0];
- ///订单后期
- s = "";
- str = new StringBuilder();
- if (lastOrderList.Count > 0)
- {
- str.Append("( 订单号 in ('" + string.Join("','", lastOrderList.ToArray()) + "') )");
- }
- else
- {
- str.Append("( 订单号 in ('-1') )");
- }
- //str.Append(" 创建时间>='" + StartTime + "' and 创建时间<='" + EndTime + " 23:59:59.000'");
- //if (EmployeeName != null && !string.IsNullOrEmpty(EmployeeName))
- //{ str.Append(" and 销售人员编号 in (" + EmployeeName + ")"); }
- s = BindSelect2();
- lastOrder = Orderbll.GetView_Custom("Vw_ErpPlusPickItems", StrWhere: str.ToString() + s.ToString(), ShowColumnName: "ID,订单号,Ord_SinceOrderNumber,金额,创建时间,商品名称,录单人编号,录单人名称,商品成本价,加挑金额来源类型,销售人员编号,销售人员名称,二销类别编号,二销类别名称,客户名称,拼音,电话,套系类别").Tables[0];
- ///获取其它消费
- s = "";
- str = new StringBuilder();
- dt = new DataTable();
- str.Append(" Tsorder_CreateDatetime>='" + StartTime + "' and Tsorder_CreateDatetime<='" + EndTime + " 23:59:59.000'");
- if (!string.IsNullOrEmpty(cbx_PaymentType.Text.Trim()))
- {
- str.Append(" and Tsorder_Category = '" + cbx_PaymentType.Tag + "'");
- }
- if (EmployeeName != null && !string.IsNullOrEmpty(EmployeeName))
- { str.Append(" and Tsorder_OpenSingle in (" + EmployeeName + ")"); }
- s = BindSelect3();
- otherOrder = Orderbll.GetView_Custom("Vw_TwoSalesOrder left join tb_ErpSystemCategory c1 on Tsorder_CategoryName = c1.Sc_ClassCode ", StrWhere: str.ToString() + s.ToString(), ShowColumnName: "Vw_TwoSalesOrder.ID,Tsorder_Number,c1.Sc_ClassName,Tsorder_Name,Tsorder_CustomerName,Tsorder_OpenSingle,Tsorder_Telephone,Cus_NamePinyin,Tsorder_Money,Tsorder_Quantity,Tsorder_Category,Tsorder_OpenSingle,Tsorder_PersonHandling,Tsorder_Remark,Tsorder_CreateDatetime,Tsorder_UpdateDatetime,User_Name,Tsorder_PersonHandlingName,Tsorder_CategoryName,Tsorder_CustomerNumber").Tables[0];
- /////获取计件提成
- //s = "";
- //str = new StringBuilder();
- //dt = new DataTable();
- //str.Append(" Pcr_CreateTime>='" + StartTime + "' and Pcr_CreateTime<='" + EndTime + " 23:59:59.000'");
- //if (!string.IsNullOrEmpty(cbx_PaymentType.Text.Trim()))
- //{
- // str.Append(" and Pcr_OrderNumber = '-1'");
- //}
- //if (EmployeeName != null && !string.IsNullOrEmpty(EmployeeName))
- //{ str.Append(" and Pcr_DigitalDivision in (" + EmployeeName + ")"); }
- //s = BindSelect4();
- //pieceworkOrder = Orderbll.GetView_Custom("Vw_ErpPieceCommissionRecords", StrWhere: str.ToString() + s.ToString(), ShowColumnName: "ID,Ord_SinceOrderNumber as Pcr_OrderNumber,Pcr_DigitalDivision,Pcr_Date,Pcr_CompletionContents,Pcr_Quantity,Pcr_CreateTime,Pcr_EntryPeople,Pcr_Type,Pcr_DigitalDivisionName,Pcr_CompletionContentsName,Pcr_EntryPeopleName,Ord_Type,Ord_Class,Cus_Name,Cus_Telephone,Ord_SeriesName,Ord_SeriesPrice,单价,总价格").Tables[0];
- ///礼服租售充值
- s = "";
- str = new StringBuilder();
- dt = new DataTable();
- str.Append(" DRR_CreateDatetime>='" + StartTime + "' and DRR_CreateDatetime<='" + EndTime + " 23:59:59.000' ");
- if (!string.IsNullOrEmpty(cbx_PaymentType.Text.Trim()))
- {
- str.Append(" and DDR_PaymentMethod = '"+ cbx_PaymentType.Tag + "'");
- }
-
- s = BindSelect10();
- dressServiceOrder = Orderbll.GetView_Custom("tb_ErpDressDepositReceivables", StrWhere: str.ToString() + s.ToString(), ShowColumnName: "ID,DDR_Number as Pay_OrdNumber,DDR_Money as Pay_AmountOf,DDR_Payments as Sc_ClassName1,'礼服租售付款' as Sc_ClassName,DRR_CreateDatetime as Pay_CreateDatetime,DRR_CreateName as Pay_OpenSingle,DRR_CreateName as Pay_ThePayee,'' as Pay_CommissionRatio,'' as Pay_Category,'' as Pay_ReceivableProject").Tables[0];
- List<string> dressNumberList = dressServiceOrder.AsEnumerable().Select(p => p.Field<string>("Pay_OrdNumber")).ToList();
- ///获取礼服租售
- s = "";
- str = new StringBuilder();
- dt = new DataTable();
- str.Append(" Dsro_Number in ('" + string.Join("','", dressNumberList.ToArray()) +"')");
- if (EmployeeName != null && !string.IsNullOrEmpty(EmployeeName))
- { str.Append(" and Dsro_CreateName in (" + EmployeeName + ")"); }
- s = BindSelect5();
- dressOrder = Orderbll.GetView_Custom("View_DressSaleRentalOrder", StrWhere: str.ToString() + s.ToString(), ShowColumnName: "ID,Dsro_Number,Dsro_Type,Dsro_Amount,Dsro_MortgageAmount,Dsro_CustomerNumber,Dsro_TakeDressTime,Dsro_ReservationBackTime,Dsro_Remark,Dsro_CreateDateTime,Dsro_CreateName,Dsro_UpdateDateTime,Dsro_UpdateName,Cus_CustomerNumber,Cus_Name,Cus_Telephone,开单人姓名").Tables[0];
- ///获取员工奖罚
- //s = "";
- //str = new StringBuilder();
- //dt = new DataTable();
- //str.Append(" Rp_RPDatetime>='" + StartTime + "' and Rp_RPDatetime<='" + EndTime + " 23:59:59.000' and Rp_Status='已执行'");
- //if (!string.IsNullOrEmpty(cbx_PaymentType.Text.Trim()))
- //{
- // strWhereTime += " and Rp_Type = '" + cbx_PaymentType.Tag + "'";
- //}
- //if (EmployeeName != null && !string.IsNullOrEmpty(EmployeeName))
- //{ str.Append(" and Rp_RelevantPeople in (" + EmployeeName + ")"); }
- //s = BindSelect6();
- //rewardOrder = Orderbll.GetView_Custom("View_ErpRewardPunishment", StrWhere: str.ToString() + s.ToString(), ShowColumnName: "ID,Rp_Type,Rp_RelevantPeople,Rp_Money,Rp_Status,Rp_RPDatetime,Rp_PersonHandling,Rp_Reason,Rp_Remark,Rp_CreateDatetime,Rp_UpdateDatetime,User_Name,Rp_PersonHandlingName").Tables[0];
- /////获取员工支出
- //s = "";
- //str = new StringBuilder();
- //dt = new DataTable();
- //str.Append(" Oiae_IEDatetime>='" + StartTime + "' and Oiae_IEDatetime<='" + EndTime + " 23:59:59.000' and (Oiae_Type='支出' or Oiae_Type='财务支出')");
- //if (!string.IsNullOrEmpty(cbx_PaymentType.Text.Trim()))
- //{
- // str.Append(" and Oiae_ProjectName = '-1'");
- //}
- //if (!string.IsNullOrEmpty(cbx_PaymentType.Text.Trim()))
- //{
- // str.Append(" and Oiae_PaymentMethod = '" + cbx_PaymentType.Tag + "'");
- //}
- //if (EmployeeName != null && !string.IsNullOrEmpty(EmployeeName))
- //{ str.Append(" and Oiae_ThePayer in (" + EmployeeName + ")"); }
- //s = BindSelect7();
- //paymentOrder = Orderbll.GetView_Custom("View_ErpOtherIncomeAndExpenses", StrWhere: str.ToString() + s.ToString(), ShowColumnName: "ID,Oiae_Type,Oiae_ProjectName,Oiae_Money,Oiae_IEDatetime,Oiae_PersonHandling,Oiae_ThePayer,Oiae_Invoice,Oiae_Remark,Oiae_CreateDatetime,Oiae_FinancialAuditState,Oiae_FinancialAuditPeople,Oiae_ManagerAuditState,Oiae_ManagerAuditPeople,Oiae_CEOAuditState,Oiae_CEOAuditPeople,Oiae_PaymentMethod,User_Name,Oiae_PersonHandlingName,Oiae_FinancialAuditPeopleName,Oiae_ManagerAuditPeopleName,Oiae_CEOAuditPeopleName,Oiae_PaymentMethodName").Tables[0];
- ///订单付款数据情况
- //List<string> payOrderList = new List<string>();
- //payOrderList.AddRange(preOrder.AsEnumerable().Select(p => p.Field<string>("Ord_Number")).ToList());
- //payOrderList.AddRange(lastOrder.AsEnumerable().Select(p => p.Field<string>("订单号")).ToList());
- //string paySql = @"SELECT
- // Pay_OrdNumber,
- // Pay_Category,
- // c2.Sc_ClassName,
- // Pay_TwoPinsCategory,
- // Pay_OpenSingle,
- // c1.Sc_ClassName as Sc_ClassName1,
- // Pay_AmountOf,
- // Pay_CreateDatetime,
- // Pay_ThePayee,
- // Pay_ReceivableProject,
- // Pay_CommissionRatio
- // FROM [tb_ErpPayment] inner join tb_ErpSystemCategory c1 on Pay_PaymentMethod = c1.Sc_ClassCode
- // left join tb_ErpSystemCategory c2 on Pay_TwoPinsCategory = c2.Sc_ClassCode
- // where Pay_OrdNumber in ('" + string.Join("','", payOrderList.ToArray()) + @"')";
- //payData = Orderbll.GetView_Custom(paySql).Tables[0];
- ///会员充值
- s = "";
- str = new StringBuilder();
- dt = new DataTable();
- str.Append(" Mcrr_CreateDatetime>='" + StartTime + "' and Mcrr_CreateDatetime<='" + EndTime + " 23:59:59.000' ");
- if (EmployeeName != null && !string.IsNullOrEmpty(EmployeeName))
- {
- //str.Append(" and Mcrr_OrderPerson in (" + EmployeeName + ")");
- string[] userNumbers = EmployeeName.Split(',');
- string strWhere = "";
- foreach(string employeeKey in userNumbers)
- {
- if(!string.IsNullOrEmpty(strWhere))
- {
- strWhere += " or ";
- }
- strWhere += " (Mcrr_OrderPerson like '%" + employeeKey.Replace("'","") + "%' or Mcrr_CommissionRatio like '%" + employeeKey.Replace("'", "") + "%' )";
- }
- str.Append(" and ("+ strWhere + ")");
- }
- if (!string.IsNullOrEmpty(cbx_PaymentType.Text.Trim()))
- {
- str.Append(" and Mcrr_PaymentMethod = '" + cbx_PaymentType.Tag + "'");
- }
- s = BindSelect8();
- string memberSql = @" select 'MCRR'+convert(varchar(50),tb_ErpMemberCardRechargeRecord.id) as id,
- Mcrr_RechargeNumber,Mcrr_RechargeAmount,c1.Sc_ClassName,Mcrr_RechargeName,
- tb_ErpCustomer.Cus_Name,Cus_Telephone,Mcrr_OrderPerson,Mcrr_CreateName,Mcrr_CreateDatetime,Mcrr_CommissionRatio
- from
- [tb_ErpMemberCardRechargeRecord]
- left join
- tb_ErpSystemCategory c1 on Mcrr_PaymentMethod = c1.Sc_ClassCode
- left join
- tb_ErpMemberCard on Mcrr_Number = Mc_Number
- left join
- tb_ErpCustomer on Cus_CustomerNumber = Mc_CustomerNumber";
- memberSql += " where " + str + s;
- mamberOrder = Orderbll.GetView_Custom(memberSql).Tables[0];
- ///服务卡充值
- s = "";
- str = new StringBuilder();
- dt = new DataTable();
- str.Append(" Mcpt_CreateDatetime>='" + StartTime + "' and Mcpt_CreateDatetime<='" + EndTime + " 23:59:59.000' ");
- if (!string.IsNullOrEmpty(cbx_PaymentType.Text.Trim()))
- {
- str.Append(" and (Mcpt_PaymentMethod = '" + cbx_PaymentType.Tag + "' )");
- }
- if (EmployeeName != null && !string.IsNullOrEmpty(EmployeeName))
- {
- //str.Append(" and Mcrr_OrderPerson in (" + EmployeeName + ")");
- string[] userNumbers = EmployeeName.Split(',');
- string strWhere = "";
- foreach (string employeeKey in userNumbers)
- {
- if (!string.IsNullOrEmpty(strWhere))
- {
- strWhere += " or ";
- }
- strWhere += " (Mcpt_OrderPerson like '%" + employeeKey.Replace("'", "") + "%' or Mcpt_CommissionRatio like '%"+ employeeKey.Replace("'", "") + "%' )";
- }
- str.Append(" and (" + strWhere + ")");
- }
- s = BindSelect9();
- string memberServiceSql = @"
- SELECT
- 'MCPT'+convert(varchar(50),tb_ErpMemberCardPayment.id) as id,
- tb_ErpCustomer.Cus_Name,Cus_Telephone,
- Mcpt_PaymentNumber,
- Mcpt_OrderPerson,
- Mcpt_PaymentType,
- c1.Sc_ClassName ,
- Mcpt_PaymentAmount,
- Mcpt_CreateDatetime,
- Mcpt_CreateName,
- Mcpt_CommissionRatio
- FROM tb_ErpMemberCardPayment left join tb_ErpSystemCategory c1 on Mcpt_PaymentMethod = c1.Sc_ClassCode
- left join
- tb_ErpMemberCard on tb_ErpMemberCardPayment.mcpt_Number = Mc_Number
- left join
- tb_ErpCustomer on Cus_CustomerNumber = Mc_CustomerNumber ";
- memberServiceSql += " where " + str + s;
- mamberServiceOrder = Orderbll.GetView_Custom(memberServiceSql).Tables[0];
- ///前期订单数据
- List<DataRow> drList = PerDt.AsEnumerable().Where(p => p.Field<int>("Cp_ProportionType") == 1).ToList();
- DataRow mainDr = PerDt.NewRow();
- DataRow deputyDr = PerDt.NewRow();
- if (drList.Count > 0)
- {
- mainDr = drList.Where(p => p.Field<string>("Cp_ProportionCode") == "MainStoreProportion").First();
- deputyDr = drList.Where(p => p.Field<string>("Cp_ProportionCode") == "DeputyStoreProportion").First();
- }
- List<DataRow> payListData = payData.AsEnumerable().Where(p => p.Field<string>("Pay_TwoPinsCategory") == "").ToList();
- GetUserOrderDataByDynamicList(ref dyUserList, preOrder, "Ord_OrderPersonNumber", "Ord_Number", "Pay_OrdNumber", "Pay_CommissionRatio"
- , "订单前期", mainDr, deputyDr, payListData);
- ///后期订单数据
- drList = PerDt.AsEnumerable().Where(p => p.Field<int>("Cp_ProportionType") == 5).ToList();
- mainDr = PerDt.NewRow();
- deputyDr = PerDt.NewRow();
- if (drList.Count > 0)
- {
- mainDr = drList.Where(p => p.Field<string>("Cp_ProportionCode") == "MainLaterOtherTwoSales").First();
- deputyDr = drList.Where(p => p.Field<string>("Cp_ProportionCode") == "DeputyLaterOtherTwoSales").First();
- }
- payListData = payData.AsEnumerable().Where(p => p.Field<string>("Pay_TwoPinsCategory") != "").ToList();
- GetUserOrderDataByDynamicList(ref dyUserList, lastOrder, "销售人员编号", "订单号", "Pay_OrdNumber", "Pay_CommissionRatio", "订单后期", mainDr, deputyDr, payListData);
- ///其他消费数据
- drList = PerDt.AsEnumerable().Where(p => p.Field<int>("Cp_ProportionType") == 5).ToList();
- mainDr = PerDt.NewRow();
- deputyDr = PerDt.NewRow();
- if (drList.Count > 0)
- {
- mainDr = drList.Where(p => p.Field<string>("Cp_ProportionCode") == "MainLaterOtherTwoSales").First();
- deputyDr = drList.Where(p => p.Field<string>("Cp_ProportionCode") == "DeputyLaterOtherTwoSales").First();
- }
- GetUserOrderDataByDynamicList(ref dyUserList, otherOrder, "Tsorder_OpenSingle", "Tsorder_Number","","", "其他消费", mainDr, deputyDr);
- ///计件提成数据
- //mainDr = PerDt.NewRow();
- //deputyDr = PerDt.NewRow();
- //GetUserOrderDataByDynamicList(ref dyUserList, pieceworkOrder, "Pcr_DigitalDivision", "Pcr_OrderNumber", "", "", "计件提成", mainDr, deputyDr);
- ///礼服租售数据
- mainDr = PerDt.NewRow();
- deputyDr = PerDt.NewRow();
- payListData = dressServiceOrder.AsEnumerable().ToList();
- GetUserOrderDataByDynamicList(ref dyUserList, dressOrder, "Dsro_CreateName", "Dsro_Number", "Pay_OrdNumber", "", "礼服租售", mainDr, deputyDr, payListData);
- ///员工奖罚
- //mainDr = PerDt.NewRow();
- //deputyDr = PerDt.NewRow();
- //GetUserOrderDataByDynamicList(ref dyUserList, rewardOrder, "Rp_RelevantPeople", "ID", "", "", "员工奖罚", mainDr, deputyDr);
- /////员工支出
- //mainDr = PerDt.NewRow();
- //deputyDr = PerDt.NewRow();
- //GetUserOrderDataByDynamicList(ref dyUserList, paymentOrder, "Oiae_ThePayer", "ID", "", "", "员工支出", mainDr, deputyDr);
- ///会员充值
- mainDr = PerDt.NewRow();
- deputyDr = PerDt.NewRow();
- GetUserOrderDataByDynamicList(ref dyUserList, mamberOrder, "Mcrr_OrderPerson", "id", "", "", "会员充值", mainDr, deputyDr);
- ///会员服务充值
- mainDr = PerDt.NewRow();
- deputyDr = PerDt.NewRow();
- GetUserOrderDataByDynamicList(ref dyUserList, mamberServiceOrder, "Mcpt_OrderPerson", "id", "", "", "会员服务充值", mainDr, deputyDr);
- }
- catch (Exception ex)
- {
- MessageBoxCustom.Show(String.Format("查询数据时出错:{0}",ex.Message));
- }
- });
- this.dgv.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.None;
- this.dgv.Rows.Clear();
- this.dgv.Columns.Clear();
- this.dgv.Columns.Add("PerformancePerson", "业绩人");
- this.dgv.Columns.Add("OrdNumber", "订单号");
- this.dgv.Columns.Add("CusName", "客户名称");
- this.dgv.Columns.Add("CusTelephone", "客户电话");
- this.dgv.Columns.Add("MoneyType", "项目类别");
- this.dgv.Columns.Add("PerformanceMoney", "单据金额");
- this.dgv.Columns.Add("PayType", "支付方式");
- this.dgv.Columns.Add("PayValue", "收款金额");
- this.dgv.Columns.Add("PayPerformance", "业绩金额");
- this.dgv.Columns.Add("PayPerformanceDis", "业绩分配");
- this.dgv.Columns.Add("PayUser", "收款人");
- this.dgv.Columns.Add("PayTime", "收款日");
- this.dgv.Columns.Add("PayName", "收款名称");
- this.dgv.Columns[1].Width = 180;
- this.dgv.Columns[11].Width = 150;
- this.dgv.Columns[9].Width = 300;
- this.dgv.Columns[8].Width = 150;
- foreach(DataGridViewColumn dataColumn in this.dgv.Columns)
- {
- dataColumn.SortMode = DataGridViewColumnSortMode.NotSortable;
- }
- DataGridViewRow dgRow = null;
- //业绩
- decimal CurrentPerformance = 0;
- //计件
- decimal PieceCommission = 0;
- //奖励
- decimal Reward = 0;
- //罚款
- decimal Fine = 0;
- //支出
- decimal Expenditure = 0;
- //总实收业绩
- decimal TotalPerformance = 0;
- //前期实收
- decimal PreAmount = 0;
- //后期实收
- decimal LastAmount = 0;
- //会员充值
- decimal MemberAmount = 0;
- ///服务充值
- decimal ServiceAmount = 0;
- Dictionary<string, decimal> dicCurrentPerformance = new Dictionary<string, decimal>();
- Dictionary<string, decimal> dicTotalPerformance = new Dictionary<string, decimal>();
- Dictionary<string, decimal> dicPreAmount = new Dictionary<string, decimal>();
- Dictionary<string, decimal> dicLastAmount = new Dictionary<string, decimal>();
- foreach (string key in dyUserList.Keys)
- {
- if(!EmployeeName.Contains(key))
- {
- continue;
- }
- dgRow = new DataGridViewRow();
- dgRow.CreateCells(this.dgv);
-
- dgRow.Cells[0].Style = GetDataGridViewCellStyle(System.Drawing.Color.White, DataGridViewContentAlignment.MiddleLeft);
- dgRow.Cells[1].Style = dgRow.Cells[0].Style;
- dgRow.Cells[2].Style = dgRow.Cells[0].Style;
- dgRow.Cells[3].Style = dgRow.Cells[0].Style;
- dgRow.Cells[4].Style = dgRow.Cells[0].Style;
- dgRow.Cells[5].Style = dgRow.Cells[0].Style;
- dgRow.Cells[6].Style = dgRow.Cells[0].Style;
- dgRow.Cells[7].Style = dgRow.Cells[0].Style;
- dgRow.Cells[8].Style = dgRow.Cells[0].Style;
- dgRow.Cells[9].Style = dgRow.Cells[0].Style;
- dgRow.Cells[10].Style = dgRow.Cells[0].Style;
- dgRow.Cells[11].Style = dgRow.Cells[0].Style;
- dgRow.Cells[12].Style = dgRow.Cells[0].Style;
- string[] StrRowValueList = key.ToString().Trim().Split(',');
- string keyName = "";
- foreach (string StrRowValue in StrRowValueList)
- {
- if (!string.IsNullOrEmpty(StrRowValue))
- {
- DataRow dtRows = LYFZ.DAL.DAL_ErpUser.SimpleUserDataTable.Rows.Find(StrRowValue);
- if(!string.IsNullOrEmpty(keyName))
- {
- keyName += ",";
- }
- if (dtRows != null)
- {
- keyName += dtRows["User_Name"].ToString().Trim();
- }
- else
- {
- keyName += "";
- }
- }
- }
- dgRow.Cells[0].Value = keyName;
- this.dgv.Rows.Add(dgRow);
- Dictionary<string, List<dynamic>> ordDataList = dyUserList[key];
- int index = 0;
- foreach (string subKey in ordDataList.Keys)
- {
- index++;
- List<dynamic> ordDyList = ordDataList[subKey];
- DataGridViewRow tempDr = dgRow;
- foreach (dynamic ordDy in ordDyList)
- {
-
- if(ordDy.业绩金额 == "付款"&& index==1)
- {
- index++;
- }
- if(index>1)
- {
- if (tempDr.Cells[6].Value.ToString()=="合计")
- {
- IDictionary<string, object> idicObj = ordDy;
- //this.dgv.Rows.Add(GetSubDataGridViewRow(subKey, dgRow, ordDy, index, ordDyList.Count == index));
- tempDr.Cells[6].Value = idicObj["支付方式"];
- tempDr.Cells[7].Value = idicObj["收款金额"];
- tempDr.Cells[9].Value = idicObj["业绩描述"];
- tempDr.Cells[8].Value = idicObj["业绩分配"];
- tempDr.Cells[10].Value = idicObj["收款人"];
- tempDr.Cells[11].Value = idicObj["收款日"].ToString();
- tempDr.Cells[12].Value = idicObj["收款名称"];
- }
- else
- {
- this.dgv.Rows.Add(GetSubDataGridViewRow(subKey, dgRow, ordDy, index, ordDyList.Count == index));
- IDictionary<string, object> idicObj = ordDy;
- if (idicObj["支付方式"].ToString()== "合计")
- {
- tempDr = this.dgv.Rows[this.dgv.Rows.Count - 1];
- }
- else
- {
- if (this.dgv.Rows[this.dgv.Rows.Count - 1].Cells["MoneyType"].Value.ToString_s() == "订单前期" || this.dgv.Rows[this.dgv.Rows.Count - 1].Cells["MoneyType"].Value.ToString_s() == "订单后期"
- || this.dgv.Rows[this.dgv.Rows.Count - 1].Cells["MoneyType"].Value.ToString_s() == "礼服租售")
- {
- this.dgv.Rows[this.dgv.Rows.Count - 1].Cells[5].Value = tempDr.Cells["PerformanceMoney"].Value;
- this.dgv.Rows[this.dgv.Rows.Count - 1].Cells[2].Value = tempDr.Cells["CusName"].Value;
- this.dgv.Rows[this.dgv.Rows.Count - 1].Cells[3].Value = tempDr.Cells["CusTelephone"].Value;
- }
- }
- if (ordDyList.Where(p => p.业绩金额 == "付款").ToList().Count==0)
- {
- if (tempDr.Cells[6].Value.ToString() == "合计")
- {
- tempDr.Cells[6].Value = "";
- }
- }
- this.dgv.Rows[this.dgv.Rows.Count - 1].Cells[0].Value = keyName;
- }
- }
- else
- {
- GetSubDataGridViewRow(subKey, dgRow, ordDy, index, ordDyList.Count == index);
-
- }
- }
- ///业绩
- //CurrentPerformance += ordDyList.Where(p=>p.收款类型== "订单前期" || p.收款类型 == "订单后期"
- // || p.收款类型 == "其他消费" || p.收款类型 == "礼服租售").Sum(p => Convert.ToInt32(p.业绩额));
- foreach(dynamic dyObj in ordDyList.Where(p => p.收款类型 == "订单前期" || p.收款类型 == "订单后期" || p.收款类型 == "其它消费" || p.收款类型 == "礼服租售"
- || p.收款类型 == "会员充值" || p.收款类型 == "会员服务充值"))
- {
- if(!dicCurrentPerformance.ContainsKey(dyObj.自定义订单号.ToString() + dyObj.收款类型.ToString()+ dyObj.收款日.ToString()))
- {
- dicCurrentPerformance.Add(dyObj.自定义订单号.ToString()+ dyObj.收款类型.ToString() + dyObj.收款日.ToString(), dyObj.收款金额);
- }
- }
- //计件提成
- PieceCommission += ordDyList.Where(p => p.收款类型 == "计件提成").Sum(p => Convert.ToInt32(p.业绩额));
- //员工支出
- Expenditure += ordDyList.Where(p => p.收款类型 == "员工支出").Sum(p => Convert.ToInt32(p.业绩额));
- //员工奖罚
- Reward += ordDyList.Where(p => p.收款类型 == "员工奖罚" && p.支付方式== "奖励").Sum(p => Convert.ToInt32(p.业绩额));
- Fine += ordDyList.Where(p => p.收款类型 == "员工奖罚" && p.支付方式 == "惩罚").Sum(p => Convert.ToInt32(p.业绩额));
- //TotalPerformance += ordDyList.Where(p => p.收款类型 == "订单前期收款" || p.收款类型 == "订单后期收款"
- // || p.收款类型 == "其他消费收款" || p.收款类型 == "礼服租售收款")
- // .Sum(p => Convert.ToInt32(p.业绩金额));
- //foreach (dynamic dyObj in ordDyList.Where(p => p.收款类型 == "订单前期收款" || p.收款类型 == "订单后期收款"
- // || p.收款类型 == "其他消费收款" || p.收款类型 == "礼服租售收款"))
- //{
- // if (!dicTotalPerformance.ContainsKey(dyObj.自定义订单号.ToString() + dyObj.收款类型.ToString() + dyObj.收款日.ToString()))
- // {
- // dicTotalPerformance.Add(dyObj.自定义订单号.ToString() + dyObj.收款类型.ToString() + dyObj.收款日.ToString(), dyObj.收款金额);
- // }
- //}
- //PreAmount += ordDyList.Where(p => p.收款类型 == "订单前期收款" ).Sum(p => Convert.ToInt32(p.收款金额));
- foreach (dynamic dyObj in ordDyList.Where(p => p.收款类型 == "订单前期收款"))
- {
- if (!dicPreAmount.ContainsKey(dyObj.自定义订单号.ToString() + dyObj.收款类型.ToString() + dyObj.收款日.ToString()))
- {
- dicPreAmount.Add(dyObj.自定义订单号.ToString() + dyObj.收款类型.ToString() + dyObj.收款日.ToString(), dyObj.收款金额);
- }
- }
- //LastAmount += ordDyList.Where(p => p.收款类型 == "订单后期收款").Sum(p => Convert.ToInt32(p.收款金额));
- foreach (dynamic dyObj in ordDyList.Where(p => p.收款类型 == "订单后期收款"))
- {
- if (!dicLastAmount.ContainsKey(dyObj.自定义订单号.ToString() + dyObj.收款类型.ToString() + dyObj.收款日.ToString()))
- {
- dicLastAmount.Add(dyObj.自定义订单号.ToString() + dyObj.收款类型.ToString() + dyObj.收款日.ToString(), dyObj.收款金额);
- }
- }
- MemberAmount += ordDyList.Where(p => p.收款类型 == "会员充值").Sum(p => Convert.ToInt32(p.业绩额));
- ServiceAmount += ordDyList.Where(p => p.收款类型 == "会员服务充值").Sum(p => Convert.ToInt32(p.业绩额));
- }
- }
-
- Dictionary<string, decimal> dicPayTypeList = new Dictionary<string, decimal>();
- dicPayTypeList.Add("订单前期", 0);
- dicPayTypeList.Add("订单后期", 0);
- dicPayTypeList.Add("其它消费", 0);
- dicPayTypeList.Add("礼服租售", 0);
- dicPayTypeList.Add("会员充值", 0);
- dicPayTypeList.Add("会员服务充值", 0);
- Dictionary<string, decimal> dicStoreTypeList = new Dictionary<string, decimal>();
- dicStoreTypeList.Add("订单前期", 0);
- dicStoreTypeList.Add("订单后期", 0);
- dicStoreTypeList.Add("其它消费", 0);
- dicStoreTypeList.Add("礼服租售", 0);
- dicStoreTypeList.Add("会员充值", 0);
- dicStoreTypeList.Add("会员服务充值", 0);
- decimal storedValue = 0;
-
- foreach (DataGridViewRow dgvr in this.dgv.Rows)
- {
- TotalPerformance += Convert.ToDecimal(dgvr.Cells["PayPerformance"].Value.ToString_s()==""?"0": dgvr.Cells["PayPerformance"].Value.ToString_s());
- if(dgvr.Cells["PayType"].Value.ToString_s()=="储值卡扣款")
- {
- storedValue += Convert.ToDecimal(dgvr.Cells["PayPerformance"].Value.ToString_s() == "" ? "0" : dgvr.Cells["PayPerformance"].Value.ToString_s());
- }
- if(dicPayTypeList.ContainsKey(dgvr.Cells["MoneyType"].Value.ToString_s()))
- {
- dicPayTypeList[dgvr.Cells["MoneyType"].Value.ToString_s()] += Convert.ToDecimal(dgvr.Cells["PayPerformance"].Value.ToString_s() == "" ? "0" : dgvr.Cells["PayPerformance"].Value.ToString_s());
- if (dgvr.Cells["PayType"].Value.ToString_s() == "储值卡扣款")
- {
- if (dicStoreTypeList.ContainsKey(dgvr.Cells["MoneyType"].Value.ToString_s()))
- {
- dicStoreTypeList[dgvr.Cells["MoneyType"].Value.ToString_s()] += Convert.ToDecimal(dgvr.Cells["PayPerformance"].Value.ToString_s() == "" ? "0" : dgvr.Cells["PayPerformance"].Value.ToString_s());
- }
- }
- }
- }
- DataTable gridDataTable = DataGriwViewToDataTable(dgv);
- dgv.Rows.Clear();
- foreach(string key in dicPayTypeList.Keys)
- {
- List<DataRow> drList = gridDataTable.AsEnumerable().Where(p => p.Field<string>("MoneyType") == key).ToList();
- if (drList.Count > 0)
- {
- dgRow = new DataGridViewRow();
- dgRow.CreateCells(this.dgv);
- dgRow.Cells[0].Style = GetDataGridViewCellStyle(System.Drawing.Color.LightCyan, DataGridViewContentAlignment.MiddleLeft);
- dgRow.Cells[1].Style = dgRow.Cells[0].Style;
- dgRow.Cells[2].Style = dgRow.Cells[0].Style;
- dgRow.Cells[3].Style = dgRow.Cells[0].Style;
- dgRow.Cells[4].Style = dgRow.Cells[0].Style;
- dgRow.Cells[5].Style = dgRow.Cells[0].Style;
- dgRow.Cells[6].Style = dgRow.Cells[0].Style;
- dgRow.Cells[7].Style = dgRow.Cells[0].Style;
- dgRow.Cells[8].Style = dgRow.Cells[0].Style;
- dgRow.Cells[9].Style = dgRow.Cells[0].Style;
- dgRow.Cells[10].Style = dgRow.Cells[0].Style;
- dgRow.Cells[11].Style = dgRow.Cells[0].Style;
- dgRow.Cells[12].Style = dgRow.Cells[0].Style;
- dgRow.Cells[0].Value = key;
- //dgRow.Cells[0].Style = new DataGridViewCellStyle() { ForeColor = Color.Red };
- dgv.Rows.Add(dgRow);
- foreach (DataRow dr in drList)
- {
- dgRow = new DataGridViewRow();
- dgRow.CreateCells(this.dgv);
- dgRow.Cells[0].Style = GetDataGridViewCellStyle(System.Drawing.Color.White, DataGridViewContentAlignment.MiddleLeft);
- dgRow.Cells[1].Style = dgRow.Cells[0].Style;
- dgRow.Cells[2].Style = dgRow.Cells[0].Style;
- dgRow.Cells[3].Style = dgRow.Cells[0].Style;
- dgRow.Cells[4].Style = dgRow.Cells[0].Style;
- dgRow.Cells[5].Style = dgRow.Cells[0].Style;
- dgRow.Cells[6].Style = dgRow.Cells[0].Style;
- dgRow.Cells[7].Style = dgRow.Cells[0].Style;
- dgRow.Cells[8].Style = dgRow.Cells[0].Style;
- dgRow.Cells[9].Style = dgRow.Cells[0].Style;
- dgRow.Cells[10].Style = dgRow.Cells[0].Style;
- dgRow.Cells[11].Style = dgRow.Cells[0].Style;
- dgRow.Cells[12].Style = dgRow.Cells[0].Style;
- for (int columnIndex =0; columnIndex < dgv.Columns.Count; columnIndex++)
- {
- dgRow.Cells[columnIndex].Value = dr[dgv.Columns[columnIndex].Name];
- }
- dgv.Rows.Add(dgRow);
- }
- }
- }
-
- PreAmount = dicPreAmount.Values.Sum();
- LastAmount = dicLastAmount.Values.Sum();
- txtCurrentUserPerformance.Text = "总业绩:" + TotalPerformance.ToString("N2")+" (其中储值卡扣款:"+ storedValue + ")";
-
- string paymentData = "";
- foreach(string key in dicPayTypeList.Keys)
- {
- if (dicPayTypeList[key] > 0)
- {
- if (!string.IsNullOrEmpty(paymentData))
- {
- paymentData += ",";
- }
- paymentData += key + ":" + dicPayTypeList[key].ToString("N2")+(dicStoreTypeList[key]>0? "(其中储值卡扣款:" + dicStoreTypeList[key] + ")":"");
- }
- }
- this.tb_DetailPerformance.Text = paymentData;
- //this.tb_PreAmount.Text = PreAmount.ToString("N2");
- //this.tb_LastAmount.Text = LastAmount.ToString("N2");
- //this.tb_MemberValue.Text = MemberAmount.ToString("N2");
- this.dgv.ClearSelection();
- #region 注释掉的代码
- /*
- #region 获取订单前期业绩
- str.Append(" Ord_CreateDateTime>='" + StartTime + "' and Ord_CreateDateTime<='" + EndTime + " 23:59:59.000' and Ord_Class='1'");
- if (EmployeeName != null && !string.IsNullOrEmpty(EmployeeName))
- { str.Append(" and Ord_OrderPersonNumber like '%" + EmployeeName + "%'"); }
- s = BindSelect1();
- LYFZ.ComponentLibrary.FrmLoadHandling.LoadDoWorkMethod(delegate(object obj, BackgroundWorker backgroundWorker)
- {
- dt = orbll.GetView_Custom("tb_ErpOrder Left Join tempTB_AggregationCustomer on GP_OrderNumber = Ord_Number", StrWhere: str.ToString() + s.ToString(), ShowColumnName: "Ord_Number,Ord_OrderPersonName,Ord_OrderPersonNumber,Cus_Name,Ord_SeriesPrice,Ord_CreateDatetime,Ord_PhotographyCategory,Ord_SeriesName").Tables[0];
- if (dt.Rows.Count > 0)
- {
- this.Invoke(new LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.UpdateControl(delegate ()
- {
- List<DataRow> drList = PerDt.AsEnumerable().Where(p => p.Field<int>("Cp_ProportionType") == 1).ToList();
- DataRow mainDr = PerDt.NewRow();
- DataRow deputyDr = PerDt.NewRow();
- if (drList.Count > 0)
- {
- mainDr = drList.Where(p => p.Field<string>("Cp_ProportionCode") == "MainStoreProportion").First();
- deputyDr = drList.Where(p => p.Field<string>("Cp_ProportionCode") == "DeputyStoreProportion").First();
- }
- for (int t = 0; t < dt.Rows.Count; t++)
- {
- DataGridViewRow dgvr = new DataGridViewRow();
- DataGridViewCell cell = null;
- //订单号
- cell = new DataGridViewTextBoxCell();
- cell.Value = dt.Rows[t]["Ord_Number"].ToString().Trim();
- dgvr.Cells.Add(cell);
- //员工
- cell = new DataGridViewTextBoxCell();
- cell.Value = dt.Rows[t]["Ord_OrderPersonName"].ToString().Trim();
- dgvr.Cells.Add(cell);
- //客户姓名
- cell = new DataGridViewTextBoxCell();
- cell.Value = dt.Rows[t]["Cus_Name"].ToString().Trim();
- dgvr.Cells.Add(cell);
- //业绩金额
- cell = new DataGridViewTextBoxCell();
- cell.Value = GetAchievement(
- Convert.ToDecimal(dt.Rows[t]["Ord_SeriesPrice"]),
- dt.Rows[t]["Ord_OrderPersonNumber"].ToString(),
- EmployeeName, mainDr, deputyDr).ToString("N2");//Convert.ToDecimal(dt.Rows[t]["Ord_SeriesPrice"]).ToString("N2");
- dgvr.Cells.Add(cell);
- //创建时间
- cell = new DataGridViewTextBoxCell();
- cell.Value = dt.Rows[t]["Ord_CreateDatetime"].ToString().Trim();
- dgvr.Cells.Add(cell);
- //套系类别
- cell = new DataGridViewTextBoxCell();
- cell.Value = dt.Rows[t]["Ord_PhotographyCategory"].ToString().Trim();
- dgvr.Cells.Add(cell);
- //套系名称
- cell = new DataGridViewTextBoxCell();
- cell.Value = dt.Rows[t]["Ord_SeriesName"].ToString().Trim();
- dgvr.Cells.Add(cell);
- //项目名称
- cell = new DataGridViewTextBoxCell();
- cell.Value = "订单前期业绩";
- dgvr.Cells.Add(cell);
- this.dgv.Rows.Add(dgvr);
- }
- dgv.ClearSelection();
- }));
- }
- });
- #endregion
- #region 获取订单后期业绩
- s = "";
- str = new StringBuilder();
- dt = new DataTable();
- str.Append(" 创建时间>='" + StartTime + "' and 创建时间<='" + EndTime + " 23:59:59.000'");
- if (EmployeeName != null && !string.IsNullOrEmpty(EmployeeName))
- { str.Append(" and 销售人员编号 like '%" + EmployeeName + "%'"); }
- s = BindSelect2();
- LYFZ.ComponentLibrary.FrmLoadHandling.LoadDoWorkMethod(delegate(object obj, BackgroundWorker backgroundWorker)
- {
- List<DataRow> drList = PerDt.AsEnumerable().Where(p => p.Field<int>("Cp_ProportionType") == 5).ToList();
- DataRow mainDr = PerDt.NewRow();
- DataRow deputyDr = PerDt.NewRow();
- if (drList.Count > 0)
- {
- mainDr = drList.Where(p => p.Field<string>("Cp_ProportionCode") == "MainLaterOtherTwoSales").First();
- deputyDr = drList.Where(p => p.Field<string>("Cp_ProportionCode") == "DeputyLaterOtherTwoSales").First();
- }
- dt = Orderbll.GetView_Custom("Vw_ErpPlusPickItems", StrWhere: str.ToString() + s.ToString(), ShowColumnName: "ID,订单号,金额,创建时间,商品名称,录单人编号,录单人名称,商品成本价,加挑金额来源类型,销售人员编号,销售人员名称,二销类别编号,二销类别名称,客户名称,拼音,电话,套系类别").Tables[0];
- if (dt.Rows.Count > 0)
- {
- this.Invoke(new LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.UpdateControl(delegate ()
- {
- for (int t = 0; t < dt.Rows.Count; t++)
- {
- DataGridViewRow dgvr = new DataGridViewRow();
- DataGridViewCell cell = null;
- //订单号
- cell = new DataGridViewTextBoxCell();
- cell.Value = dt.Rows[t]["订单号"].ToString().Trim();
- dgvr.Cells.Add(cell);
- //员工
- cell = new DataGridViewTextBoxCell();
- cell.Value = dt.Rows[t]["销售人员名称"].ToString().Trim();
- dgvr.Cells.Add(cell);
- //客户姓名
- cell = new DataGridViewTextBoxCell();
- cell.Value = dt.Rows[t]["客户名称"].ToString().Trim();
- dgvr.Cells.Add(cell);
- //业绩金额
- cell = new DataGridViewTextBoxCell();
- cell.Value = GetAchievement(
- Convert.ToDecimal(dt.Rows[t]["金额"]),
- dt.Rows[t]["销售人员编号"].ToString(),
- EmployeeName, mainDr, deputyDr).ToString("N2"); //Convert.ToDecimal(dt.Rows[t]["金额"]).ToString("N2");
- dgvr.Cells.Add(cell);
- //创建时间
- cell = new DataGridViewTextBoxCell();
- cell.Value = dt.Rows[t]["创建时间"].ToString().Trim();
- dgvr.Cells.Add(cell);
- //套系类别
- cell = new DataGridViewTextBoxCell();
- cell.Value = dt.Rows[t]["二销类别名称"].ToString().Trim();
- dgvr.Cells.Add(cell);
- //套系名称
- cell = new DataGridViewTextBoxCell();
- cell.Value = dt.Rows[t]["商品名称"].ToString().Trim();
- dgvr.Cells.Add(cell);
- //项目名称
- cell = new DataGridViewTextBoxCell();
- cell.Value = "订单后期业绩";
- dgvr.Cells.Add(cell);
- this.dgv.Rows.Add(dgvr);
- }
- dgv.ClearSelection();
- }));
- }
- });
- #endregion
- #region 获取其它消费
- s = "";
- str = new StringBuilder();
- dt = new DataTable();
- str.Append(" Tsorder_CreateDatetime>='" + StartTime + "' and Tsorder_CreateDatetime<='" + EndTime + " 23:59:59.000'");
- if (EmployeeName != null && !string.IsNullOrEmpty(EmployeeName))
- { str.Append(" and Tsorder_OpenSingle like '%" + EmployeeName + "%'"); }
- s = BindSelect3();
- LYFZ.ComponentLibrary.FrmLoadHandling.LoadDoWorkMethod(delegate(object obj, BackgroundWorker backgroundWorker)
- {
- List<DataRow> drList = PerDt.AsEnumerable().Where(p => p.Field<int>("Cp_ProportionType") == 5).ToList();
- DataRow mainDr = PerDt.NewRow();
- DataRow deputyDr = PerDt.NewRow();
- if (drList.Count > 0)
- {
- mainDr = drList.Where(p => p.Field<string>("Cp_ProportionCode") == "MainLaterOtherTwoSales").First();
- deputyDr = drList.Where(p => p.Field<string>("Cp_ProportionCode") == "DeputyLaterOtherTwoSales").First();
- }
- // dt = AllViewSetbll.Vw_Customer_PaymentOrders(str.ToString() + s.ToString()).Tables[0];
- dt = Orderbll.GetView_Custom("Vw_TwoSalesOrder", StrWhere: str.ToString() + s.ToString(), ShowColumnName: "ID,Tsorder_Number,Tsorder_Name,Tsorder_CustomerName,Tsorder_OpenSingle,Tsorder_Telephone,Cus_NamePinyin,Tsorder_Money,Tsorder_Quantity,Tsorder_Category,Tsorder_OpenSingle,Tsorder_PersonHandling,Tsorder_Remark,Tsorder_CreateDatetime,Tsorder_UpdateDatetime,User_Name,Tsorder_PersonHandlingName,Tsorder_CategoryName,Tsorder_CustomerNumber").Tables[0];
- if (dt.Rows.Count > 0)
- {
- this.Invoke(new LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.UpdateControl(delegate ()
- {
- for (int t = 0; t < dt.Rows.Count; t++)
- {
- DataGridViewRow dgvr = new DataGridViewRow();
- DataGridViewCell cell = null;
- //订单号
- cell = new DataGridViewTextBoxCell();
- cell.Value = dt.Rows[t]["Tsorder_Number"].ToString().Trim();
- dgvr.Cells.Add(cell);
- //员工
- cell = new DataGridViewTextBoxCell();
- cell.Value = dt.Rows[t]["User_Name"].ToString().Trim();
- dgvr.Cells.Add(cell);
- //客户姓名
- cell = new DataGridViewTextBoxCell();
- cell.Value = dt.Rows[t]["Tsorder_CustomerName"].ToString().Trim();
- dgvr.Cells.Add(cell);
- //业绩金额
- cell = new DataGridViewTextBoxCell();
- cell.Value = GetAchievement(
- Convert.ToDecimal(dt.Rows[t]["Tsorder_Money"]),
- dt.Rows[t]["Tsorder_OpenSingle"].ToString(),
- EmployeeName, mainDr, deputyDr).ToString("N2"); //Convert.ToDecimal(dt.Rows[t]["Tsorder_Money"]).ToString("N2");
- dgvr.Cells.Add(cell);
- //创建时间
- cell = new DataGridViewTextBoxCell();
- cell.Value = dt.Rows[t]["Tsorder_CreateDatetime"].ToString().Trim();
- dgvr.Cells.Add(cell);
- //套系类别
- cell = new DataGridViewTextBoxCell();
- cell.Value = dt.Rows[t]["Tsorder_CategoryName"].ToString().Trim();
- dgvr.Cells.Add(cell);
- //套系名称
- cell = new DataGridViewTextBoxCell();
- cell.Value = dt.Rows[t]["Tsorder_Name"].ToString().Trim();
- dgvr.Cells.Add(cell);
- //项目名称
- cell = new DataGridViewTextBoxCell();
- cell.Value = "其它消费";
- dgvr.Cells.Add(cell);
- this.dgv.Rows.Add(dgvr);
- }
- dgv.ClearSelection();
- }));
- }
- });
- #endregion
- #region 获取计件提成
- s = "";
- str = new StringBuilder();
- dt = new DataTable();
- str.Append(" Pcr_CreateTime>='" + StartTime + "' and Pcr_CreateTime<='" + EndTime + " 23:59:59.000'");
- if (EmployeeName != null && !string.IsNullOrEmpty(EmployeeName))
- { str.Append(" and Pcr_DigitalDivision like '%" + EmployeeName + "%'"); }
- s = BindSelect4();
- LYFZ.ComponentLibrary.FrmLoadHandling.LoadDoWorkMethod(delegate(object obj, BackgroundWorker backgroundWorker)
- {
- dt = Orderbll.GetView_Custom("Vw_ErpPieceCommissionRecords", StrWhere: str.ToString() + s.ToString(), ShowColumnName: "ID,Pcr_OrderNumber,Pcr_DigitalDivision,Pcr_Date,Pcr_CompletionContents,Pcr_Quantity,Pcr_CreateTime,Pcr_EntryPeople,Pcr_Type,Pcr_DigitalDivisionName,Pcr_CompletionContentsName,Pcr_EntryPeopleName,Ord_Type,Ord_Class,Cus_Name,Cus_Telephone,Ord_SeriesName,Ord_SeriesPrice,总价格").Tables[0];
- if (dt.Rows.Count > 0)
- {
- this.Invoke(new LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.UpdateControl(delegate()
- {
- for (int t = 0; t < dt.Rows.Count; t++)
- {
- DataGridViewRow dgvr = new DataGridViewRow();
- DataGridViewCell cell = null;
- //订单号
- cell = new DataGridViewTextBoxCell();
- cell.Value = dt.Rows[t]["Pcr_OrderNumber"].ToString().Trim();
- dgvr.Cells.Add(cell);
- //员工
- cell = new DataGridViewTextBoxCell();
- cell.Value = dt.Rows[t]["Pcr_DigitalDivisionName"].ToString().Trim();
- dgvr.Cells.Add(cell);
- //客户姓名
- cell = new DataGridViewTextBoxCell();
- cell.Value = dt.Rows[t]["Cus_Name"].ToString().Trim();
- dgvr.Cells.Add(cell);
- //业绩金额
- cell = new DataGridViewTextBoxCell();
- cell.Value = dt.Rows[t]["总价格"].ToString() == "" ? "0" : Convert.ToDecimal(dt.Rows[t]["总价格"]).ToString("N2");
- dgvr.Cells.Add(cell);
- //创建时间
- cell = new DataGridViewTextBoxCell();
- cell.Value = dt.Rows[t]["Pcr_CreateTime"].ToString().Trim();
- dgvr.Cells.Add(cell);
- //套系类别
- cell = new DataGridViewTextBoxCell();
- cell.Value = dt.Rows[t]["Pcr_CompletionContentsName"].ToString().Trim();
- dgvr.Cells.Add(cell);
- //套系名称
- cell = new DataGridViewTextBoxCell();
- cell.Value = dt.Rows[t]["Ord_SeriesName"].ToString().Trim();
- dgvr.Cells.Add(cell);
- //项目名称
- cell = new DataGridViewTextBoxCell();
- cell.Value = "计件提成";
- dgvr.Cells.Add(cell);
- this.dgv.Rows.Add(dgvr);
- }
- dgv.ClearSelection();
- }));
- }
- });
- #endregion
- #region 获取礼服租售
- s = "";
- str = new StringBuilder();
- dt = new DataTable();
- str.Append(" Dsro_CreateDateTime>='" + StartTime + "' and Dsro_CreateDateTime<='" + EndTime + " 23:59:59.000' and Dsro_Type != '2'");
- if (EmployeeName != null && !string.IsNullOrEmpty(EmployeeName))
- { str.Append(" and Dsro_CreateName like '%" + EmployeeName + "%'"); }
- s = BindSelect5();
- LYFZ.ComponentLibrary.FrmLoadHandling.LoadDoWorkMethod(delegate(object obj, BackgroundWorker backgroundWorker)
- {
- dt = Orderbll.GetView_Custom("View_DressSaleRentalOrder", StrWhere: str.ToString() + s.ToString(), ShowColumnName: "ID,Dsro_Number,Dsro_Type,Dsro_Amount,Dsro_MortgageAmount,Dsro_CustomerNumber,Dsro_TakeDressTime,Dsro_ReservationBackTime,Dsro_Remark,Dsro_CreateDateTime,Dsro_CreateName,Dsro_UpdateDateTime,Dsro_UpdateName,Cus_CustomerNumber,Cus_Name,开单人姓名").Tables[0];
- if (dt.Rows.Count > 0)
- {
- this.Invoke(new LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.UpdateControl(delegate()
- {
- for (int t = 0; t < dt.Rows.Count; t++)
- {
- DataGridViewRow dgvr = new DataGridViewRow();
- DataGridViewCell cell = null;
- //订单号
- cell = new DataGridViewTextBoxCell();
- cell.Value = dt.Rows[t]["Dsro_Number"].ToString().Trim();
- dgvr.Cells.Add(cell);
- //员工
- cell = new DataGridViewTextBoxCell();
- cell.Value = dt.Rows[t]["开单人姓名"].ToString().Trim();
- dgvr.Cells.Add(cell);
- //客户姓名
- cell = new DataGridViewTextBoxCell();
- cell.Value = dt.Rows[t]["Cus_Name"].ToString().Trim();
- dgvr.Cells.Add(cell);
- //业绩金额
- cell = new DataGridViewTextBoxCell();
- cell.Value = Convert.ToDecimal(dt.Rows[t]["Dsro_Amount"]).ToString("N2");
- dgvr.Cells.Add(cell);
- //创建时间
- cell = new DataGridViewTextBoxCell();
- cell.Value = dt.Rows[t]["Dsro_CreateDateTime"].ToString().Trim();
- dgvr.Cells.Add(cell);
- //套系类别
- cell = new DataGridViewTextBoxCell();
- cell.Value = "礼服租售";
- dgvr.Cells.Add(cell);
- //套系名称
- cell = new DataGridViewTextBoxCell();
- if (dt.Rows[t]["Dsro_Type"].ToString().Trim() == "0")
- { cell.Value = "出租"; }
- else if (dt.Rows[t]["Dsro_Type"].ToString().Trim() == "1")
- { cell.Value = "出售"; }
- dgvr.Cells.Add(cell);
- //项目名称
- cell = new DataGridViewTextBoxCell();
- cell.Value = "礼服租售";
- dgvr.Cells.Add(cell);
- this.dgv.Rows.Add(dgvr);
- }
- dgv.ClearSelection();
- }));
- }
- });
- #endregion
- #region 获取员工奖罚
- s = "";
- str = new StringBuilder();
- dt = new DataTable();
- str.Append(" Rp_RPDatetime>='" + StartTime + "' and Rp_RPDatetime<='" + EndTime + " 23:59:59.000' and Rp_Status='已执行'");
- if (EmployeeName != null && !string.IsNullOrEmpty(EmployeeName))
- { str.Append(" and Rp_RelevantPeople like '%" + EmployeeName + "%'"); }
- s = BindSelect6();
- LYFZ.ComponentLibrary.FrmLoadHandling.LoadDoWorkMethod(delegate(object obj, BackgroundWorker backgroundWorker)
- {
- dt = Orderbll.GetView_Custom("View_ErpRewardPunishment", StrWhere: str.ToString() + s.ToString(), ShowColumnName: "ID,Rp_Type,Rp_RelevantPeople,Rp_Money,Rp_Status,Rp_RPDatetime,Rp_PersonHandling,Rp_Reason,Rp_Remark,Rp_CreateDatetime,Rp_UpdateDatetime,User_Name,Rp_PersonHandlingName").Tables[0];
- if (dt.Rows.Count > 0)
- {
- this.Invoke(new LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.UpdateControl(delegate()
- {
- for (int t = 0; t < dt.Rows.Count; t++)
- {
- DataGridViewRow dgvr = new DataGridViewRow();
- DataGridViewCell cell = null;
- //订单号
- cell = new DataGridViewTextBoxCell();
- cell.Value = dt.Rows[t]["ID"].ToString().Trim();
- dgvr.Cells.Add(cell);
- //员工
- cell = new DataGridViewTextBoxCell();
- cell.Value = dt.Rows[t]["User_Name"].ToString().Trim();
- dgvr.Cells.Add(cell);
- //客户姓名
- cell = new DataGridViewTextBoxCell();
- cell.Value = "";// dt.Rows[t]["Cus_Name"].ToString().Trim();
- dgvr.Cells.Add(cell);
- //业绩金额
- cell = new DataGridViewTextBoxCell();
- cell.Value = Convert.ToDecimal(dt.Rows[t]["Rp_Money"]).ToString("N2");
- dgvr.Cells.Add(cell);
- //创建时间
- cell = new DataGridViewTextBoxCell();
- cell.Value = dt.Rows[t]["Rp_RPDatetime"].ToString().Trim();
- dgvr.Cells.Add(cell);
- //套系类别
- cell = new DataGridViewTextBoxCell();
- cell.Value = "员工奖罚";
- dgvr.Cells.Add(cell);
- //套系名称
- cell = new DataGridViewTextBoxCell();
- cell.Value = dt.Rows[t]["Rp_Type"].ToString().Trim();
- dgvr.Cells.Add(cell);
- //项目名称
- cell = new DataGridViewTextBoxCell();
- cell.Value = "员工奖罚";
- dgvr.Cells.Add(cell);
- this.dgv.Rows.Add(dgvr);
- }
- dgv.ClearSelection();
- }));
- }
- });
- #endregion
- #region 获取员工支出
- s = "";
- str = new StringBuilder();
- dt = new DataTable();
- str.Append(" Oiae_IEDatetime>='" + StartTime + "' and Oiae_IEDatetime<='" + EndTime + " 23:59:59.000' and (Oiae_Type='支出' or Oiae_Type='财务支出')");
- if (EmployeeName != null && !string.IsNullOrEmpty(EmployeeName))
- { str.Append(" and Oiae_ThePayer like '%" + EmployeeName + "%'"); }
- s = BindSelect7();
- LYFZ.ComponentLibrary.FrmLoadHandling.LoadDoWorkMethod(delegate(object obj, BackgroundWorker backgroundWorker)
- {
- dt = Orderbll.GetView_Custom("View_ErpOtherIncomeAndExpenses", StrWhere: str.ToString() + s.ToString(), ShowColumnName: "ID,Oiae_Type,Oiae_ProjectName,Oiae_Money,Oiae_IEDatetime,Oiae_PersonHandling,Oiae_ThePayer,Oiae_Invoice,Oiae_Remark,Oiae_CreateDatetime,Oiae_FinancialAuditState,Oiae_FinancialAuditPeople,Oiae_ManagerAuditState,Oiae_ManagerAuditPeople,Oiae_CEOAuditState,Oiae_CEOAuditPeople,Oiae_PaymentMethod,User_Name,Oiae_PersonHandlingName,Oiae_FinancialAuditPeopleName,Oiae_ManagerAuditPeopleName,Oiae_CEOAuditPeopleName,Oiae_PaymentMethodName").Tables[0];
- if (dt.Rows.Count > 0)
- {
- this.Invoke(new LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.UpdateControl(delegate()
- {
- for (int t = 0; t < dt.Rows.Count; t++)
- {
- DataGridViewRow dgvr = new DataGridViewRow();
- DataGridViewCell cell = null;
- //订单号
- cell = new DataGridViewTextBoxCell();
- cell.Value = dt.Rows[t]["ID"].ToString().Trim();
- dgvr.Cells.Add(cell);
- //员工
- cell = new DataGridViewTextBoxCell();
- cell.Value = dt.Rows[t]["User_Name"].ToString().Trim();
- dgvr.Cells.Add(cell);
- //客户姓名
- cell = new DataGridViewTextBoxCell();
- cell.Value = "";// dt.Rows[t]["Cus_Name"].ToString().Trim();
- dgvr.Cells.Add(cell);
- //业绩金额
- cell = new DataGridViewTextBoxCell();
- cell.Value = Convert.ToDecimal(dt.Rows[t]["Oiae_Money"]).ToString("N2");
- dgvr.Cells.Add(cell);
- //创建时间
- cell = new DataGridViewTextBoxCell();
- cell.Value = dt.Rows[t]["Oiae_IEDatetime"].ToString().Trim();
- dgvr.Cells.Add(cell);
- //套系类别
- cell = new DataGridViewTextBoxCell();
- cell.Value = "员工支出";
- dgvr.Cells.Add(cell);
- //套系名称
- cell = new DataGridViewTextBoxCell();
- cell.Value = dt.Rows[t]["Oiae_ProjectName"].ToString().Trim();
- dgvr.Cells.Add(cell);
- //项目名称
- cell = new DataGridViewTextBoxCell();
- cell.Value = "员工支出";
- dgvr.Cells.Add(cell);
- this.dgv.Rows.Add(dgvr);
- }
- dgv.ClearSelection();
- }));
- }
- });
- #endregion
- */
- /*
- #region 显示绘画(合计业绩)
- if (this.dgv.Rows.Count > 0)
- {
- //业绩
- decimal CurrentPerformance = 0;
- //计件
- decimal PieceCommission = 0;
- //奖励
- decimal Reward = 0;
- //罚款
- decimal Fine = 0;
- //支出
- decimal Expenditure = 0;
- for (int i = 0; i < this.dgv.Rows.Count; i++)
- {
- #region 参数
- object Project_Name = this.dgv.Rows[i].Cells["Column8"].Value;
- object Type = this.dgv.Rows[i].Cells["Column6"].Value;
- decimal Pay_AmountOf = Convert.ToDecimal(this.dgv.Rows[i].Cells["Column3"].Value);
- #endregion
- #region 合计
- if (Project_Name.ToString() != "")
- {
- if (Project_Name.ToString() == "订单前期业绩" || Project_Name.ToString() == "订单后期业绩" || Project_Name.ToString() == "其它消费" || Project_Name.ToString() == "礼服租售")
- {
- CurrentPerformance += Pay_AmountOf;
- }
- if (Project_Name.ToString() == "计件提成")
- {
- PieceCommission += Pay_AmountOf;
- }
- if (Project_Name.ToString() == "员工支出")
- {
- Expenditure += Pay_AmountOf;
- }
- if (Project_Name.ToString() == "员工奖罚")
- {
- if (Type.ToString() == "奖励")
- {
- Reward += Pay_AmountOf;
- }
- if (Type.ToString() == "惩罚")
- {
- Fine += Pay_AmountOf;
- }
- }
- }
- #endregion
- }
- Sum = CurrentPerformance;
- this.txtPieceCommission.Text = PieceCommission.ToString("N2");
- this.txtRewardPunishment.Text = "奖:" + Reward + "," + "罚:" + Fine;
- this.txtExpenditure.Text = Expenditure.ToString("N2");
- }
- #endregion
- */
- #endregion
- return Sum;
- }
- DataTable DataGriwViewToDataTable(DataGridView dataGridView)
- {
- DataTable dt = new DataTable();
- foreach(DataGridViewColumn column in dataGridView.Columns)
- {
- dt.Columns.Add(column.Name);
- }
- foreach(DataGridViewRow gridRow in dataGridView.Rows)
- {
- DataRow dr = dt.NewRow();
- foreach (DataGridViewColumn column in dataGridView.Columns)
- {
- dr[column.Name] = gridRow.Cells[column.Name].Value;
- }
- dt.Rows.Add(dr);
- }
- return dt;
- }
- private string BindSelect10()
- {
- StringBuilder str = new StringBuilder();
- if (!string.IsNullOrEmpty(this.CtvPak_Name.Text.Trim()))
- { str.Append(" and tb_ErpDressDepositReceivables.id=-3"); }
- if (!string.IsNullOrEmpty(this.cmbItemCategory.Text.Trim()))
- {
- if (this.cmbItemCategory.Text != "礼服租售")
- { str.Append(" and tb_ErpDressDepositReceivables.id=-3"); }
- }
- return str.ToString();
- }
- /// <summary>
- ///
- /// </summary>
- /// <param name="wqcRow">统计查询方案</param>
- /// <param name="uEmployeeID"></param>
- /// <param name="isEndRow"></param>
- /// <returns></returns>
- DataGridViewRow GetSubDataGridViewRow(string ordNumber, DataGridViewRow firstDr, dynamic ordDy, int index, bool isEndRow = false)
- {
- IDictionary<string, object> idicObj = ordDy;
- DataGridViewRow dgRow = new DataGridViewRow();
- if (index > 1)
- {
- dgRow.CreateCells(this.dgv);
- dgRow.Cells[0].Style = GetDataGridViewCellStyle(System.Drawing.Color.White, DataGridViewContentAlignment.MiddleLeft);
- dgRow.Cells[1].Style = dgRow.Cells[0].Style;
- dgRow.Cells[2].Style = dgRow.Cells[0].Style;
- dgRow.Cells[3].Style = dgRow.Cells[0].Style;
- dgRow.Cells[4].Style = dgRow.Cells[0].Style;
- dgRow.Cells[5].Style = dgRow.Cells[0].Style;
- dgRow.Cells[6].Style = dgRow.Cells[0].Style;
- dgRow.Cells[7].Style = dgRow.Cells[0].Style;
- dgRow.Cells[8].Style = dgRow.Cells[0].Style;
- dgRow.Cells[9].Style = dgRow.Cells[0].Style;
- dgRow.Cells[10].Style = dgRow.Cells[0].Style;
- dgRow.Cells[11].Style = dgRow.Cells[0].Style;
- dgRow.Cells[12].Style = dgRow.Cells[0].Style;
- if (isEndRow)
- {
- dgRow.Cells[0].Tag = this.dgv.EraseCellDrawLineHEnd;
- dgRow.Cells[1].Tag = this.dgv.EraseCellDrawLineHEnd;
- dgRow.Cells[2].Tag = this.dgv.EraseCellDrawLineHEnd;
- dgRow.Cells[3].Tag = this.dgv.EraseCellDrawLineHEnd;
- dgRow.Cells[4].Tag = this.dgv.EraseCellDrawLineHEnd;
- dgRow.Cells[5].Tag = this.dgv.EraseCellDrawLineHEnd;
- dgRow.Cells[6].Tag = this.dgv.EraseCellDrawLineVHEnd;
- }
- else
- {
- dgRow.Cells[0].Tag = this.dgv.EraseCellDrawLine;
- dgRow.Cells[1].Tag = this.dgv.EraseCellDrawLine;
- dgRow.Cells[2].Tag = this.dgv.EraseCellDrawLine;
- dgRow.Cells[3].Tag = this.dgv.EraseCellDrawLine;
- dgRow.Cells[4].Tag = this.dgv.EraseCellDrawLine;
- dgRow.Cells[5].Tag = this.dgv.EraseCellDrawLine;
- dgRow.Cells[6].Tag = this.dgv.EraseCellDrawLineVEnd;
- }
- }
- else
- {
- dgRow = firstDr;
- }
- dgRow.Cells[2].Value = idicObj["客户姓名"];
- dgRow.Cells[3].Value = idicObj["客户电话"];
-
- if (idicObj["业绩金额"].ToString() != "付款")
- {
- dgRow.Cells[1].Value = idicObj.ContainsKey("自定义订单号") ? idicObj["自定义订单号"] : ordNumber;
- dgRow.Cells[5].Value = idicObj["业绩金额"];
- dgRow.Cells[4].Value = idicObj["收款类型"];
- }
- else
- {
- dgRow.Cells[1].Value = idicObj.ContainsKey("自定义订单号") ? idicObj["自定义订单号"] : ordNumber;
- //dgRow.Cells[5].Value = firstDr.Cells["PerformanceMoney"].Value;
- dgRow.Cells[4].Value = idicObj["收款类型"].ToString().Replace("收款","");
- //dgRow.Cells[5].Value = firstDr.Cells["PerformanceMoney"].Value;
- //dgRow.Cells[2].Value = firstDr.Cells["CusName"].Value;
- //dgRow.Cells[3].Value = firstDr.Cells["CusTelephone"].Value;
- }
- dgRow.Cells[6].Value = idicObj["支付方式"];
- dgRow.Cells[7].Value = idicObj["收款金额"];
- dgRow.Cells[9].Value = idicObj["业绩描述"];
- dgRow.Cells[8].Value = idicObj["业绩分配"];
- dgRow.Cells[10].Value = idicObj["收款人"];
- dgRow.Cells[11].Value = idicObj["收款日"].ToString();
- dgRow.Cells[12].Value = idicObj["收款名称"];
- return dgRow;
- }
- #region 字段样式定义
- System.Windows.Forms.DataGridViewCellStyle GetDataGridViewCellStyle(System.Drawing.Color bgcolor, System.Windows.Forms.DataGridViewContentAlignment alignment = DataGridViewContentAlignment.MiddleCenter)
- {
- System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle2 = new System.Windows.Forms.DataGridViewCellStyle();
- dataGridViewCellStyle2.Alignment = alignment;
- dataGridViewCellStyle2.BackColor = bgcolor;//System.Drawing.Color.FromArgb(((int)(((byte)(43)))), ((int)(((byte)(108)))), ((int)(((byte)(150)))));
- dataGridViewCellStyle2.Font = new System.Drawing.Font("微软雅黑", 10.5f, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
- dataGridViewCellStyle2.ForeColor = System.Drawing.Color.Black;
- dataGridViewCellStyle2.SelectionBackColor = System.Drawing.SystemColors.Highlight;
- dataGridViewCellStyle2.SelectionForeColor = System.Drawing.SystemColors.HighlightText;
-
- return dataGridViewCellStyle2;
- }
- #endregion
- #region 绑定数据信息
- /// <summary>
- /// 获取业绩人数据组
- /// </summary>
- /// <param name="dyUserList"></param>
- /// <param name="preOrder"></param>
- void GetUserOrderDataByDynamicList(ref Dictionary<string, Dictionary<string, List<dynamic>>> dyUserList, DataTable lastOrder,
- string strKeyValue,string strOrderNumberKey,string payNumberKey ,string performanceKey, string typeName, DataRow mainDr, DataRow deputyDr, List<DataRow> payRowList = null)
- {
- foreach (DataRow dr in lastOrder.Rows)
- {//"销售人员编号"
- ////付款数据
- if(payRowList!=null)
- {
- string userKeys = "";
- List<DataRow> payTempRowList = payRowList.FindAll(p => p.Field<string>(payNumberKey) == dr[strOrderNumberKey].ToString());
- if (!string.IsNullOrEmpty(performanceKey))
- {
- foreach (DataRow payDr in payTempRowList)
- {
- if (!string.IsNullOrEmpty(payDr[performanceKey].ToString_s()))
- {
- List<dynamic> dyList = Newtonsoft.Json.JsonConvert.DeserializeObject<List<dynamic>>(payDr[performanceKey].ToString_s());
- string[] openSingleList = userKeys.Split(',');
- foreach (dynamic dyObj in dyList)
- {
- if (!userKeys.Contains(dyObj.UserID.ToString()))
- {
- if (!string.IsNullOrEmpty(userKeys))
- {
- userKeys += ",";
- }
- userKeys += dyObj.UserID;
- }
- }
- }
- }
- }
- if(!string.IsNullOrEmpty(userKeys))
- {
- dr[strKeyValue] = userKeys;
- }
- }
- ///人员数据绑定
- if (dyUserList.ContainsKey(dr[strKeyValue].ToString_s()))
- {
- Dictionary<string, List<dynamic>> dicOrderList = dyUserList[dr[strKeyValue].ToString_s()];
- BindUserOrderDataByDynamic(ref dicOrderList,ref dyUserList, dr[strKeyValue].ToString_s(), dr, strOrderNumberKey, typeName, mainDr, deputyDr, payRowList);
- }
- else
- {
- Dictionary<string, List<dynamic>> dicOrderList = new Dictionary<string, List<dynamic>>();
- string[] personNumberList = dr[strKeyValue].ToString_s().Split(',');
- foreach(string perKey in personNumberList)
- {
- if(dyUserList.ContainsKey(perKey))
- {
- dicOrderList = dyUserList[perKey];
- BindUserOrderDataByDynamic(ref dicOrderList, ref dyUserList, perKey, dr, strOrderNumberKey, typeName, mainDr, deputyDr, payRowList);
- }
- else
- {
- dicOrderList = new Dictionary<string, List<dynamic>>();
- dyUserList.Add(perKey, dicOrderList);
- BindUserOrderDataByDynamic(ref dicOrderList, ref dyUserList, perKey, dr, strOrderNumberKey, typeName, mainDr, deputyDr, payRowList);
- }
- }
-
- }
- }
- }
- /// <summary>
- /// 获取订单数据组
- /// </summary>
- /// <param name="dicOrderList"></param>
- /// <param name="dr"></param>
- void BindUserOrderDataByDynamic(ref Dictionary<string, List<dynamic>> dicOrderList, ref Dictionary<string, Dictionary<string, List<dynamic>>> dyUserList,
- string employeeId,
- DataRow dr, string strKeyValue, string typeName
- , DataRow mainDr, DataRow deputyDr, List<DataRow> payRowList = null)
- {//"订单号"
- if (dicOrderList.ContainsKey(dr[strKeyValue].ToString_s()))
- {
- List<dynamic> orderTypeData = dicOrderList[SetFistKeyData(typeName) + dr[strKeyValue].ToString_s()];
- BindUserOrderData(ref orderTypeData, ref dyUserList, employeeId, dr, typeName, mainDr, deputyDr);
- if (payRowList != null)
- {
- List<DataRow> searchPayList = payRowList.Where(p => p.Field<string>("Pay_OrdNumber") == dr[strKeyValue].ToString_s()).ToList();
- orderTypeData[orderTypeData.Count - 1].收款金额 = searchPayList.Sum(p => p.Field<decimal>("Pay_AmountOf"));
- if (typeName == "订单后期")
- {
- searchPayList = searchPayList.FindAll(p => p.Field<string>("Pay_ReceivableProject") == dr["商品名称"].ToString_s());
- }
- BindUserPayDynamicData(ref orderTypeData, ref dyUserList, employeeId, searchPayList, typeName, mainDr, deputyDr);
- }
- }
- else
- {
- List<dynamic> orderTypeData = new List<dynamic>();
- dicOrderList.Add(SetFistKeyData(typeName) + dr[strKeyValue].ToString_s(), orderTypeData);
- BindUserOrderData(ref orderTypeData, ref dyUserList, employeeId, dr, typeName, mainDr, deputyDr);
- if (payRowList != null)
- {
- List<DataRow> searchPayList = payRowList.Where(p => p.Field<string>("Pay_OrdNumber") == dr[strKeyValue].ToString_s()).ToList();
- orderTypeData[orderTypeData.Count - 1].收款金额 = searchPayList.Sum(p => p.Field<decimal>("Pay_AmountOf"));
- if (typeName == "订单后期")
- {
- searchPayList = searchPayList.FindAll(p => p.Field<string>("Pay_ReceivableProject") == dr["商品名称"].ToString_s());
- }
- BindUserPayDynamicData(ref orderTypeData, ref dyUserList, employeeId, searchPayList, typeName, mainDr, deputyDr);
- }
- }
- }
- string SetFistKeyData(string typeName)
- {
- switch (typeName)
- {
- case "员工奖罚":
- return "URP";
- break;
- case "员工支出":
- return "UPM";
- break;
- default:
- return "";
- break;
- }
- }
- void BindUserOrderData(ref List<dynamic> orderTypeData, ref Dictionary<string, Dictionary<string, List<dynamic>>> dyUserList,
- string employeeId,
- DataRow dr,string typeName
- , DataRow mainDr, DataRow deputyDr)
- {
- switch(typeName)
- {
- case "订单前期":
- BindUserOrderData(ref orderTypeData, dr, mainDr, deputyDr);
- break;
- case "订单后期":
- BindUserLastOrderData(ref orderTypeData, dr, mainDr, deputyDr);
- break;
- case "其他消费":
- BindUserOtherData(ref orderTypeData, dr, mainDr, deputyDr, employeeId);
- break;
- case "计件提成":
- BindUserPieceworkData(ref orderTypeData, dr);
- break;
- case "礼服租售":
- BindUserDressData(ref orderTypeData, dr);
- break;
- case "员工奖罚":
- BindUserRewardPunishment(ref orderTypeData, dr);
- break;
- case "员工支出":
- BindUserIncomeAndExpenses(ref orderTypeData, dr);
- break;
- case "会员充值":
- BindMemberData(ref orderTypeData,ref dyUserList, employeeId, dr);
- break;
- case "会员服务充值":
- BindMemberServiceData(ref orderTypeData,ref dyUserList, employeeId, dr);
- break;
- }
- }
- private void BindMemberServiceData(ref List<dynamic> orderTypeData, ref Dictionary<string, Dictionary<string, List<dynamic>>> dyUserList,
- string employeeId, DataRow dr)
- {
- dynamic dyObj = new System.Dynamic.ExpandoObject();
- IDictionary<string, object> idicData = dyObj;
- idicData.Add("自定义订单号", dr["id"].ToString_s());
- idicData.Add("客户姓名", dr["Cus_Name"].ToString_s());
- idicData.Add("客户电话", dr["Cus_Telephone"].ToString_s());
- idicData.Add("收款类型", "会员服务充值");
- idicData.Add("业绩金额", dr["Mcpt_PaymentAmount"].ToString_s());
- idicData.Add("业绩额", Convert.ToDecimal(dr["Mcpt_PaymentAmount"].ToString_s()));
- idicData.Add("业绩人", dr["Mcpt_OrderPerson"].ToString_s());
- idicData.Add("支付方式", dr["Sc_ClassName"].ToString_s());
- idicData.Add("收款金额", Convert.ToDecimal(dr["Mcpt_PaymentAmount"].ToString_s()));
- if (!string.IsNullOrEmpty(dr["Mcpt_CommissionRatio"].ToString_s()))
- {
- idicData.Add("业绩分配", GetCommissionRatio(Convert.ToDecimal(dr["Mcpt_PaymentAmount"]),
- dr["Mcpt_OrderPerson"].ToString(),
- dr["Mcpt_CommissionRatio"].ToString_s(), employeeId));
- idicData.Add("业绩描述", GetCommissionRatioDis(Convert.ToDecimal(dr["Mcpt_PaymentAmount"]),
- dr["Mcpt_OrderPerson"].ToString(),
- dr["Mcpt_CommissionRatio"].ToString_s(), employeeId));
- }
- else
- {
- idicData.Add("业绩分配", dr["Mcpt_PaymentAmount"].ToString_s());
- idicData.Add("业绩描述", "");
- }
- string strPerformance = idicData["业绩分配"].ToString();
- if (!string.IsNullOrEmpty(strPerformance))
- {
- string[] orderPersonList = dr["Mcpt_OrderPerson"].ToString().Split(',');
- foreach (string perKey in orderPersonList)
- {
- DataRow perDtRows = LYFZ.DAL.DAL_ErpUser.SimpleUserDataTable.Rows.Find(perKey);
- if (perDtRows != null)
- {
- strPerformance = strPerformance.Replace(perKey, perDtRows["User_Name"].ToString().Trim());
- }
- }
- idicData["业绩分配"] = strPerformance;
- }
- string thePayee = dr["Mcpt_CreateName"].ToString_s();
- DataRow dtRows = LYFZ.DAL.DAL_ErpUser.SimpleUserDataTable.Rows.Find(dr["Mcpt_CreateName"].ToString_s());
- if (dtRows != null)
- {
- thePayee = dtRows["User_Name"].ToString().Trim();
- }
- idicData.Add("收款人", thePayee);
- idicData.Add("收款日", dr["Mcpt_CreateDatetime"].ToString_s());
- idicData.Add("收款名称", dr["Mcpt_PaymentType"].ToString_s());
- orderTypeData.Add(dyObj);
- }
- /// <summary>
- /// 会员充值
- /// </summary>
- /// <param name="orderTypeData"></param>
- /// <param name="dr"></param>
- private void BindMemberData(ref List<dynamic> orderTypeData, ref Dictionary<string, Dictionary<string, List<dynamic>>> dyUserList,
- string employeeId,
- DataRow dr, DataRow mainDr = null, DataRow deputyDr = null)
- {
- dynamic dyObj = new System.Dynamic.ExpandoObject();
- IDictionary<string, object> idicData = dyObj;
- idicData.Add("自定义订单号", dr["id"].ToString_s());
- idicData.Add("客户姓名", dr["Cus_Name"].ToString_s());
- idicData.Add("客户电话", dr["Cus_Telephone"].ToString_s());
- idicData.Add("收款类型", "会员充值");
- idicData.Add("业绩金额", dr["Mcrr_RechargeAmount"].ToString_s());
- idicData.Add("业绩额", Convert.ToDecimal(dr["Mcrr_RechargeAmount"].ToString_s()));
- idicData.Add("业绩人", dr["Mcrr_OrderPerson"].ToString_s());
- idicData.Add("支付方式", dr["Sc_ClassName"].ToString_s() );
- idicData.Add("收款金额", Convert.ToDecimal(dr["Mcrr_RechargeAmount"].ToString_s()));
- if (!string.IsNullOrEmpty(dr["Mcrr_CommissionRatio"].ToString_s()))
- {
- idicData.Add("业绩分配", GetCommissionRatio(Convert.ToDecimal(dr["Mcrr_RechargeAmount"]),
- dr["Mcrr_OrderPerson"].ToString(),
- dr["Mcrr_CommissionRatio"].ToString_s(), employeeId));
- idicData.Add("业绩描述", GetCommissionRatioDis(Convert.ToDecimal(dr["Mcrr_RechargeAmount"]),
- dr["Mcrr_OrderPerson"].ToString(),
- dr["Mcrr_CommissionRatio"].ToString_s(), employeeId));
- }
- else if (mainDr != null && deputyDr != null)
- {
- idicData.Add("业绩分配", GetAchievement(Convert.ToDecimal(dr["Mcrr_RechargeAmount"]),
- dr["Mcrr_OrderPerson"].ToString(),
- mainDr, deputyDr, employeeId));
- idicData.Add("业绩描述", GetAchievementDis(Convert.ToDecimal(dr["Mcrr_RechargeAmount"]),
- dr["Mcrr_OrderPerson"].ToString(),
- mainDr, deputyDr, employeeId));
- }
- else
- {
- idicData.Add("业绩分配", dr["Mcrr_RechargeAmount"].ToString_s());
- idicData.Add("业绩描述", "");
- }
- string strPerformance = idicData["业绩分配"].ToString();
- if (!string.IsNullOrEmpty(strPerformance))
- {
- string[] orderPersonList = dr["Mcrr_OrderPerson"].ToString().Split(',');
- foreach (string perKey in orderPersonList)
- {
- DataRow perDtRows = LYFZ.DAL.DAL_ErpUser.SimpleUserDataTable.Rows.Find(perKey);
- if (perDtRows != null)
- {
- strPerformance = strPerformance.Replace(perKey, perDtRows["User_Name"].ToString().Trim());
- }
- }
- idicData["业绩分配"] = strPerformance;
- }
- string thePayee = dr["Mcrr_CreateName"].ToString_s();
- DataRow dtRows = LYFZ.DAL.DAL_ErpUser.SimpleUserDataTable.Rows.Find(dr["Mcrr_CreateName"].ToString_s());
- if (dtRows != null)
- {
- thePayee = dtRows["User_Name"].ToString().Trim();
- }
- idicData.Add("收款人", thePayee);
- idicData.Add("收款日", dr["Mcrr_CreateDatetime"].ToString_s());
- idicData.Add("收款名称", dr["Mcrr_RechargeName"].ToString_s());
- orderTypeData.Add(dyObj);
- }
- #region 绑定付款数据
- void BindUserPayDynamicData(ref List<dynamic> orderTypeData, ref Dictionary<string, Dictionary<string, List<dynamic>>> dyUserList,
- string employeeId, List<DataRow> payDrList,
- string typeName,DataRow mainDr=null ,DataRow deputyDr = null)
- {
- foreach (DataRow dr in payDrList)
- {
- dynamic dyObj = new System.Dynamic.ExpandoObject();
- IDictionary<string, object> idicData = dyObj;
- idicData.Add("自定义订单号", dr["Pay_OrdNumber"].ToString());
- idicData.Add("客户姓名", "");
- idicData.Add("客户电话", "");
- idicData.Add("收款类型", typeName + "收款");
- idicData.Add("业绩金额", "付款");
- idicData.Add("业绩人", dr["Pay_OpenSingle"].ToString());
- idicData.Add("支付方式", dr["Sc_ClassName1"]);
- idicData.Add("收款金额", Convert.ToDecimal(dr["Pay_AmountOf"]));
- if (!string.IsNullOrEmpty(dr["Pay_CommissionRatio"].ToString_s()))
- {
- idicData.Add("业绩分配", GetCommissionRatio(Convert.ToDecimal(dr["Pay_AmountOf"]),
- dr["Pay_OpenSingle"].ToString(),
- dr["Pay_CommissionRatio"].ToString_s(), employeeId));
- idicData.Add("业绩描述", GetCommissionRatioDis(Convert.ToDecimal(dr["Pay_AmountOf"]),
- dr["Pay_OpenSingle"].ToString(),
- dr["Pay_CommissionRatio"].ToString_s(), employeeId));
- }
- else if (mainDr != null && deputyDr != null)
- {
- idicData.Add("业绩分配", GetAchievement(Convert.ToDecimal(dr["Pay_AmountOf"]),
- dr["Pay_OpenSingle"].ToString(),
- mainDr, deputyDr, employeeId));
- idicData.Add("业绩描述", GetAchievementDis(Convert.ToDecimal(dr["Pay_AmountOf"]),
- dr["Pay_OpenSingle"].ToString(),
- mainDr, deputyDr, employeeId));
- }
- else
- {
- idicData.Add("业绩分配", "");
- idicData.Add("业绩描述", "");
- }
- string strPerformance = idicData["业绩分配"].ToString();
- if (!string.IsNullOrEmpty(strPerformance))
- {
- string[] orderPersonList = dr["Pay_OpenSingle"].ToString().Split(',');
- foreach (string perKey in orderPersonList)
- {
- DataRow perDtRows = LYFZ.DAL.DAL_ErpUser.SimpleUserDataTable.Rows.Find(perKey);
- if (perDtRows != null)
- {
- strPerformance = strPerformance.Replace(perKey, perDtRows["User_Name"].ToString().Trim());
- }
- }
- idicData["业绩分配"] = strPerformance;
- }
- string thePayee = dr["Pay_ThePayee"].ToString_s();
- DataRow dtRows = LYFZ.DAL.DAL_ErpUser.SimpleUserDataTable.Rows.Find(dr["Pay_ThePayee"].ToString_s());
- if (dtRows != null)
- {
- thePayee = dtRows["User_Name"].ToString().Trim();
- }
- idicData.Add("收款人", thePayee);
- idicData.Add("收款日", dr["Pay_CreateDatetime"]);
- idicData.Add("收款名称", dr["Pay_Category"] + "-" + dr["Sc_ClassName"] +
- (string.IsNullOrEmpty(dr["Pay_ReceivableProject"].ToString_s()) ? "" : "-" + dr["Pay_ReceivableProject"].ToString_s()));
- ///收款控制,过去收款金额不同的数据
- orderTypeData.Add(dyObj);
- }
- }
- private string GetCommissionRatio(
- decimal amountOf, string openSingle, string commissionRatio,string employeeId)
- {
- string strOpenSingle = "";
- if (commissionRatio != "")
- {
- List<dynamic> dyList = Newtonsoft.Json.JsonConvert.DeserializeObject<List<dynamic>>(commissionRatio);
- string[] openSingleList = openSingle.Split(',');
- foreach (dynamic dyObj in dyList)
- {
- if(employeeId== dyObj.UserID.ToString())
- {
- strOpenSingle = Convert.ToDecimal(amountOf * Convert.ToDecimal(dyObj.CommissionRatio) / 100).ToString("0.00");
- break;
- }
- //strOpenSingle += dyObj.UserID + ":" + Convert.ToDecimal(amountOf * Convert.ToDecimal(dyObj.CommissionRatio) / 100).ToString("0.00");
- }
- }
- return strOpenSingle;
- }
- private string GetCommissionRatioDis(
- decimal amountOf, string openSingle, string commissionRatio,string employeeId)
- {
- string strOpenSingle = "";
- if (commissionRatio != "")
- {
- List<dynamic> dyList = Newtonsoft.Json.JsonConvert.DeserializeObject<List<dynamic>>(commissionRatio);
- string[] openSingleList = openSingle.Split(',');
- foreach (dynamic dyObj in dyList)
- {
- //if(employeeId== dyObj.UserID.ToString())
- //{
- // strOpenSingle = Convert.ToDecimal(amountOf * Convert.ToDecimal(dyObj.CommissionRatio) / 100).ToString("0.00");
- // break;
- //}
- if(!string.IsNullOrEmpty(strOpenSingle))
- {
- strOpenSingle += " , ";
- }
- strOpenSingle += BLL.Common.BLL_Com_Data.GetUserName(dyObj.UserID.ToString(), LYFZ.DAL.DAL_ErpUser.SimpleUserDataTable) + ":" + Convert.ToDecimal(amountOf * Convert.ToDecimal(dyObj.CommissionRatio) / 100).ToString("0.00");
- }
- }
- return strOpenSingle;
- }
- #endregion
- #region 前期订单数据
- /// <summary>
- /// 获取订单数据
- /// </summary>
- /// <param name="orderTypeData"></param>
- /// <param name="dr"></param>
- void BindUserOrderData(ref List<dynamic> orderTypeData, DataRow dr, DataRow mainDr, DataRow deputyDr)
- {
- dynamic dyObj = new System.Dynamic.ExpandoObject();
- IDictionary<string, object> idicData = dyObj;
- idicData.Add("自定义订单号", dr["Ord_SinceOrderNumber"].ToString_s());
- idicData.Add("客户姓名", dr["Cus_Name"].ToString_s());
- idicData.Add("客户电话", dr["Cus_Telephone"].ToString_s());
- idicData.Add("收款类型", "订单前期");
- idicData.Add("业绩金额", dr["Ord_SeriesPrice"].ToString_s());
- idicData.Add("业绩额", Convert.ToDecimal(dr["Ord_SeriesPrice"]));
- idicData.Add("业绩人", dr["Ord_OrderPersonName"].ToString_s());
- idicData.Add("支付方式", "合计");
- idicData.Add("收款金额", "");
- idicData.Add("业绩分配", "");
- idicData.Add("业绩描述", "");
- idicData.Add("收款人", "");
- idicData.Add("收款日", "");
- idicData.Add("收款名称", "");
- orderTypeData.Add(dyObj);
- }
- #endregion
- #region 后期订单数据
-
- /// <summary>
- /// 获取订单数据
- /// </summary>
- /// <param name="orderTypeData"></param>
- /// <param name="dr"></param>
- void BindUserLastOrderData(ref List<dynamic> orderTypeData, DataRow dr, DataRow mainDr, DataRow deputyDr)
- {
- dynamic dyObj = new System.Dynamic.ExpandoObject();
- IDictionary<string, object> idicData = dyObj;
- idicData.Add("自定义订单号", dr["Ord_SinceOrderNumber"].ToString_s());
- idicData.Add("客户姓名", dr["客户名称"].ToString_s());
- idicData.Add("客户电话", dr["电话"].ToString_s());
- idicData.Add("收款类型", "订单后期");
- idicData.Add("业绩金额", dr["金额"].ToString_s());
- idicData.Add("业绩额", Convert.ToDecimal(dr["金额"]));
- idicData.Add("业绩人", dr["销售人员名称"].ToString_s());
- idicData.Add("支付方式", "合计");
- idicData.Add("收款金额", "");
- idicData.Add("业绩分配", "");
- idicData.Add("业绩描述", "");
- idicData.Add("收款人", "");
- idicData.Add("收款日", "");
- idicData.Add("收款名称", "");
- orderTypeData.Add(dyObj);
- }
- #endregion
- #region 其它消费数据
- void BindUserOtherData(ref List<dynamic> orderTypeData, DataRow dr, DataRow mainDr, DataRow deputyDr,string employeeId)
- {
- dynamic dyObj = new System.Dynamic.ExpandoObject();
- IDictionary<string, object> idicData = dyObj;
- idicData.Add("自定义订单号", dr["Tsorder_Number"].ToString_s());
- idicData.Add("客户姓名", dr["Tsorder_CustomerName"].ToString_s());
- idicData.Add("客户电话", dr["Tsorder_Telephone"].ToString_s());
- idicData.Add("收款类型", "其它消费");
- idicData.Add("业绩金额", GetAchievement( Convert.ToDecimal(dr["Tsorder_Money"]),
- dr["Tsorder_OpenSingle"].ToString(),
- mainDr, deputyDr, employeeId));
- idicData.Add("业绩额", Convert.ToDecimal(dr["Tsorder_Money"]));
- idicData.Add("业绩人", dr["User_Name"].ToString_s());
- idicData.Add("支付方式", "");
- idicData.Add("收款金额", dr["Tsorder_Money"]);
- idicData.Add("业绩分配", dr["Tsorder_Money"]);
- idicData.Add("业绩描述", "");
- idicData.Add("收款人", dr["Tsorder_PersonHandlingName"]);
- idicData.Add("收款日", dr["Tsorder_CreateDatetime"]);
- idicData.Add("收款名称", "");
- orderTypeData.Add(dyObj);
- }
- #endregion
- #region 计件提成数据
- void BindUserPieceworkData(ref List<dynamic> orderTypeData, DataRow dr)
- {
- dynamic dyObj = new System.Dynamic.ExpandoObject();
- IDictionary<string, object> idicData = dyObj;
- idicData.Add("客户姓名", dr["Cus_Name"].ToString_s());
- idicData.Add("客户电话", dr["Cus_Telephone"].ToString_s());
- idicData.Add("收款类型", "计件提成");
- idicData.Add("业绩金额","");
- idicData.Add("业绩额", dr["总价格"].ToString() == "" ? 0 : Convert.ToDecimal(dr["总价格"]));
- idicData.Add("业绩人", dr["Pcr_DigitalDivisionName"].ToString_s());
- idicData.Add("支付方式", PayTypeData(dr["Pcr_Type"].ToString_s()));
- idicData.Add("收款金额", "");
- idicData.Add("业绩分配", dr["总价格"].ToString() == "" ? "0" : Convert.ToDecimal(dr["总价格"]).ToString("N2"));
- idicData.Add("业绩描述", "完成数量:"+dr["Pcr_Quantity"]+" , 计件单价:"+dr["单价"]+",总提成:"+dr["总价格"]);
- idicData.Add("收款人", dr["Pcr_EntryPeopleName"]);
- idicData.Add("收款日", dr["Pcr_CreateTime"]);
- idicData.Add("收款名称", dr["Pcr_CompletionContentsName"].ToString_s());
- orderTypeData.Add(dyObj);
- }
- #endregion
- string PayTypeData(string type)
- {
- //0:计件式提成录入、1:预约服务录入、2:拍照导片录入、3:初修导片录入、4:设计导片录入
- switch (type)
- {
- case "0":
- return "计件式提成录入";
- case "1":
- return "预约服务录入";
- break;
- case "2":
- return "拍照导片录入";
- break;
- case "3":
- return "初修导片录入";
- break;
- case "4":
- return "设计导片录入";
- break;
- default:
- return "";
- }
- }
- #region 礼服租售数据
- void BindUserDressData(ref List<dynamic> orderTypeData, DataRow dr)
- {
- dynamic dyObj = new System.Dynamic.ExpandoObject();
- IDictionary<string, object> idicData = dyObj;
- idicData.Add("自定义订单号", dr["Dsro_Number"].ToString_s());
- idicData.Add("客户姓名", dr["Cus_Name"].ToString_s());
- idicData.Add("客户电话", dr["Cus_Telephone"].ToString_s());
- idicData.Add("收款类型", "礼服租售");
- idicData.Add("业绩金额", Convert.ToDecimal(dr["Dsro_Amount"]).ToString("N2"));
- idicData.Add("业绩额", Convert.ToDecimal(dr["Dsro_Amount"]));
- idicData.Add("业绩人", dr["开单人姓名"].ToString_s());
- idicData.Add("支付方式", "合计");
- idicData.Add("收款金额", "");
- idicData.Add("业绩分配", "");
- idicData.Add("业绩描述", "");
- idicData.Add("收款人", "");
- idicData.Add("收款日", "");
- idicData.Add("收款名称", "");
- orderTypeData.Add(dyObj);
- }
- #endregion
- #region 员工奖罚
- void BindUserRewardPunishment(ref List<dynamic> orderTypeData, DataRow dr)
- {
- dynamic dyObj = new System.Dynamic.ExpandoObject();
- IDictionary<string, object> idicData = dyObj;
- idicData.Add("客户姓名", "");
- idicData.Add("客户电话", "");
- idicData.Add("收款类型", "员工奖罚");
- idicData.Add("业绩金额", "");
- idicData.Add("业绩额", Convert.ToDecimal(dr["Rp_Money"]));
- idicData.Add("业绩人", dr["User_Name"].ToString_s());
- idicData.Add("支付方式", dr["Rp_Type"].ToString_s());
- idicData.Add("收款金额", Convert.ToDecimal(dr["Rp_Money"]).ToString("N2"));
- idicData.Add("业绩分配", "");
- idicData.Add("业绩描述", "");
- idicData.Add("收款人", dr["Rp_PersonHandlingName"].ToString_s());
- idicData.Add("收款日", dr["Rp_CreateDatetime"].ToString_s());
- idicData.Add("收款名称", dr["Rp_Status"].ToString_s());
- orderTypeData.Add(dyObj);
- }
- #endregion
- #region 员工支出
- private void BindUserIncomeAndExpenses(ref List<dynamic> orderTypeData, DataRow dr)
- {
- dynamic dyObj = new System.Dynamic.ExpandoObject();
- IDictionary<string, object> idicData = dyObj;
- idicData.Add("客户姓名", "");
- idicData.Add("客户电话", "");
- idicData.Add("收款类型", "员工支出");
- idicData.Add("业绩金额", "");
- idicData.Add("业绩额", Convert.ToDecimal(dr["Oiae_Money"]));
- idicData.Add("业绩人", dr["User_Name"].ToString_s());
- idicData.Add("支付方式", dr["Oiae_Type"].ToString_s());
- idicData.Add("收款金额", Convert.ToDecimal(dr["Oiae_Money"]).ToString("N2"));
- idicData.Add("业绩分配", "");
- idicData.Add("业绩描述", "");
- idicData.Add("收款人", dr["User_Name"].ToString_s());
- idicData.Add("收款日", dr["Oiae_PersonHandlingName"].ToString_s());
- idicData.Add("收款名称", dr["Oiae_ProjectName"].ToString_s());
- orderTypeData.Add(dyObj);
- }
- #endregion
- #endregion
- string GetAchievement(decimal totalValue, string personData, DataRow mainDr, DataRow deputyDr,string employeeId)
- {
- string txtInfo = "";
- string[] personList = personData.Split(',');
- //List<string> personDataList = new List<string>();
-
- //personList = personDataList.ToArray();
- if (personList.Length > 1)
- {
- //txtInfo = "总业绩:"+totalValue.ToString("N2")+"";
- for (int i = 0; i < personList.Length; i++)
- {
- //txtInfo += " (";
- if (employeeId == personList[i])
- {
- if (i == 0)
- {
- if (mainDr["Cp_Enabled"].ToString() == "1")
- {
- txtInfo += (totalValue / (Convert.ToInt32(mainDr["Cp_Proportion"]) + Convert.ToInt32(deputyDr["Cp_Proportion"]) * (personList.Length - 1)) * Convert.ToInt32(mainDr["Cp_Proportion"])).ToString("N2");
- }
- else
- {
- txtInfo += totalValue.ToString("N2");
- }
- }
- else
- {
- if (deputyDr["Cp_Enabled"].ToString() == "1")
- {
- txtInfo += (totalValue / (Convert.ToInt32(mainDr["Cp_Proportion"]) + Convert.ToInt32(deputyDr["Cp_Proportion"]) * (personList.Length - 1)) * Convert.ToInt32(deputyDr["Cp_Proportion"])).ToString("N2");
- }
- else
- {
- txtInfo += totalValue.ToString("N2");
- }
- }
- }
- //txtInfo += ") ";
- }
- }
- else
- {
- txtInfo = totalValue.ToString("N2");
- }
- return txtInfo;
- }
- string GetAchievementDis(decimal totalValue, string personData, DataRow mainDr, DataRow deputyDr, string employeeId)
- {
- string txtInfo = "";
- string[] personList = personData.Split(',');
- //List<string> personDataList = new List<string>();
- //personList = personDataList.ToArray();
- if (personList.Length > 1)
- {
- txtInfo = "总业绩:" + totalValue.ToString("N2") + "";
- for (int i = 0; i < personList.Length; i++)
- {
- txtInfo += " (";
- if (i == 0)
- {
- if (mainDr["Cp_Enabled"].ToString() == "1")
- {
- txtInfo += BLL.Common.BLL_Com_Data.GetUserName(personList[i], LYFZ.DAL.DAL_ErpUser.SimpleUserDataTable) + ":" + (totalValue / (Convert.ToInt32(mainDr["Cp_Proportion"]) + Convert.ToInt32(deputyDr["Cp_Proportion"]) * (personList.Length - 1)) * Convert.ToInt32(mainDr["Cp_Proportion"])).ToString("N2");
- }
- else
- {
- txtInfo += BLL.Common.BLL_Com_Data.GetUserName(personList[i], LYFZ.DAL.DAL_ErpUser.SimpleUserDataTable) + ":" + totalValue.ToString("N2");
- }
- }
- else
- {
- if (deputyDr["Cp_Enabled"].ToString() == "1")
- {
- txtInfo += BLL.Common.BLL_Com_Data.GetUserName(personList[i], LYFZ.DAL.DAL_ErpUser.SimpleUserDataTable) + ":" + (totalValue / (Convert.ToInt32(mainDr["Cp_Proportion"]) + Convert.ToInt32(deputyDr["Cp_Proportion"]) * (personList.Length - 1)) * Convert.ToInt32(deputyDr["Cp_Proportion"])).ToString("N2");
- }
- else
- {
- txtInfo += BLL.Common.BLL_Com_Data.GetUserName(personList[i], LYFZ.DAL.DAL_ErpUser.SimpleUserDataTable) + ":" + totalValue.ToString("N2");
- }
- }
- txtInfo += ") ";
- }
- }
- else
- {
- txtInfo = totalValue.ToString("N2");
- }
- return txtInfo;
- }
- /// <summary>
- /// 统计业绩
- /// </summary>
- public void TotalPerformance()
- {
- LYFZ.BLL.BLL_ErpOrder Orderbll = new LYFZ.BLL.BLL_ErpOrder();
- DataTable dt = new DataTable();
- this.dgvAll.Rows.Clear();
- Dictionary<string, List<DataRow>> dsTableList = GetTotalPerformanceValue(this.txtTimeStart.DateValue.ToString().Trim(), this.txtTimeEnd.DateValue.ToString().Trim());
- if (this.cmbEmployeeName.Text.Trim() == "全部")
- {
- dt = Orderbll.GetView_Custom("tb_ErpUser", StrWhere: "User_Status='在职'", filedOrder: "", ShowColumnName: "User_Name,User_EmployeeID").Tables[0];
- if (dt.Rows.Count > 0)
- {
- for (int t = 0; t < dt.Rows.Count; t++)
- {
- try
- {
- #region
- DataGridViewRow dgvr = new DataGridViewRow();
- DataGridViewCell cell = null;
- //员工编号
- cell = new DataGridViewTextBoxCell();
- cell.Value = dt.Rows[t]["User_EmployeeID"].ToString().Trim();
- dgvr.Cells.Add(cell);
- //员工姓名
- cell = new DataGridViewTextBoxCell();
- cell.Value = dt.Rows[t]["User_Name"].ToString().Trim();
- dgvr.Cells.Add(cell);
- //当前业绩
- cell = new DataGridViewTextBoxCell();
- cell.Value = GetTotalPerformanceValue(dsTableList["员工业绩"], dt.Rows[t]["User_EmployeeID"].ToString().Trim()).ToString("N2");
- //Convert.ToDecimal(this.BindPerformance(this.txtTimeStart.DateValue.ToString().Trim(), this.txtTimeEnd.DateValue.ToString().Trim(), dt.Rows[t]["User_EmployeeID"].ToString().Trim())).ToString("N2"); ;
- dgvr.Cells.Add(cell);
- this.dgvAll.Rows.Add(dgvr);
- #endregion
- }
- catch (Exception ex) { MessageBoxCustom.Show(ex.Message); }
- }
- dgvAll.ClearSelection();
- }
- }
- else if (this.cmbEmployeeName.Name.ToString().Trim() == "Department")
- {
- dt = Orderbll.GetView_Custom("tb_ErpUser", StrWhere: "User_Status='在职' and User_Department='" + this.cmbEmployeeName.Tag.ToString() + "'", ShowColumnName: "User_Name,User_EmployeeID").Tables[0];
- if (dt.Rows.Count > 0)
- {
- for (int t = 0; t < dt.Rows.Count; t++)
- {
- #region
- DataGridViewRow dgvr = new DataGridViewRow();
- DataGridViewCell cell = null;
- //员工编号
- cell = new DataGridViewTextBoxCell();
- cell.Value = dt.Rows[t]["User_EmployeeID"].ToString().Trim();
- dgvr.Cells.Add(cell);
- //员工姓名
- cell = new DataGridViewTextBoxCell();
- cell.Value = dt.Rows[t]["User_Name"].ToString().Trim();
- dgvr.Cells.Add(cell);
- //当前业绩
- cell = new DataGridViewTextBoxCell();
- cell.Value = GetTotalPerformanceValue(dsTableList["员工业绩"], dt.Rows[t]["User_EmployeeID"].ToString().Trim()).ToString("N2");
- //Convert.ToDecimal(this.BindPerformance(this.txtTimeStart.DateValue.ToString().Trim(), this.txtTimeEnd.DateValue.ToString().Trim(), dt.Rows[t]["User_EmployeeID"].ToString().Trim())).ToString("N2");
- dgvr.Cells.Add(cell);
- this.dgvAll.Rows.Add(dgvr);
- #endregion
- }
- dgvAll.ClearSelection();
- }
- }
- //this.txtPieceCommission.Text = GetTotalPerformanceValue(dsTableList["计件提成"]).ToString("N2");
- //this.txtRewardPunishment.Text = "奖:" + GetTotalPerformanceValue(dsTableList["奖励"]).ToString("N2") + "," + "罚:" + GetTotalPerformanceValue(dsTableList["惩罚"]).ToString("N2");
- //this.txtExpenditure.Text = GetTotalPerformanceValue(dsTableList["员工支出"]).ToString("N2");
- this.txtCurrentUserPerformance.Text = GetTotalPerformanceValue(dsTableList["员工业绩"]).ToString("N2");
- }
- decimal GetTotalPerformanceValue(List<DataRow> dsTableList,string employeeID)
- {
- decimal totalValue = 0;
- List<DataRow> drList = dsTableList.FindAll(p => p["EmployeeID"].ToString().Contains(employeeID));
- foreach(DataRow dr in drList)
- {
- decimal tempPrice = 0;
- decimal.TryParse(dr["Price"].ToString(),out tempPrice);
- totalValue += tempPrice;
- }
- return totalValue;
- }
- decimal GetTotalPerformanceValue(List<DataRow> dsTableList)
- {
- decimal totalValue = 0;
- foreach (DataRow dr in dsTableList)
- {
- decimal tempPrice = 0;
- decimal.TryParse(dr["Price"].ToString(), out tempPrice);
- totalValue += tempPrice;
- }
- return totalValue;
- }
- /// <summary>
- /// 获取业绩条数数据
- /// </summary>
- /// <param name="startTime"></param>
- /// <param name="endTime"></param>
- /// <returns></returns>
- Dictionary<string, List<DataRow>> GetTotalPerformanceValue(string startTime , string endTime)
- {
- Dictionary<string, List<DataRow>> dataRows = new Dictionary<string, List<DataRow>>();
- dataRows.Add("员工业绩", new List<DataRow>());
- dataRows.Add("计件提成", new List<DataRow>());
- dataRows.Add("员工支出", new List<DataRow>());
- dataRows.Add("奖励", new List<DataRow>());
- dataRows.Add("惩罚", new List<DataRow>());
- LYFZ.BLL.BLL_ErpOrder orbll = new BLL.BLL_ErpOrder();
- orbll.GetTotalPerformanceValue(startTime, endTime, ref dataRows);
- return dataRows;
- }
- /// <summary>
- /// 计算
- /// </summary>
- public void BindCalculate()
- {
- if (string.IsNullOrEmpty(this.txtTimeStart.DateValue))
- { MessageBoxCustom.Show("开始时间不能为空!"); return; }
- if (string.IsNullOrEmpty(this.txtTimeEnd.DateValue))
- { MessageBoxCustom.Show("结束时间不能为空!"); return; }
- if (this.cmbEmployeeName.Tag != null && this.cmbEmployeeName.Text != "全部" && this.cmbEmployeeName.Name.ToString() != "Department")
- {
- //获取员工业绩列表
- this.BindPerformance(this.txtTimeStart.DateValue.ToString().Trim(), this.txtTimeEnd.DateValue.ToString().Trim(),
- GetEmployeeDataInfo());
- //this.txtCurrentUserPerformance.Text = Convert.ToDecimal(this.BindPerformance(this.txtTimeStart.DateValue.ToString().Trim(), this.txtTimeEnd.DateValue.ToString().Trim(),
- // GetEmployeeDataInfo())).ToString("N2");
- }
- if (this.cmbEmployeeName.Text == "全部" || this.cmbEmployeeName.Name.ToString() == "Department")
- {
- this.txtCurrentUserPerformance.Text = "0";
- //this.txtExpenditure.Text = "";
- //this.txtPieceCommission.Text = "";
- //this.txtRewardPunishment.Text = "";
- this.TotalPerformance();
- }
- }
- string GetEmployeeDataInfo()
- {
- string strWhere = "'-1'";
- TreeNode tBode = this.cmbEmployeeName.SelectedNode;
- if (tBode.Name== "StoreName")
- {
- if (tBode.Nodes.Count > 0)
- {
- foreach (TreeNode node in tBode.Nodes)
- {
- if (node.Nodes.Count > 0)
- {
- foreach (TreeNode userNode in node.Nodes)
- {
- if(strWhere=="-1" || strWhere == "'-1'")
- {
- strWhere = "";
- }
- if(strWhere!="")
- {
- strWhere += ",";
- }
- strWhere += "'" + userNode.Tag + "'";
- }
- }
- }
- }
- }
- else if (tBode.Name == "Department")
- {
- if (tBode.Nodes.Count > 0)
- {
- foreach (TreeNode userNode in tBode.Nodes)
- {
- if (strWhere == "-1" || strWhere == "'-1'")
- {
- strWhere = "";
- }
- if (strWhere != "")
- {
- strWhere += ",";
- }
- strWhere += "'" + userNode.Tag + "'";
- }
- }
- }
- else if (tBode.Name == "User")
- {
- if (strWhere == "-1"|| strWhere == "'-1'")
- {
- strWhere = "";
- }
- strWhere += "'" + tBode.Tag + "'";
- }
- //strDepartment = "'" + string.Join("','", department.ToArray()) + "'";
- return strWhere;
- }
- /// <summary>
- /// 选择人员姓名查询人员工资基本信息
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- protected override void cmbEmployeeName_ComboBoxTree_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e)
- {
- if (this.cmbEmployeeName.Tag.ToString().Trim() != null && this.cmbEmployeeName.Text.Trim() != "全部")
- {
- this.dgvAll.Visible = false;
- this.dgv.Visible = true;
- }
- if (this.cmbEmployeeName.Text.Trim() == "全部" || this.cmbEmployeeName.Name.ToString().Trim() == "Department")
- {
- this.dgvAll.Visible = true;
- this.dgv.Visible = false;
- this.dgv.Rows.Clear();
- this.txtCurrentUserPerformance.Text = "0";
- //this.txtExpenditure.Text = "";
- //this.txtPieceCommission.Text = "";
- //this.txtRewardPunishment.Text = "";
- }
- this.BindCalculate();
- }
- /// <summary>
- /// 选择项目类别
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- protected override void cmbItemCategory_ComboBoxTree_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e)
- {
- //清空项目名称
- this.cmbProjectTitle.Enabled = false;
- this.cmbProjectTitle.TreeView.Nodes.Clear();
- this.cmbProjectTitle.Text = "";
- switch (this.cmbItemCategory.Text.Trim())
- {
- case "订单前期":
- case "会员充值":
- case "服务卡充值":
- case "员工支出": break;
- case "订单后期":
- case "其它消费":
- this.cmbProjectTitle.Enabled = true;
- LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.BindComboBoxTreeView_SystemCategory("BEBACDAJDFDDEACGJ", this.cmbProjectTitle, IsFirstNodeNull: true, StrWhere: "Sc_ClassCode not in ('BEBCADBFBCDFBGJHC','BEBCADBFBDDEGGABF','BEBCBFBICGDHCGBEJ','BEBCABBAAICBDHDHI','BEBCABBAAICJAAGDG','BEBCBFBICFCECBHFF')");
- break;
- case "礼服租售":
- this.cmbProjectTitle.Enabled = true;
- LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.BindComboxTreeView(this.cmbProjectTitle, "礼服出租,礼服出售", IsFirstNodeNull: true);
- break;
- case "员工奖罚":
- this.cmbProjectTitle.Enabled = true;
- LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.BindComboxTreeView(this.cmbProjectTitle, "奖励,罚款", IsFirstNodeNull: true);
- break;
- case "计件提成":
- this.cmbProjectTitle.Enabled = true;
- LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.BindComboBoxTreeView_SystemCategory("BEBBBABBEBAIHGDCB", this.cmbProjectTitle, IsFirstNodeNull: true);
- break;
- default:
- this.cmbItemCategory.Text = this.cmbItemCategory.Text.Trim();
- break;
- }
- this.BindCalculate();
- }
- /// <summary>
- /// 项目名称
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- protected override void cmbProjectTitle_ComboBoxTree_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e)
- {
- this.BindCalculate();
- }
- /// <summary>
- /// 套系类别
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- protected override void CtvPak_Name_ComboBoxTree_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e)
- {
- this.BindCalculate();
- }
- /// <summary>
- /// 排序
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- protected override void dgvAll_SortCompare(object sender, DataGridViewSortCompareEventArgs e)
- {
- if (e.Column.Name == "员工姓名" || e.Column.Name == "当前业绩")
- { e.SortResult = (Convert.ToDouble(e.CellValue1) - Convert.ToDouble(e.CellValue2) > 0) ? 1 : (Convert.ToDouble(e.CellValue1) - Convert.ToDouble(e.CellValue2) < 0) ? -1 : 0; }
- //否则,按字符串比较
- else
- { e.SortResult = System.String.Compare(Convert.ToString(e.CellValue1), Convert.ToString(e.CellValue2)); }
- e.Handled = true;//不能省掉,不然没效果
- }
- /// <summary>
- /// 关闭
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- protected override void btnClose_Click(object sender, EventArgs e)
- {
- this.Close();
- }
- /// <summary>
- /// 查询
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- protected override void btnSelect_Click(object sender, EventArgs e)
- {
- this.BindCalculate();
- }
- }
- }
|