FrmLeaderRpt.cs 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656
  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. using CoreFS.CA06;
  10. using Core.Mes.Client.Comm.Control;
  11. using System.Collections;
  12. using Core.StlMes.Client.YdmPipeManage;
  13. using Core.Mes.Client.Comm.Server;
  14. using Infragistics.Win.UltraWinGrid;
  15. namespace Core.StlMes.Client.YdmPipeReport
  16. {
  17. public partial class FrmLeaderRpt : FrmBase
  18. {
  19. private Hashtable ShapeRelation = null;
  20. public FrmLeaderRpt()
  21. {
  22. this.IsLoadUserView = true;
  23. InitializeComponent();
  24. }
  25. private void FrmLeaderRpt_Load(object sender, EventArgs e)
  26. {
  27. dtBathYear.Value = DateTime.Parse(DateTime.Now.ToString("yyyy-MM"));
  28. }
  29. public override void ToolBar_Click(object sender, string ToolbarKey)
  30. {
  31. switch (ToolbarKey)
  32. {
  33. case "Query":
  34. //queryData();
  35. queryDataB();
  36. break;
  37. case "Export":
  38. exportData();
  39. break;
  40. case "Close":
  41. this.Close();
  42. break;
  43. }
  44. }
  45. /// <summary>
  46. /// 查询
  47. /// </summary>
  48. private void queryData()
  49. {
  50. string yearMothTim = "";
  51. try
  52. {
  53. this.Cursor = Cursors.WaitCursor; //控制鼠标的样式为等待
  54. if (Constant.WaitingForm == null)
  55. {
  56. Constant.WaitingForm = new WaitingForm();
  57. }
  58. Constant.WaitingForm.ShowToUser = true;
  59. Constant.WaitingForm.Show();
  60. Constant.WaitingForm.Update();
  61. yearMothTim = this.dtBathYear.Value.ToString("yyyyMM");
  62. //本月期初
  63. DataTable table1 = null;
  64. if (!this.GetOriginalLast(yearMothTim, out table1))
  65. {
  66. }
  67. //本月入库量
  68. DataTable table2 = null;
  69. if (!this.GetThisIn(yearMothTim, out table2))
  70. {
  71. //return;
  72. }
  73. //本月出库量
  74. DataTable table3 = null;
  75. if (!this.GetThisOut(yearMothTim, out table3))
  76. {
  77. //return;
  78. }
  79. //实物库存
  80. DataTable table4 = null;
  81. if (!this.GetThisMat(yearMothTim, out table4))
  82. {
  83. }
  84. //销售账面库存
  85. DataTable table5 = null;
  86. if (!this.GetThisXsMat(yearMothTim, out table5))
  87. {
  88. }
  89. //财务账面库存(末次)
  90. DataTable table6 = null;
  91. if (!this.GetThisZmMat(yearMothTim, out table6))
  92. {
  93. }
  94. //财务账面库存(首次)
  95. DataTable table7 = null;
  96. if (!this.GetThisZmMat1(yearMothTim, out table7))
  97. {
  98. }
  99. //调差量
  100. DataTable table8 = null;
  101. if(!this.GetAdjustWgt(yearMothTim,out table8))
  102. {
  103. }
  104. DataTable table = new DataTable();
  105. string[] strMergeColumns = new string[] { "BELONG_NAME" };
  106. if (table1 != null)
  107. {
  108. table = table1.DefaultView.ToTable(true, strMergeColumns);
  109. }
  110. if(table2 != null)
  111. {
  112. table = table2.DefaultView.ToTable(true, strMergeColumns);
  113. }
  114. if (table3 != null)
  115. {
  116. table = table3.DefaultView.ToTable(true, strMergeColumns);
  117. }
  118. if (table4 != null)
  119. {
  120. table = table4.DefaultView.ToTable(true, strMergeColumns);
  121. }
  122. if (table5 != null)
  123. {
  124. table = table5.DefaultView.ToTable(true, strMergeColumns);
  125. }
  126. if (table6 != null)
  127. {
  128. table = table6.DefaultView.ToTable(true, strMergeColumns);
  129. }
  130. //if (table8 != null)
  131. //{
  132. // table = table8.DefaultView.ToTable(true, strMergeColumns);
  133. //}
  134. if (table7 != null)
  135. {
  136. table = table7.DefaultView.ToTable(true, strMergeColumns);
  137. }
  138. if (table != null)
  139. {
  140. table.DefaultView.Sort = "BELONG_NAME";
  141. table = table.DefaultView.ToTable(true, strMergeColumns);
  142. }
  143. else
  144. {
  145. return;
  146. }
  147. string strSort = "", strBelongName = "";
  148. DataRow newrow;
  149. DataRow[] rows;
  150. this.dataTable1.Rows.Clear();
  151. decimal dWgt = 0.0M, dThisIn_Month = 0.0M, dThisOut_Month = 0.00M, dThisMatWgt = 0.00M, dThisXsWgt = 0.00M, dThisCwWgt = 0.00M,dThisCwWgt1 = 0.0M,dThisAdjustWgt = 0.00M;
  152. string strRowFilters = "";
  153. for (int i = 0; i < table.Rows.Count; i++)
  154. {
  155. newrow = this.dataTable1.NewRow();
  156. strBelongName = Convert.ToString(table.Rows[i]["BELONG_NAME"]);
  157. strRowFilters = string.IsNullOrEmpty(strBelongName) ? " BELONG_NAME is null " : " BELONG_NAME = '" + strBelongName + "' ";
  158. try
  159. {
  160. table1.CaseSensitive = true;
  161. rows = table1.Select(strRowFilters);
  162. if (rows.Length > 0)
  163. {
  164. try
  165. {
  166. dWgt = decimal.Parse(Convert.ToString(rows[0]["ACT_WEIGHT"]));
  167. }
  168. catch
  169. {
  170. dWgt = 0.0M;
  171. }
  172. }
  173. else
  174. {
  175. dWgt = 0.0M;
  176. }
  177. }
  178. catch
  179. {
  180. dWgt = 0.0M;
  181. }
  182. try
  183. {
  184. table2.CaseSensitive = true;
  185. rows = table2.Select(strRowFilters);
  186. if (rows.Length > 0)
  187. {
  188. try
  189. {
  190. dThisIn_Month = decimal.Parse(Convert.ToString(rows[0]["RKWGT"]));
  191. }
  192. catch
  193. {
  194. dThisIn_Month = 0.0M;
  195. }
  196. }
  197. else
  198. {
  199. dThisIn_Month = 0.0M;
  200. }
  201. }
  202. catch
  203. {
  204. dThisIn_Month = 0.0M;
  205. }
  206. try
  207. {
  208. table3.CaseSensitive = true;
  209. rows = table3.Select(strRowFilters);
  210. if (rows.Length > 0)
  211. {
  212. try
  213. {
  214. dThisOut_Month = decimal.Parse(Convert.ToString(rows[0]["CKWGT"]));
  215. }
  216. catch
  217. {
  218. dThisOut_Month = 0.0M;
  219. }
  220. }
  221. else
  222. {
  223. dThisOut_Month = 0.0M;
  224. }
  225. }
  226. catch
  227. {
  228. dThisOut_Month = 0.0M;
  229. }
  230. try
  231. {
  232. table4.CaseSensitive = true;
  233. rows = table4.Select(strRowFilters);
  234. if (rows.Length > 0)
  235. {
  236. try
  237. {
  238. dThisMatWgt = decimal.Parse(Convert.ToString(rows[0]["SWWGT"]));
  239. }
  240. catch
  241. {
  242. dThisMatWgt = 0.0M;
  243. }
  244. }
  245. else
  246. {
  247. dThisMatWgt = 0.0M;
  248. }
  249. }
  250. catch
  251. {
  252. dThisMatWgt = 0.0M;
  253. }
  254. try
  255. {
  256. table5.CaseSensitive = true;
  257. rows = table5.Select(strRowFilters);
  258. if (rows.Length > 0)
  259. {
  260. try
  261. {
  262. dThisXsWgt = decimal.Parse(Convert.ToString(rows[0]["XSWGT"]));
  263. }
  264. catch
  265. {
  266. dThisXsWgt = 0.0M;
  267. }
  268. }
  269. else
  270. {
  271. dThisXsWgt = 0.0M;
  272. }
  273. }
  274. catch
  275. {
  276. dThisXsWgt = 0.0M;
  277. }
  278. try
  279. {
  280. table6.CaseSensitive = true;
  281. rows = table6.Select(strRowFilters);
  282. if (rows.Length > 0)
  283. {
  284. try
  285. {
  286. dThisCwWgt = decimal.Parse(Convert.ToString(rows[0]["CWWGT"]));
  287. }
  288. catch
  289. {
  290. dThisCwWgt = 0.0M;
  291. }
  292. }
  293. else
  294. {
  295. dThisCwWgt = 0.0M;
  296. }
  297. }
  298. catch
  299. {
  300. dThisCwWgt = 0.0M;
  301. }
  302. try
  303. {
  304. table7.CaseSensitive = true;
  305. rows = table7.Select(strRowFilters);
  306. if (rows.Length > 0)
  307. {
  308. try
  309. {
  310. dThisCwWgt1 = decimal.Parse(Convert.ToString(rows[0]["CWWGT1"]));
  311. }
  312. catch
  313. {
  314. dThisCwWgt1 = 0.0M;
  315. }
  316. }
  317. else
  318. {
  319. dThisCwWgt1 = 0.0M;
  320. }
  321. }
  322. catch
  323. {
  324. dThisCwWgt1 = 0.0M;
  325. }
  326. try
  327. {
  328. table8.CaseSensitive = true;
  329. rows = table8.Select(strRowFilters);
  330. if (rows.Length > 0)
  331. {
  332. try
  333. {
  334. dThisAdjustWgt = decimal.Parse(Convert.ToString(rows[0]["ADJUSTWGT"]));
  335. }
  336. catch
  337. {
  338. dThisAdjustWgt = 0.0M;
  339. }
  340. }
  341. else
  342. {
  343. dThisAdjustWgt = 0.0M;
  344. }
  345. }
  346. catch
  347. {
  348. dThisAdjustWgt = 0.0M;
  349. }
  350. newrow["BELONG_NAME"] = strBelongName;
  351. newrow["ACT_WEIGHT"] = Convert.ToString(dWgt).Trim();
  352. newrow["RUWGT"] = Convert.ToString(dThisIn_Month).Trim();
  353. newrow["CKWGT"] = Convert.ToString(dThisOut_Month).Trim();
  354. newrow["SWWGT"] = Convert.ToString(dThisMatWgt).Trim();
  355. newrow["XSWGT"] = Convert.ToString(dThisXsWgt).Trim();
  356. newrow["CWWGT"] = Convert.ToString(dThisCwWgt).Trim();
  357. newrow["CWWGT2"] = Convert.ToString(dThisCwWgt1).Trim();
  358. newrow["ADJUSTWGT"] = Convert.ToString(dThisAdjustWgt).Trim();
  359. try
  360. {
  361. if (ShapeRelation.Contains(strBelongName))
  362. {
  363. strSort = ShapeRelation[strBelongName].ToString();
  364. }
  365. else
  366. {
  367. strSort = "";
  368. }
  369. }
  370. catch
  371. {
  372. strSort = "";
  373. }
  374. this.dataSet1.Tables[0].Rows.Add(newrow);
  375. }
  376. this.SetStaticsInfo();
  377. CommonMethod.SetGridSumArea(this.ultraGrid1);
  378. this.Cursor = Cursors.Default;
  379. Constant.WaitingForm.ShowToUser = false;
  380. Constant.WaitingForm.Close();
  381. Constant.WaitingForm = null;
  382. }
  383. catch (Exception e)
  384. {
  385. this.Cursor = Cursors.Default;
  386. Constant.WaitingForm.ShowToUser = false;
  387. Constant.WaitingForm.Close();
  388. Constant.WaitingForm = null;
  389. }
  390. }
  391. /// <summary>
  392. /// 查询
  393. /// </summary>
  394. private void queryDataB()
  395. {
  396. string yearMothTim = this.dtBathYear.Value.ToString("yyyyMM");
  397. DataTable dt = ServerHelper.GetData("com.steering.pss.ydm.Report.FrmLeaderRpt.doQueryData", new object[] { yearMothTim }, ob);
  398. GridHelper.CopyDataToDatatable(ref dt, ref dataTable1, true);
  399. this.SetStaticsInfo();
  400. CommonMethod.SetGridSumArea(this.ultraGrid1);
  401. }
  402. private void SetStaticsInfo()
  403. {
  404. try
  405. {
  406. if (this.ultraGrid1.Rows.Count == 0)
  407. {
  408. this.ultraGrid1.DisplayLayout.Bands[0].Summaries.Clear();
  409. }
  410. else
  411. {
  412. ArrayList alist = new ArrayList();
  413. alist.Add("ACT_WEIGHT");
  414. alist.Add("RUWGT");
  415. alist.Add("CKWGT");
  416. alist.Add("SWWGT");
  417. alist.Add("XSWGT");
  418. alist.Add("CWWGT");
  419. alist.Add("CWWGT2");
  420. alist.Add("ADJUSTWGT");
  421. //CommonMethod.SetStaticsInfoSum(ref this.ultraGrid1, alist, true);
  422. CommonMethod.SetStaticsInfoSum(ref this.ultraGrid1, alist, true);
  423. }
  424. }
  425. catch { }
  426. }
  427. /// <summary>
  428. /// 调差量
  429. /// </summary>
  430. /// <param name="yearMothTim"></param>
  431. /// <param name="table"></param>
  432. /// <returns></returns>
  433. private bool GetAdjustWgt(string yearMothTim,out DataTable table)
  434. {
  435. table = null;
  436. DataSet set = new DataSet();
  437. DataTable ds = ServerHelper.GetData("com.steering.pss.ydm.Report.FrmLeaderRpt.getAdjustWgt", new object[] { yearMothTim }, this.ob);
  438. if (ds != null && ds.Rows.Count > 0)
  439. {
  440. set.Tables.Add(ds);
  441. table = set.Tables[0];
  442. return true;
  443. }
  444. return false;
  445. }
  446. /// <summary>
  447. /// 财务账面库存(首次)
  448. /// </summary>
  449. /// <param name="yearMothTim"></param>
  450. /// <param name="table6"></param>
  451. /// <returns></returns>
  452. private bool GetThisZmMat1(string yearMothTim, out DataTable table)
  453. {
  454. table = null;
  455. DataSet set = new DataSet();
  456. DataTable ds = ServerHelper.GetData("com.steering.pss.ydm.Report.FrmLeaderRpt.getThisCwMat1", new object[] { yearMothTim }, this.ob);
  457. if (ds != null && ds.Rows.Count > 0)
  458. {
  459. set.Tables.Add(ds);
  460. table = set.Tables[0];
  461. return true;
  462. }
  463. return false;
  464. }
  465. /// <summary>
  466. /// 财务账面库存(末次)
  467. /// </summary>
  468. /// <param name="yearMothTim"></param>
  469. /// <param name="table6"></param>
  470. /// <returns></returns>
  471. private bool GetThisZmMat(string yearMothTim, out DataTable table)
  472. {
  473. table = null;
  474. DataSet set = new DataSet();
  475. DataTable ds = ServerHelper.GetData("com.steering.pss.ydm.Report.FrmLeaderRpt.getThisCwMat", new object[] { yearMothTim }, this.ob);
  476. if (ds != null && ds.Rows.Count > 0)
  477. {
  478. set.Tables.Add(ds);
  479. table = set.Tables[0];
  480. return true;
  481. }
  482. return false;
  483. }
  484. /// <summary>
  485. /// 销售账面库存
  486. /// </summary>
  487. /// <param name="yearMothTim"></param>
  488. /// <param name="table5"></param>
  489. /// <returns></returns>
  490. private bool GetThisXsMat(string yearMothTim, out DataTable table)
  491. {
  492. table = null;
  493. DataSet set = new DataSet();
  494. DataTable ds = ServerHelper.GetData("com.steering.pss.ydm.Report.FrmLeaderRpt.getThisXsMat", new object[] { yearMothTim }, this.ob);
  495. if (ds != null && ds.Rows.Count > 0)
  496. {
  497. set.Tables.Add(ds);
  498. table = set.Tables[0];
  499. return true;
  500. }
  501. return false;
  502. }
  503. /// <summary>
  504. /// 实物库存
  505. /// </summary>
  506. /// <param name="yearMothTim"></param>
  507. /// <param name="table4"></param>
  508. /// <returns></returns>
  509. private bool GetThisMat(string yearMothTim, out DataTable table)
  510. {
  511. table = null;
  512. DataSet set = new DataSet();
  513. DataTable ds = ServerHelper.GetData("com.steering.pss.ydm.Report.FrmLeaderRpt.getThisSwMat", new object[] { yearMothTim }, this.ob);
  514. if (ds != null && ds.Rows.Count > 0)
  515. {
  516. set.Tables.Add(ds);
  517. table = set.Tables[0];
  518. return true;
  519. }
  520. return false;
  521. }
  522. //本期出库量
  523. private bool GetThisOut(string yearMothTim,out DataTable table)
  524. {
  525. table = null;
  526. DataSet set = new DataSet();
  527. DataTable ds = ServerHelper.GetData("com.steering.pss.ydm.Report.FrmLeaderRpt.getThisOut", new object[] { yearMothTim }, this.ob);
  528. if (ds != null && ds.Rows.Count > 0)
  529. {
  530. set.Tables.Add(ds);
  531. table = set.Tables[0];
  532. return true;
  533. }
  534. return false;
  535. }
  536. //本期入库量
  537. private bool GetThisIn(string yearMothTim,out DataTable table)
  538. {
  539. table = null;
  540. DataSet set = new DataSet();
  541. DataTable ds = ServerHelper.GetData("com.steering.pss.ydm.Report.FrmLeaderRpt.getThisIn", new object[] { yearMothTim }, this.ob);
  542. if (ds != null && ds.Rows.Count > 0)
  543. {
  544. set.Tables.Add(ds);
  545. table = set.Tables[0];
  546. return true;
  547. }
  548. return false;
  549. }
  550. //期初
  551. private bool GetOriginalLast(string yearMothTim, out DataTable table)
  552. {
  553. table = null;
  554. DataSet set = new DataSet();
  555. DataTable ds = ServerHelper.GetData("com.steering.pss.ydm.Report.FrmLeaderRpt.getOriginalLast", new object[] { yearMothTim }, this.ob);
  556. if (ds != null && ds.Rows.Count > 0)
  557. {
  558. set.Tables.Add(ds);
  559. table = set.Tables[0];
  560. return true;
  561. }
  562. return false;
  563. }
  564. /// <summary>
  565. /// 导出
  566. /// </summary>
  567. private void exportData()
  568. {
  569. GridHelper.ulGridToExcel(this.ultraGrid1, "本月收发存结总汇");
  570. }
  571. private void chkRegTime_CheckedChanged(object sender, EventArgs e)
  572. {
  573. this.dtBathYear.Enabled = this.chkRegTime.Checked;
  574. }
  575. private void ultraGrid1_InitializeLayout(object sender, Infragistics.Win.UltraWinGrid.InitializeLayoutEventArgs e)
  576. {
  577. e.Layout.Override.DefaultRowHeight = 45;
  578. e.Layout.Override.RowSizing = RowSizing.Free;
  579. this.ultraGrid1.DisplayLayout.Override.RowSizing = RowSizing.Free;
  580. }
  581. }
  582. }