FrmIndividualPerformance.cs 148 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Windows.Forms;
  9. namespace LYFZ.Software.MainBusiness.StatisticalInquiry
  10. {
  11. public partial class FrmIndividualPerformance : LYFZ.Software.UI.StatisticalInquiry.FrmIndividualPerformance
  12. {
  13. LYFZ.BLL.BLL_ErpOrder orbll = new BLL.BLL_ErpOrder();
  14. public FrmIndividualPerformance()
  15. {
  16. btn_Export.Click += Btn_Export_Click;
  17. this.cmbEmployeeName.Enabled = LYFZ.BLL.BLL_ErpUser.GetRights(LYFZ.BLL.BLL_ErpUser.CurrentUserRights.IndividualPerformanceCompetence, CustomAttributes.OperatingAuthority.ViewAll);
  18. }
  19. private void Btn_Export_Click(object sender, EventArgs e)
  20. {
  21. this.dgv.ExportDataTable();
  22. }
  23. /// <summary>
  24. /// 窗体加载事件
  25. /// </summary>
  26. /// <param name="sender"></param>
  27. /// <param name="e"></param>
  28. protected override void FrmIndividualPerformance_Shown(object sender, EventArgs e)
  29. {
  30. this.txtTimeStart.Text = SDateTime.Now.ToString("yyyy-MM-") + "01";
  31. this.txtTimeEnd.Text = Convert.ToDateTime(this.txtTimeStart.Text).AddMonths(1).AddSeconds(-1).ToString("yyyy-MM-dd");
  32. //部门人员绑定
  33. LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.BindComboBoxTreeView_DepartmentAndEmployee(this.cmbEmployeeName, IsFirstNodeNull: true, IsFirstNodeName: "全部", IsShowAdmin: true);
  34. //项目类别
  35. LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.BindComboxTreeView(this.cmbItemCategory, "订单前期,订单后期,其它消费,礼服租售,会员充值,会员服务充值", IsFirstNodeNull: true);//会员充值,服务卡充值
  36. //套系类别
  37. LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.BindComboBoxTreeView_SystemCategory("BFAGAHBFDGCABAJIH", this.CtvPak_Name, IsFirstNodeNull: true);
  38. LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.BindComboBoxTreeView_SystemCategory("BEBACCAFCCEAGAIHH", this.cbx_PaymentType, IsFirstNodeNull: true);
  39. this.cmbEmployeeName.Enabled = LYFZ.BLL.BLL_ErpUser.GetRights(LYFZ.BLL.BLL_ErpUser.CurrentUserRights.IndividualPerformanceCompetence, CustomAttributes.OperatingAuthority.ViewAll);
  40. if (LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.LoginUserModel.User_Account != LYFZ.AuthorizeUserName.AdministratorsName)
  41. {
  42. this.cmbEmployeeName.Tag = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.LoginUserModel.User_EmployeeID;
  43. this.cmbEmployeeName.Text = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.LoginUserModel.User_Name;
  44. //CmbEmployeeName_SelectedIndexChanged(null, null);
  45. }
  46. this.cmbEmployeeName.ComboBoxTreeViewEx_TextChanged += CmbEmployeeName_SelectedIndexChanged;
  47. this.cbx_PaymentType.ComboBoxTreeViewEx_TextChanged += Cbx_PaymentType_ComboBoxTreeViewEx_TextChanged;
  48. //this.cmbEmployeeName.TextFindTag("全部");
  49. this.cmbEmployeeName.TagFindText(LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.LoginUserModel.User_EmployeeID);
  50. this.BindPerformance(this.txtTimeStart.DateValue.ToString().Trim(), this.txtTimeEnd.DateValue.ToString().Trim(),
  51. GetEmployeeDataInfo());
  52. }
  53. private void Cbx_PaymentType_ComboBoxTreeViewEx_TextChanged(object sender, TreeViewEventArgs e)
  54. {
  55. this.BindCalculate();
  56. }
  57. private void CmbEmployeeName_SelectedIndexChanged(object sender, EventArgs e)
  58. {
  59. this.cmbEmployeeName_ComboBoxTree_NodeMouseClick(null, null);
  60. }
  61. /// <summary>
  62. /// 绑定业绩列表查询方法1(订单前期)
  63. /// </summary>
  64. public string BindSelect1()
  65. {
  66. StringBuilder str = new StringBuilder();
  67. if (!string.IsNullOrEmpty(this.CtvPak_Name.Text) && this.CtvPak_Name.Tag != null)
  68. { str.Append(" and Ord_OrderClass='" + this.CtvPak_Name.Text + "'"); }
  69. if (!string.IsNullOrEmpty(this.cmbItemCategory.Text.Trim()))
  70. {
  71. if (cmbItemCategory.Text != "订单前期")
  72. { str.Append(" and tb_ErpOrder.id=-3"); }
  73. }
  74. return str.ToString();
  75. }
  76. /// <summary>
  77. /// 绑定业绩列表查询方法2(订单后期)
  78. /// </summary>
  79. public string BindSelect2()
  80. {
  81. StringBuilder str = new StringBuilder();
  82. if (!string.IsNullOrEmpty(this.CtvPak_Name.Text.Trim()))
  83. { str.Append(" and 套系类别='" + this.CtvPak_Name.Text.ToString() + "'"); }
  84. if (!string.IsNullOrEmpty(this.cmbItemCategory.Text.Trim()))
  85. {
  86. if (this.cmbItemCategory.Text == "订单后期")
  87. {
  88. if (!string.IsNullOrEmpty(this.cmbProjectTitle.Text))
  89. { str.Append(" and 二销类别编号='" + this.cmbProjectTitle.Tag.ToString() + "'"); }
  90. }
  91. else
  92. { str.Append(" and id=-3"); }
  93. }
  94. return str.ToString();
  95. }
  96. /// <summary>
  97. /// 绑定业绩列表查询方法3(订单后期)
  98. /// </summary>
  99. public string BindSelect3()
  100. {
  101. StringBuilder str = new StringBuilder();
  102. if (!string.IsNullOrEmpty(this.CtvPak_Name.Text.Trim()))
  103. { str.Append(" and Vw_TwoSalesOrder.id=-3"); }
  104. if (!string.IsNullOrEmpty(this.cmbItemCategory.Text.Trim()))
  105. {
  106. if (this.cmbItemCategory.Text == "其它消费")
  107. {
  108. if (!string.IsNullOrEmpty(this.cmbProjectTitle.Text))
  109. { str.Append(" and Tsorder_Category='" + this.cmbProjectTitle.Tag.ToString() + "'"); }
  110. }
  111. else
  112. { str.Append(" and Vw_TwoSalesOrder.id=-3"); }
  113. }
  114. return str.ToString();
  115. }
  116. /// <summary>
  117. /// 绑定业绩列表查询方法4(计件提成)
  118. /// </summary>
  119. public string BindSelect4()
  120. {
  121. StringBuilder str = new StringBuilder();
  122. if (!string.IsNullOrEmpty(this.CtvPak_Name.Text.Trim()))
  123. { str.Append(" and id=-3"); }
  124. if (!string.IsNullOrEmpty(this.cmbItemCategory.Text.Trim()))
  125. {
  126. if (this.cmbItemCategory.Text == "计件提成")
  127. {
  128. if (!string.IsNullOrEmpty(this.cmbProjectTitle.Text))
  129. { str.Append(" and Pcr_CompletionContents='" + this.cmbProjectTitle.Tag + "'"); }
  130. }
  131. else
  132. { str.Append("and id=-3"); }
  133. }
  134. return str.ToString();
  135. }
  136. /// <summary>
  137. /// 绑定业绩列表查询方法4(计件提成)
  138. /// </summary>
  139. public string BindSelect5()
  140. {
  141. StringBuilder str = new StringBuilder();
  142. if (!string.IsNullOrEmpty(this.CtvPak_Name.Text.Trim()))
  143. { str.Append(" and id=-3"); }
  144. if (!string.IsNullOrEmpty(this.cmbItemCategory.Text.Trim()))
  145. {
  146. if (this.cmbItemCategory.Text == "礼服租售")
  147. {
  148. if (!string.IsNullOrEmpty(this.cmbProjectTitle.Text))
  149. {
  150. if (this.cmbProjectTitle.Text == "礼服出租")
  151. { str.Append(" and Dsro_Type=0"); }
  152. if (this.cmbProjectTitle.Text == "礼服出售")
  153. { str.Append(" and Dsro_Type=1"); }
  154. }
  155. }
  156. else
  157. { str.Append(" and id=-3"); }
  158. }
  159. return str.ToString();
  160. }
  161. /// <summary>
  162. /// 绑定业绩列表查询方法6(员工奖罚)
  163. /// </summary>
  164. public string BindSelect6()
  165. {
  166. StringBuilder str = new StringBuilder();
  167. if (!string.IsNullOrEmpty(this.CtvPak_Name.Text.Trim()))
  168. { str.Append(" and id=-3"); }
  169. if (!string.IsNullOrEmpty(this.cmbItemCategory.Text.Trim()))
  170. {
  171. if (this.cmbItemCategory.Text == "员工奖罚")
  172. {
  173. if (!string.IsNullOrEmpty(this.cmbProjectTitle.Text.Trim()))
  174. { str.Append(" and Rp_Type='" + this.cmbProjectTitle.Text.Trim() + "'"); }
  175. }
  176. else
  177. { str.Append(" and id=-3"); }
  178. }
  179. return str.ToString();
  180. }
  181. /// <summary>
  182. /// 绑定业绩列表查询方法7(员工支出)
  183. /// </summary>礼服租售数据
  184. public string BindSelect7()
  185. {
  186. StringBuilder str = new StringBuilder();
  187. if (!string.IsNullOrEmpty(this.CtvPak_Name.Text.Trim()))
  188. { str.Append(" and id=-3"); }
  189. if (!string.IsNullOrEmpty(this.cmbItemCategory.Text.Trim()))
  190. {
  191. if (this.cmbItemCategory.Text != "员工支出")
  192. { str.Append(" and id=-3"); }
  193. }
  194. return str.ToString();
  195. }
  196. public string BindSelect8()
  197. {
  198. StringBuilder str = new StringBuilder();
  199. if (!string.IsNullOrEmpty(this.CtvPak_Name.Text.Trim()))
  200. { str.Append(" and [tb_ErpMemberCardRechargeRecord].id=-3"); }
  201. if (!string.IsNullOrEmpty(this.cmbItemCategory.Text.Trim()))
  202. {
  203. if (this.cmbItemCategory.Text != "会员充值")
  204. { str.Append(" and [tb_ErpMemberCardRechargeRecord].id=-3"); }
  205. }
  206. return str.ToString();
  207. }
  208. public string BindSelect9()
  209. {
  210. StringBuilder str = new StringBuilder();
  211. if (!string.IsNullOrEmpty(this.CtvPak_Name.Text.Trim()))
  212. { str.Append(" and tb_ErpMemberCardPayment.id=-3"); }
  213. if (!string.IsNullOrEmpty(this.cmbItemCategory.Text.Trim()))
  214. {
  215. if (this.cmbItemCategory.Text != "会员服务充值")
  216. { str.Append(" and tb_ErpMemberCardPayment.id=-3"); }
  217. }
  218. return str.ToString();
  219. }
  220. /// <summary>
  221. /// 获取所有业绩列表
  222. /// </summary>
  223. public decimal BindPerformance(string StartTime, string EndTime, string EmployeeName)
  224. {
  225. decimal Sum = 0;
  226. this.dgv.Rows.Clear();
  227. string s = "";
  228. LYFZ.BLL.BLL_AllViewSet AllViewSetbll = new BLL.BLL_AllViewSet();
  229. LYFZ.BLL.BLL_ErpOrder Orderbll = new BLL.BLL_ErpOrder();
  230. LYFZ.BLL.BLL_ErpOrdersPhotography OrdersPhotographybll = new BLL.BLL_ErpOrdersPhotography();
  231. DataTable dt = new DataTable();
  232. ///订单前期
  233. DataTable preOrder = new DataTable();
  234. ///订单后期
  235. DataTable lastOrder = new DataTable();
  236. ///获取其它消费
  237. DataTable otherOrder = new DataTable();
  238. ///获取计件提成
  239. DataTable pieceworkOrder = new DataTable();
  240. ///获取礼服租售
  241. DataTable dressOrder = new DataTable();
  242. ///获取员工奖罚
  243. DataTable rewardOrder = new DataTable();
  244. ///获取员工支出
  245. DataTable paymentOrder = new DataTable();
  246. ///付款方式
  247. DataTable payData = new DataTable();
  248. ///会员充值
  249. DataTable mamberOrder = new DataTable();
  250. ///会员服务充值
  251. DataTable mamberServiceOrder = new DataTable();
  252. ///礼服租售充值
  253. DataTable dressServiceOrder = new DataTable();
  254. StringBuilder str = new StringBuilder();
  255. Dictionary<string, Dictionary<string, List<dynamic>>> dyUserList = new Dictionary<string, Dictionary<string, List<dynamic>>>();
  256. string sql = " select * from tb_ErpCommissionPercentage where Cp_ProportionType in(1,5) ";
  257. DataTable PerDt = orbll.GetView_Custom(sql).Tables[0];
  258. LYFZ.ComponentLibrary.FrmLoadHandling.LoadDoWorkMethod(delegate (object obj, BackgroundWorker backgroundWorker)
  259. {
  260. try
  261. {
  262. ///订单付款
  263. List<string> perOrderList = new List<string>();
  264. List<string> lastOrderList = new List<string>();
  265. string strWhereTime = " Pay_CreateDatetime>='" + StartTime + "' and Pay_CreateDatetime<='" + EndTime + " 23:59:59.000' ";
  266. if(!string.IsNullOrEmpty(cbx_PaymentType.Text.Trim()))
  267. {
  268. strWhereTime += " and Pay_PaymentMethod = '" + cbx_PaymentType.Tag + "'";
  269. }
  270. if (EmployeeName != null && !string.IsNullOrEmpty(EmployeeName))
  271. {
  272. string[] userNumbers = EmployeeName.Split(',');
  273. string strOpenWhere = "";
  274. string strCommissionRatio = "";
  275. foreach (string employeeKey in userNumbers)
  276. {
  277. if (!string.IsNullOrEmpty(strOpenWhere))
  278. {
  279. strOpenWhere += " or ";
  280. }
  281. strOpenWhere += " Pay_OpenSingle like '%" + employeeKey.Replace("'", "") + "%' ";
  282. }
  283. foreach (string employeeKey in userNumbers)
  284. {
  285. if (!string.IsNullOrEmpty(strCommissionRatio))
  286. {
  287. strCommissionRatio += " or ";
  288. }
  289. strCommissionRatio += " Pay_CommissionRatio like '%" + employeeKey.Replace("'", "") + "%' ";
  290. }
  291. strWhereTime += (" and ((" + strOpenWhere + ") or ("+ strCommissionRatio + ") )");
  292. //str.Append(" and Pay_OpenSingle in (" + EmployeeName + ")");
  293. }
  294. //if (EmployeeName != null && !string.IsNullOrEmpty(EmployeeName))
  295. //{
  296. // //str.Append(" and 销售人员编号 in (" + EmployeeName + ")");
  297. // strWhereTime += " and (Pay_OpenSingle like '%" + EmployeeName + "%' or Pay_CommissionRatio like '%" + EmployeeName + "%' ) ";
  298. //}
  299. string paySql = @"SELECT
  300. Pay_OrdNumber,
  301. Pay_Category,
  302. c2.Sc_ClassName,
  303. Pay_TwoPinsCategory,
  304. Pay_OpenSingle,
  305. c1.Sc_ClassName as Sc_ClassName1,
  306. Pay_AmountOf,
  307. Pay_CreateDatetime,
  308. Pay_ThePayee,
  309. Pay_ReceivableProject,
  310. Pay_CommissionRatio
  311. FROM [tb_ErpPayment] inner join tb_ErpSystemCategory c1 on Pay_PaymentMethod = c1.Sc_ClassCode
  312. left join tb_ErpSystemCategory c2 on Pay_TwoPinsCategory = c2.Sc_ClassCode
  313. where "+ strWhereTime;
  314. payData = Orderbll.GetView_Custom(paySql).Tables[0];
  315. perOrderList = payData.AsEnumerable().Where(p => p.Field<string> ("Pay_Category").IndexOf("后期") == -1).Select(p=>p.Field<string>("Pay_OrdNumber")).Distinct().ToList();
  316. lastOrderList = payData.AsEnumerable().Where(p => p.Field<string>("Pay_Category").IndexOf("后期") != -1).Select(p => p.Field<string>("Pay_OrdNumber")).Distinct().ToList();
  317. ///订单前期
  318. if (perOrderList.Count > 0)
  319. {
  320. str.Append("( Ord_Number in ('" + string.Join("','", perOrderList.ToArray()) + "') )");
  321. }
  322. else
  323. {
  324. str.Append("( Ord_Number in ('-1') )");
  325. }
  326. //if (EmployeeName != null && !string.IsNullOrEmpty(EmployeeName))
  327. //{
  328. // string[] userNumbers = EmployeeName.Split(',');
  329. // string strWhere = "";
  330. // foreach(string employeeKey in userNumbers)
  331. // {
  332. // if(!string.IsNullOrEmpty(strWhere))
  333. // {
  334. // strWhere += " or ";
  335. // }
  336. // strWhere += " Ord_OrderPersonNumber like '%" + employeeKey.Replace("'","") + "%' ";
  337. // }
  338. // str.Append(" and ("+ strWhere + ")");
  339. // //str.Append(" and Pay_OpenSingle in (" + EmployeeName + ")");
  340. //}
  341. s = BindSelect1();
  342. 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];
  343. ///订单后期
  344. s = "";
  345. str = new StringBuilder();
  346. if (lastOrderList.Count > 0)
  347. {
  348. str.Append("( 订单号 in ('" + string.Join("','", lastOrderList.ToArray()) + "') )");
  349. }
  350. else
  351. {
  352. str.Append("( 订单号 in ('-1') )");
  353. }
  354. //str.Append(" 创建时间>='" + StartTime + "' and 创建时间<='" + EndTime + " 23:59:59.000'");
  355. //if (EmployeeName != null && !string.IsNullOrEmpty(EmployeeName))
  356. //{ str.Append(" and 销售人员编号 in (" + EmployeeName + ")"); }
  357. s = BindSelect2();
  358. lastOrder = Orderbll.GetView_Custom("Vw_ErpPlusPickItems", StrWhere: str.ToString() + s.ToString(), ShowColumnName: "ID,订单号,Ord_SinceOrderNumber,金额,创建时间,商品名称,录单人编号,录单人名称,商品成本价,加挑金额来源类型,销售人员编号,销售人员名称,二销类别编号,二销类别名称,客户名称,拼音,电话,套系类别").Tables[0];
  359. ///获取其它消费
  360. s = "";
  361. str = new StringBuilder();
  362. dt = new DataTable();
  363. str.Append(" Tsorder_CreateDatetime>='" + StartTime + "' and Tsorder_CreateDatetime<='" + EndTime + " 23:59:59.000'");
  364. if (!string.IsNullOrEmpty(cbx_PaymentType.Text.Trim()))
  365. {
  366. str.Append(" and Tsorder_Category = '" + cbx_PaymentType.Tag + "'");
  367. }
  368. if (EmployeeName != null && !string.IsNullOrEmpty(EmployeeName))
  369. { str.Append(" and Tsorder_OpenSingle in (" + EmployeeName + ")"); }
  370. s = BindSelect3();
  371. 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];
  372. /////获取计件提成
  373. //s = "";
  374. //str = new StringBuilder();
  375. //dt = new DataTable();
  376. //str.Append(" Pcr_CreateTime>='" + StartTime + "' and Pcr_CreateTime<='" + EndTime + " 23:59:59.000'");
  377. //if (!string.IsNullOrEmpty(cbx_PaymentType.Text.Trim()))
  378. //{
  379. // str.Append(" and Pcr_OrderNumber = '-1'");
  380. //}
  381. //if (EmployeeName != null && !string.IsNullOrEmpty(EmployeeName))
  382. //{ str.Append(" and Pcr_DigitalDivision in (" + EmployeeName + ")"); }
  383. //s = BindSelect4();
  384. //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];
  385. ///礼服租售充值
  386. s = "";
  387. str = new StringBuilder();
  388. dt = new DataTable();
  389. str.Append(" DRR_CreateDatetime>='" + StartTime + "' and DRR_CreateDatetime<='" + EndTime + " 23:59:59.000' ");
  390. if (!string.IsNullOrEmpty(cbx_PaymentType.Text.Trim()))
  391. {
  392. str.Append(" and DDR_PaymentMethod = '"+ cbx_PaymentType.Tag + "'");
  393. }
  394. s = BindSelect10();
  395. 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];
  396. List<string> dressNumberList = dressServiceOrder.AsEnumerable().Select(p => p.Field<string>("Pay_OrdNumber")).ToList();
  397. ///获取礼服租售
  398. s = "";
  399. str = new StringBuilder();
  400. dt = new DataTable();
  401. str.Append(" Dsro_Number in ('" + string.Join("','", dressNumberList.ToArray()) +"')");
  402. if (EmployeeName != null && !string.IsNullOrEmpty(EmployeeName))
  403. { str.Append(" and Dsro_CreateName in (" + EmployeeName + ")"); }
  404. s = BindSelect5();
  405. 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];
  406. ///获取员工奖罚
  407. //s = "";
  408. //str = new StringBuilder();
  409. //dt = new DataTable();
  410. //str.Append(" Rp_RPDatetime>='" + StartTime + "' and Rp_RPDatetime<='" + EndTime + " 23:59:59.000' and Rp_Status='已执行'");
  411. //if (!string.IsNullOrEmpty(cbx_PaymentType.Text.Trim()))
  412. //{
  413. // strWhereTime += " and Rp_Type = '" + cbx_PaymentType.Tag + "'";
  414. //}
  415. //if (EmployeeName != null && !string.IsNullOrEmpty(EmployeeName))
  416. //{ str.Append(" and Rp_RelevantPeople in (" + EmployeeName + ")"); }
  417. //s = BindSelect6();
  418. //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];
  419. /////获取员工支出
  420. //s = "";
  421. //str = new StringBuilder();
  422. //dt = new DataTable();
  423. //str.Append(" Oiae_IEDatetime>='" + StartTime + "' and Oiae_IEDatetime<='" + EndTime + " 23:59:59.000' and (Oiae_Type='支出' or Oiae_Type='财务支出')");
  424. //if (!string.IsNullOrEmpty(cbx_PaymentType.Text.Trim()))
  425. //{
  426. // str.Append(" and Oiae_ProjectName = '-1'");
  427. //}
  428. //if (!string.IsNullOrEmpty(cbx_PaymentType.Text.Trim()))
  429. //{
  430. // str.Append(" and Oiae_PaymentMethod = '" + cbx_PaymentType.Tag + "'");
  431. //}
  432. //if (EmployeeName != null && !string.IsNullOrEmpty(EmployeeName))
  433. //{ str.Append(" and Oiae_ThePayer in (" + EmployeeName + ")"); }
  434. //s = BindSelect7();
  435. //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];
  436. ///订单付款数据情况
  437. //List<string> payOrderList = new List<string>();
  438. //payOrderList.AddRange(preOrder.AsEnumerable().Select(p => p.Field<string>("Ord_Number")).ToList());
  439. //payOrderList.AddRange(lastOrder.AsEnumerable().Select(p => p.Field<string>("订单号")).ToList());
  440. //string paySql = @"SELECT
  441. // Pay_OrdNumber,
  442. // Pay_Category,
  443. // c2.Sc_ClassName,
  444. // Pay_TwoPinsCategory,
  445. // Pay_OpenSingle,
  446. // c1.Sc_ClassName as Sc_ClassName1,
  447. // Pay_AmountOf,
  448. // Pay_CreateDatetime,
  449. // Pay_ThePayee,
  450. // Pay_ReceivableProject,
  451. // Pay_CommissionRatio
  452. // FROM [tb_ErpPayment] inner join tb_ErpSystemCategory c1 on Pay_PaymentMethod = c1.Sc_ClassCode
  453. // left join tb_ErpSystemCategory c2 on Pay_TwoPinsCategory = c2.Sc_ClassCode
  454. // where Pay_OrdNumber in ('" + string.Join("','", payOrderList.ToArray()) + @"')";
  455. //payData = Orderbll.GetView_Custom(paySql).Tables[0];
  456. ///会员充值
  457. s = "";
  458. str = new StringBuilder();
  459. dt = new DataTable();
  460. str.Append(" Mcrr_CreateDatetime>='" + StartTime + "' and Mcrr_CreateDatetime<='" + EndTime + " 23:59:59.000' ");
  461. if (EmployeeName != null && !string.IsNullOrEmpty(EmployeeName))
  462. {
  463. //str.Append(" and Mcrr_OrderPerson in (" + EmployeeName + ")");
  464. string[] userNumbers = EmployeeName.Split(',');
  465. string strWhere = "";
  466. foreach(string employeeKey in userNumbers)
  467. {
  468. if(!string.IsNullOrEmpty(strWhere))
  469. {
  470. strWhere += " or ";
  471. }
  472. strWhere += " (Mcrr_OrderPerson like '%" + employeeKey.Replace("'","") + "%' or Mcrr_CommissionRatio like '%" + employeeKey.Replace("'", "") + "%' )";
  473. }
  474. str.Append(" and ("+ strWhere + ")");
  475. }
  476. if (!string.IsNullOrEmpty(cbx_PaymentType.Text.Trim()))
  477. {
  478. str.Append(" and Mcrr_PaymentMethod = '" + cbx_PaymentType.Tag + "'");
  479. }
  480. s = BindSelect8();
  481. string memberSql = @" select 'MCRR'+convert(varchar(50),tb_ErpMemberCardRechargeRecord.id) as id,
  482. Mcrr_RechargeNumber,Mcrr_RechargeAmount,c1.Sc_ClassName,Mcrr_RechargeName,
  483. tb_ErpCustomer.Cus_Name,Cus_Telephone,Mcrr_OrderPerson,Mcrr_CreateName,Mcrr_CreateDatetime,Mcrr_CommissionRatio
  484. from
  485. [tb_ErpMemberCardRechargeRecord]
  486. left join
  487. tb_ErpSystemCategory c1 on Mcrr_PaymentMethod = c1.Sc_ClassCode
  488. left join
  489. tb_ErpMemberCard on Mcrr_Number = Mc_Number
  490. left join
  491. tb_ErpCustomer on Cus_CustomerNumber = Mc_CustomerNumber";
  492. memberSql += " where " + str + s;
  493. mamberOrder = Orderbll.GetView_Custom(memberSql).Tables[0];
  494. ///服务卡充值
  495. s = "";
  496. str = new StringBuilder();
  497. dt = new DataTable();
  498. str.Append(" Mcpt_CreateDatetime>='" + StartTime + "' and Mcpt_CreateDatetime<='" + EndTime + " 23:59:59.000' ");
  499. if (!string.IsNullOrEmpty(cbx_PaymentType.Text.Trim()))
  500. {
  501. str.Append(" and (Mcpt_PaymentMethod = '" + cbx_PaymentType.Tag + "' )");
  502. }
  503. if (EmployeeName != null && !string.IsNullOrEmpty(EmployeeName))
  504. {
  505. //str.Append(" and Mcrr_OrderPerson in (" + EmployeeName + ")");
  506. string[] userNumbers = EmployeeName.Split(',');
  507. string strWhere = "";
  508. foreach (string employeeKey in userNumbers)
  509. {
  510. if (!string.IsNullOrEmpty(strWhere))
  511. {
  512. strWhere += " or ";
  513. }
  514. strWhere += " (Mcpt_OrderPerson like '%" + employeeKey.Replace("'", "") + "%' or Mcpt_CommissionRatio like '%"+ employeeKey.Replace("'", "") + "%' )";
  515. }
  516. str.Append(" and (" + strWhere + ")");
  517. }
  518. s = BindSelect9();
  519. string memberServiceSql = @"
  520. SELECT
  521. 'MCPT'+convert(varchar(50),tb_ErpMemberCardPayment.id) as id,
  522. tb_ErpCustomer.Cus_Name,Cus_Telephone,
  523. Mcpt_PaymentNumber,
  524. Mcpt_OrderPerson,
  525. Mcpt_PaymentType,
  526. c1.Sc_ClassName ,
  527. Mcpt_PaymentAmount,
  528. Mcpt_CreateDatetime,
  529. Mcpt_CreateName,
  530. Mcpt_CommissionRatio
  531. FROM tb_ErpMemberCardPayment left join tb_ErpSystemCategory c1 on Mcpt_PaymentMethod = c1.Sc_ClassCode
  532. left join
  533. tb_ErpMemberCard on tb_ErpMemberCardPayment.mcpt_Number = Mc_Number
  534. left join
  535. tb_ErpCustomer on Cus_CustomerNumber = Mc_CustomerNumber ";
  536. memberServiceSql += " where " + str + s;
  537. mamberServiceOrder = Orderbll.GetView_Custom(memberServiceSql).Tables[0];
  538. ///前期订单数据
  539. List<DataRow> drList = PerDt.AsEnumerable().Where(p => p.Field<int>("Cp_ProportionType") == 1).ToList();
  540. DataRow mainDr = PerDt.NewRow();
  541. DataRow deputyDr = PerDt.NewRow();
  542. if (drList.Count > 0)
  543. {
  544. mainDr = drList.Where(p => p.Field<string>("Cp_ProportionCode") == "MainStoreProportion").First();
  545. deputyDr = drList.Where(p => p.Field<string>("Cp_ProportionCode") == "DeputyStoreProportion").First();
  546. }
  547. List<DataRow> payListData = payData.AsEnumerable().Where(p => p.Field<string>("Pay_TwoPinsCategory") == "").ToList();
  548. GetUserOrderDataByDynamicList(ref dyUserList, preOrder, "Ord_OrderPersonNumber", "Ord_Number", "Pay_OrdNumber", "Pay_CommissionRatio"
  549. , "订单前期", mainDr, deputyDr, payListData);
  550. ///后期订单数据
  551. drList = PerDt.AsEnumerable().Where(p => p.Field<int>("Cp_ProportionType") == 5).ToList();
  552. mainDr = PerDt.NewRow();
  553. deputyDr = PerDt.NewRow();
  554. if (drList.Count > 0)
  555. {
  556. mainDr = drList.Where(p => p.Field<string>("Cp_ProportionCode") == "MainLaterOtherTwoSales").First();
  557. deputyDr = drList.Where(p => p.Field<string>("Cp_ProportionCode") == "DeputyLaterOtherTwoSales").First();
  558. }
  559. payListData = payData.AsEnumerable().Where(p => p.Field<string>("Pay_TwoPinsCategory") != "").ToList();
  560. GetUserOrderDataByDynamicList(ref dyUserList, lastOrder, "销售人员编号", "订单号", "Pay_OrdNumber", "Pay_CommissionRatio", "订单后期", mainDr, deputyDr, payListData);
  561. ///其他消费数据
  562. drList = PerDt.AsEnumerable().Where(p => p.Field<int>("Cp_ProportionType") == 5).ToList();
  563. mainDr = PerDt.NewRow();
  564. deputyDr = PerDt.NewRow();
  565. if (drList.Count > 0)
  566. {
  567. mainDr = drList.Where(p => p.Field<string>("Cp_ProportionCode") == "MainLaterOtherTwoSales").First();
  568. deputyDr = drList.Where(p => p.Field<string>("Cp_ProportionCode") == "DeputyLaterOtherTwoSales").First();
  569. }
  570. GetUserOrderDataByDynamicList(ref dyUserList, otherOrder, "Tsorder_OpenSingle", "Tsorder_Number","","", "其他消费", mainDr, deputyDr);
  571. ///计件提成数据
  572. //mainDr = PerDt.NewRow();
  573. //deputyDr = PerDt.NewRow();
  574. //GetUserOrderDataByDynamicList(ref dyUserList, pieceworkOrder, "Pcr_DigitalDivision", "Pcr_OrderNumber", "", "", "计件提成", mainDr, deputyDr);
  575. ///礼服租售数据
  576. mainDr = PerDt.NewRow();
  577. deputyDr = PerDt.NewRow();
  578. payListData = dressServiceOrder.AsEnumerable().ToList();
  579. GetUserOrderDataByDynamicList(ref dyUserList, dressOrder, "Dsro_CreateName", "Dsro_Number", "Pay_OrdNumber", "", "礼服租售", mainDr, deputyDr, payListData);
  580. ///员工奖罚
  581. //mainDr = PerDt.NewRow();
  582. //deputyDr = PerDt.NewRow();
  583. //GetUserOrderDataByDynamicList(ref dyUserList, rewardOrder, "Rp_RelevantPeople", "ID", "", "", "员工奖罚", mainDr, deputyDr);
  584. /////员工支出
  585. //mainDr = PerDt.NewRow();
  586. //deputyDr = PerDt.NewRow();
  587. //GetUserOrderDataByDynamicList(ref dyUserList, paymentOrder, "Oiae_ThePayer", "ID", "", "", "员工支出", mainDr, deputyDr);
  588. ///会员充值
  589. mainDr = PerDt.NewRow();
  590. deputyDr = PerDt.NewRow();
  591. GetUserOrderDataByDynamicList(ref dyUserList, mamberOrder, "Mcrr_OrderPerson", "id", "", "", "会员充值", mainDr, deputyDr);
  592. ///会员服务充值
  593. mainDr = PerDt.NewRow();
  594. deputyDr = PerDt.NewRow();
  595. GetUserOrderDataByDynamicList(ref dyUserList, mamberServiceOrder, "Mcpt_OrderPerson", "id", "", "", "会员服务充值", mainDr, deputyDr);
  596. }
  597. catch (Exception ex)
  598. {
  599. MessageBoxCustom.Show(String.Format("查询数据时出错:{0}",ex.Message));
  600. }
  601. });
  602. this.dgv.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.None;
  603. this.dgv.Rows.Clear();
  604. this.dgv.Columns.Clear();
  605. this.dgv.Columns.Add("PerformancePerson", "业绩人");
  606. this.dgv.Columns.Add("OrdNumber", "订单号");
  607. this.dgv.Columns.Add("CusName", "客户名称");
  608. this.dgv.Columns.Add("CusTelephone", "客户电话");
  609. this.dgv.Columns.Add("MoneyType", "项目类别");
  610. this.dgv.Columns.Add("PerformanceMoney", "单据金额");
  611. this.dgv.Columns.Add("PayType", "支付方式");
  612. this.dgv.Columns.Add("PayValue", "收款金额");
  613. this.dgv.Columns.Add("PayPerformance", "业绩金额");
  614. this.dgv.Columns.Add("PayPerformanceDis", "业绩分配");
  615. this.dgv.Columns.Add("PayUser", "收款人");
  616. this.dgv.Columns.Add("PayTime", "收款日");
  617. this.dgv.Columns.Add("PayName", "收款名称");
  618. this.dgv.Columns[1].Width = 180;
  619. this.dgv.Columns[11].Width = 150;
  620. this.dgv.Columns[9].Width = 300;
  621. this.dgv.Columns[8].Width = 150;
  622. foreach(DataGridViewColumn dataColumn in this.dgv.Columns)
  623. {
  624. dataColumn.SortMode = DataGridViewColumnSortMode.NotSortable;
  625. }
  626. DataGridViewRow dgRow = null;
  627. //业绩
  628. decimal CurrentPerformance = 0;
  629. //计件
  630. decimal PieceCommission = 0;
  631. //奖励
  632. decimal Reward = 0;
  633. //罚款
  634. decimal Fine = 0;
  635. //支出
  636. decimal Expenditure = 0;
  637. //总实收业绩
  638. decimal TotalPerformance = 0;
  639. //前期实收
  640. decimal PreAmount = 0;
  641. //后期实收
  642. decimal LastAmount = 0;
  643. //会员充值
  644. decimal MemberAmount = 0;
  645. ///服务充值
  646. decimal ServiceAmount = 0;
  647. Dictionary<string, decimal> dicCurrentPerformance = new Dictionary<string, decimal>();
  648. Dictionary<string, decimal> dicTotalPerformance = new Dictionary<string, decimal>();
  649. Dictionary<string, decimal> dicPreAmount = new Dictionary<string, decimal>();
  650. Dictionary<string, decimal> dicLastAmount = new Dictionary<string, decimal>();
  651. foreach (string key in dyUserList.Keys)
  652. {
  653. if(!EmployeeName.Contains(key))
  654. {
  655. continue;
  656. }
  657. dgRow = new DataGridViewRow();
  658. dgRow.CreateCells(this.dgv);
  659. dgRow.Cells[0].Style = GetDataGridViewCellStyle(System.Drawing.Color.White, DataGridViewContentAlignment.MiddleLeft);
  660. dgRow.Cells[1].Style = dgRow.Cells[0].Style;
  661. dgRow.Cells[2].Style = dgRow.Cells[0].Style;
  662. dgRow.Cells[3].Style = dgRow.Cells[0].Style;
  663. dgRow.Cells[4].Style = dgRow.Cells[0].Style;
  664. dgRow.Cells[5].Style = dgRow.Cells[0].Style;
  665. dgRow.Cells[6].Style = dgRow.Cells[0].Style;
  666. dgRow.Cells[7].Style = dgRow.Cells[0].Style;
  667. dgRow.Cells[8].Style = dgRow.Cells[0].Style;
  668. dgRow.Cells[9].Style = dgRow.Cells[0].Style;
  669. dgRow.Cells[10].Style = dgRow.Cells[0].Style;
  670. dgRow.Cells[11].Style = dgRow.Cells[0].Style;
  671. dgRow.Cells[12].Style = dgRow.Cells[0].Style;
  672. string[] StrRowValueList = key.ToString().Trim().Split(',');
  673. string keyName = "";
  674. foreach (string StrRowValue in StrRowValueList)
  675. {
  676. if (!string.IsNullOrEmpty(StrRowValue))
  677. {
  678. DataRow dtRows = LYFZ.DAL.DAL_ErpUser.SimpleUserDataTable.Rows.Find(StrRowValue);
  679. if(!string.IsNullOrEmpty(keyName))
  680. {
  681. keyName += ",";
  682. }
  683. if (dtRows != null)
  684. {
  685. keyName += dtRows["User_Name"].ToString().Trim();
  686. }
  687. else
  688. {
  689. keyName += "";
  690. }
  691. }
  692. }
  693. dgRow.Cells[0].Value = keyName;
  694. this.dgv.Rows.Add(dgRow);
  695. Dictionary<string, List<dynamic>> ordDataList = dyUserList[key];
  696. int index = 0;
  697. foreach (string subKey in ordDataList.Keys)
  698. {
  699. index++;
  700. List<dynamic> ordDyList = ordDataList[subKey];
  701. DataGridViewRow tempDr = dgRow;
  702. foreach (dynamic ordDy in ordDyList)
  703. {
  704. if(ordDy.业绩金额 == "付款"&& index==1)
  705. {
  706. index++;
  707. }
  708. if(index>1)
  709. {
  710. if (tempDr.Cells[6].Value.ToString()=="合计")
  711. {
  712. IDictionary<string, object> idicObj = ordDy;
  713. //this.dgv.Rows.Add(GetSubDataGridViewRow(subKey, dgRow, ordDy, index, ordDyList.Count == index));
  714. tempDr.Cells[6].Value = idicObj["支付方式"];
  715. tempDr.Cells[7].Value = idicObj["收款金额"];
  716. tempDr.Cells[9].Value = idicObj["业绩描述"];
  717. tempDr.Cells[8].Value = idicObj["业绩分配"];
  718. tempDr.Cells[10].Value = idicObj["收款人"];
  719. tempDr.Cells[11].Value = idicObj["收款日"].ToString();
  720. tempDr.Cells[12].Value = idicObj["收款名称"];
  721. }
  722. else
  723. {
  724. this.dgv.Rows.Add(GetSubDataGridViewRow(subKey, dgRow, ordDy, index, ordDyList.Count == index));
  725. IDictionary<string, object> idicObj = ordDy;
  726. if (idicObj["支付方式"].ToString()== "合计")
  727. {
  728. tempDr = this.dgv.Rows[this.dgv.Rows.Count - 1];
  729. }
  730. else
  731. {
  732. 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() == "订单后期"
  733. || this.dgv.Rows[this.dgv.Rows.Count - 1].Cells["MoneyType"].Value.ToString_s() == "礼服租售")
  734. {
  735. this.dgv.Rows[this.dgv.Rows.Count - 1].Cells[5].Value = tempDr.Cells["PerformanceMoney"].Value;
  736. this.dgv.Rows[this.dgv.Rows.Count - 1].Cells[2].Value = tempDr.Cells["CusName"].Value;
  737. this.dgv.Rows[this.dgv.Rows.Count - 1].Cells[3].Value = tempDr.Cells["CusTelephone"].Value;
  738. }
  739. }
  740. if (ordDyList.Where(p => p.业绩金额 == "付款").ToList().Count==0)
  741. {
  742. if (tempDr.Cells[6].Value.ToString() == "合计")
  743. {
  744. tempDr.Cells[6].Value = "";
  745. }
  746. }
  747. this.dgv.Rows[this.dgv.Rows.Count - 1].Cells[0].Value = keyName;
  748. }
  749. }
  750. else
  751. {
  752. GetSubDataGridViewRow(subKey, dgRow, ordDy, index, ordDyList.Count == index);
  753. }
  754. }
  755. ///业绩
  756. //CurrentPerformance += ordDyList.Where(p=>p.收款类型== "订单前期" || p.收款类型 == "订单后期"
  757. // || p.收款类型 == "其他消费" || p.收款类型 == "礼服租售").Sum(p => Convert.ToInt32(p.业绩额));
  758. foreach(dynamic dyObj in ordDyList.Where(p => p.收款类型 == "订单前期" || p.收款类型 == "订单后期" || p.收款类型 == "其它消费" || p.收款类型 == "礼服租售"
  759. || p.收款类型 == "会员充值" || p.收款类型 == "会员服务充值"))
  760. {
  761. if(!dicCurrentPerformance.ContainsKey(dyObj.自定义订单号.ToString() + dyObj.收款类型.ToString()+ dyObj.收款日.ToString()))
  762. {
  763. dicCurrentPerformance.Add(dyObj.自定义订单号.ToString()+ dyObj.收款类型.ToString() + dyObj.收款日.ToString(), dyObj.收款金额);
  764. }
  765. }
  766. //计件提成
  767. PieceCommission += ordDyList.Where(p => p.收款类型 == "计件提成").Sum(p => Convert.ToInt32(p.业绩额));
  768. //员工支出
  769. Expenditure += ordDyList.Where(p => p.收款类型 == "员工支出").Sum(p => Convert.ToInt32(p.业绩额));
  770. //员工奖罚
  771. Reward += ordDyList.Where(p => p.收款类型 == "员工奖罚" && p.支付方式== "奖励").Sum(p => Convert.ToInt32(p.业绩额));
  772. Fine += ordDyList.Where(p => p.收款类型 == "员工奖罚" && p.支付方式 == "惩罚").Sum(p => Convert.ToInt32(p.业绩额));
  773. //TotalPerformance += ordDyList.Where(p => p.收款类型 == "订单前期收款" || p.收款类型 == "订单后期收款"
  774. // || p.收款类型 == "其他消费收款" || p.收款类型 == "礼服租售收款")
  775. // .Sum(p => Convert.ToInt32(p.业绩金额));
  776. //foreach (dynamic dyObj in ordDyList.Where(p => p.收款类型 == "订单前期收款" || p.收款类型 == "订单后期收款"
  777. // || p.收款类型 == "其他消费收款" || p.收款类型 == "礼服租售收款"))
  778. //{
  779. // if (!dicTotalPerformance.ContainsKey(dyObj.自定义订单号.ToString() + dyObj.收款类型.ToString() + dyObj.收款日.ToString()))
  780. // {
  781. // dicTotalPerformance.Add(dyObj.自定义订单号.ToString() + dyObj.收款类型.ToString() + dyObj.收款日.ToString(), dyObj.收款金额);
  782. // }
  783. //}
  784. //PreAmount += ordDyList.Where(p => p.收款类型 == "订单前期收款" ).Sum(p => Convert.ToInt32(p.收款金额));
  785. foreach (dynamic dyObj in ordDyList.Where(p => p.收款类型 == "订单前期收款"))
  786. {
  787. if (!dicPreAmount.ContainsKey(dyObj.自定义订单号.ToString() + dyObj.收款类型.ToString() + dyObj.收款日.ToString()))
  788. {
  789. dicPreAmount.Add(dyObj.自定义订单号.ToString() + dyObj.收款类型.ToString() + dyObj.收款日.ToString(), dyObj.收款金额);
  790. }
  791. }
  792. //LastAmount += ordDyList.Where(p => p.收款类型 == "订单后期收款").Sum(p => Convert.ToInt32(p.收款金额));
  793. foreach (dynamic dyObj in ordDyList.Where(p => p.收款类型 == "订单后期收款"))
  794. {
  795. if (!dicLastAmount.ContainsKey(dyObj.自定义订单号.ToString() + dyObj.收款类型.ToString() + dyObj.收款日.ToString()))
  796. {
  797. dicLastAmount.Add(dyObj.自定义订单号.ToString() + dyObj.收款类型.ToString() + dyObj.收款日.ToString(), dyObj.收款金额);
  798. }
  799. }
  800. MemberAmount += ordDyList.Where(p => p.收款类型 == "会员充值").Sum(p => Convert.ToInt32(p.业绩额));
  801. ServiceAmount += ordDyList.Where(p => p.收款类型 == "会员服务充值").Sum(p => Convert.ToInt32(p.业绩额));
  802. }
  803. }
  804. Dictionary<string, decimal> dicPayTypeList = new Dictionary<string, decimal>();
  805. dicPayTypeList.Add("订单前期", 0);
  806. dicPayTypeList.Add("订单后期", 0);
  807. dicPayTypeList.Add("其它消费", 0);
  808. dicPayTypeList.Add("礼服租售", 0);
  809. dicPayTypeList.Add("会员充值", 0);
  810. dicPayTypeList.Add("会员服务充值", 0);
  811. Dictionary<string, decimal> dicStoreTypeList = new Dictionary<string, decimal>();
  812. dicStoreTypeList.Add("订单前期", 0);
  813. dicStoreTypeList.Add("订单后期", 0);
  814. dicStoreTypeList.Add("其它消费", 0);
  815. dicStoreTypeList.Add("礼服租售", 0);
  816. dicStoreTypeList.Add("会员充值", 0);
  817. dicStoreTypeList.Add("会员服务充值", 0);
  818. decimal storedValue = 0;
  819. foreach (DataGridViewRow dgvr in this.dgv.Rows)
  820. {
  821. TotalPerformance += Convert.ToDecimal(dgvr.Cells["PayPerformance"].Value.ToString_s()==""?"0": dgvr.Cells["PayPerformance"].Value.ToString_s());
  822. if(dgvr.Cells["PayType"].Value.ToString_s()=="储值卡扣款")
  823. {
  824. storedValue += Convert.ToDecimal(dgvr.Cells["PayPerformance"].Value.ToString_s() == "" ? "0" : dgvr.Cells["PayPerformance"].Value.ToString_s());
  825. }
  826. if(dicPayTypeList.ContainsKey(dgvr.Cells["MoneyType"].Value.ToString_s()))
  827. {
  828. dicPayTypeList[dgvr.Cells["MoneyType"].Value.ToString_s()] += Convert.ToDecimal(dgvr.Cells["PayPerformance"].Value.ToString_s() == "" ? "0" : dgvr.Cells["PayPerformance"].Value.ToString_s());
  829. if (dgvr.Cells["PayType"].Value.ToString_s() == "储值卡扣款")
  830. {
  831. if (dicStoreTypeList.ContainsKey(dgvr.Cells["MoneyType"].Value.ToString_s()))
  832. {
  833. dicStoreTypeList[dgvr.Cells["MoneyType"].Value.ToString_s()] += Convert.ToDecimal(dgvr.Cells["PayPerformance"].Value.ToString_s() == "" ? "0" : dgvr.Cells["PayPerformance"].Value.ToString_s());
  834. }
  835. }
  836. }
  837. }
  838. DataTable gridDataTable = DataGriwViewToDataTable(dgv);
  839. dgv.Rows.Clear();
  840. foreach(string key in dicPayTypeList.Keys)
  841. {
  842. List<DataRow> drList = gridDataTable.AsEnumerable().Where(p => p.Field<string>("MoneyType") == key).ToList();
  843. if (drList.Count > 0)
  844. {
  845. dgRow = new DataGridViewRow();
  846. dgRow.CreateCells(this.dgv);
  847. dgRow.Cells[0].Style = GetDataGridViewCellStyle(System.Drawing.Color.LightCyan, DataGridViewContentAlignment.MiddleLeft);
  848. dgRow.Cells[1].Style = dgRow.Cells[0].Style;
  849. dgRow.Cells[2].Style = dgRow.Cells[0].Style;
  850. dgRow.Cells[3].Style = dgRow.Cells[0].Style;
  851. dgRow.Cells[4].Style = dgRow.Cells[0].Style;
  852. dgRow.Cells[5].Style = dgRow.Cells[0].Style;
  853. dgRow.Cells[6].Style = dgRow.Cells[0].Style;
  854. dgRow.Cells[7].Style = dgRow.Cells[0].Style;
  855. dgRow.Cells[8].Style = dgRow.Cells[0].Style;
  856. dgRow.Cells[9].Style = dgRow.Cells[0].Style;
  857. dgRow.Cells[10].Style = dgRow.Cells[0].Style;
  858. dgRow.Cells[11].Style = dgRow.Cells[0].Style;
  859. dgRow.Cells[12].Style = dgRow.Cells[0].Style;
  860. dgRow.Cells[0].Value = key;
  861. //dgRow.Cells[0].Style = new DataGridViewCellStyle() { ForeColor = Color.Red };
  862. dgv.Rows.Add(dgRow);
  863. foreach (DataRow dr in drList)
  864. {
  865. dgRow = new DataGridViewRow();
  866. dgRow.CreateCells(this.dgv);
  867. dgRow.Cells[0].Style = GetDataGridViewCellStyle(System.Drawing.Color.White, DataGridViewContentAlignment.MiddleLeft);
  868. dgRow.Cells[1].Style = dgRow.Cells[0].Style;
  869. dgRow.Cells[2].Style = dgRow.Cells[0].Style;
  870. dgRow.Cells[3].Style = dgRow.Cells[0].Style;
  871. dgRow.Cells[4].Style = dgRow.Cells[0].Style;
  872. dgRow.Cells[5].Style = dgRow.Cells[0].Style;
  873. dgRow.Cells[6].Style = dgRow.Cells[0].Style;
  874. dgRow.Cells[7].Style = dgRow.Cells[0].Style;
  875. dgRow.Cells[8].Style = dgRow.Cells[0].Style;
  876. dgRow.Cells[9].Style = dgRow.Cells[0].Style;
  877. dgRow.Cells[10].Style = dgRow.Cells[0].Style;
  878. dgRow.Cells[11].Style = dgRow.Cells[0].Style;
  879. dgRow.Cells[12].Style = dgRow.Cells[0].Style;
  880. for (int columnIndex =0; columnIndex < dgv.Columns.Count; columnIndex++)
  881. {
  882. dgRow.Cells[columnIndex].Value = dr[dgv.Columns[columnIndex].Name];
  883. }
  884. dgv.Rows.Add(dgRow);
  885. }
  886. }
  887. }
  888. PreAmount = dicPreAmount.Values.Sum();
  889. LastAmount = dicLastAmount.Values.Sum();
  890. txtCurrentUserPerformance.Text = "总业绩:" + TotalPerformance.ToString("N2")+" (其中储值卡扣款:"+ storedValue + ")";
  891. string paymentData = "";
  892. foreach(string key in dicPayTypeList.Keys)
  893. {
  894. if (dicPayTypeList[key] > 0)
  895. {
  896. if (!string.IsNullOrEmpty(paymentData))
  897. {
  898. paymentData += ",";
  899. }
  900. paymentData += key + ":" + dicPayTypeList[key].ToString("N2")+(dicStoreTypeList[key]>0? "(其中储值卡扣款:" + dicStoreTypeList[key] + ")":"");
  901. }
  902. }
  903. this.tb_DetailPerformance.Text = paymentData;
  904. //this.tb_PreAmount.Text = PreAmount.ToString("N2");
  905. //this.tb_LastAmount.Text = LastAmount.ToString("N2");
  906. //this.tb_MemberValue.Text = MemberAmount.ToString("N2");
  907. this.dgv.ClearSelection();
  908. #region 注释掉的代码
  909. /*
  910. #region 获取订单前期业绩
  911. str.Append(" Ord_CreateDateTime>='" + StartTime + "' and Ord_CreateDateTime<='" + EndTime + " 23:59:59.000' and Ord_Class='1'");
  912. if (EmployeeName != null && !string.IsNullOrEmpty(EmployeeName))
  913. { str.Append(" and Ord_OrderPersonNumber like '%" + EmployeeName + "%'"); }
  914. s = BindSelect1();
  915. LYFZ.ComponentLibrary.FrmLoadHandling.LoadDoWorkMethod(delegate(object obj, BackgroundWorker backgroundWorker)
  916. {
  917. 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];
  918. if (dt.Rows.Count > 0)
  919. {
  920. this.Invoke(new LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.UpdateControl(delegate ()
  921. {
  922. List<DataRow> drList = PerDt.AsEnumerable().Where(p => p.Field<int>("Cp_ProportionType") == 1).ToList();
  923. DataRow mainDr = PerDt.NewRow();
  924. DataRow deputyDr = PerDt.NewRow();
  925. if (drList.Count > 0)
  926. {
  927. mainDr = drList.Where(p => p.Field<string>("Cp_ProportionCode") == "MainStoreProportion").First();
  928. deputyDr = drList.Where(p => p.Field<string>("Cp_ProportionCode") == "DeputyStoreProportion").First();
  929. }
  930. for (int t = 0; t < dt.Rows.Count; t++)
  931. {
  932. DataGridViewRow dgvr = new DataGridViewRow();
  933. DataGridViewCell cell = null;
  934. //订单号
  935. cell = new DataGridViewTextBoxCell();
  936. cell.Value = dt.Rows[t]["Ord_Number"].ToString().Trim();
  937. dgvr.Cells.Add(cell);
  938. //员工
  939. cell = new DataGridViewTextBoxCell();
  940. cell.Value = dt.Rows[t]["Ord_OrderPersonName"].ToString().Trim();
  941. dgvr.Cells.Add(cell);
  942. //客户姓名
  943. cell = new DataGridViewTextBoxCell();
  944. cell.Value = dt.Rows[t]["Cus_Name"].ToString().Trim();
  945. dgvr.Cells.Add(cell);
  946. //业绩金额
  947. cell = new DataGridViewTextBoxCell();
  948. cell.Value = GetAchievement(
  949. Convert.ToDecimal(dt.Rows[t]["Ord_SeriesPrice"]),
  950. dt.Rows[t]["Ord_OrderPersonNumber"].ToString(),
  951. EmployeeName, mainDr, deputyDr).ToString("N2");//Convert.ToDecimal(dt.Rows[t]["Ord_SeriesPrice"]).ToString("N2");
  952. dgvr.Cells.Add(cell);
  953. //创建时间
  954. cell = new DataGridViewTextBoxCell();
  955. cell.Value = dt.Rows[t]["Ord_CreateDatetime"].ToString().Trim();
  956. dgvr.Cells.Add(cell);
  957. //套系类别
  958. cell = new DataGridViewTextBoxCell();
  959. cell.Value = dt.Rows[t]["Ord_PhotographyCategory"].ToString().Trim();
  960. dgvr.Cells.Add(cell);
  961. //套系名称
  962. cell = new DataGridViewTextBoxCell();
  963. cell.Value = dt.Rows[t]["Ord_SeriesName"].ToString().Trim();
  964. dgvr.Cells.Add(cell);
  965. //项目名称
  966. cell = new DataGridViewTextBoxCell();
  967. cell.Value = "订单前期业绩";
  968. dgvr.Cells.Add(cell);
  969. this.dgv.Rows.Add(dgvr);
  970. }
  971. dgv.ClearSelection();
  972. }));
  973. }
  974. });
  975. #endregion
  976. #region 获取订单后期业绩
  977. s = "";
  978. str = new StringBuilder();
  979. dt = new DataTable();
  980. str.Append(" 创建时间>='" + StartTime + "' and 创建时间<='" + EndTime + " 23:59:59.000'");
  981. if (EmployeeName != null && !string.IsNullOrEmpty(EmployeeName))
  982. { str.Append(" and 销售人员编号 like '%" + EmployeeName + "%'"); }
  983. s = BindSelect2();
  984. LYFZ.ComponentLibrary.FrmLoadHandling.LoadDoWorkMethod(delegate(object obj, BackgroundWorker backgroundWorker)
  985. {
  986. List<DataRow> drList = PerDt.AsEnumerable().Where(p => p.Field<int>("Cp_ProportionType") == 5).ToList();
  987. DataRow mainDr = PerDt.NewRow();
  988. DataRow deputyDr = PerDt.NewRow();
  989. if (drList.Count > 0)
  990. {
  991. mainDr = drList.Where(p => p.Field<string>("Cp_ProportionCode") == "MainLaterOtherTwoSales").First();
  992. deputyDr = drList.Where(p => p.Field<string>("Cp_ProportionCode") == "DeputyLaterOtherTwoSales").First();
  993. }
  994. dt = Orderbll.GetView_Custom("Vw_ErpPlusPickItems", StrWhere: str.ToString() + s.ToString(), ShowColumnName: "ID,订单号,金额,创建时间,商品名称,录单人编号,录单人名称,商品成本价,加挑金额来源类型,销售人员编号,销售人员名称,二销类别编号,二销类别名称,客户名称,拼音,电话,套系类别").Tables[0];
  995. if (dt.Rows.Count > 0)
  996. {
  997. this.Invoke(new LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.UpdateControl(delegate ()
  998. {
  999. for (int t = 0; t < dt.Rows.Count; t++)
  1000. {
  1001. DataGridViewRow dgvr = new DataGridViewRow();
  1002. DataGridViewCell cell = null;
  1003. //订单号
  1004. cell = new DataGridViewTextBoxCell();
  1005. cell.Value = dt.Rows[t]["订单号"].ToString().Trim();
  1006. dgvr.Cells.Add(cell);
  1007. //员工
  1008. cell = new DataGridViewTextBoxCell();
  1009. cell.Value = dt.Rows[t]["销售人员名称"].ToString().Trim();
  1010. dgvr.Cells.Add(cell);
  1011. //客户姓名
  1012. cell = new DataGridViewTextBoxCell();
  1013. cell.Value = dt.Rows[t]["客户名称"].ToString().Trim();
  1014. dgvr.Cells.Add(cell);
  1015. //业绩金额
  1016. cell = new DataGridViewTextBoxCell();
  1017. cell.Value = GetAchievement(
  1018. Convert.ToDecimal(dt.Rows[t]["金额"]),
  1019. dt.Rows[t]["销售人员编号"].ToString(),
  1020. EmployeeName, mainDr, deputyDr).ToString("N2"); //Convert.ToDecimal(dt.Rows[t]["金额"]).ToString("N2");
  1021. dgvr.Cells.Add(cell);
  1022. //创建时间
  1023. cell = new DataGridViewTextBoxCell();
  1024. cell.Value = dt.Rows[t]["创建时间"].ToString().Trim();
  1025. dgvr.Cells.Add(cell);
  1026. //套系类别
  1027. cell = new DataGridViewTextBoxCell();
  1028. cell.Value = dt.Rows[t]["二销类别名称"].ToString().Trim();
  1029. dgvr.Cells.Add(cell);
  1030. //套系名称
  1031. cell = new DataGridViewTextBoxCell();
  1032. cell.Value = dt.Rows[t]["商品名称"].ToString().Trim();
  1033. dgvr.Cells.Add(cell);
  1034. //项目名称
  1035. cell = new DataGridViewTextBoxCell();
  1036. cell.Value = "订单后期业绩";
  1037. dgvr.Cells.Add(cell);
  1038. this.dgv.Rows.Add(dgvr);
  1039. }
  1040. dgv.ClearSelection();
  1041. }));
  1042. }
  1043. });
  1044. #endregion
  1045. #region 获取其它消费
  1046. s = "";
  1047. str = new StringBuilder();
  1048. dt = new DataTable();
  1049. str.Append(" Tsorder_CreateDatetime>='" + StartTime + "' and Tsorder_CreateDatetime<='" + EndTime + " 23:59:59.000'");
  1050. if (EmployeeName != null && !string.IsNullOrEmpty(EmployeeName))
  1051. { str.Append(" and Tsorder_OpenSingle like '%" + EmployeeName + "%'"); }
  1052. s = BindSelect3();
  1053. LYFZ.ComponentLibrary.FrmLoadHandling.LoadDoWorkMethod(delegate(object obj, BackgroundWorker backgroundWorker)
  1054. {
  1055. List<DataRow> drList = PerDt.AsEnumerable().Where(p => p.Field<int>("Cp_ProportionType") == 5).ToList();
  1056. DataRow mainDr = PerDt.NewRow();
  1057. DataRow deputyDr = PerDt.NewRow();
  1058. if (drList.Count > 0)
  1059. {
  1060. mainDr = drList.Where(p => p.Field<string>("Cp_ProportionCode") == "MainLaterOtherTwoSales").First();
  1061. deputyDr = drList.Where(p => p.Field<string>("Cp_ProportionCode") == "DeputyLaterOtherTwoSales").First();
  1062. }
  1063. // dt = AllViewSetbll.Vw_Customer_PaymentOrders(str.ToString() + s.ToString()).Tables[0];
  1064. 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];
  1065. if (dt.Rows.Count > 0)
  1066. {
  1067. this.Invoke(new LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.UpdateControl(delegate ()
  1068. {
  1069. for (int t = 0; t < dt.Rows.Count; t++)
  1070. {
  1071. DataGridViewRow dgvr = new DataGridViewRow();
  1072. DataGridViewCell cell = null;
  1073. //订单号
  1074. cell = new DataGridViewTextBoxCell();
  1075. cell.Value = dt.Rows[t]["Tsorder_Number"].ToString().Trim();
  1076. dgvr.Cells.Add(cell);
  1077. //员工
  1078. cell = new DataGridViewTextBoxCell();
  1079. cell.Value = dt.Rows[t]["User_Name"].ToString().Trim();
  1080. dgvr.Cells.Add(cell);
  1081. //客户姓名
  1082. cell = new DataGridViewTextBoxCell();
  1083. cell.Value = dt.Rows[t]["Tsorder_CustomerName"].ToString().Trim();
  1084. dgvr.Cells.Add(cell);
  1085. //业绩金额
  1086. cell = new DataGridViewTextBoxCell();
  1087. cell.Value = GetAchievement(
  1088. Convert.ToDecimal(dt.Rows[t]["Tsorder_Money"]),
  1089. dt.Rows[t]["Tsorder_OpenSingle"].ToString(),
  1090. EmployeeName, mainDr, deputyDr).ToString("N2"); //Convert.ToDecimal(dt.Rows[t]["Tsorder_Money"]).ToString("N2");
  1091. dgvr.Cells.Add(cell);
  1092. //创建时间
  1093. cell = new DataGridViewTextBoxCell();
  1094. cell.Value = dt.Rows[t]["Tsorder_CreateDatetime"].ToString().Trim();
  1095. dgvr.Cells.Add(cell);
  1096. //套系类别
  1097. cell = new DataGridViewTextBoxCell();
  1098. cell.Value = dt.Rows[t]["Tsorder_CategoryName"].ToString().Trim();
  1099. dgvr.Cells.Add(cell);
  1100. //套系名称
  1101. cell = new DataGridViewTextBoxCell();
  1102. cell.Value = dt.Rows[t]["Tsorder_Name"].ToString().Trim();
  1103. dgvr.Cells.Add(cell);
  1104. //项目名称
  1105. cell = new DataGridViewTextBoxCell();
  1106. cell.Value = "其它消费";
  1107. dgvr.Cells.Add(cell);
  1108. this.dgv.Rows.Add(dgvr);
  1109. }
  1110. dgv.ClearSelection();
  1111. }));
  1112. }
  1113. });
  1114. #endregion
  1115. #region 获取计件提成
  1116. s = "";
  1117. str = new StringBuilder();
  1118. dt = new DataTable();
  1119. str.Append(" Pcr_CreateTime>='" + StartTime + "' and Pcr_CreateTime<='" + EndTime + " 23:59:59.000'");
  1120. if (EmployeeName != null && !string.IsNullOrEmpty(EmployeeName))
  1121. { str.Append(" and Pcr_DigitalDivision like '%" + EmployeeName + "%'"); }
  1122. s = BindSelect4();
  1123. LYFZ.ComponentLibrary.FrmLoadHandling.LoadDoWorkMethod(delegate(object obj, BackgroundWorker backgroundWorker)
  1124. {
  1125. 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];
  1126. if (dt.Rows.Count > 0)
  1127. {
  1128. this.Invoke(new LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.UpdateControl(delegate()
  1129. {
  1130. for (int t = 0; t < dt.Rows.Count; t++)
  1131. {
  1132. DataGridViewRow dgvr = new DataGridViewRow();
  1133. DataGridViewCell cell = null;
  1134. //订单号
  1135. cell = new DataGridViewTextBoxCell();
  1136. cell.Value = dt.Rows[t]["Pcr_OrderNumber"].ToString().Trim();
  1137. dgvr.Cells.Add(cell);
  1138. //员工
  1139. cell = new DataGridViewTextBoxCell();
  1140. cell.Value = dt.Rows[t]["Pcr_DigitalDivisionName"].ToString().Trim();
  1141. dgvr.Cells.Add(cell);
  1142. //客户姓名
  1143. cell = new DataGridViewTextBoxCell();
  1144. cell.Value = dt.Rows[t]["Cus_Name"].ToString().Trim();
  1145. dgvr.Cells.Add(cell);
  1146. //业绩金额
  1147. cell = new DataGridViewTextBoxCell();
  1148. cell.Value = dt.Rows[t]["总价格"].ToString() == "" ? "0" : Convert.ToDecimal(dt.Rows[t]["总价格"]).ToString("N2");
  1149. dgvr.Cells.Add(cell);
  1150. //创建时间
  1151. cell = new DataGridViewTextBoxCell();
  1152. cell.Value = dt.Rows[t]["Pcr_CreateTime"].ToString().Trim();
  1153. dgvr.Cells.Add(cell);
  1154. //套系类别
  1155. cell = new DataGridViewTextBoxCell();
  1156. cell.Value = dt.Rows[t]["Pcr_CompletionContentsName"].ToString().Trim();
  1157. dgvr.Cells.Add(cell);
  1158. //套系名称
  1159. cell = new DataGridViewTextBoxCell();
  1160. cell.Value = dt.Rows[t]["Ord_SeriesName"].ToString().Trim();
  1161. dgvr.Cells.Add(cell);
  1162. //项目名称
  1163. cell = new DataGridViewTextBoxCell();
  1164. cell.Value = "计件提成";
  1165. dgvr.Cells.Add(cell);
  1166. this.dgv.Rows.Add(dgvr);
  1167. }
  1168. dgv.ClearSelection();
  1169. }));
  1170. }
  1171. });
  1172. #endregion
  1173. #region 获取礼服租售
  1174. s = "";
  1175. str = new StringBuilder();
  1176. dt = new DataTable();
  1177. str.Append(" Dsro_CreateDateTime>='" + StartTime + "' and Dsro_CreateDateTime<='" + EndTime + " 23:59:59.000' and Dsro_Type != '2'");
  1178. if (EmployeeName != null && !string.IsNullOrEmpty(EmployeeName))
  1179. { str.Append(" and Dsro_CreateName like '%" + EmployeeName + "%'"); }
  1180. s = BindSelect5();
  1181. LYFZ.ComponentLibrary.FrmLoadHandling.LoadDoWorkMethod(delegate(object obj, BackgroundWorker backgroundWorker)
  1182. {
  1183. 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];
  1184. if (dt.Rows.Count > 0)
  1185. {
  1186. this.Invoke(new LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.UpdateControl(delegate()
  1187. {
  1188. for (int t = 0; t < dt.Rows.Count; t++)
  1189. {
  1190. DataGridViewRow dgvr = new DataGridViewRow();
  1191. DataGridViewCell cell = null;
  1192. //订单号
  1193. cell = new DataGridViewTextBoxCell();
  1194. cell.Value = dt.Rows[t]["Dsro_Number"].ToString().Trim();
  1195. dgvr.Cells.Add(cell);
  1196. //员工
  1197. cell = new DataGridViewTextBoxCell();
  1198. cell.Value = dt.Rows[t]["开单人姓名"].ToString().Trim();
  1199. dgvr.Cells.Add(cell);
  1200. //客户姓名
  1201. cell = new DataGridViewTextBoxCell();
  1202. cell.Value = dt.Rows[t]["Cus_Name"].ToString().Trim();
  1203. dgvr.Cells.Add(cell);
  1204. //业绩金额
  1205. cell = new DataGridViewTextBoxCell();
  1206. cell.Value = Convert.ToDecimal(dt.Rows[t]["Dsro_Amount"]).ToString("N2");
  1207. dgvr.Cells.Add(cell);
  1208. //创建时间
  1209. cell = new DataGridViewTextBoxCell();
  1210. cell.Value = dt.Rows[t]["Dsro_CreateDateTime"].ToString().Trim();
  1211. dgvr.Cells.Add(cell);
  1212. //套系类别
  1213. cell = new DataGridViewTextBoxCell();
  1214. cell.Value = "礼服租售";
  1215. dgvr.Cells.Add(cell);
  1216. //套系名称
  1217. cell = new DataGridViewTextBoxCell();
  1218. if (dt.Rows[t]["Dsro_Type"].ToString().Trim() == "0")
  1219. { cell.Value = "出租"; }
  1220. else if (dt.Rows[t]["Dsro_Type"].ToString().Trim() == "1")
  1221. { cell.Value = "出售"; }
  1222. dgvr.Cells.Add(cell);
  1223. //项目名称
  1224. cell = new DataGridViewTextBoxCell();
  1225. cell.Value = "礼服租售";
  1226. dgvr.Cells.Add(cell);
  1227. this.dgv.Rows.Add(dgvr);
  1228. }
  1229. dgv.ClearSelection();
  1230. }));
  1231. }
  1232. });
  1233. #endregion
  1234. #region 获取员工奖罚
  1235. s = "";
  1236. str = new StringBuilder();
  1237. dt = new DataTable();
  1238. str.Append(" Rp_RPDatetime>='" + StartTime + "' and Rp_RPDatetime<='" + EndTime + " 23:59:59.000' and Rp_Status='已执行'");
  1239. if (EmployeeName != null && !string.IsNullOrEmpty(EmployeeName))
  1240. { str.Append(" and Rp_RelevantPeople like '%" + EmployeeName + "%'"); }
  1241. s = BindSelect6();
  1242. LYFZ.ComponentLibrary.FrmLoadHandling.LoadDoWorkMethod(delegate(object obj, BackgroundWorker backgroundWorker)
  1243. {
  1244. 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];
  1245. if (dt.Rows.Count > 0)
  1246. {
  1247. this.Invoke(new LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.UpdateControl(delegate()
  1248. {
  1249. for (int t = 0; t < dt.Rows.Count; t++)
  1250. {
  1251. DataGridViewRow dgvr = new DataGridViewRow();
  1252. DataGridViewCell cell = null;
  1253. //订单号
  1254. cell = new DataGridViewTextBoxCell();
  1255. cell.Value = dt.Rows[t]["ID"].ToString().Trim();
  1256. dgvr.Cells.Add(cell);
  1257. //员工
  1258. cell = new DataGridViewTextBoxCell();
  1259. cell.Value = dt.Rows[t]["User_Name"].ToString().Trim();
  1260. dgvr.Cells.Add(cell);
  1261. //客户姓名
  1262. cell = new DataGridViewTextBoxCell();
  1263. cell.Value = "";// dt.Rows[t]["Cus_Name"].ToString().Trim();
  1264. dgvr.Cells.Add(cell);
  1265. //业绩金额
  1266. cell = new DataGridViewTextBoxCell();
  1267. cell.Value = Convert.ToDecimal(dt.Rows[t]["Rp_Money"]).ToString("N2");
  1268. dgvr.Cells.Add(cell);
  1269. //创建时间
  1270. cell = new DataGridViewTextBoxCell();
  1271. cell.Value = dt.Rows[t]["Rp_RPDatetime"].ToString().Trim();
  1272. dgvr.Cells.Add(cell);
  1273. //套系类别
  1274. cell = new DataGridViewTextBoxCell();
  1275. cell.Value = "员工奖罚";
  1276. dgvr.Cells.Add(cell);
  1277. //套系名称
  1278. cell = new DataGridViewTextBoxCell();
  1279. cell.Value = dt.Rows[t]["Rp_Type"].ToString().Trim();
  1280. dgvr.Cells.Add(cell);
  1281. //项目名称
  1282. cell = new DataGridViewTextBoxCell();
  1283. cell.Value = "员工奖罚";
  1284. dgvr.Cells.Add(cell);
  1285. this.dgv.Rows.Add(dgvr);
  1286. }
  1287. dgv.ClearSelection();
  1288. }));
  1289. }
  1290. });
  1291. #endregion
  1292. #region 获取员工支出
  1293. s = "";
  1294. str = new StringBuilder();
  1295. dt = new DataTable();
  1296. str.Append(" Oiae_IEDatetime>='" + StartTime + "' and Oiae_IEDatetime<='" + EndTime + " 23:59:59.000' and (Oiae_Type='支出' or Oiae_Type='财务支出')");
  1297. if (EmployeeName != null && !string.IsNullOrEmpty(EmployeeName))
  1298. { str.Append(" and Oiae_ThePayer like '%" + EmployeeName + "%'"); }
  1299. s = BindSelect7();
  1300. LYFZ.ComponentLibrary.FrmLoadHandling.LoadDoWorkMethod(delegate(object obj, BackgroundWorker backgroundWorker)
  1301. {
  1302. 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];
  1303. if (dt.Rows.Count > 0)
  1304. {
  1305. this.Invoke(new LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.UpdateControl(delegate()
  1306. {
  1307. for (int t = 0; t < dt.Rows.Count; t++)
  1308. {
  1309. DataGridViewRow dgvr = new DataGridViewRow();
  1310. DataGridViewCell cell = null;
  1311. //订单号
  1312. cell = new DataGridViewTextBoxCell();
  1313. cell.Value = dt.Rows[t]["ID"].ToString().Trim();
  1314. dgvr.Cells.Add(cell);
  1315. //员工
  1316. cell = new DataGridViewTextBoxCell();
  1317. cell.Value = dt.Rows[t]["User_Name"].ToString().Trim();
  1318. dgvr.Cells.Add(cell);
  1319. //客户姓名
  1320. cell = new DataGridViewTextBoxCell();
  1321. cell.Value = "";// dt.Rows[t]["Cus_Name"].ToString().Trim();
  1322. dgvr.Cells.Add(cell);
  1323. //业绩金额
  1324. cell = new DataGridViewTextBoxCell();
  1325. cell.Value = Convert.ToDecimal(dt.Rows[t]["Oiae_Money"]).ToString("N2");
  1326. dgvr.Cells.Add(cell);
  1327. //创建时间
  1328. cell = new DataGridViewTextBoxCell();
  1329. cell.Value = dt.Rows[t]["Oiae_IEDatetime"].ToString().Trim();
  1330. dgvr.Cells.Add(cell);
  1331. //套系类别
  1332. cell = new DataGridViewTextBoxCell();
  1333. cell.Value = "员工支出";
  1334. dgvr.Cells.Add(cell);
  1335. //套系名称
  1336. cell = new DataGridViewTextBoxCell();
  1337. cell.Value = dt.Rows[t]["Oiae_ProjectName"].ToString().Trim();
  1338. dgvr.Cells.Add(cell);
  1339. //项目名称
  1340. cell = new DataGridViewTextBoxCell();
  1341. cell.Value = "员工支出";
  1342. dgvr.Cells.Add(cell);
  1343. this.dgv.Rows.Add(dgvr);
  1344. }
  1345. dgv.ClearSelection();
  1346. }));
  1347. }
  1348. });
  1349. #endregion
  1350. */
  1351. /*
  1352. #region 显示绘画(合计业绩)
  1353. if (this.dgv.Rows.Count > 0)
  1354. {
  1355. //业绩
  1356. decimal CurrentPerformance = 0;
  1357. //计件
  1358. decimal PieceCommission = 0;
  1359. //奖励
  1360. decimal Reward = 0;
  1361. //罚款
  1362. decimal Fine = 0;
  1363. //支出
  1364. decimal Expenditure = 0;
  1365. for (int i = 0; i < this.dgv.Rows.Count; i++)
  1366. {
  1367. #region 参数
  1368. object Project_Name = this.dgv.Rows[i].Cells["Column8"].Value;
  1369. object Type = this.dgv.Rows[i].Cells["Column6"].Value;
  1370. decimal Pay_AmountOf = Convert.ToDecimal(this.dgv.Rows[i].Cells["Column3"].Value);
  1371. #endregion
  1372. #region 合计
  1373. if (Project_Name.ToString() != "")
  1374. {
  1375. if (Project_Name.ToString() == "订单前期业绩" || Project_Name.ToString() == "订单后期业绩" || Project_Name.ToString() == "其它消费" || Project_Name.ToString() == "礼服租售")
  1376. {
  1377. CurrentPerformance += Pay_AmountOf;
  1378. }
  1379. if (Project_Name.ToString() == "计件提成")
  1380. {
  1381. PieceCommission += Pay_AmountOf;
  1382. }
  1383. if (Project_Name.ToString() == "员工支出")
  1384. {
  1385. Expenditure += Pay_AmountOf;
  1386. }
  1387. if (Project_Name.ToString() == "员工奖罚")
  1388. {
  1389. if (Type.ToString() == "奖励")
  1390. {
  1391. Reward += Pay_AmountOf;
  1392. }
  1393. if (Type.ToString() == "惩罚")
  1394. {
  1395. Fine += Pay_AmountOf;
  1396. }
  1397. }
  1398. }
  1399. #endregion
  1400. }
  1401. Sum = CurrentPerformance;
  1402. this.txtPieceCommission.Text = PieceCommission.ToString("N2");
  1403. this.txtRewardPunishment.Text = "奖:" + Reward + "," + "罚:" + Fine;
  1404. this.txtExpenditure.Text = Expenditure.ToString("N2");
  1405. }
  1406. #endregion
  1407. */
  1408. #endregion
  1409. return Sum;
  1410. }
  1411. DataTable DataGriwViewToDataTable(DataGridView dataGridView)
  1412. {
  1413. DataTable dt = new DataTable();
  1414. foreach(DataGridViewColumn column in dataGridView.Columns)
  1415. {
  1416. dt.Columns.Add(column.Name);
  1417. }
  1418. foreach(DataGridViewRow gridRow in dataGridView.Rows)
  1419. {
  1420. DataRow dr = dt.NewRow();
  1421. foreach (DataGridViewColumn column in dataGridView.Columns)
  1422. {
  1423. dr[column.Name] = gridRow.Cells[column.Name].Value;
  1424. }
  1425. dt.Rows.Add(dr);
  1426. }
  1427. return dt;
  1428. }
  1429. private string BindSelect10()
  1430. {
  1431. StringBuilder str = new StringBuilder();
  1432. if (!string.IsNullOrEmpty(this.CtvPak_Name.Text.Trim()))
  1433. { str.Append(" and tb_ErpDressDepositReceivables.id=-3"); }
  1434. if (!string.IsNullOrEmpty(this.cmbItemCategory.Text.Trim()))
  1435. {
  1436. if (this.cmbItemCategory.Text != "礼服租售")
  1437. { str.Append(" and tb_ErpDressDepositReceivables.id=-3"); }
  1438. }
  1439. return str.ToString();
  1440. }
  1441. /// <summary>
  1442. ///
  1443. /// </summary>
  1444. /// <param name="wqcRow">统计查询方案</param>
  1445. /// <param name="uEmployeeID"></param>
  1446. /// <param name="isEndRow"></param>
  1447. /// <returns></returns>
  1448. DataGridViewRow GetSubDataGridViewRow(string ordNumber, DataGridViewRow firstDr, dynamic ordDy, int index, bool isEndRow = false)
  1449. {
  1450. IDictionary<string, object> idicObj = ordDy;
  1451. DataGridViewRow dgRow = new DataGridViewRow();
  1452. if (index > 1)
  1453. {
  1454. dgRow.CreateCells(this.dgv);
  1455. dgRow.Cells[0].Style = GetDataGridViewCellStyle(System.Drawing.Color.White, DataGridViewContentAlignment.MiddleLeft);
  1456. dgRow.Cells[1].Style = dgRow.Cells[0].Style;
  1457. dgRow.Cells[2].Style = dgRow.Cells[0].Style;
  1458. dgRow.Cells[3].Style = dgRow.Cells[0].Style;
  1459. dgRow.Cells[4].Style = dgRow.Cells[0].Style;
  1460. dgRow.Cells[5].Style = dgRow.Cells[0].Style;
  1461. dgRow.Cells[6].Style = dgRow.Cells[0].Style;
  1462. dgRow.Cells[7].Style = dgRow.Cells[0].Style;
  1463. dgRow.Cells[8].Style = dgRow.Cells[0].Style;
  1464. dgRow.Cells[9].Style = dgRow.Cells[0].Style;
  1465. dgRow.Cells[10].Style = dgRow.Cells[0].Style;
  1466. dgRow.Cells[11].Style = dgRow.Cells[0].Style;
  1467. dgRow.Cells[12].Style = dgRow.Cells[0].Style;
  1468. if (isEndRow)
  1469. {
  1470. dgRow.Cells[0].Tag = this.dgv.EraseCellDrawLineHEnd;
  1471. dgRow.Cells[1].Tag = this.dgv.EraseCellDrawLineHEnd;
  1472. dgRow.Cells[2].Tag = this.dgv.EraseCellDrawLineHEnd;
  1473. dgRow.Cells[3].Tag = this.dgv.EraseCellDrawLineHEnd;
  1474. dgRow.Cells[4].Tag = this.dgv.EraseCellDrawLineHEnd;
  1475. dgRow.Cells[5].Tag = this.dgv.EraseCellDrawLineHEnd;
  1476. dgRow.Cells[6].Tag = this.dgv.EraseCellDrawLineVHEnd;
  1477. }
  1478. else
  1479. {
  1480. dgRow.Cells[0].Tag = this.dgv.EraseCellDrawLine;
  1481. dgRow.Cells[1].Tag = this.dgv.EraseCellDrawLine;
  1482. dgRow.Cells[2].Tag = this.dgv.EraseCellDrawLine;
  1483. dgRow.Cells[3].Tag = this.dgv.EraseCellDrawLine;
  1484. dgRow.Cells[4].Tag = this.dgv.EraseCellDrawLine;
  1485. dgRow.Cells[5].Tag = this.dgv.EraseCellDrawLine;
  1486. dgRow.Cells[6].Tag = this.dgv.EraseCellDrawLineVEnd;
  1487. }
  1488. }
  1489. else
  1490. {
  1491. dgRow = firstDr;
  1492. }
  1493. dgRow.Cells[2].Value = idicObj["客户姓名"];
  1494. dgRow.Cells[3].Value = idicObj["客户电话"];
  1495. if (idicObj["业绩金额"].ToString() != "付款")
  1496. {
  1497. dgRow.Cells[1].Value = idicObj.ContainsKey("自定义订单号") ? idicObj["自定义订单号"] : ordNumber;
  1498. dgRow.Cells[5].Value = idicObj["业绩金额"];
  1499. dgRow.Cells[4].Value = idicObj["收款类型"];
  1500. }
  1501. else
  1502. {
  1503. dgRow.Cells[1].Value = idicObj.ContainsKey("自定义订单号") ? idicObj["自定义订单号"] : ordNumber;
  1504. //dgRow.Cells[5].Value = firstDr.Cells["PerformanceMoney"].Value;
  1505. dgRow.Cells[4].Value = idicObj["收款类型"].ToString().Replace("收款","");
  1506. //dgRow.Cells[5].Value = firstDr.Cells["PerformanceMoney"].Value;
  1507. //dgRow.Cells[2].Value = firstDr.Cells["CusName"].Value;
  1508. //dgRow.Cells[3].Value = firstDr.Cells["CusTelephone"].Value;
  1509. }
  1510. dgRow.Cells[6].Value = idicObj["支付方式"];
  1511. dgRow.Cells[7].Value = idicObj["收款金额"];
  1512. dgRow.Cells[9].Value = idicObj["业绩描述"];
  1513. dgRow.Cells[8].Value = idicObj["业绩分配"];
  1514. dgRow.Cells[10].Value = idicObj["收款人"];
  1515. dgRow.Cells[11].Value = idicObj["收款日"].ToString();
  1516. dgRow.Cells[12].Value = idicObj["收款名称"];
  1517. return dgRow;
  1518. }
  1519. #region 字段样式定义
  1520. System.Windows.Forms.DataGridViewCellStyle GetDataGridViewCellStyle(System.Drawing.Color bgcolor, System.Windows.Forms.DataGridViewContentAlignment alignment = DataGridViewContentAlignment.MiddleCenter)
  1521. {
  1522. System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle2 = new System.Windows.Forms.DataGridViewCellStyle();
  1523. dataGridViewCellStyle2.Alignment = alignment;
  1524. dataGridViewCellStyle2.BackColor = bgcolor;//System.Drawing.Color.FromArgb(((int)(((byte)(43)))), ((int)(((byte)(108)))), ((int)(((byte)(150)))));
  1525. dataGridViewCellStyle2.Font = new System.Drawing.Font("微软雅黑", 10.5f, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
  1526. dataGridViewCellStyle2.ForeColor = System.Drawing.Color.Black;
  1527. dataGridViewCellStyle2.SelectionBackColor = System.Drawing.SystemColors.Highlight;
  1528. dataGridViewCellStyle2.SelectionForeColor = System.Drawing.SystemColors.HighlightText;
  1529. return dataGridViewCellStyle2;
  1530. }
  1531. #endregion
  1532. #region 绑定数据信息
  1533. /// <summary>
  1534. /// 获取业绩人数据组
  1535. /// </summary>
  1536. /// <param name="dyUserList"></param>
  1537. /// <param name="preOrder"></param>
  1538. void GetUserOrderDataByDynamicList(ref Dictionary<string, Dictionary<string, List<dynamic>>> dyUserList, DataTable lastOrder,
  1539. string strKeyValue,string strOrderNumberKey,string payNumberKey ,string performanceKey, string typeName, DataRow mainDr, DataRow deputyDr, List<DataRow> payRowList = null)
  1540. {
  1541. foreach (DataRow dr in lastOrder.Rows)
  1542. {//"销售人员编号"
  1543. ////付款数据
  1544. if(payRowList!=null)
  1545. {
  1546. string userKeys = "";
  1547. List<DataRow> payTempRowList = payRowList.FindAll(p => p.Field<string>(payNumberKey) == dr[strOrderNumberKey].ToString());
  1548. if (!string.IsNullOrEmpty(performanceKey))
  1549. {
  1550. foreach (DataRow payDr in payTempRowList)
  1551. {
  1552. if (!string.IsNullOrEmpty(payDr[performanceKey].ToString_s()))
  1553. {
  1554. List<dynamic> dyList = Newtonsoft.Json.JsonConvert.DeserializeObject<List<dynamic>>(payDr[performanceKey].ToString_s());
  1555. string[] openSingleList = userKeys.Split(',');
  1556. foreach (dynamic dyObj in dyList)
  1557. {
  1558. if (!userKeys.Contains(dyObj.UserID.ToString()))
  1559. {
  1560. if (!string.IsNullOrEmpty(userKeys))
  1561. {
  1562. userKeys += ",";
  1563. }
  1564. userKeys += dyObj.UserID;
  1565. }
  1566. }
  1567. }
  1568. }
  1569. }
  1570. if(!string.IsNullOrEmpty(userKeys))
  1571. {
  1572. dr[strKeyValue] = userKeys;
  1573. }
  1574. }
  1575. ///人员数据绑定
  1576. if (dyUserList.ContainsKey(dr[strKeyValue].ToString_s()))
  1577. {
  1578. Dictionary<string, List<dynamic>> dicOrderList = dyUserList[dr[strKeyValue].ToString_s()];
  1579. BindUserOrderDataByDynamic(ref dicOrderList,ref dyUserList, dr[strKeyValue].ToString_s(), dr, strOrderNumberKey, typeName, mainDr, deputyDr, payRowList);
  1580. }
  1581. else
  1582. {
  1583. Dictionary<string, List<dynamic>> dicOrderList = new Dictionary<string, List<dynamic>>();
  1584. string[] personNumberList = dr[strKeyValue].ToString_s().Split(',');
  1585. foreach(string perKey in personNumberList)
  1586. {
  1587. if(dyUserList.ContainsKey(perKey))
  1588. {
  1589. dicOrderList = dyUserList[perKey];
  1590. BindUserOrderDataByDynamic(ref dicOrderList, ref dyUserList, perKey, dr, strOrderNumberKey, typeName, mainDr, deputyDr, payRowList);
  1591. }
  1592. else
  1593. {
  1594. dicOrderList = new Dictionary<string, List<dynamic>>();
  1595. dyUserList.Add(perKey, dicOrderList);
  1596. BindUserOrderDataByDynamic(ref dicOrderList, ref dyUserList, perKey, dr, strOrderNumberKey, typeName, mainDr, deputyDr, payRowList);
  1597. }
  1598. }
  1599. }
  1600. }
  1601. }
  1602. /// <summary>
  1603. /// 获取订单数据组
  1604. /// </summary>
  1605. /// <param name="dicOrderList"></param>
  1606. /// <param name="dr"></param>
  1607. void BindUserOrderDataByDynamic(ref Dictionary<string, List<dynamic>> dicOrderList, ref Dictionary<string, Dictionary<string, List<dynamic>>> dyUserList,
  1608. string employeeId,
  1609. DataRow dr, string strKeyValue, string typeName
  1610. , DataRow mainDr, DataRow deputyDr, List<DataRow> payRowList = null)
  1611. {//"订单号"
  1612. if (dicOrderList.ContainsKey(dr[strKeyValue].ToString_s()))
  1613. {
  1614. List<dynamic> orderTypeData = dicOrderList[SetFistKeyData(typeName) + dr[strKeyValue].ToString_s()];
  1615. BindUserOrderData(ref orderTypeData, ref dyUserList, employeeId, dr, typeName, mainDr, deputyDr);
  1616. if (payRowList != null)
  1617. {
  1618. List<DataRow> searchPayList = payRowList.Where(p => p.Field<string>("Pay_OrdNumber") == dr[strKeyValue].ToString_s()).ToList();
  1619. orderTypeData[orderTypeData.Count - 1].收款金额 = searchPayList.Sum(p => p.Field<decimal>("Pay_AmountOf"));
  1620. if (typeName == "订单后期")
  1621. {
  1622. searchPayList = searchPayList.FindAll(p => p.Field<string>("Pay_ReceivableProject") == dr["商品名称"].ToString_s());
  1623. }
  1624. BindUserPayDynamicData(ref orderTypeData, ref dyUserList, employeeId, searchPayList, typeName, mainDr, deputyDr);
  1625. }
  1626. }
  1627. else
  1628. {
  1629. List<dynamic> orderTypeData = new List<dynamic>();
  1630. dicOrderList.Add(SetFistKeyData(typeName) + dr[strKeyValue].ToString_s(), orderTypeData);
  1631. BindUserOrderData(ref orderTypeData, ref dyUserList, employeeId, dr, typeName, mainDr, deputyDr);
  1632. if (payRowList != null)
  1633. {
  1634. List<DataRow> searchPayList = payRowList.Where(p => p.Field<string>("Pay_OrdNumber") == dr[strKeyValue].ToString_s()).ToList();
  1635. orderTypeData[orderTypeData.Count - 1].收款金额 = searchPayList.Sum(p => p.Field<decimal>("Pay_AmountOf"));
  1636. if (typeName == "订单后期")
  1637. {
  1638. searchPayList = searchPayList.FindAll(p => p.Field<string>("Pay_ReceivableProject") == dr["商品名称"].ToString_s());
  1639. }
  1640. BindUserPayDynamicData(ref orderTypeData, ref dyUserList, employeeId, searchPayList, typeName, mainDr, deputyDr);
  1641. }
  1642. }
  1643. }
  1644. string SetFistKeyData(string typeName)
  1645. {
  1646. switch (typeName)
  1647. {
  1648. case "员工奖罚":
  1649. return "URP";
  1650. break;
  1651. case "员工支出":
  1652. return "UPM";
  1653. break;
  1654. default:
  1655. return "";
  1656. break;
  1657. }
  1658. }
  1659. void BindUserOrderData(ref List<dynamic> orderTypeData, ref Dictionary<string, Dictionary<string, List<dynamic>>> dyUserList,
  1660. string employeeId,
  1661. DataRow dr,string typeName
  1662. , DataRow mainDr, DataRow deputyDr)
  1663. {
  1664. switch(typeName)
  1665. {
  1666. case "订单前期":
  1667. BindUserOrderData(ref orderTypeData, dr, mainDr, deputyDr);
  1668. break;
  1669. case "订单后期":
  1670. BindUserLastOrderData(ref orderTypeData, dr, mainDr, deputyDr);
  1671. break;
  1672. case "其他消费":
  1673. BindUserOtherData(ref orderTypeData, dr, mainDr, deputyDr, employeeId);
  1674. break;
  1675. case "计件提成":
  1676. BindUserPieceworkData(ref orderTypeData, dr);
  1677. break;
  1678. case "礼服租售":
  1679. BindUserDressData(ref orderTypeData, dr);
  1680. break;
  1681. case "员工奖罚":
  1682. BindUserRewardPunishment(ref orderTypeData, dr);
  1683. break;
  1684. case "员工支出":
  1685. BindUserIncomeAndExpenses(ref orderTypeData, dr);
  1686. break;
  1687. case "会员充值":
  1688. BindMemberData(ref orderTypeData,ref dyUserList, employeeId, dr);
  1689. break;
  1690. case "会员服务充值":
  1691. BindMemberServiceData(ref orderTypeData,ref dyUserList, employeeId, dr);
  1692. break;
  1693. }
  1694. }
  1695. private void BindMemberServiceData(ref List<dynamic> orderTypeData, ref Dictionary<string, Dictionary<string, List<dynamic>>> dyUserList,
  1696. string employeeId, DataRow dr)
  1697. {
  1698. dynamic dyObj = new System.Dynamic.ExpandoObject();
  1699. IDictionary<string, object> idicData = dyObj;
  1700. idicData.Add("自定义订单号", dr["id"].ToString_s());
  1701. idicData.Add("客户姓名", dr["Cus_Name"].ToString_s());
  1702. idicData.Add("客户电话", dr["Cus_Telephone"].ToString_s());
  1703. idicData.Add("收款类型", "会员服务充值");
  1704. idicData.Add("业绩金额", dr["Mcpt_PaymentAmount"].ToString_s());
  1705. idicData.Add("业绩额", Convert.ToDecimal(dr["Mcpt_PaymentAmount"].ToString_s()));
  1706. idicData.Add("业绩人", dr["Mcpt_OrderPerson"].ToString_s());
  1707. idicData.Add("支付方式", dr["Sc_ClassName"].ToString_s());
  1708. idicData.Add("收款金额", Convert.ToDecimal(dr["Mcpt_PaymentAmount"].ToString_s()));
  1709. if (!string.IsNullOrEmpty(dr["Mcpt_CommissionRatio"].ToString_s()))
  1710. {
  1711. idicData.Add("业绩分配", GetCommissionRatio(Convert.ToDecimal(dr["Mcpt_PaymentAmount"]),
  1712. dr["Mcpt_OrderPerson"].ToString(),
  1713. dr["Mcpt_CommissionRatio"].ToString_s(), employeeId));
  1714. idicData.Add("业绩描述", GetCommissionRatioDis(Convert.ToDecimal(dr["Mcpt_PaymentAmount"]),
  1715. dr["Mcpt_OrderPerson"].ToString(),
  1716. dr["Mcpt_CommissionRatio"].ToString_s(), employeeId));
  1717. }
  1718. else
  1719. {
  1720. idicData.Add("业绩分配", dr["Mcpt_PaymentAmount"].ToString_s());
  1721. idicData.Add("业绩描述", "");
  1722. }
  1723. string strPerformance = idicData["业绩分配"].ToString();
  1724. if (!string.IsNullOrEmpty(strPerformance))
  1725. {
  1726. string[] orderPersonList = dr["Mcpt_OrderPerson"].ToString().Split(',');
  1727. foreach (string perKey in orderPersonList)
  1728. {
  1729. DataRow perDtRows = LYFZ.DAL.DAL_ErpUser.SimpleUserDataTable.Rows.Find(perKey);
  1730. if (perDtRows != null)
  1731. {
  1732. strPerformance = strPerformance.Replace(perKey, perDtRows["User_Name"].ToString().Trim());
  1733. }
  1734. }
  1735. idicData["业绩分配"] = strPerformance;
  1736. }
  1737. string thePayee = dr["Mcpt_CreateName"].ToString_s();
  1738. DataRow dtRows = LYFZ.DAL.DAL_ErpUser.SimpleUserDataTable.Rows.Find(dr["Mcpt_CreateName"].ToString_s());
  1739. if (dtRows != null)
  1740. {
  1741. thePayee = dtRows["User_Name"].ToString().Trim();
  1742. }
  1743. idicData.Add("收款人", thePayee);
  1744. idicData.Add("收款日", dr["Mcpt_CreateDatetime"].ToString_s());
  1745. idicData.Add("收款名称", dr["Mcpt_PaymentType"].ToString_s());
  1746. orderTypeData.Add(dyObj);
  1747. }
  1748. /// <summary>
  1749. /// 会员充值
  1750. /// </summary>
  1751. /// <param name="orderTypeData"></param>
  1752. /// <param name="dr"></param>
  1753. private void BindMemberData(ref List<dynamic> orderTypeData, ref Dictionary<string, Dictionary<string, List<dynamic>>> dyUserList,
  1754. string employeeId,
  1755. DataRow dr, DataRow mainDr = null, DataRow deputyDr = null)
  1756. {
  1757. dynamic dyObj = new System.Dynamic.ExpandoObject();
  1758. IDictionary<string, object> idicData = dyObj;
  1759. idicData.Add("自定义订单号", dr["id"].ToString_s());
  1760. idicData.Add("客户姓名", dr["Cus_Name"].ToString_s());
  1761. idicData.Add("客户电话", dr["Cus_Telephone"].ToString_s());
  1762. idicData.Add("收款类型", "会员充值");
  1763. idicData.Add("业绩金额", dr["Mcrr_RechargeAmount"].ToString_s());
  1764. idicData.Add("业绩额", Convert.ToDecimal(dr["Mcrr_RechargeAmount"].ToString_s()));
  1765. idicData.Add("业绩人", dr["Mcrr_OrderPerson"].ToString_s());
  1766. idicData.Add("支付方式", dr["Sc_ClassName"].ToString_s() );
  1767. idicData.Add("收款金额", Convert.ToDecimal(dr["Mcrr_RechargeAmount"].ToString_s()));
  1768. if (!string.IsNullOrEmpty(dr["Mcrr_CommissionRatio"].ToString_s()))
  1769. {
  1770. idicData.Add("业绩分配", GetCommissionRatio(Convert.ToDecimal(dr["Mcrr_RechargeAmount"]),
  1771. dr["Mcrr_OrderPerson"].ToString(),
  1772. dr["Mcrr_CommissionRatio"].ToString_s(), employeeId));
  1773. idicData.Add("业绩描述", GetCommissionRatioDis(Convert.ToDecimal(dr["Mcrr_RechargeAmount"]),
  1774. dr["Mcrr_OrderPerson"].ToString(),
  1775. dr["Mcrr_CommissionRatio"].ToString_s(), employeeId));
  1776. }
  1777. else if (mainDr != null && deputyDr != null)
  1778. {
  1779. idicData.Add("业绩分配", GetAchievement(Convert.ToDecimal(dr["Mcrr_RechargeAmount"]),
  1780. dr["Mcrr_OrderPerson"].ToString(),
  1781. mainDr, deputyDr, employeeId));
  1782. idicData.Add("业绩描述", GetAchievementDis(Convert.ToDecimal(dr["Mcrr_RechargeAmount"]),
  1783. dr["Mcrr_OrderPerson"].ToString(),
  1784. mainDr, deputyDr, employeeId));
  1785. }
  1786. else
  1787. {
  1788. idicData.Add("业绩分配", dr["Mcrr_RechargeAmount"].ToString_s());
  1789. idicData.Add("业绩描述", "");
  1790. }
  1791. string strPerformance = idicData["业绩分配"].ToString();
  1792. if (!string.IsNullOrEmpty(strPerformance))
  1793. {
  1794. string[] orderPersonList = dr["Mcrr_OrderPerson"].ToString().Split(',');
  1795. foreach (string perKey in orderPersonList)
  1796. {
  1797. DataRow perDtRows = LYFZ.DAL.DAL_ErpUser.SimpleUserDataTable.Rows.Find(perKey);
  1798. if (perDtRows != null)
  1799. {
  1800. strPerformance = strPerformance.Replace(perKey, perDtRows["User_Name"].ToString().Trim());
  1801. }
  1802. }
  1803. idicData["业绩分配"] = strPerformance;
  1804. }
  1805. string thePayee = dr["Mcrr_CreateName"].ToString_s();
  1806. DataRow dtRows = LYFZ.DAL.DAL_ErpUser.SimpleUserDataTable.Rows.Find(dr["Mcrr_CreateName"].ToString_s());
  1807. if (dtRows != null)
  1808. {
  1809. thePayee = dtRows["User_Name"].ToString().Trim();
  1810. }
  1811. idicData.Add("收款人", thePayee);
  1812. idicData.Add("收款日", dr["Mcrr_CreateDatetime"].ToString_s());
  1813. idicData.Add("收款名称", dr["Mcrr_RechargeName"].ToString_s());
  1814. orderTypeData.Add(dyObj);
  1815. }
  1816. #region 绑定付款数据
  1817. void BindUserPayDynamicData(ref List<dynamic> orderTypeData, ref Dictionary<string, Dictionary<string, List<dynamic>>> dyUserList,
  1818. string employeeId, List<DataRow> payDrList,
  1819. string typeName,DataRow mainDr=null ,DataRow deputyDr = null)
  1820. {
  1821. foreach (DataRow dr in payDrList)
  1822. {
  1823. dynamic dyObj = new System.Dynamic.ExpandoObject();
  1824. IDictionary<string, object> idicData = dyObj;
  1825. idicData.Add("自定义订单号", dr["Pay_OrdNumber"].ToString());
  1826. idicData.Add("客户姓名", "");
  1827. idicData.Add("客户电话", "");
  1828. idicData.Add("收款类型", typeName + "收款");
  1829. idicData.Add("业绩金额", "付款");
  1830. idicData.Add("业绩人", dr["Pay_OpenSingle"].ToString());
  1831. idicData.Add("支付方式", dr["Sc_ClassName1"]);
  1832. idicData.Add("收款金额", Convert.ToDecimal(dr["Pay_AmountOf"]));
  1833. if (!string.IsNullOrEmpty(dr["Pay_CommissionRatio"].ToString_s()))
  1834. {
  1835. idicData.Add("业绩分配", GetCommissionRatio(Convert.ToDecimal(dr["Pay_AmountOf"]),
  1836. dr["Pay_OpenSingle"].ToString(),
  1837. dr["Pay_CommissionRatio"].ToString_s(), employeeId));
  1838. idicData.Add("业绩描述", GetCommissionRatioDis(Convert.ToDecimal(dr["Pay_AmountOf"]),
  1839. dr["Pay_OpenSingle"].ToString(),
  1840. dr["Pay_CommissionRatio"].ToString_s(), employeeId));
  1841. }
  1842. else if (mainDr != null && deputyDr != null)
  1843. {
  1844. idicData.Add("业绩分配", GetAchievement(Convert.ToDecimal(dr["Pay_AmountOf"]),
  1845. dr["Pay_OpenSingle"].ToString(),
  1846. mainDr, deputyDr, employeeId));
  1847. idicData.Add("业绩描述", GetAchievementDis(Convert.ToDecimal(dr["Pay_AmountOf"]),
  1848. dr["Pay_OpenSingle"].ToString(),
  1849. mainDr, deputyDr, employeeId));
  1850. }
  1851. else
  1852. {
  1853. idicData.Add("业绩分配", "");
  1854. idicData.Add("业绩描述", "");
  1855. }
  1856. string strPerformance = idicData["业绩分配"].ToString();
  1857. if (!string.IsNullOrEmpty(strPerformance))
  1858. {
  1859. string[] orderPersonList = dr["Pay_OpenSingle"].ToString().Split(',');
  1860. foreach (string perKey in orderPersonList)
  1861. {
  1862. DataRow perDtRows = LYFZ.DAL.DAL_ErpUser.SimpleUserDataTable.Rows.Find(perKey);
  1863. if (perDtRows != null)
  1864. {
  1865. strPerformance = strPerformance.Replace(perKey, perDtRows["User_Name"].ToString().Trim());
  1866. }
  1867. }
  1868. idicData["业绩分配"] = strPerformance;
  1869. }
  1870. string thePayee = dr["Pay_ThePayee"].ToString_s();
  1871. DataRow dtRows = LYFZ.DAL.DAL_ErpUser.SimpleUserDataTable.Rows.Find(dr["Pay_ThePayee"].ToString_s());
  1872. if (dtRows != null)
  1873. {
  1874. thePayee = dtRows["User_Name"].ToString().Trim();
  1875. }
  1876. idicData.Add("收款人", thePayee);
  1877. idicData.Add("收款日", dr["Pay_CreateDatetime"]);
  1878. idicData.Add("收款名称", dr["Pay_Category"] + "-" + dr["Sc_ClassName"] +
  1879. (string.IsNullOrEmpty(dr["Pay_ReceivableProject"].ToString_s()) ? "" : "-" + dr["Pay_ReceivableProject"].ToString_s()));
  1880. ///收款控制,过去收款金额不同的数据
  1881. orderTypeData.Add(dyObj);
  1882. }
  1883. }
  1884. private string GetCommissionRatio(
  1885. decimal amountOf, string openSingle, string commissionRatio,string employeeId)
  1886. {
  1887. string strOpenSingle = "";
  1888. if (commissionRatio != "")
  1889. {
  1890. List<dynamic> dyList = Newtonsoft.Json.JsonConvert.DeserializeObject<List<dynamic>>(commissionRatio);
  1891. string[] openSingleList = openSingle.Split(',');
  1892. foreach (dynamic dyObj in dyList)
  1893. {
  1894. if(employeeId== dyObj.UserID.ToString())
  1895. {
  1896. strOpenSingle = Convert.ToDecimal(amountOf * Convert.ToDecimal(dyObj.CommissionRatio) / 100).ToString("0.00");
  1897. break;
  1898. }
  1899. //strOpenSingle += dyObj.UserID + ":" + Convert.ToDecimal(amountOf * Convert.ToDecimal(dyObj.CommissionRatio) / 100).ToString("0.00");
  1900. }
  1901. }
  1902. return strOpenSingle;
  1903. }
  1904. private string GetCommissionRatioDis(
  1905. decimal amountOf, string openSingle, string commissionRatio,string employeeId)
  1906. {
  1907. string strOpenSingle = "";
  1908. if (commissionRatio != "")
  1909. {
  1910. List<dynamic> dyList = Newtonsoft.Json.JsonConvert.DeserializeObject<List<dynamic>>(commissionRatio);
  1911. string[] openSingleList = openSingle.Split(',');
  1912. foreach (dynamic dyObj in dyList)
  1913. {
  1914. //if(employeeId== dyObj.UserID.ToString())
  1915. //{
  1916. // strOpenSingle = Convert.ToDecimal(amountOf * Convert.ToDecimal(dyObj.CommissionRatio) / 100).ToString("0.00");
  1917. // break;
  1918. //}
  1919. if(!string.IsNullOrEmpty(strOpenSingle))
  1920. {
  1921. strOpenSingle += " , ";
  1922. }
  1923. 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");
  1924. }
  1925. }
  1926. return strOpenSingle;
  1927. }
  1928. #endregion
  1929. #region 前期订单数据
  1930. /// <summary>
  1931. /// 获取订单数据
  1932. /// </summary>
  1933. /// <param name="orderTypeData"></param>
  1934. /// <param name="dr"></param>
  1935. void BindUserOrderData(ref List<dynamic> orderTypeData, DataRow dr, DataRow mainDr, DataRow deputyDr)
  1936. {
  1937. dynamic dyObj = new System.Dynamic.ExpandoObject();
  1938. IDictionary<string, object> idicData = dyObj;
  1939. idicData.Add("自定义订单号", dr["Ord_SinceOrderNumber"].ToString_s());
  1940. idicData.Add("客户姓名", dr["Cus_Name"].ToString_s());
  1941. idicData.Add("客户电话", dr["Cus_Telephone"].ToString_s());
  1942. idicData.Add("收款类型", "订单前期");
  1943. idicData.Add("业绩金额", dr["Ord_SeriesPrice"].ToString_s());
  1944. idicData.Add("业绩额", Convert.ToDecimal(dr["Ord_SeriesPrice"]));
  1945. idicData.Add("业绩人", dr["Ord_OrderPersonName"].ToString_s());
  1946. idicData.Add("支付方式", "合计");
  1947. idicData.Add("收款金额", "");
  1948. idicData.Add("业绩分配", "");
  1949. idicData.Add("业绩描述", "");
  1950. idicData.Add("收款人", "");
  1951. idicData.Add("收款日", "");
  1952. idicData.Add("收款名称", "");
  1953. orderTypeData.Add(dyObj);
  1954. }
  1955. #endregion
  1956. #region 后期订单数据
  1957. /// <summary>
  1958. /// 获取订单数据
  1959. /// </summary>
  1960. /// <param name="orderTypeData"></param>
  1961. /// <param name="dr"></param>
  1962. void BindUserLastOrderData(ref List<dynamic> orderTypeData, DataRow dr, DataRow mainDr, DataRow deputyDr)
  1963. {
  1964. dynamic dyObj = new System.Dynamic.ExpandoObject();
  1965. IDictionary<string, object> idicData = dyObj;
  1966. idicData.Add("自定义订单号", dr["Ord_SinceOrderNumber"].ToString_s());
  1967. idicData.Add("客户姓名", dr["客户名称"].ToString_s());
  1968. idicData.Add("客户电话", dr["电话"].ToString_s());
  1969. idicData.Add("收款类型", "订单后期");
  1970. idicData.Add("业绩金额", dr["金额"].ToString_s());
  1971. idicData.Add("业绩额", Convert.ToDecimal(dr["金额"]));
  1972. idicData.Add("业绩人", dr["销售人员名称"].ToString_s());
  1973. idicData.Add("支付方式", "合计");
  1974. idicData.Add("收款金额", "");
  1975. idicData.Add("业绩分配", "");
  1976. idicData.Add("业绩描述", "");
  1977. idicData.Add("收款人", "");
  1978. idicData.Add("收款日", "");
  1979. idicData.Add("收款名称", "");
  1980. orderTypeData.Add(dyObj);
  1981. }
  1982. #endregion
  1983. #region 其它消费数据
  1984. void BindUserOtherData(ref List<dynamic> orderTypeData, DataRow dr, DataRow mainDr, DataRow deputyDr,string employeeId)
  1985. {
  1986. dynamic dyObj = new System.Dynamic.ExpandoObject();
  1987. IDictionary<string, object> idicData = dyObj;
  1988. idicData.Add("自定义订单号", dr["Tsorder_Number"].ToString_s());
  1989. idicData.Add("客户姓名", dr["Tsorder_CustomerName"].ToString_s());
  1990. idicData.Add("客户电话", dr["Tsorder_Telephone"].ToString_s());
  1991. idicData.Add("收款类型", "其它消费");
  1992. idicData.Add("业绩金额", GetAchievement( Convert.ToDecimal(dr["Tsorder_Money"]),
  1993. dr["Tsorder_OpenSingle"].ToString(),
  1994. mainDr, deputyDr, employeeId));
  1995. idicData.Add("业绩额", Convert.ToDecimal(dr["Tsorder_Money"]));
  1996. idicData.Add("业绩人", dr["User_Name"].ToString_s());
  1997. idicData.Add("支付方式", "");
  1998. idicData.Add("收款金额", dr["Tsorder_Money"]);
  1999. idicData.Add("业绩分配", dr["Tsorder_Money"]);
  2000. idicData.Add("业绩描述", "");
  2001. idicData.Add("收款人", dr["Tsorder_PersonHandlingName"]);
  2002. idicData.Add("收款日", dr["Tsorder_CreateDatetime"]);
  2003. idicData.Add("收款名称", "");
  2004. orderTypeData.Add(dyObj);
  2005. }
  2006. #endregion
  2007. #region 计件提成数据
  2008. void BindUserPieceworkData(ref List<dynamic> orderTypeData, DataRow dr)
  2009. {
  2010. dynamic dyObj = new System.Dynamic.ExpandoObject();
  2011. IDictionary<string, object> idicData = dyObj;
  2012. idicData.Add("客户姓名", dr["Cus_Name"].ToString_s());
  2013. idicData.Add("客户电话", dr["Cus_Telephone"].ToString_s());
  2014. idicData.Add("收款类型", "计件提成");
  2015. idicData.Add("业绩金额","");
  2016. idicData.Add("业绩额", dr["总价格"].ToString() == "" ? 0 : Convert.ToDecimal(dr["总价格"]));
  2017. idicData.Add("业绩人", dr["Pcr_DigitalDivisionName"].ToString_s());
  2018. idicData.Add("支付方式", PayTypeData(dr["Pcr_Type"].ToString_s()));
  2019. idicData.Add("收款金额", "");
  2020. idicData.Add("业绩分配", dr["总价格"].ToString() == "" ? "0" : Convert.ToDecimal(dr["总价格"]).ToString("N2"));
  2021. idicData.Add("业绩描述", "完成数量:"+dr["Pcr_Quantity"]+" , 计件单价:"+dr["单价"]+",总提成:"+dr["总价格"]);
  2022. idicData.Add("收款人", dr["Pcr_EntryPeopleName"]);
  2023. idicData.Add("收款日", dr["Pcr_CreateTime"]);
  2024. idicData.Add("收款名称", dr["Pcr_CompletionContentsName"].ToString_s());
  2025. orderTypeData.Add(dyObj);
  2026. }
  2027. #endregion
  2028. string PayTypeData(string type)
  2029. {
  2030. //0:计件式提成录入、1:预约服务录入、2:拍照导片录入、3:初修导片录入、4:设计导片录入
  2031. switch (type)
  2032. {
  2033. case "0":
  2034. return "计件式提成录入";
  2035. case "1":
  2036. return "预约服务录入";
  2037. break;
  2038. case "2":
  2039. return "拍照导片录入";
  2040. break;
  2041. case "3":
  2042. return "初修导片录入";
  2043. break;
  2044. case "4":
  2045. return "设计导片录入";
  2046. break;
  2047. default:
  2048. return "";
  2049. }
  2050. }
  2051. #region 礼服租售数据
  2052. void BindUserDressData(ref List<dynamic> orderTypeData, DataRow dr)
  2053. {
  2054. dynamic dyObj = new System.Dynamic.ExpandoObject();
  2055. IDictionary<string, object> idicData = dyObj;
  2056. idicData.Add("自定义订单号", dr["Dsro_Number"].ToString_s());
  2057. idicData.Add("客户姓名", dr["Cus_Name"].ToString_s());
  2058. idicData.Add("客户电话", dr["Cus_Telephone"].ToString_s());
  2059. idicData.Add("收款类型", "礼服租售");
  2060. idicData.Add("业绩金额", Convert.ToDecimal(dr["Dsro_Amount"]).ToString("N2"));
  2061. idicData.Add("业绩额", Convert.ToDecimal(dr["Dsro_Amount"]));
  2062. idicData.Add("业绩人", dr["开单人姓名"].ToString_s());
  2063. idicData.Add("支付方式", "合计");
  2064. idicData.Add("收款金额", "");
  2065. idicData.Add("业绩分配", "");
  2066. idicData.Add("业绩描述", "");
  2067. idicData.Add("收款人", "");
  2068. idicData.Add("收款日", "");
  2069. idicData.Add("收款名称", "");
  2070. orderTypeData.Add(dyObj);
  2071. }
  2072. #endregion
  2073. #region 员工奖罚
  2074. void BindUserRewardPunishment(ref List<dynamic> orderTypeData, DataRow dr)
  2075. {
  2076. dynamic dyObj = new System.Dynamic.ExpandoObject();
  2077. IDictionary<string, object> idicData = dyObj;
  2078. idicData.Add("客户姓名", "");
  2079. idicData.Add("客户电话", "");
  2080. idicData.Add("收款类型", "员工奖罚");
  2081. idicData.Add("业绩金额", "");
  2082. idicData.Add("业绩额", Convert.ToDecimal(dr["Rp_Money"]));
  2083. idicData.Add("业绩人", dr["User_Name"].ToString_s());
  2084. idicData.Add("支付方式", dr["Rp_Type"].ToString_s());
  2085. idicData.Add("收款金额", Convert.ToDecimal(dr["Rp_Money"]).ToString("N2"));
  2086. idicData.Add("业绩分配", "");
  2087. idicData.Add("业绩描述", "");
  2088. idicData.Add("收款人", dr["Rp_PersonHandlingName"].ToString_s());
  2089. idicData.Add("收款日", dr["Rp_CreateDatetime"].ToString_s());
  2090. idicData.Add("收款名称", dr["Rp_Status"].ToString_s());
  2091. orderTypeData.Add(dyObj);
  2092. }
  2093. #endregion
  2094. #region 员工支出
  2095. private void BindUserIncomeAndExpenses(ref List<dynamic> orderTypeData, DataRow dr)
  2096. {
  2097. dynamic dyObj = new System.Dynamic.ExpandoObject();
  2098. IDictionary<string, object> idicData = dyObj;
  2099. idicData.Add("客户姓名", "");
  2100. idicData.Add("客户电话", "");
  2101. idicData.Add("收款类型", "员工支出");
  2102. idicData.Add("业绩金额", "");
  2103. idicData.Add("业绩额", Convert.ToDecimal(dr["Oiae_Money"]));
  2104. idicData.Add("业绩人", dr["User_Name"].ToString_s());
  2105. idicData.Add("支付方式", dr["Oiae_Type"].ToString_s());
  2106. idicData.Add("收款金额", Convert.ToDecimal(dr["Oiae_Money"]).ToString("N2"));
  2107. idicData.Add("业绩分配", "");
  2108. idicData.Add("业绩描述", "");
  2109. idicData.Add("收款人", dr["User_Name"].ToString_s());
  2110. idicData.Add("收款日", dr["Oiae_PersonHandlingName"].ToString_s());
  2111. idicData.Add("收款名称", dr["Oiae_ProjectName"].ToString_s());
  2112. orderTypeData.Add(dyObj);
  2113. }
  2114. #endregion
  2115. #endregion
  2116. string GetAchievement(decimal totalValue, string personData, DataRow mainDr, DataRow deputyDr,string employeeId)
  2117. {
  2118. string txtInfo = "";
  2119. string[] personList = personData.Split(',');
  2120. //List<string> personDataList = new List<string>();
  2121. //personList = personDataList.ToArray();
  2122. if (personList.Length > 1)
  2123. {
  2124. //txtInfo = "总业绩:"+totalValue.ToString("N2")+"";
  2125. for (int i = 0; i < personList.Length; i++)
  2126. {
  2127. //txtInfo += " (";
  2128. if (employeeId == personList[i])
  2129. {
  2130. if (i == 0)
  2131. {
  2132. if (mainDr["Cp_Enabled"].ToString() == "1")
  2133. {
  2134. txtInfo += (totalValue / (Convert.ToInt32(mainDr["Cp_Proportion"]) + Convert.ToInt32(deputyDr["Cp_Proportion"]) * (personList.Length - 1)) * Convert.ToInt32(mainDr["Cp_Proportion"])).ToString("N2");
  2135. }
  2136. else
  2137. {
  2138. txtInfo += totalValue.ToString("N2");
  2139. }
  2140. }
  2141. else
  2142. {
  2143. if (deputyDr["Cp_Enabled"].ToString() == "1")
  2144. {
  2145. txtInfo += (totalValue / (Convert.ToInt32(mainDr["Cp_Proportion"]) + Convert.ToInt32(deputyDr["Cp_Proportion"]) * (personList.Length - 1)) * Convert.ToInt32(deputyDr["Cp_Proportion"])).ToString("N2");
  2146. }
  2147. else
  2148. {
  2149. txtInfo += totalValue.ToString("N2");
  2150. }
  2151. }
  2152. }
  2153. //txtInfo += ") ";
  2154. }
  2155. }
  2156. else
  2157. {
  2158. txtInfo = totalValue.ToString("N2");
  2159. }
  2160. return txtInfo;
  2161. }
  2162. string GetAchievementDis(decimal totalValue, string personData, DataRow mainDr, DataRow deputyDr, string employeeId)
  2163. {
  2164. string txtInfo = "";
  2165. string[] personList = personData.Split(',');
  2166. //List<string> personDataList = new List<string>();
  2167. //personList = personDataList.ToArray();
  2168. if (personList.Length > 1)
  2169. {
  2170. txtInfo = "总业绩:" + totalValue.ToString("N2") + "";
  2171. for (int i = 0; i < personList.Length; i++)
  2172. {
  2173. txtInfo += " (";
  2174. if (i == 0)
  2175. {
  2176. if (mainDr["Cp_Enabled"].ToString() == "1")
  2177. {
  2178. 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");
  2179. }
  2180. else
  2181. {
  2182. txtInfo += BLL.Common.BLL_Com_Data.GetUserName(personList[i], LYFZ.DAL.DAL_ErpUser.SimpleUserDataTable) + ":" + totalValue.ToString("N2");
  2183. }
  2184. }
  2185. else
  2186. {
  2187. if (deputyDr["Cp_Enabled"].ToString() == "1")
  2188. {
  2189. 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");
  2190. }
  2191. else
  2192. {
  2193. txtInfo += BLL.Common.BLL_Com_Data.GetUserName(personList[i], LYFZ.DAL.DAL_ErpUser.SimpleUserDataTable) + ":" + totalValue.ToString("N2");
  2194. }
  2195. }
  2196. txtInfo += ") ";
  2197. }
  2198. }
  2199. else
  2200. {
  2201. txtInfo = totalValue.ToString("N2");
  2202. }
  2203. return txtInfo;
  2204. }
  2205. /// <summary>
  2206. /// 统计业绩
  2207. /// </summary>
  2208. public void TotalPerformance()
  2209. {
  2210. LYFZ.BLL.BLL_ErpOrder Orderbll = new LYFZ.BLL.BLL_ErpOrder();
  2211. DataTable dt = new DataTable();
  2212. this.dgvAll.Rows.Clear();
  2213. Dictionary<string, List<DataRow>> dsTableList = GetTotalPerformanceValue(this.txtTimeStart.DateValue.ToString().Trim(), this.txtTimeEnd.DateValue.ToString().Trim());
  2214. if (this.cmbEmployeeName.Text.Trim() == "全部")
  2215. {
  2216. dt = Orderbll.GetView_Custom("tb_ErpUser", StrWhere: "User_Status='在职'", filedOrder: "", ShowColumnName: "User_Name,User_EmployeeID").Tables[0];
  2217. if (dt.Rows.Count > 0)
  2218. {
  2219. for (int t = 0; t < dt.Rows.Count; t++)
  2220. {
  2221. try
  2222. {
  2223. #region
  2224. DataGridViewRow dgvr = new DataGridViewRow();
  2225. DataGridViewCell cell = null;
  2226. //员工编号
  2227. cell = new DataGridViewTextBoxCell();
  2228. cell.Value = dt.Rows[t]["User_EmployeeID"].ToString().Trim();
  2229. dgvr.Cells.Add(cell);
  2230. //员工姓名
  2231. cell = new DataGridViewTextBoxCell();
  2232. cell.Value = dt.Rows[t]["User_Name"].ToString().Trim();
  2233. dgvr.Cells.Add(cell);
  2234. //当前业绩
  2235. cell = new DataGridViewTextBoxCell();
  2236. cell.Value = GetTotalPerformanceValue(dsTableList["员工业绩"], dt.Rows[t]["User_EmployeeID"].ToString().Trim()).ToString("N2");
  2237. //Convert.ToDecimal(this.BindPerformance(this.txtTimeStart.DateValue.ToString().Trim(), this.txtTimeEnd.DateValue.ToString().Trim(), dt.Rows[t]["User_EmployeeID"].ToString().Trim())).ToString("N2"); ;
  2238. dgvr.Cells.Add(cell);
  2239. this.dgvAll.Rows.Add(dgvr);
  2240. #endregion
  2241. }
  2242. catch (Exception ex) { MessageBoxCustom.Show(ex.Message); }
  2243. }
  2244. dgvAll.ClearSelection();
  2245. }
  2246. }
  2247. else if (this.cmbEmployeeName.Name.ToString().Trim() == "Department")
  2248. {
  2249. dt = Orderbll.GetView_Custom("tb_ErpUser", StrWhere: "User_Status='在职' and User_Department='" + this.cmbEmployeeName.Tag.ToString() + "'", ShowColumnName: "User_Name,User_EmployeeID").Tables[0];
  2250. if (dt.Rows.Count > 0)
  2251. {
  2252. for (int t = 0; t < dt.Rows.Count; t++)
  2253. {
  2254. #region
  2255. DataGridViewRow dgvr = new DataGridViewRow();
  2256. DataGridViewCell cell = null;
  2257. //员工编号
  2258. cell = new DataGridViewTextBoxCell();
  2259. cell.Value = dt.Rows[t]["User_EmployeeID"].ToString().Trim();
  2260. dgvr.Cells.Add(cell);
  2261. //员工姓名
  2262. cell = new DataGridViewTextBoxCell();
  2263. cell.Value = dt.Rows[t]["User_Name"].ToString().Trim();
  2264. dgvr.Cells.Add(cell);
  2265. //当前业绩
  2266. cell = new DataGridViewTextBoxCell();
  2267. cell.Value = GetTotalPerformanceValue(dsTableList["员工业绩"], dt.Rows[t]["User_EmployeeID"].ToString().Trim()).ToString("N2");
  2268. //Convert.ToDecimal(this.BindPerformance(this.txtTimeStart.DateValue.ToString().Trim(), this.txtTimeEnd.DateValue.ToString().Trim(), dt.Rows[t]["User_EmployeeID"].ToString().Trim())).ToString("N2");
  2269. dgvr.Cells.Add(cell);
  2270. this.dgvAll.Rows.Add(dgvr);
  2271. #endregion
  2272. }
  2273. dgvAll.ClearSelection();
  2274. }
  2275. }
  2276. //this.txtPieceCommission.Text = GetTotalPerformanceValue(dsTableList["计件提成"]).ToString("N2");
  2277. //this.txtRewardPunishment.Text = "奖:" + GetTotalPerformanceValue(dsTableList["奖励"]).ToString("N2") + "," + "罚:" + GetTotalPerformanceValue(dsTableList["惩罚"]).ToString("N2");
  2278. //this.txtExpenditure.Text = GetTotalPerformanceValue(dsTableList["员工支出"]).ToString("N2");
  2279. this.txtCurrentUserPerformance.Text = GetTotalPerformanceValue(dsTableList["员工业绩"]).ToString("N2");
  2280. }
  2281. decimal GetTotalPerformanceValue(List<DataRow> dsTableList,string employeeID)
  2282. {
  2283. decimal totalValue = 0;
  2284. List<DataRow> drList = dsTableList.FindAll(p => p["EmployeeID"].ToString().Contains(employeeID));
  2285. foreach(DataRow dr in drList)
  2286. {
  2287. decimal tempPrice = 0;
  2288. decimal.TryParse(dr["Price"].ToString(),out tempPrice);
  2289. totalValue += tempPrice;
  2290. }
  2291. return totalValue;
  2292. }
  2293. decimal GetTotalPerformanceValue(List<DataRow> dsTableList)
  2294. {
  2295. decimal totalValue = 0;
  2296. foreach (DataRow dr in dsTableList)
  2297. {
  2298. decimal tempPrice = 0;
  2299. decimal.TryParse(dr["Price"].ToString(), out tempPrice);
  2300. totalValue += tempPrice;
  2301. }
  2302. return totalValue;
  2303. }
  2304. /// <summary>
  2305. /// 获取业绩条数数据
  2306. /// </summary>
  2307. /// <param name="startTime"></param>
  2308. /// <param name="endTime"></param>
  2309. /// <returns></returns>
  2310. Dictionary<string, List<DataRow>> GetTotalPerformanceValue(string startTime , string endTime)
  2311. {
  2312. Dictionary<string, List<DataRow>> dataRows = new Dictionary<string, List<DataRow>>();
  2313. dataRows.Add("员工业绩", new List<DataRow>());
  2314. dataRows.Add("计件提成", new List<DataRow>());
  2315. dataRows.Add("员工支出", new List<DataRow>());
  2316. dataRows.Add("奖励", new List<DataRow>());
  2317. dataRows.Add("惩罚", new List<DataRow>());
  2318. LYFZ.BLL.BLL_ErpOrder orbll = new BLL.BLL_ErpOrder();
  2319. orbll.GetTotalPerformanceValue(startTime, endTime, ref dataRows);
  2320. return dataRows;
  2321. }
  2322. /// <summary>
  2323. /// 计算
  2324. /// </summary>
  2325. public void BindCalculate()
  2326. {
  2327. if (string.IsNullOrEmpty(this.txtTimeStart.DateValue))
  2328. { MessageBoxCustom.Show("开始时间不能为空!"); return; }
  2329. if (string.IsNullOrEmpty(this.txtTimeEnd.DateValue))
  2330. { MessageBoxCustom.Show("结束时间不能为空!"); return; }
  2331. if (this.cmbEmployeeName.Tag != null && this.cmbEmployeeName.Text != "全部" && this.cmbEmployeeName.Name.ToString() != "Department")
  2332. {
  2333. //获取员工业绩列表
  2334. this.BindPerformance(this.txtTimeStart.DateValue.ToString().Trim(), this.txtTimeEnd.DateValue.ToString().Trim(),
  2335. GetEmployeeDataInfo());
  2336. //this.txtCurrentUserPerformance.Text = Convert.ToDecimal(this.BindPerformance(this.txtTimeStart.DateValue.ToString().Trim(), this.txtTimeEnd.DateValue.ToString().Trim(),
  2337. // GetEmployeeDataInfo())).ToString("N2");
  2338. }
  2339. if (this.cmbEmployeeName.Text == "全部" || this.cmbEmployeeName.Name.ToString() == "Department")
  2340. {
  2341. this.txtCurrentUserPerformance.Text = "0";
  2342. //this.txtExpenditure.Text = "";
  2343. //this.txtPieceCommission.Text = "";
  2344. //this.txtRewardPunishment.Text = "";
  2345. this.TotalPerformance();
  2346. }
  2347. }
  2348. string GetEmployeeDataInfo()
  2349. {
  2350. string strWhere = "'-1'";
  2351. TreeNode tBode = this.cmbEmployeeName.SelectedNode;
  2352. if (tBode.Name== "StoreName")
  2353. {
  2354. if (tBode.Nodes.Count > 0)
  2355. {
  2356. foreach (TreeNode node in tBode.Nodes)
  2357. {
  2358. if (node.Nodes.Count > 0)
  2359. {
  2360. foreach (TreeNode userNode in node.Nodes)
  2361. {
  2362. if(strWhere=="-1" || strWhere == "'-1'")
  2363. {
  2364. strWhere = "";
  2365. }
  2366. if(strWhere!="")
  2367. {
  2368. strWhere += ",";
  2369. }
  2370. strWhere += "'" + userNode.Tag + "'";
  2371. }
  2372. }
  2373. }
  2374. }
  2375. }
  2376. else if (tBode.Name == "Department")
  2377. {
  2378. if (tBode.Nodes.Count > 0)
  2379. {
  2380. foreach (TreeNode userNode in tBode.Nodes)
  2381. {
  2382. if (strWhere == "-1" || strWhere == "'-1'")
  2383. {
  2384. strWhere = "";
  2385. }
  2386. if (strWhere != "")
  2387. {
  2388. strWhere += ",";
  2389. }
  2390. strWhere += "'" + userNode.Tag + "'";
  2391. }
  2392. }
  2393. }
  2394. else if (tBode.Name == "User")
  2395. {
  2396. if (strWhere == "-1"|| strWhere == "'-1'")
  2397. {
  2398. strWhere = "";
  2399. }
  2400. strWhere += "'" + tBode.Tag + "'";
  2401. }
  2402. //strDepartment = "'" + string.Join("','", department.ToArray()) + "'";
  2403. return strWhere;
  2404. }
  2405. /// <summary>
  2406. /// 选择人员姓名查询人员工资基本信息
  2407. /// </summary>
  2408. /// <param name="sender"></param>
  2409. /// <param name="e"></param>
  2410. protected override void cmbEmployeeName_ComboBoxTree_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e)
  2411. {
  2412. if (this.cmbEmployeeName.Tag.ToString().Trim() != null && this.cmbEmployeeName.Text.Trim() != "全部")
  2413. {
  2414. this.dgvAll.Visible = false;
  2415. this.dgv.Visible = true;
  2416. }
  2417. if (this.cmbEmployeeName.Text.Trim() == "全部" || this.cmbEmployeeName.Name.ToString().Trim() == "Department")
  2418. {
  2419. this.dgvAll.Visible = true;
  2420. this.dgv.Visible = false;
  2421. this.dgv.Rows.Clear();
  2422. this.txtCurrentUserPerformance.Text = "0";
  2423. //this.txtExpenditure.Text = "";
  2424. //this.txtPieceCommission.Text = "";
  2425. //this.txtRewardPunishment.Text = "";
  2426. }
  2427. this.BindCalculate();
  2428. }
  2429. /// <summary>
  2430. /// 选择项目类别
  2431. /// </summary>
  2432. /// <param name="sender"></param>
  2433. /// <param name="e"></param>
  2434. protected override void cmbItemCategory_ComboBoxTree_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e)
  2435. {
  2436. //清空项目名称
  2437. this.cmbProjectTitle.Enabled = false;
  2438. this.cmbProjectTitle.TreeView.Nodes.Clear();
  2439. this.cmbProjectTitle.Text = "";
  2440. switch (this.cmbItemCategory.Text.Trim())
  2441. {
  2442. case "订单前期":
  2443. case "会员充值":
  2444. case "服务卡充值":
  2445. case "员工支出": break;
  2446. case "订单后期":
  2447. case "其它消费":
  2448. this.cmbProjectTitle.Enabled = true;
  2449. LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.BindComboBoxTreeView_SystemCategory("BEBACDAJDFDDEACGJ", this.cmbProjectTitle, IsFirstNodeNull: true, StrWhere: "Sc_ClassCode not in ('BEBCADBFBCDFBGJHC','BEBCADBFBDDEGGABF','BEBCBFBICGDHCGBEJ','BEBCABBAAICBDHDHI','BEBCABBAAICJAAGDG','BEBCBFBICFCECBHFF')");
  2450. break;
  2451. case "礼服租售":
  2452. this.cmbProjectTitle.Enabled = true;
  2453. LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.BindComboxTreeView(this.cmbProjectTitle, "礼服出租,礼服出售", IsFirstNodeNull: true);
  2454. break;
  2455. case "员工奖罚":
  2456. this.cmbProjectTitle.Enabled = true;
  2457. LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.BindComboxTreeView(this.cmbProjectTitle, "奖励,罚款", IsFirstNodeNull: true);
  2458. break;
  2459. case "计件提成":
  2460. this.cmbProjectTitle.Enabled = true;
  2461. LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.BindComboBoxTreeView_SystemCategory("BEBBBABBEBAIHGDCB", this.cmbProjectTitle, IsFirstNodeNull: true);
  2462. break;
  2463. default:
  2464. this.cmbItemCategory.Text = this.cmbItemCategory.Text.Trim();
  2465. break;
  2466. }
  2467. this.BindCalculate();
  2468. }
  2469. /// <summary>
  2470. /// 项目名称
  2471. /// </summary>
  2472. /// <param name="sender"></param>
  2473. /// <param name="e"></param>
  2474. protected override void cmbProjectTitle_ComboBoxTree_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e)
  2475. {
  2476. this.BindCalculate();
  2477. }
  2478. /// <summary>
  2479. /// 套系类别
  2480. /// </summary>
  2481. /// <param name="sender"></param>
  2482. /// <param name="e"></param>
  2483. protected override void CtvPak_Name_ComboBoxTree_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e)
  2484. {
  2485. this.BindCalculate();
  2486. }
  2487. /// <summary>
  2488. /// 排序
  2489. /// </summary>
  2490. /// <param name="sender"></param>
  2491. /// <param name="e"></param>
  2492. protected override void dgvAll_SortCompare(object sender, DataGridViewSortCompareEventArgs e)
  2493. {
  2494. if (e.Column.Name == "员工姓名" || e.Column.Name == "当前业绩")
  2495. { e.SortResult = (Convert.ToDouble(e.CellValue1) - Convert.ToDouble(e.CellValue2) > 0) ? 1 : (Convert.ToDouble(e.CellValue1) - Convert.ToDouble(e.CellValue2) < 0) ? -1 : 0; }
  2496. //否则,按字符串比较
  2497. else
  2498. { e.SortResult = System.String.Compare(Convert.ToString(e.CellValue1), Convert.ToString(e.CellValue2)); }
  2499. e.Handled = true;//不能省掉,不然没效果
  2500. }
  2501. /// <summary>
  2502. /// 关闭
  2503. /// </summary>
  2504. /// <param name="sender"></param>
  2505. /// <param name="e"></param>
  2506. protected override void btnClose_Click(object sender, EventArgs e)
  2507. {
  2508. this.Close();
  2509. }
  2510. /// <summary>
  2511. /// 查询
  2512. /// </summary>
  2513. /// <param name="sender"></param>
  2514. /// <param name="e"></param>
  2515. protected override void btnSelect_Click(object sender, EventArgs e)
  2516. {
  2517. this.BindCalculate();
  2518. }
  2519. }
  2520. }