rptSendClosing.cs 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578
  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 System.Collections;
  11. using Core.Mes.Client.Comm.Tool;
  12. using Core.Mes.Client.Comm.Server;
  13. using Core.Mes.Client.Comm.Control;
  14. using Core.StlMes.Client.YdmPipeManage.Tool;
  15. namespace Core.StlMes.Client.YdmPipeReport
  16. {
  17. public partial class rptSendClosing : FrmBase
  18. {
  19. public rptSendClosing()
  20. {
  21. this.IsLoadUserView = true;
  22. InitializeComponent();
  23. }
  24. private void rptSendClosing_Load(object sender, EventArgs e)
  25. {
  26. //StatTime.Value = DateTime.Parse(DateTime.Now.ToString("yyyy-MM") + "-01" + " 00:00:00");
  27. //endTime.Value = DateTime.Today.AddDays(1).AddSeconds(-1);
  28. DateTime d1 = new DateTime(DateTime.Now.Year, DateTime.Now.Month, 1);
  29. this.StartTime.Value = DateTime.Parse(DateTime.Now.ToString("yyyy-MM"));
  30. }
  31. private Hashtable ShapeRelation = null;
  32. string[] arr = null;
  33. /// <summary>
  34. /// 重写基类方法
  35. /// </summary>
  36. /// <param name="sender"></param>
  37. /// <param name="ToolbarKey"></param>
  38. public override void ToolBar_Click(object sender, string ToolbarKey)
  39. {
  40. switch (ToolbarKey)
  41. {
  42. case "Query":
  43. QueryData();
  44. break;
  45. case "Export":
  46. ExportData();
  47. break;
  48. case "Close":
  49. this.Close();
  50. break;
  51. }
  52. }
  53. /// <summary>
  54. /// 查询
  55. /// </summary>
  56. private void QueryData()
  57. {
  58. //if (this.StatTime.Value > this.endTime.Value)
  59. //{
  60. // MessageUtil.ShowTips("起始日期不能大于结束日期!");
  61. // this.endTime.Focus();
  62. // return;
  63. //}
  64. string bathYear = this.StartTime.Value.ToString("yyyyMM");
  65. string strDateFrom = "";
  66. string strDateTo = "";
  67. string beglogCode = this.ComBeglog.Value.ToString2();
  68. arr = BaseMethod.InitPermissions(this.ValidDataPurviewIds, ob);
  69. string[] strMergeColumns = new string[] { "BILL_NO", "JUDGE_STOVE_NO", "BATCH_NO", "BATCH_GROUD_NO", "PRODUCNAME", "STD_STYLE_DESC", "STEELNAME", "SPEC_NAME", "MODEL_DESC" };
  70. //出库实单量
  71. DataTable table1 = null;
  72. if (!this.GetSOutWgt(strDateFrom, strDateTo, bathYear, out table1))
  73. {
  74. return;
  75. }
  76. //出库虚单量
  77. DataTable table2 = null;
  78. if (!this.GetXOutWgt(strDateFrom, strDateTo, bathYear, out table2))
  79. {
  80. }
  81. //已结算实单量
  82. DataTable table3 = null;
  83. if (!this.GetSClosingWgt(strDateFrom, strDateTo, bathYear, out table3))
  84. {
  85. }
  86. //已结算虚单量
  87. DataTable table4 = null;
  88. if (!this.GetXClosingWgt(strDateFrom, strDateTo, bathYear, out table4))
  89. {
  90. }
  91. //实时未结算量
  92. DataTable table5 = null;
  93. if (!this.GetRealNoClosingWgt(strDateFrom, strDateTo, bathYear, out table5))
  94. {
  95. }
  96. //票据未对齐
  97. DataTable table6 = null;
  98. if (!this.GetReaggedWgt(strDateFrom, strDateTo, bathYear, out table6))
  99. {
  100. }
  101. DataTable table = table1.DefaultView.ToTable(true, strMergeColumns);
  102. if (table2 != null)
  103. {
  104. table.Merge(table2.DefaultView.ToTable(true, strMergeColumns));
  105. }
  106. if (table3 != null)
  107. {
  108. table.Merge(table3.DefaultView.ToTable(true, strMergeColumns));
  109. }
  110. if (table4 != null)
  111. {
  112. table.Merge(table4.DefaultView.ToTable(true, strMergeColumns));
  113. }
  114. if (table5 != null)
  115. {
  116. table.Merge(table5.DefaultView.ToTable(true, strMergeColumns));
  117. }
  118. if(table6 != null)
  119. {
  120. table.Merge(table6.DefaultView.ToTable(true, strMergeColumns));
  121. }
  122. table.DefaultView.Sort = "BILL_NO,JUDGE_STOVE_NO,BATCH_NO,BATCH_GROUD_NO,PRODUCNAME,STD_STYLE_DESC,STEELNAME,SPEC_NAME,MODEL_DESC";
  123. table = table.DefaultView.ToTable(true, strMergeColumns);
  124. string strSort = "", strBillNo = "", strJudgeNo = "", strBatchNo = "",strGroupNo = "",strPro = "",strStyle = "",strSte = "",strSpec = "",strMode = "" ;
  125. DataRow newrow;
  126. DataRow[] rows;
  127. this.dataTable1.Rows.Clear();
  128. int dSOutCount = 0, dXOutCount = 0, dSdClosingCount = 0, dXdClosingCount = 0, dNoClosingCount = 0, dReaggedCount = 0, dCzCount = 0;
  129. decimal dSOutWgt = 0.0M, dXOutWgt = 0.0M, dSdClosingWgt = 0.0M, dXdClosingWgt = 0.0M, dNoClosingWgt = 0.0M, dReaggedWgt = 0.0M,dCzWgt = 0.0M;
  130. string strRowFilters = "";
  131. for (int i = 0; i < table.Rows.Count; i++)
  132. {
  133. newrow = this.dataTable1.NewRow();
  134. try
  135. {
  136. strBillNo = Convert.ToString(table.Rows[i]["BILL_NO"]);//提单号
  137. strJudgeNo = Convert.ToString(table.Rows[i]["JUDGE_STOVE_NO"]);
  138. strBatchNo = Convert.ToString(table.Rows[i]["BATCH_NO"]);
  139. strGroupNo = Convert.ToString(table.Rows[i]["BATCH_GROUD_NO"]);
  140. strPro = Convert.ToString(table.Rows[i]["PRODUCNAME"]);
  141. strStyle = Convert.ToString(table.Rows[i]["STD_STYLE_DESC"]);
  142. strSte = Convert.ToString(table.Rows[i]["STEELNAME"]);
  143. strSpec = Convert.ToString(table.Rows[i]["SPEC_NAME"]);
  144. strMode = Convert.ToString(table.Rows[i]["MODEL_DESC"]);
  145. strRowFilters = string.IsNullOrEmpty(strBillNo) ? " BILL_NO is null " : " BILL_NO = '" + strBillNo + "' ";
  146. strRowFilters += string.IsNullOrEmpty(strJudgeNo) ? " and JUDGE_STOVE_NO is null " : " and JUDGE_STOVE_NO = '" + strJudgeNo + "' ";
  147. strRowFilters += string.IsNullOrEmpty(strBatchNo) ? " and BATCH_NO is null " : " and BATCH_NO = '" + strBatchNo + "' ";
  148. strRowFilters += string.IsNullOrEmpty(strGroupNo) ? " and BATCH_GROUD_NO is null " : " and BATCH_GROUD_NO = '" + strGroupNo + "' ";
  149. strRowFilters += string.IsNullOrEmpty(strPro) ? " and PRODUCNAME is null " : " and PRODUCNAME = '" + strPro + "' ";
  150. strRowFilters += string.IsNullOrEmpty(strStyle) ? " and STD_STYLE_DESC is null " : " and STD_STYLE_DESC = '" + strStyle + "' ";
  151. strRowFilters += string.IsNullOrEmpty(strSte) ? " and STEELNAME is null " : " and STEELNAME = '" + strSte + "' ";
  152. strRowFilters += string.IsNullOrEmpty(strSpec) ? " and SPEC_NAME is null " : " and SPEC_NAME = '" + strSpec + "' ";
  153. strRowFilters += string.IsNullOrEmpty(strMode) ? " and MODEL_DESC is null " : " and MODEL_DESC = '" + strMode + "' ";
  154. try
  155. {
  156. table1.CaseSensitive = true;
  157. rows = table1.Select(strRowFilters);
  158. if (rows.Length > 0)
  159. {
  160. try
  161. {
  162. dSOutCount = int.Parse(Convert.ToString(rows[0]["SOUTCOUNT"]));
  163. dSOutWgt = decimal.Parse(Convert.ToString(rows[0]["SOUTWEIGHT"]));
  164. }
  165. catch
  166. {
  167. dSOutCount = 0;
  168. dSOutWgt = 0.0M;
  169. }
  170. }
  171. else
  172. {
  173. dSOutCount = 0;
  174. dSOutWgt = 0.0M;
  175. }
  176. }
  177. catch
  178. {
  179. dSOutCount = 0;
  180. dSOutWgt = 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. dXOutCount = int.Parse(Convert.ToString(rows[0]["XOUTCOUNT"]));
  191. dXOutWgt = decimal.Parse(Convert.ToString(rows[0]["XOUTWEIGHT"]));
  192. }
  193. catch
  194. {
  195. dXOutCount = 0;
  196. dXOutWgt = 0.0M;
  197. }
  198. }
  199. else
  200. {
  201. dXOutCount = 0;
  202. dXOutWgt = 0.0M;
  203. }
  204. }
  205. catch
  206. {
  207. dXOutCount = 0;
  208. dXOutWgt = 0.0M;
  209. }
  210. try
  211. {
  212. table3.CaseSensitive = true;
  213. rows = table3.Select(strRowFilters);
  214. if (rows.Length > 0)
  215. {
  216. try
  217. {
  218. dSdClosingCount = int.Parse(Convert.ToString(rows[0]["SCLOSINGCOUNT"]));
  219. dSdClosingWgt = decimal.Parse(Convert.ToString(rows[0]["SCLOSINGWEIGHT"]));
  220. }
  221. catch
  222. {
  223. dSdClosingCount = 0;
  224. dSdClosingWgt = 0.0M;
  225. }
  226. }
  227. else
  228. {
  229. dSdClosingCount = 0;
  230. dSdClosingWgt = 0.0M;
  231. }
  232. }
  233. catch
  234. {
  235. dSdClosingCount = 0;
  236. dSdClosingWgt = 0.0M;
  237. }
  238. try
  239. {
  240. table4.CaseSensitive = true;
  241. rows = table4.Select(strRowFilters);
  242. if (rows.Length > 0)
  243. {
  244. try
  245. {
  246. dXdClosingCount = int.Parse(Convert.ToString(rows[0]["XCLOSINGCOUNT"]));
  247. dXdClosingWgt = decimal.Parse(Convert.ToString(rows[0]["XCLOSINGWEIGHT"]));
  248. }
  249. catch
  250. {
  251. dXdClosingCount = 0;
  252. dXdClosingWgt = 0.0M;
  253. }
  254. }
  255. else
  256. {
  257. dXdClosingCount = 0;
  258. dXdClosingWgt = 0.0M;
  259. }
  260. }
  261. catch
  262. {
  263. dXdClosingCount = 0;
  264. dXdClosingWgt = 0.0M;
  265. }
  266. try
  267. {
  268. table5.CaseSensitive = true;
  269. rows = table5.Select(strRowFilters);
  270. if (rows.Length > 0)
  271. {
  272. try
  273. {
  274. dNoClosingCount = int.Parse(Convert.ToString(rows[0]["TIMEPOINTCOUNT"]));
  275. dNoClosingWgt = decimal.Parse(Convert.ToString(rows[0]["TIMEPOINTWEIGHT"]));
  276. }
  277. catch
  278. {
  279. dNoClosingCount = 0;
  280. dNoClosingWgt = 0.0M;
  281. }
  282. }
  283. else
  284. {
  285. dNoClosingCount = 0;
  286. dNoClosingWgt = 0.0M;
  287. }
  288. }
  289. catch
  290. {
  291. dNoClosingCount = 0;
  292. dNoClosingWgt = 0.0M;
  293. }
  294. try
  295. {
  296. table6.CaseSensitive = true;
  297. rows = table6.Select(strRowFilters);
  298. if (rows.Length > 0)
  299. {
  300. try
  301. {
  302. dReaggedCount = int.Parse(Convert.ToString(rows[0]["RAGGEDCOUNT"]));
  303. dReaggedWgt = decimal.Parse(Convert.ToString(rows[0]["RAGGEDWEIGHT"]));
  304. }
  305. catch
  306. {
  307. dReaggedCount = 0;
  308. dReaggedWgt = 0.0M;
  309. }
  310. }
  311. else
  312. {
  313. dReaggedCount = 0;
  314. dReaggedWgt = 0.0M;
  315. }
  316. }
  317. catch
  318. {
  319. dReaggedCount = 0;
  320. dReaggedWgt = 0.0M;
  321. }
  322. try
  323. {
  324. newrow["BILL_NO"] = strBillNo;
  325. newrow["JUDGE_STOVE_NO"] = strJudgeNo;
  326. newrow["BATCH_NO"] = strBatchNo;
  327. newrow["BATCH_GROUD_NO"] = strGroupNo;
  328. newrow["PRODUCNAME"] = strPro;
  329. newrow["STD_STYLE_DESC"] = strStyle;
  330. newrow["STEELNAME"] = strSte;
  331. newrow["SPEC_NAME"] = strSpec;
  332. newrow["MODEL_DESC"] = strMode;
  333. newrow["SOUTCOUNT"] = dSOutCount.ToString();
  334. newrow["SOUTWEIGHT"] = dSOutWgt.ToString();
  335. newrow["XOUTCOUNT"] = dXOutCount.ToString();
  336. newrow["XOUTWEIGHT"] = dXOutWgt.ToString();
  337. newrow["SCLOSINGCOUNT"] = dSdClosingCount.ToString();
  338. newrow["SCLOSINGWEIGHT"] = dSdClosingWgt.ToString();
  339. newrow["XCLOSINGCOUNT"] = dXdClosingCount.ToString();
  340. newrow["XCLOSINGWEIGHT"] = dXdClosingWgt.ToString();
  341. //newrow["TIMEPOINTCOUNT"] = Convert.ToString(dSOutCount + dXOutCount - dSdClosingCount - dXdClosingCount).Trim();
  342. //newrow["TIMEPOINTWEIGHT"] = Convert.ToString(dSOutWgt + dXOutWgt - dSdClosingWgt - dXdClosingWgt).Trim();
  343. newrow["REALTIMECOUNT"] = dNoClosingCount.ToString();
  344. newrow["REALTIMEWEIGHT"] = dNoClosingWgt.ToString();
  345. newrow["RAGGEDCOUNT"] = dReaggedCount.ToString();
  346. newrow["RAGGEDWEIGHT"] = dReaggedWgt.ToString();
  347. newrow["DIFCOUNT"] = Convert.ToString(dSOutCount + dXOutCount - dReaggedCount - dSdClosingCount - dXdClosingCount - dNoClosingCount).Trim();
  348. newrow["DIFWEIGHT"] = Convert.ToString(dSOutWgt + dXOutWgt - dReaggedWgt - dSdClosingWgt - dXdClosingWgt - dNoClosingWgt).Trim();
  349. try
  350. {
  351. if (ShapeRelation.Contains(strBillNo))
  352. {
  353. strSort = ShapeRelation[strBillNo].ToString();
  354. }
  355. else
  356. {
  357. strSort = "";
  358. }
  359. }
  360. catch
  361. {
  362. strSort = "";
  363. }
  364. //newrow["PRODUCT_SORT"] = strSort;
  365. this.dataSet1.Tables[0].Rows.Add(newrow);
  366. }
  367. catch { }
  368. }
  369. catch { }
  370. }
  371. this.SetStaticsInfo();
  372. CommonMethod.SetGridSumArea(this.ultraGrid1);
  373. }
  374. private void SetStaticsInfo()
  375. {
  376. try
  377. {
  378. if (this.ultraGrid1.Rows.Count == 0)
  379. {
  380. this.ultraGrid1.DisplayLayout.Bands[0].Summaries.Clear();
  381. }
  382. else
  383. {
  384. ArrayList alist = new ArrayList();
  385. alist.Add("SOUTCOUNT");
  386. alist.Add("SOUTWEIGHT");
  387. alist.Add("XOUTCOUNT");
  388. alist.Add("XOUTWEIGHT");
  389. alist.Add("SCLOSINGCOUNT");
  390. alist.Add("SCLOSINGWEIGHT");
  391. alist.Add("XCLOSINGCOUNT");
  392. alist.Add("XCLOSINGWEIGHT");
  393. //alist.Add("TIMEPOINTCOUNT");
  394. //alist.Add("TIMEPOINTWEIGHT");
  395. alist.Add("REALTIMECOUNT");
  396. alist.Add("REALTIMEWEIGHT");
  397. alist.Add("DIFCOUNT");
  398. alist.Add("DIFWEIGHT");
  399. alist.Add("RAGGEDCOUNT");
  400. alist.Add("RAGGEDWEIGHT");
  401. CommonMethod.SetStaticsInfoSum(ref this.ultraGrid1, alist, true);
  402. }
  403. }
  404. catch { }
  405. }
  406. /// <summary>
  407. /// 票据未对齐
  408. /// </summary>
  409. /// <param name="strDateFrom"></param>
  410. /// <param name="strDateTo"></param>
  411. /// <param name="table3"></param>
  412. /// <returns></returns>
  413. private bool GetReaggedWgt(string strDateFrom, string strDateTo,string beglogCode, out DataTable table)
  414. {
  415. table = null;
  416. DataSet set = new DataSet();
  417. DataTable ds = ServerHelper.GetData("com.steering.pss.ydm.Report.FrmrptSendClosing.getReaggedWgt", new object[] { strDateFrom, strDateTo,beglogCode, arr }, this.ob);
  418. if (ds != null && ds.Rows.Count > 0)
  419. {
  420. set.Tables.Add(ds);
  421. table = set.Tables[0];
  422. return true;
  423. }
  424. return false;
  425. }
  426. /// <summary>
  427. /// 实时未结算
  428. /// </summary>
  429. /// <param name="strDateFrom"></param>
  430. /// <param name="strDateTo"></param>
  431. /// <param name="table3"></param>
  432. /// <returns></returns>
  433. private bool GetRealNoClosingWgt(string strDateFrom, string strDateTo,string beglogCode, out DataTable table)
  434. {
  435. table = null;
  436. DataSet set = new DataSet();
  437. DataTable ds = ServerHelper.GetData("com.steering.pss.ydm.Report.FrmrptSendClosing.getRealNoClosingWgt", new object[] { strDateFrom, strDateTo,beglogCode,arr }, 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="strDateFrom"></param>
  450. /// <param name="strDateTo"></param>
  451. /// <param name="table2"></param>
  452. /// <returns></returns>
  453. private bool GetXClosingWgt(string strDateFrom, string strDateTo,string beglogCode, out DataTable table)
  454. {
  455. table = null;
  456. DataSet set = new DataSet();
  457. DataTable ds = ServerHelper.GetData("com.steering.pss.ydm.Report.FrmrptSendClosing.getXClosingWgt", new object[] { strDateFrom, strDateTo,beglogCode, arr }, this.ob);
  458. if (ds != null && ds.Rows.Count > 0)
  459. {
  460. set.Tables.Add(ds);
  461. table = set.Tables[0];
  462. return true;
  463. }
  464. return false;
  465. }
  466. /// <summary>
  467. /// 已结算实单量
  468. /// </summary>
  469. /// <param name="strDateFrom"></param>
  470. /// <param name="strDateTo"></param>
  471. /// <param name="table2"></param>
  472. /// <returns></returns>
  473. private bool GetSClosingWgt(string strDateFrom, string strDateTo,string beglogCode, out DataTable table)
  474. {
  475. table = null;
  476. DataSet set = new DataSet();
  477. DataTable ds = ServerHelper.GetData("com.steering.pss.ydm.Report.FrmrptSendClosing.getSClosingWgt", new object[] { strDateFrom, strDateTo ,beglogCode,arr }, this.ob);
  478. if (ds != null && ds.Rows.Count > 0)
  479. {
  480. set.Tables.Add(ds);
  481. table = set.Tables[0];
  482. return true;
  483. }
  484. return false;
  485. }
  486. /// <summary>
  487. /// 出库虚单量
  488. /// </summary>
  489. /// <param name="strDateFrom"></param>
  490. /// <param name="strDateTo"></param>
  491. /// <param name="table1"></param>
  492. /// <returns></returns>
  493. private bool GetXOutWgt(string strDateFrom, string strDateTo, string beglogCode, out DataTable table)
  494. {
  495. table = null;
  496. DataSet set = new DataSet();
  497. DataTable ds = ServerHelper.GetData("com.steering.pss.ydm.Report.FrmrptSendClosing.getXOutWgt", new object[] { strDateFrom, strDateTo,beglogCode, arr }, this.ob);
  498. if (ds != null && ds.Rows.Count > 0)
  499. {
  500. set.Tables.Add(ds);
  501. table = set.Tables[0];
  502. return true;
  503. }
  504. return false;
  505. }
  506. /// <summary>
  507. /// 出库实单量
  508. /// </summary>
  509. /// <param name="strDateFrom"></param>
  510. /// <param name="strDateTo"></param>
  511. /// <param name="table1"></param>
  512. /// <returns></returns>
  513. private bool GetSOutWgt(string strDateFrom, string strDateTo,string beglogCode, out DataTable table)
  514. {
  515. table = null;
  516. DataSet set = new DataSet();
  517. DataTable ds = ServerHelper.GetData("com.steering.pss.ydm.Report.FrmrptSendClosing.getSOutWgt", new object[] { strDateFrom, strDateTo,beglogCode, arr }, this.ob);
  518. if (ds != null && ds.Rows.Count > 0)
  519. {
  520. set.Tables.Add(ds);
  521. table = set.Tables[0];
  522. return true;
  523. }
  524. return false;
  525. }
  526. /// <summary>
  527. /// 导出
  528. /// </summary>
  529. private void ExportData()
  530. {
  531. GridHelper.ulGridToExcel(ultraGrid1, "出库结算汇总");
  532. }
  533. }
  534. }