PurSuppPerReport.cs 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769
  1. using com.hnshituo.pur.vo;
  2. using Core.Mes.Client.Comm;
  3. using Core.Mes.Client.Comm.Control;
  4. using Core.Mes.Client.Comm.Format;
  5. using Core.Mes.Client.Comm.Server;
  6. using Core.Mes.Client.Comm.Tool;
  7. using CoreFS.CA06;
  8. using Infragistics.Win.UltraWinGrid;
  9. using Pur.Entity;
  10. using Pur.Entity.configureEntity;
  11. using System;
  12. using System.Collections;
  13. using System.Collections.Generic;
  14. using System.ComponentModel;
  15. using System.Data;
  16. using System.Drawing;
  17. using System.Linq;
  18. using System.Text;
  19. using System.Windows.Forms;
  20. namespace Pur.Report
  21. {
  22. public partial class PurSuppPerReport : FrmPmsBase
  23. {
  24. public PurSuppPerReport()
  25. {
  26. InitializeComponent();
  27. }
  28. private void PurSuppPerReport_Load(object sender, EventArgs e)
  29. {
  30. EntityHelper.ShowGridCaption<PurPerformanceMEntity>(ultraGrid1.DisplayLayout.Bands[0]);
  31. //StartTime.Value = DateTime.Now.ToString("YYYY");
  32. //DateTime now = DateTime.Now;
  33. //StartTime.Value = now.ToString("yyyy-");
  34. DateTime now = DateTime.Now;
  35. DateTime dtNow = new DateTime(now.Year, now.Month, 1);//当月第一天
  36. DateTime dt1 = new DateTime(now.Year, 1, 1);//取年第一天
  37. DateTime dt2 = dtNow.AddMonths(1).AddDays(-1);//当月最后一天
  38. this.StartTime.Value = DateTime.Parse(dt1.ToString("yyyy-MM-dd") + " 00:00:00");
  39. this.EndTime.Value = DateTime.Parse(dt2.ToString("yyyy-MM-dd") + " 23:59:59");
  40. DataTable dt = ServerHelper.GetData("com.hnshituo.pur.balance.service.impl.FrmBalanceOutBillManage.getDept", new object[] { }, ob);
  41. unit.DataSource = dt;
  42. unit.DisplayMember = "BUYER_DEPT_DESC";
  43. unit.ValueMember = "ROWNUM";
  44. txtResult.Value = "0";
  45. txtSupp.Value = "0";
  46. }
  47. /// <summary>
  48. /// 重写基类方法
  49. /// </summary>
  50. /// <param name="sender"></param>
  51. /// <param name="ToolbarKey"></param>
  52. public override void ToolBar_Click(object sender, string ToolbarKey)
  53. {
  54. switch (ToolbarKey)
  55. {
  56. case "DoQuery":
  57. QuerySinglePlan(); //计算
  58. break;
  59. case "DoUpdate":
  60. doUpdate(); //查询
  61. break;
  62. case "Doremedy":
  63. doRemedy();//添加
  64. break;
  65. case "DoSave":
  66. doSave();//保存
  67. break;
  68. case "Query":
  69. QueryHis();//查询历史数据
  70. break;
  71. case "doExcel"://导出excel
  72. doExcel();
  73. break;
  74. case "doOver"://结转
  75. doOver();
  76. break;
  77. case "Close":
  78. this.Close();
  79. break;
  80. }
  81. }
  82. private void QueryHis()
  83. {
  84. this.ultraGrid1.UpdateData();
  85. string startTime = "";
  86. string txtunit = "";
  87. this.ultraGrid1.UpdateData();
  88. if (StartTime.Text != "")
  89. {
  90. startTime = StartTime.Value.ToString("yyyy");
  91. }
  92. if (unit.Text != "")
  93. {
  94. txtunit = unit.Text;
  95. }
  96. else
  97. {
  98. txtunit = "";
  99. }
  100. List<PurPerformanceMEntity> listSource = EntityHelper.GetData<PurPerformanceMEntity>(
  101. "com.hnshituo.pur.balance.service.impl.FrmBalanceOutBillManage.doQueryHis", new object[] { startTime, txtunit }, this.ob);
  102. PurPerformanceMbindingSource1.DataSource = listSource;
  103. }
  104. private void doSave()
  105. {
  106. ArrayList list1 = new ArrayList();
  107. foreach(UltraGridRow row in ultraGrid1.Rows)
  108. {
  109. if(row==null)
  110. {
  111. MessageUtil.ShowTips("没有数据,请查询!");
  112. return;
  113. }
  114. ArrayList list = new ArrayList();
  115. list.Add(row.Cells["PerformanceYear"].Value);
  116. list.Add(row.Cells["SuppCode"].Value);
  117. list.Add(row.Cells["SuppName"].Value);
  118. list.Add(row.Cells["Values1"].Value);
  119. list.Add(row.Cells["Values2"].Value);
  120. list.Add(row.Cells["Values3"].Value);
  121. list.Add(row.Cells["Values4"].Value);
  122. list.Add(row.Cells["Values5"].Value);
  123. list.Add(row.Cells["Values6"].Value);
  124. list.Add(row.Cells["Values7"].Value);
  125. list.Add(row.Cells["Values8"].Value);
  126. list.Add(row.Cells["Values9"].Value);
  127. list.Add(row.Cells["Values10"].Value);
  128. list.Add(row.Cells["Values11"].Value);
  129. list.Add(row.Cells["Values12"].Value);
  130. list.Add(row.Cells["Values13"].Value);
  131. list.Add(row.Cells["Values14"].Value);
  132. list.Add(row.Cells["Values16"].Value);
  133. list.Add(row.Cells["Values17"].Value);
  134. list.Add(row.Cells["Values18"].Value);
  135. list.Add(row.Cells["Values19"].Value);
  136. list.Add(row.Cells["Values20"].Value);
  137. list.Add(row.Cells["Values21"].Value);
  138. list.Add(row.Cells["Values22"].Value);
  139. list.Add(row.Cells["Values23"].Value);
  140. list.Add(row.Cells["BuyerUnitCode"].Value);
  141. list.Add(row.Cells["BuyerUnitDesc"].Value);
  142. list1.Add(list);
  143. }
  144. CoreClientParam ccp = new CoreClientParam();
  145. ccp.ServerName = "com.hnshituo.pur.balance.service.impl.FrmBalanceOutBillManage";
  146. ccp.MethodName = "doPurPerSave";
  147. ccp.ServerParams = new object[] { list1 };
  148. ccp = ob.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  149. if (ccp.ReturnCode != -1)
  150. {
  151. if (ccp.ReturnInfo.Equals("保存成功!"))
  152. {
  153. MessageUtil.ShowTips(ccp.ReturnInfo);
  154. }
  155. else
  156. {
  157. MessageUtil.ShowTips(ccp.ReturnInfo);
  158. }
  159. }
  160. }
  161. private void doOver()
  162. {
  163. string txtTime = "";
  164. string txtunit = "";
  165. this.ultraGrid1.UpdateData();
  166. if (StartTime.Text != "")
  167. {
  168. txtTime = StartTime.Text;
  169. }
  170. else
  171. {
  172. txtTime = "";
  173. }
  174. if (unit.Text != "")
  175. {
  176. txtunit = unit.Text;
  177. }
  178. else
  179. {
  180. txtunit = "";
  181. }
  182. CoreClientParam ccp = new CoreClientParam();
  183. foreach(UltraGridRow urg in ultraGrid1.Rows)
  184. {
  185. ArrayList list = new ArrayList();
  186. list.Add(urg.Cells["PerformanceYear"].Text);
  187. list.Add(urg.Cells["SuppCode"].Text);
  188. list.Add(urg.Cells["SuppName"].Text);
  189. list.Add(urg.Cells["VALUES7"].Text);//二房认证
  190. list.Add(urg.Cells["VALUES1"].Text);//以前的供应商
  191. list.Add(urg.Cells["BuyerUnitCode"].Text);
  192. list.Add(urg.Cells["BuyerUnitDesc"].Text);
  193. //DataTable dt1 = ServerHelper.GetData("com.hnshituo.pur.balance.service.impl.FrmBalanceOutBillManage.doUpdatePer", new Object[] { list }, ob);
  194. ccp.ServerName = "com.hnshituo.pur.balance.service.impl.FrmBalanceOutBillManage";
  195. ccp.MethodName = "doOver";
  196. ccp.ServerParams = new object[] { list };
  197. ccp = ob.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  198. }
  199. if (ccp.ReturnCode != -1)
  200. {
  201. if (ccp.ReturnInfo.Equals("结转成功!"))
  202. {
  203. MessageUtil.ShowTips(ccp.ReturnInfo);
  204. }
  205. else
  206. {
  207. MessageUtil.ShowTips(ccp.ReturnInfo);
  208. }
  209. }
  210. }
  211. private void doExcel()
  212. {
  213. try
  214. {
  215. this.Cursor = Cursors.WaitCursor;
  216. ArrayList alUltraGrid = new ArrayList();
  217. alUltraGrid.Add(ultraGrid1);
  218. ArrayList alSheeft = new ArrayList();
  219. alSheeft.Add("供应商绩效报表");
  220. if (ultraGrid1.Rows.Count > 0)
  221. {
  222. GridHelper.ulGridToExcel(alUltraGrid, alSheeft, "供应商绩效报表");//导出excel
  223. }
  224. }
  225. catch (Exception e)
  226. {
  227. MessageUtil.ShowTips("导出失败" + e.Message);
  228. }
  229. finally
  230. {
  231. this.Cursor = Cursors.Default;
  232. }
  233. }
  234. private void QuerySinglePlan()
  235. {
  236. this.ultraGrid1.UpdateData();
  237. getLar();
  238. }
  239. private void doUpdate()
  240. {
  241. string txtTime = "";
  242. string endTime = "";
  243. string txtunit = "";
  244. this.ultraGrid1.UpdateData();
  245. if(StartTime.Text!="")
  246. {
  247. txtTime = StartTime.Text;
  248. endTime = EndTime.Text;
  249. }
  250. if(unit.Text!="")
  251. {
  252. txtunit = unit.Text;
  253. }else
  254. {
  255. txtunit = "";
  256. }
  257. CoreClientParam ccp = new CoreClientParam();
  258. ccp.ServerName = "com.hnshituo.pur.balance.service.impl.FrmBalanceOutBillManage";
  259. ccp.MethodName = "doUpdate";
  260. ccp.ServerParams = new object[] { txtTime,endTime, txtunit};
  261. ccp = ob.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  262. if (ccp.ReturnCode != -1)
  263. {
  264. if (ccp.ReturnInfo.Equals("查询成功!"))
  265. {
  266. Query();
  267. MessageUtil.ShowTips(ccp.ReturnInfo);
  268. }
  269. else
  270. {
  271. MessageUtil.ShowTips(ccp.ReturnInfo);
  272. }
  273. }
  274. }
  275. private void Query()
  276. {
  277. this.ultraGrid1.UpdateData();
  278. List<PurPerformanceMEntity> listSource = EntityHelper.GetData<PurPerformanceMEntity>(
  279. "com.hnshituo.pur.balance.service.impl.FrmBalanceOutBillManage.doQuery", null, this.ob);
  280. PurPerformanceMbindingSource1.DataSource = listSource;
  281. }
  282. private void doRemedy()
  283. {
  284. string suppCode = "";
  285. this.ultraGrid1.UpdateData();
  286. IQueryable<UltraGridRow> checkMags = this.ultraGrid1.Rows.AsQueryable().Where(" CHK = 'True'");
  287. if(checkMags.Count() == 0)
  288. {
  289. MessageUtil.ShowTips("请勾选需要添加的数据行!");
  290. return;
  291. }
  292. ArrayList parmList = new ArrayList();
  293. foreach (UltraGridRow row in checkMags)
  294. {
  295. ArrayList list = new ArrayList();
  296. suppCode = row.Cells["SuppCode"].Value.ToString();
  297. string check = "0";
  298. string result = "0";
  299. string supp = "0";
  300. if (txtCheck.Text != "")
  301. {
  302. check = txtCheck.Text.Trim();
  303. if (check.Equals("一档"))
  304. {
  305. check = "65%";
  306. }
  307. else if (check.Equals("二挡"))
  308. {
  309. check = "45%";
  310. }
  311. else if (check.Equals("三挡"))
  312. {
  313. check = "15%";
  314. }
  315. else if (check.Equals("四挡"))
  316. {
  317. check = "0%";
  318. }
  319. row.Cells["VALUES7"].Value = check;
  320. }
  321. if (txtResult.Text != "")
  322. {
  323. result = txtResult.Text.Trim();
  324. if (Convert.ToDouble(txtResult.Text) / 100 > 0.05)
  325. {
  326. MessageUtil.ShowTips("其它绩效不能大于5%");
  327. return;
  328. }
  329. row.Cells["VALUES22"].Value = result + "%";
  330. row.Cells["VALUES21"].Value = result + "%";
  331. }
  332. if (txtSupp.Text != "")
  333. {
  334. supp = txtSupp.Text.Trim();
  335. if (Convert.ToDouble(txtSupp.Text) / 100 > 0.05)
  336. {
  337. MessageUtil.ShowTips("特别供货不能大于5%");
  338. return;
  339. }
  340. row.Cells["VALUES11"].Value = supp + "%";
  341. row.Cells["VALUES12"].Value = supp + "%";
  342. }
  343. row.Cells["VALUES8"].Value = (Convert.ToDouble(row.Cells["VALUES4"].Text.Replace("%", "")) * 0.27 + Convert.ToDouble(row.Cells["VALUES6"].Text.Replace("%", "")) * 0.55 + Convert.ToDouble(row.Cells["VALUES7"].Text.Replace("%", "")) * 0.18) + "%";
  344. row.Cells["VALUES20"].Value = (Convert.ToDouble(row.Cells["VALUES17"].Text.Replace("%", "")) * 0.5 + Convert.ToDouble(row.Cells["VALUES19"].Text.Replace("%", "")) * 0.5) + "%";
  345. row.Cells["VALUES2"].Value = (Convert.ToDouble(row.Cells["VALUES8"].Text.Replace("%", "")) * 0.4 + Convert.ToDouble(row.Cells["VALUES13"].Text.Replace("%", "")) * 0.15
  346. + Convert.ToDouble(row.Cells["VALUES14"].Text.Replace("%", "")) * 0.15 + Convert.ToDouble(row.Cells["VALUES20"].Text.Replace("%", "")) * 0.15
  347. + Convert.ToDouble(row.Cells["VALUES22"].Text.Replace("%", "")) * 1 + Convert.ToDouble(row.Cells["VALUES12"].Text.Replace("%", "")) * 1).ToString("f2") + "%";
  348. if (row.Cells["VALUES23"].Text == null || row.Cells["VALUES23"].Text == "")
  349. {
  350. row.Cells["Values1"].Value = (Convert.ToDouble(row.Cells["VALUES2"].Text.Replace("%", ""))).ToString("f2") + "%";
  351. }
  352. else
  353. {
  354. row.Cells["Values1"].Value = (Convert.ToDouble(row.Cells["VALUES2"].Text.Replace("%", "")) + Convert.ToDouble(row.Cells["VALUES23"].Text.Replace("%", "")) * 0.1).ToString("f2") + "%";
  355. }
  356. if (check == "" && result == "" && supp == "")
  357. {
  358. MessageUtil.ShowTips("二方审核、其它绩效、特别供货不能全为空");
  359. }
  360. list.Add(check);
  361. list.Add(result);
  362. list.Add(supp);
  363. list.Add(suppCode);
  364. parmList.Add(list);
  365. }
  366. CoreClientParam ccp = new CoreClientParam();
  367. ccp.ServerName = "com.hnshituo.pur.balance.service.impl.FrmBalanceOutBillManage";
  368. ccp.MethodName = "doRemedy";
  369. ccp.ServerParams = new object[] { parmList };
  370. ccp = ob.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  371. if (ccp.ReturnCode != -1)
  372. {
  373. if (ccp.ReturnInfo.Equals("添加成功!"))
  374. {
  375. MessageUtil.ShowTips(ccp.ReturnInfo);
  376. }
  377. else
  378. {
  379. MessageUtil.ShowTips(ccp.ReturnInfo);
  380. }
  381. }
  382. }
  383. private void getLar()
  384. {
  385. string txtTime = "";
  386. string startTime = "";
  387. string endTime = "";
  388. string txtunit = "";
  389. if (StartTime.Text != "")
  390. {
  391. txtTime = StartTime.Text;
  392. startTime = StartTime.Value.ToString("yyyy");
  393. endTime = EndTime.Text;
  394. }
  395. if (unit.Text != "")
  396. {
  397. txtunit = unit.Text;
  398. }
  399. else
  400. {
  401. txtunit = "";
  402. }
  403. string lar = "";
  404. string larScore = "";
  405. List<UltraGridRow> rows = ComHelper.UltraGridGetOtherRows(ultraGrid1, "CHK");
  406. foreach (UltraGridRow urg in rows)
  407. {
  408. ArrayList list = new ArrayList();
  409. list.Add(txtTime);
  410. list.Add(endTime);
  411. list.Add(urg.Cells["SuppCode"].Text);
  412. list.Add(txtTime);
  413. list.Add(endTime);
  414. list.Add(urg.Cells["SuppCode"].Text);
  415. ArrayList list1 = new ArrayList();
  416. list1.Add(startTime);
  417. list1.Add(urg.Cells["SuppCode"].Text);
  418. ArrayList list2 = new ArrayList();
  419. list2.Add(txtTime);
  420. list2.Add(endTime);
  421. list2.Add(urg.Cells["SuppCode"].Text);
  422. //查询供应商绩效期初表
  423. DataTable dtPerE = ServerHelper.GetData("com.hnshituo.pur.balance.service.impl.FrmBalanceOutBillManage.doQueryPerE", new Object[] { list1 }, ob);
  424. if(dtPerE.Rows.Count>0)
  425. {
  426. urg.Cells["VALUES7"].Value = dtPerE.Rows[0]["VALUES1"].ToString();
  427. urg.Cells["VALUES23"].Value = dtPerE.Rows[0]["VALUES2"].ToString();
  428. }
  429. //lar
  430. DataTable dt1 = ServerHelper.GetData("com.hnshituo.pur.balance.service.impl.FrmBalanceOutBillManage.doReportDataDivider", new Object[] { list2 }, ob);
  431. if(dt1.Rows.Count > 0)
  432. {
  433. lar = dt1.Rows[0]["COUNT"].ToString();
  434. }
  435. if (lar.Equals("0"))
  436. {
  437. urg.Cells["VALUES3"].Value = "0%";
  438. lar = "0";
  439. }
  440. else
  441. {
  442. DataTable dt = ServerHelper.GetData("com.hnshituo.pur.balance.service.impl.FrmBalanceOutBillManage.doReportData", new Object[] { list }, ob);
  443. if (dt.Rows.Count > 0)
  444. {
  445. urg.Cells["VALUES3"].Value = dt.Rows[0]["LAR"].ToString();
  446. lar = dt.Rows[0]["LAR"].ToString().Replace("%", "").Trim();
  447. }
  448. }
  449. if (Convert.ToDouble(lar)/100 >= 0.8 && Convert.ToDouble(lar)/100 < 0.9)
  450. {
  451. larScore = "80%";
  452. }
  453. else if (Convert.ToDouble(lar)/100 >= 0.7 && Convert.ToDouble(lar)/100 < 0.8)
  454. {
  455. larScore = "70%";
  456. }
  457. else if (Convert.ToDouble(lar)/100 >= 0.6 && Convert.ToDouble(lar)/100 < 0.7)
  458. {
  459. larScore = "60%";
  460. }
  461. else if (Convert.ToDouble(lar)/100 >= 0.5 && Convert.ToDouble(lar)/100 < 0.6)
  462. {
  463. larScore = "50%";
  464. }
  465. else if (Convert.ToDouble(lar)/100 >= 0.4 && Convert.ToDouble(lar)/100 < 0.5)
  466. {
  467. larScore = "40%";
  468. }
  469. else if (Convert.ToDouble(lar)/100 >= 0.3 && Convert.ToDouble(lar)/100 < 0.4)
  470. {
  471. larScore = "30%";
  472. }
  473. else if (Convert.ToDouble(lar)/100 >= 0.2 && Convert.ToDouble(lar)/100 < 0.3)
  474. {
  475. larScore = "20%";
  476. }
  477. else if (Convert.ToDouble(lar)/100 >= 0.1 && Convert.ToDouble(lar)/100 < 0.2)
  478. {
  479. larScore = "10%";
  480. }
  481. else if (Convert.ToDouble(lar)/100 >= 0.0 && Convert.ToDouble(lar)/100 < 0.1)
  482. {
  483. larScore = "0%";
  484. }
  485. else if (Convert.ToDouble(lar)/100 >= 0.9 && Convert.ToDouble(lar)/100 < 1)
  486. {
  487. larScore = "90%";
  488. }
  489. else if (Convert.ToDouble(lar)/100 >= 1)
  490. {
  491. larScore = "100%";
  492. }
  493. urg.Cells["VALUES4"].Value = larScore;
  494. //ppm
  495. string ppm = "";
  496. string ppmScore = "";
  497. DataTable dtPm = ServerHelper.GetData("com.hnshituo.pur.balance.service.impl.FrmBalanceOutBillManage.doReportDataPpmDivider", new Object[] { list2 }, ob);
  498. if (dtPm.Rows.Count > 0)
  499. {
  500. ppm = dtPm.Rows[0]["DIVIDER"].ToString();
  501. }
  502. if (ppm.Equals("0"))
  503. {
  504. urg.Cells["VALUES5"].Value = "0%";
  505. ppm = "0";
  506. }
  507. else
  508. {
  509. DataTable dtPmscore = ServerHelper.GetData("com.hnshituo.pur.balance.service.impl.FrmBalanceOutBillManage.doReportDataPpmData", new Object[] { list2 }, ob);
  510. if (dtPmscore.Rows.Count > 0)
  511. {
  512. urg.Cells["VALUES5"].Value = dtPmscore.Rows[0]["ppm"];
  513. ppm = dtPmscore.Rows[0]["ppm"].ToString().Replace("%", "").Trim();
  514. }
  515. }
  516. if (Convert.ToDouble(ppm)/100 < 0.0003)
  517. {
  518. ppmScore = "90%";
  519. }
  520. else if(Convert.ToDouble(ppm)/100>=0.0003&&Convert.ToDouble(ppm)/100<0.0005){
  521. ppmScore = "80%";
  522. }
  523. else if (Convert.ToDouble(ppm)/100 >= 0.0005 && Convert.ToDouble(ppm)/100 < 0.001)
  524. {
  525. ppmScore = "60%";
  526. }
  527. else if(Convert.ToDouble(ppm)/100>=0.001)
  528. {
  529. ppmScore = "0%";
  530. }
  531. urg.Cells["VALUES6"].Value = larScore;
  532. //供货占比
  533. string supply = "0";
  534. string supplyScore = "";
  535. double hege = 0.0;
  536. double hege1 = 0.0;
  537. ArrayList Arr = new ArrayList();
  538. Arr.Add(txtTime);
  539. Arr.Add(endTime);
  540. Arr.Add(txtTime);
  541. Arr.Add(endTime);
  542. Arr.Add(urg.Cells["SuppCode"].Text);
  543. ArrayList arrayList = new ArrayList();
  544. arrayList.Add(txtTime);
  545. arrayList.Add(endTime);
  546. arrayList.Add(urg.Cells["SuppCode"].Text);
  547. arrayList.Add(txtTime);
  548. arrayList.Add(endTime);
  549. arrayList.Add(urg.Cells["SuppCode"].Text);
  550. arrayList.Add(txtTime);
  551. arrayList.Add(endTime);
  552. arrayList.Add(txtTime);
  553. arrayList.Add(endTime);
  554. arrayList.Add(urg.Cells["SuppCode"].Text);
  555. DataTable dtPriceFenMu = ServerHelper.GetData("com.hnshituo.pur.balance.service.impl.FrmBalanceOutBillManage.doReportDataFenMu", new Object[] { Arr }, ob);
  556. if (dtPriceFenMu.Rows[0]["HEGE"].ToString() != "0")
  557. {
  558. DataTable dtSupply = ServerHelper.GetData("com.hnshituo.pur.balance.service.impl.FrmBalanceOutBillManage.doReportDataSupply", new Object[] { arrayList }, ob);
  559. if (dtSupply.Rows.Count > 0)
  560. {
  561. urg.Cells["VALUES9"].Value = (Convert.ToDouble(dtSupply.Rows[0]["HEGE"].ToString()) * 100).ToString("f2") + "%";
  562. supply = dtSupply.Rows[0]["HEGE"].ToString();
  563. }
  564. }
  565. else
  566. {
  567. urg.Cells["VALUES9"].Value = "0%";
  568. }
  569. if(Convert.ToDouble(supply)>=0.30)
  570. {
  571. supplyScore = "100%";
  572. }else if(Convert.ToDouble(supply)>=0.20&&Convert.ToDouble(supply)<0.30)
  573. {
  574. supplyScore = "80%";
  575. }else if(Convert.ToDouble(supply)>=0.10&&Convert.ToDouble(supply)<0.20)
  576. {
  577. supplyScore = "50%";
  578. }else if(Convert.ToDouble(supply)<0.10)
  579. {
  580. supplyScore = "10%";
  581. }
  582. urg.Cells["VALUES10"].Value = supplyScore;
  583. urg.Cells["VALUES13"].Value = supplyScore;
  584. //反应能力评分和特别供货是相等的
  585. //otd
  586. string orderId = "";
  587. double time = 0.0;
  588. double ave = 0.0;
  589. DataTable dtOrder = ServerHelper.GetData("com.hnshituo.pur.balance.service.impl.FrmBalanceOutBillManage.doReportDataOrderDivider", new Object[] { list2 }, ob);
  590. if (dtOrder.Rows.Count > 0)
  591. {
  592. for (int i = 0; i < dtOrder.Rows.Count; i++)
  593. {
  594. orderId = dtOrder.Rows[i]["ORDER_ID"].ToString();
  595. ArrayList List = new ArrayList();
  596. List.Add(txtTime);
  597. List.Add(endTime);
  598. List.Add(urg.Cells["SuppCode"].Text);
  599. List.Add(orderId);
  600. DataTable dtOtd = ServerHelper.GetData("com.hnshituo.pur.balance.service.impl.FrmBalanceOutBillManage.doReportDataOtdData", new Object[] { List }, ob);
  601. if(dtOtd.Rows.Count>0)
  602. {
  603. time = Convert.ToInt64(dtOtd.Rows[0]["CHATIME"].ToString());
  604. ave += (1 - time * 0.01) / dtOrder.Rows.Count;
  605. // ave = Convert.ToInt64(ave * 100 + "%");
  606. }
  607. }
  608. }
  609. urg.Cells["VALUES14"].Value = (ave*100).ToString("f2")+"%";
  610. //成交价格波动
  611. string deal = "0";
  612. string dealScore = "";
  613. ////先求供应商对应的物料种类
  614. //ArrayList arrayList1 = new ArrayList();
  615. //arrayList1.Add(txtTime);
  616. //arrayList1.Add(urg.Cells["SuppCode"].Text);
  617. //DataTable dtItem1 = ServerHelper.GetData("com.hnshituo.pur.balance.service.impl.FrmBalanceOutBillManage.doReportDataItem", new Object[] { arrayList1 }, ob);
  618. ArrayList arrayList1 = new ArrayList();
  619. arrayList1.Add(txtTime);
  620. arrayList1.Add(endTime);
  621. arrayList1.Add(urg.Cells["SuppCode"].Text);
  622. arrayList1.Add(txtTime);
  623. arrayList1.Add(endTime);
  624. arrayList1.Add(urg.Cells["SuppCode"].Text);
  625. arrayList1.Add(txtTime);
  626. arrayList1.Add(endTime);
  627. arrayList1.Add(urg.Cells["SuppCode"].Text);
  628. arrayList1.Add(txtTime);
  629. arrayList1.Add(endTime);
  630. arrayList1.Add(urg.Cells["SuppCode"].Text);
  631. arrayList1.Add(txtTime);
  632. arrayList1.Add(endTime);
  633. arrayList1.Add(urg.Cells["SuppCode"].Text);
  634. DataTable dtPrice1 = ServerHelper.GetData("com.hnshituo.pur.balance.service.impl.FrmBalanceOutBillManage.doReportDataPrice", new Object[] { arrayList1 }, ob);
  635. if (dtPrice1.Rows.Count > 0)
  636. {
  637. urg.Cells["VALUES16"].Value = System.Math.Abs(((Convert.ToDouble(dtPrice1.Rows[0]["BID"].ToString()) * 100) - 100)).ToString("f2") + "%";
  638. deal = System.Math.Abs(Convert.ToDouble(dtPrice1.Rows[0]["BID"].ToString()) - 1).ToString("f2");
  639. }
  640. if (Convert.ToDouble(deal) < 0.1)
  641. {
  642. dealScore = "100%";
  643. }
  644. else if (Convert.ToDouble(deal) >= 0.1 && Convert.ToDouble(deal) < 0.2)
  645. {
  646. dealScore = "70%";
  647. }
  648. else if (Convert.ToDouble(deal) >= 0.2 && Convert.ToDouble(deal) < 0.4)
  649. {
  650. dealScore = "30%";
  651. }
  652. else if (Convert.ToDouble(deal) >= 0.4)
  653. {
  654. dealScore = "0%";
  655. }
  656. urg.Cells["VALUES17"].Value = dealScore;
  657. //报价价格波动
  658. string price = "";
  659. string priceScore = "";
  660. DataTable dtPrice = ServerHelper.GetData("com.hnshituo.pur.balance.service.impl.FrmBalanceOutBillManage.doReportDataWavePriceDivider", new Object[] { list2 }, ob);
  661. if (dtPrice.Rows.Count > 0)
  662. {
  663. if(Convert.ToDouble(dtPrice.Rows[0]["COUNT"].ToString())==0.0)
  664. {
  665. price = "0";
  666. }
  667. else
  668. {
  669. if (dtPrice.Rows[0]["RES_WITH_TAX_PRICE"].ToString() == null||dtPrice.Rows[0]["RES_WITH_TAX_PRICE"].ToString() =="")
  670. {
  671. price = "0";
  672. }
  673. else
  674. {
  675. price = (Convert.ToDouble(dtPrice.Rows[0]["RES_WITH_TAX_PRICE"].ToString()) / Convert.ToDouble(dtPrice.Rows[0]["COUNT"].ToString())).ToString("f2");
  676. }
  677. }
  678. }
  679. urg.Cells["VALUES18"].Value = (100 - Convert.ToDouble(price) * 100) + "%";
  680. if (Convert.ToDouble(1 - Convert.ToDouble(price)) <= 0.03)
  681. {
  682. priceScore = "100%";
  683. }
  684. else if (Convert.ToDouble(1 - Convert.ToDouble(price)) > 0.03 && Convert.ToDouble(1 - Convert.ToDouble(price)) <= 0.05)
  685. {
  686. priceScore = "70%";
  687. }
  688. else if (Convert.ToDouble(1 - Convert.ToDouble(price)) > 0.05 && Convert.ToDouble(1 - Convert.ToDouble(price)) <= 0.1)
  689. {
  690. priceScore = "30%";
  691. }
  692. else if (Convert.ToDouble(1 - Convert.ToDouble(price)) > 0.1)
  693. {
  694. priceScore = "0%";
  695. }
  696. urg.Cells["VALUES19"].Value = priceScore;
  697. ultraGrid1.UpdateData();
  698. }
  699. }
  700. private void ultraGrid1_AfterRowActivate(object sender, EventArgs e)
  701. {
  702. UltraGridRow urg = ultraGrid1.ActiveRow;
  703. if(urg==null)
  704. {
  705. return;
  706. }
  707. ultraGrid1.UpdateData();
  708. // txtCheck.Text = urg.Cells["VALUES7"].Text;
  709. if (urg.Cells["VALUES7"].Text == "65.00%")
  710. {
  711. txtCheck.SelectedIndex = 0;
  712. }
  713. else if (urg.Cells["VALUES7"].Text == "45.00%")
  714. {
  715. txtCheck.SelectedIndex = 1;
  716. }
  717. else if (urg.Cells["VALUES7"].Text == "15.00%")
  718. {
  719. txtCheck.SelectedIndex = 2;
  720. }
  721. else if (urg.Cells["VALUES7"].Text == "0.00%" || urg.Cells["VALUES7"].Text == "")
  722. {
  723. txtCheck.SelectedIndex = 3;
  724. }
  725. }
  726. }
  727. }