FrmRunTimeRptXs.cs 42 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973
  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 Core.StlMes.Client.YdmPipeManage.Tool;
  12. using Core.Mes.Client.Comm.Tool;
  13. using Core.Mes.Client.Comm.Server;
  14. using System.Collections;
  15. using Core.StlMes.Client.YdmPipeManage;
  16. using Infragistics.Win;
  17. using Infragistics.Win.UltraWinGrid;
  18. using Core.StlMes.Client.YdmBase;
  19. namespace Core.StlMes.Client.YdmPipeReport
  20. {
  21. public partial class FrmRunTimeRptXs : FrmBase
  22. {
  23. public FrmRunTimeRptXs()
  24. {
  25. this.IsLoadUserView = true;
  26. InitializeComponent();
  27. }
  28. private Hashtable ShapeRelation = null;
  29. private void FrmRunTimeRpt_Load(object sender, EventArgs e)
  30. {
  31. dtBathYear.Value = DateTime.Parse(DateTime.Now.ToString("yyyy-MM"));
  32. YdmBaseClass.InitComboEditor(cmbStoreNo, "com.steering.pss.ydm.pipemanage.CorePipeInTemp.getStorageDetail", "STORAGE_NO", this.ob, false);
  33. }
  34. public override void ToolBar_Click(object sender, string ToolbarKey)
  35. {
  36. switch (ToolbarKey)
  37. {
  38. case"Query":
  39. queryData1();
  40. break;
  41. case"Query1":
  42. queryTal();
  43. break;
  44. case"Export":
  45. exportData();
  46. break;
  47. case "insertTal":
  48. insertTal();
  49. break;
  50. case "insertInital":
  51. insertInital();
  52. break;
  53. case"Close":
  54. this.Close();
  55. break;
  56. }
  57. }
  58. /// <summary>
  59. /// 结转
  60. /// </summary>
  61. private void insertInital()
  62. {
  63. UltraGridRow row = this.ultraGrid1.ActiveRow;
  64. string dtNowTim = DateTime.Now.AddMonths(1).ToString("yyyyMM");
  65. dtNowTim = dtBathYear.Value.AddMonths(1).ToString("yyyyMM");
  66. //if (row == null || row.Index < 0)
  67. //{
  68. // MessageUtil.ShowWarning("期初中转信息,无法结转!");
  69. // return;
  70. //}
  71. string[] arr = BaseMethod.InitPermissions(this.ValidDataPurviewIds, ob);
  72. DataTable ds = ServerHelper.GetData("com.steering.pss.ydm.Report.FrmRunTimeRpt.getIntalJZXs", new object[] { dtNowTim, arr, this.CustomInfo,"XS" }, ob);
  73. if (int.Parse(ds.Rows[0][0].ToString()) > 0)
  74. {
  75. MessageUtil.ShowTips("已存在结转数据,不允许重复结转!");
  76. return;
  77. }
  78. ArrayList parm = new ArrayList();
  79. if (MessageUtil.ShowYesNoAndQuestion("是否结转期初数据?") == DialogResult.No) return;
  80. try
  81. {
  82. this.Cursor = Cursors.WaitCursor; // 控制鼠标的样式为等待
  83. if (Constant.WaitingForm == null)
  84. {
  85. Constant.WaitingForm = new WaitingForm();
  86. }
  87. Constant.WaitingForm.ShowToUser = true;
  88. Constant.WaitingForm.Show();
  89. Constant.WaitingForm.Update();
  90. Dictionary<string, List<UltraGridRow>> groupedData = new Dictionary<string, List<UltraGridRow>>();
  91. // 遍历 ultraGrid1.Rows,将数据根据 JUDGE_STOVE_NO 和 BATCH_NO 分组
  92. foreach (UltraGridRow uRow in ultraGrid1.Rows)
  93. {
  94. string key = $"{uRow.Cells["JUDGE_STOVE_NO"].Value}_{uRow.Cells["BATCH_NO"].Value}";
  95. if (!groupedData.ContainsKey(key))
  96. {
  97. groupedData[key] = new List<UltraGridRow>();
  98. }
  99. groupedData[key].Add(uRow);
  100. }
  101. decimal totalCountAllGroups = 0; // 总支数
  102. decimal totalAmountAllGroups = 0; // 总重量
  103. foreach (var group in groupedData)
  104. {
  105. decimal totalCount = 0; // 当前分组的总支数
  106. decimal totalAmount = 0; // 当前分组的总重量
  107. // 遍历当前分组内的所有行,累加支数和重量
  108. foreach (var uRow in group.Value)
  109. {
  110. totalCount += decimal.Parse(uRow.Cells["END_COUNT"].Text);
  111. totalAmount += decimal.Parse(uRow.Cells["END_AMOUNT"].Text);
  112. }
  113. /*if (Convert.ToInt32(totalCount.ToString()) <= 0)
  114. {
  115. //System.Diagnostics.Debug.WriteLine($"炉号 {group.Key}: 支数{totalCount.ToString()}小于等于0 不计入");
  116. continue;
  117. }*/
  118. // System.Diagnostics.Debug.WriteLine($"分组 {group.Key}: 支数总和 = {totalCount}, 重量总和 = {totalAmount}");
  119. // 获取当前分组中最小的 BATCH_GROUD_NO 和 BELONG_CODE
  120. string minBatchGroupNo = group.Value.Min(gridRow => gridRow.Cells["BATCH_GROUD_NO"].Value.ToString());
  121. string minBelongCode = group.Value.Min(gridRow => gridRow.Cells["BELONG_CODE"].Value.ToString());
  122. // 使用 LINQ 分组,按 PRODUCNAME, STD_STYLE_DESC, STEELNAME, SPEC_NAME, MODEL_DESC 等字段进行分组
  123. var detailedGroups = group.Value
  124. .GroupBy(gridRow => new
  125. {
  126. PRODUCNAME = gridRow.Cells["PRODUCNAME"].Value.ToString(),
  127. STD_STYLE_DESC = gridRow.Cells["STD_STYLE_DESC"].Value.ToString(),
  128. STEELNAME = gridRow.Cells["STEELNAME"].Value.ToString(),
  129. SPEC_NAME = gridRow.Cells["SPEC_NAME"].Value.ToString(),
  130. MODEL_DESC = gridRow.Cells["MODEL_DESC"].Value.ToString()
  131. })
  132. .ToList();
  133. // 对每一个详细分组(按字段不同的组合)生成对应的 list
  134. foreach (var detailedGroup in detailedGroups)
  135. {
  136. // 重新计算当前子组的总支数和总重量
  137. decimal groupCount = 0;
  138. decimal groupAmount = 0;
  139. foreach (var uRow in detailedGroup)
  140. {
  141. groupCount += decimal.Parse(uRow.Cells["END_COUNT"].Text);
  142. groupAmount += decimal.Parse(uRow.Cells["END_AMOUNT"].Text);
  143. }
  144. // 如果支数小于等于0,则跳过该组
  145. /*if (Convert.ToInt32(groupCount.ToString()) <= 0)
  146. {
  147. continue;
  148. }*/
  149. // 获取当前分组中的第一个 uRow(用作模板)来生成 `list`
  150. var firstGridRow = detailedGroup.First();
  151. // 构建列表并添加数据
  152. ArrayList list = new ArrayList();
  153. System.Diagnostics.Debug.WriteLine($"炉号 {firstGridRow.Cells["JUDGE_STOVE_NO"].Value.ToString()}");
  154. list.Add(firstGridRow.Cells["JUDGE_STOVE_NO"].Value.ToString()); // JUDGE_STOVE_NO
  155. list.Add(firstGridRow.Cells["BATCH_NO"].Value.ToString()); // BATCH_NO
  156. list.Add(minBatchGroupNo); // 取最小的 BATCH_GROUD_NO
  157. list.Add(groupCount.ToString()); // 当前子组的支数
  158. list.Add(groupAmount.ToString()); // 当前子组的重量
  159. list.Add(firstGridRow.Cells["PRODUCNAME"].Value.ToString()); // PRODUCNAME
  160. list.Add(firstGridRow.Cells["STD_STYLE_DESC"].Value.ToString()); // STD_STYLE_DESC
  161. list.Add(firstGridRow.Cells["STEELNAME"].Value.ToString()); // STEELNAME
  162. list.Add(firstGridRow.Cells["SPEC_NAME"].Value.ToString()); // SPEC_NAME
  163. list.Add(firstGridRow.Cells["MODEL_DESC"].Value.ToString()); // MODEL_DESC
  164. list.Add(dtNowTim); // 当前时间
  165. list.Add(this.UserInfo.GetUserName()); // 当前用户
  166. list.Add(minBelongCode); // 取最小的 BELONG_CODE
  167. // 将每个列表添加到最终的参数列表 parm 中
  168. parm.Add(list);
  169. }
  170. // 累加所有分组的支数和重量
  171. totalCountAllGroups += totalCount;
  172. totalAmountAllGroups += totalAmount;
  173. }
  174. // 输出总汇总信息
  175. System.Diagnostics.Debug.WriteLine($"所有分组的汇总: 支数总和 = {totalCountAllGroups}, 重量总和 = {totalAmountAllGroups}");
  176. CoreClientParam ccp = new CoreClientParam();
  177. ccp.ServerName = "com.steering.pss.ydm.Report.FrmRunTimeRpt";
  178. ccp.MethodName = "insertInitalXs";
  179. ccp.ServerParams = new object[] { parm, this.dtBathYear.Value.ToString("yyyyMM"), arr, this.CustomInfo,"XS" };
  180. ccp = ob.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  181. if (ccp.ReturnCode != -1)
  182. {
  183. if (ccp.ReturnInfo.Equals("期初数据结转成功!"))
  184. {
  185. MessageUtil.ShowTips(ccp.ReturnInfo);
  186. }
  187. else
  188. {
  189. MessageUtil.ShowTips(ccp.ReturnInfo);
  190. }
  191. }
  192. this.Cursor = Cursors.Default;
  193. Constant.WaitingForm.ShowToUser = false;
  194. Constant.WaitingForm.Close();
  195. Constant.WaitingForm = null;
  196. }
  197. catch (Exception e)
  198. {
  199. this.Cursor = Cursors.Default;
  200. Constant.WaitingForm.ShowToUser = false;
  201. Constant.WaitingForm.Close();
  202. Constant.WaitingForm = null;
  203. // 在这里可以增加对错误的日志处理
  204. MessageUtil.ShowError("发生错误:" + e.Message);
  205. }
  206. }
  207. /// <summary>
  208. /// 查询中转过去的数据
  209. /// </summary>
  210. private void queryTal()
  211. {
  212. string yearMoth = this.dtBathYear.Value.ToString("yyyyMM");
  213. string heatNo = "";
  214. if (chkStove.Checked && string.IsNullOrEmpty(this.cmbStoveNo.Text.Trim()))
  215. {
  216. MessageUtil.ShowTips("请输入炉号!");
  217. this.cmbStoveNo.Focus();
  218. return;
  219. }
  220. if (chkStove.Checked)
  221. {
  222. heatNo = this.cmbStoveNo.Text.Trim();
  223. }
  224. string[] arr = BaseMethod.InitPermissions(this.ValidDataPurviewIds, ob);
  225. try {
  226. this.Cursor = Cursors.WaitCursor; //控制鼠标的样式为等待
  227. if (Constant.WaitingForm == null)
  228. {
  229. Constant.WaitingForm = new WaitingForm();
  230. }
  231. Constant.WaitingForm.ShowToUser = true;
  232. Constant.WaitingForm.Show();
  233. Constant.WaitingForm.Update();
  234. DataTable dt = ServerHelper.GetData("com.steering.pss.ydm.Report.FrmRunTimeRpt.getTal", new object[] { yearMoth, heatNo, arr}, ob);
  235. GridHelper.CopyDataToDatatable(ref dt, ref dataTable2, true);
  236. this.SetStaticsInfoC();
  237. //CommonMethod.SetGridSumArea(this.ultraGrid2);
  238. this.Cursor = Cursors.Default;
  239. Constant.WaitingForm.ShowToUser = false;
  240. Constant.WaitingForm.Close();
  241. Constant.WaitingForm = null;
  242. }catch(Exception e)
  243. {
  244. this.Cursor = Cursors.Default;
  245. Constant.WaitingForm.ShowToUser = false;
  246. Constant.WaitingForm.Close();
  247. Constant.WaitingForm = null;
  248. }
  249. }
  250. private void SetStaticsInfoC()
  251. {
  252. //try
  253. //{
  254. // if (this.ultraGrid2.Rows.Count == 0)
  255. // {
  256. // this.ultraGrid2.DisplayLayout.Bands[0].Summaries.Clear();
  257. // }
  258. // else
  259. // {
  260. // ArrayList alist = new ArrayList();
  261. // alist.Add("ACT_COUNT");
  262. // alist.Add("Act_Weight");
  263. // CommonMethod.SetStaticsInfoSum(ref this.ultraGrid2, alist, true);
  264. // }
  265. //}
  266. //catch { }
  267. }
  268. /// <summary>
  269. /// 插入中转数据
  270. /// </summary>
  271. private void insertTal()
  272. {
  273. string dtYear = this.dtBathYear.Value.ToString("yyyyMM");
  274. string dtNowTim = DateTime.Now.ToString("yyyyMM");
  275. if (!this.dtBathYear.Value.AddMonths(1).ToString("yyyyMM").Equals(dtNowTim))
  276. {
  277. MessageUtil.ShowTips("所选结转年月与当前所在月往后推一月不一致,请重新选择结转年月!");
  278. return;
  279. }
  280. string[] arr = BaseMethod.InitPermissions(this.ValidDataPurviewIds, ob);
  281. DataTable ds = doQueryTalCount(arr);
  282. if (int.Parse(ds.Rows[0]["ACOUNT"].ToString()) > 0)
  283. {
  284. MessageUtil.ShowTips("已存在当前年月的中转数据了,不允许再进行中转!");
  285. return;
  286. }
  287. UltraGridRow row = this.ultraGrid1.ActiveRow;
  288. if (row == null || row.Index < 0)
  289. {
  290. MessageUtil.ShowWarning("无库存信息,无法中转!");
  291. return;
  292. }
  293. ArrayList parm = new ArrayList();
  294. if (MessageUtil.ShowYesNoAndQuestion("是否中转期初数据?") == DialogResult.No) return;
  295. try
  296. {
  297. this.Cursor = Cursors.WaitCursor; //控制鼠标的样式为等待
  298. if (Constant.WaitingForm == null)
  299. {
  300. Constant.WaitingForm = new WaitingForm();
  301. }
  302. Constant.WaitingForm.ShowToUser = true;
  303. Constant.WaitingForm.Show();
  304. Constant.WaitingForm.Update();
  305. foreach (UltraGridRow uRow in ultraGrid1.Rows)
  306. {
  307. //ArrayList ss = new ArrayList();
  308. //ss.Add(uRow.Cells["JUDGE_STOVE_NO"].Value.ToString());
  309. //ss.Add(uRow.Cells["BATCH_NO"].Value.ToString());
  310. //ss.Add(uRow.Cells["BATCH_GROUD_NO"].Value.ToString());
  311. //ss.Add(dtNowTim);
  312. //DataTable ds = ServerHelper.GetData("com.steering.pss.ydm.Report.FrmRunTimeRpt.getIntal", new object[] { ss }, ob);
  313. //if (int.Parse(ds.Rows[0]["ACOUNT"].ToString()) > 0)
  314. //{
  315. // MessageUtil.ShowTips("此数据已进行中转,不允许再次中转!");
  316. // return;
  317. //}
  318. if (int.Parse(uRow.Cells["END_COUNT"].Value.ToString()) > 0)
  319. {
  320. ArrayList list = new ArrayList();
  321. list.Add(uRow.Cells["JUDGE_STOVE_NO"].Value.ToString());
  322. list.Add(uRow.Cells["BATCH_NO"].Value.ToString());
  323. list.Add(uRow.Cells["BATCH_GROUD_NO"].Value.ToString());
  324. list.Add(uRow.Cells["END_COUNT"].Value.ToString());
  325. list.Add(uRow.Cells["END_AMOUNT"].Value.ToString());
  326. list.Add(this.dtBathYear.Value.AddMonths(1).ToString("yyyyMM"));
  327. parm.Add(list);
  328. }
  329. }
  330. CoreClientParam ccp = new CoreClientParam();
  331. ccp.ServerName = "com.steering.pss.ydm.Report.FrmRunTimeRpt";
  332. ccp.MethodName = "insertTal";
  333. ccp.ServerParams = new object[] { parm, arr };
  334. ccp = ob.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  335. if (ccp.ReturnCode != -1)
  336. {
  337. if (ccp.ReturnInfo.Equals("期初数据中转成功!"))
  338. {
  339. MessageUtil.ShowTips(ccp.ReturnInfo);
  340. }
  341. else
  342. {
  343. MessageUtil.ShowTips(ccp.ReturnInfo);
  344. }
  345. }
  346. this.Cursor = Cursors.Default;
  347. Constant.WaitingForm.ShowToUser = false;
  348. Constant.WaitingForm.Close();
  349. Constant.WaitingForm = null;
  350. }
  351. catch (Exception e)
  352. {
  353. this.Cursor = Cursors.Default;
  354. Constant.WaitingForm.ShowToUser = false;
  355. Constant.WaitingForm.Close();
  356. Constant.WaitingForm = null;
  357. }
  358. }
  359. /// <summary>
  360. /// 查询是否存在中转数据
  361. /// </summary>
  362. private DataTable doQueryTalCount(string[] arr)
  363. {
  364. DataTable ds = ServerHelper.GetData("com.steering.pss.ydm.Report.FrmRunTimeRpt.doQueryTail", new object[] { DateTime.Now.ToString("yyyyMM"), arr }, ob);
  365. return ds;
  366. }
  367. /// <summary>
  368. /// 导出
  369. /// </summary>
  370. private void exportData()
  371. {
  372. GridHelper.ulGridToExcel(ultraGrid1, "炉批运行年月收发存汇总");
  373. }
  374. /// <summary>
  375. /// 查询
  376. /// </summary>
  377. private void queryData1()
  378. {
  379. string yearMothTim = "";
  380. string[] arr = BaseMethod.InitPermissions(this.ValidDataPurviewIds, ob);
  381. try
  382. {
  383. this.Cursor = Cursors.WaitCursor; //控制鼠标的样式为等待
  384. if (Constant.WaitingForm == null)
  385. {
  386. Constant.WaitingForm = new WaitingForm();
  387. }
  388. Constant.WaitingForm.ShowToUser = true;
  389. Constant.WaitingForm.Show();
  390. Constant.WaitingForm.Update();
  391. yearMothTim = this.dtBathYear.Value.ToString("yyyyMM");
  392. string supplyUnit = this.CustomInfo;
  393. DataTable dt = ServerHelper.GetData("com.steering.pss.ydm.Report.FrmRunTimeRpt.getQueryDataXs", new object[] { yearMothTim, arr, supplyUnit, "XS" }, ob);
  394. GridHelper.CopyDataToDatatable(ref dt, ref this.dataTable1, true);
  395. this.SetStaticsInfo();
  396. CommonMethod.SetGridSumArea(this.ultraGrid1);
  397. this.Cursor = Cursors.Default;
  398. Constant.WaitingForm.ShowToUser = false;
  399. Constant.WaitingForm.Close();
  400. Constant.WaitingForm = null;
  401. }
  402. catch (Exception e)
  403. {
  404. this.Cursor = Cursors.Default;
  405. Constant.WaitingForm.ShowToUser = false;
  406. Constant.WaitingForm.Close();
  407. Constant.WaitingForm = null;
  408. }
  409. }
  410. /// <summary>
  411. /// 查询
  412. /// </summary>
  413. private void queryData()
  414. {
  415. string yearMothTim = "";
  416. string stoveNo = "";
  417. string[] arr = BaseMethod.InitPermissions(this.ValidDataPurviewIds, ob);
  418. if (chkStove.Checked && string.IsNullOrEmpty(this.cmbStoveNo.Text.Trim()))
  419. {
  420. MessageUtil.ShowTips("请输入炉号!");
  421. this.cmbStoveNo.Focus();
  422. return;
  423. }
  424. try
  425. {
  426. this.Cursor = Cursors.WaitCursor; //控制鼠标的样式为等待
  427. if (Constant.WaitingForm == null)
  428. {
  429. Constant.WaitingForm = new WaitingForm();
  430. }
  431. Constant.WaitingForm.ShowToUser = true;
  432. Constant.WaitingForm.Show();
  433. Constant.WaitingForm.Update();
  434. yearMothTim = this.dtBathYear.Value.ToString("yyyyMM");
  435. string strWhere1 = "", strWhere2 = "", strWhere3 = "", strWhere4 = "";
  436. if (this.chkStove.Checked)
  437. {
  438. strWhere1 += " and t.JUDGE_STOVE_NO like '%'||'" + this.cmbStoveNo.Value.ToString() + "'||'%'";
  439. strWhere2 += " and t.JUDGE_STOVE_NO like '%'||'" + this.cmbStoveNo.Value.ToString() + "'||'%'";
  440. strWhere3 += " and t.JUDGE_STOVE_NO like '%'||'" + this.cmbStoveNo.Value.ToString() + "'||'%'";
  441. strWhere4 += " and s.JUDGE_STOVE_NO like '%'||'" + this.cmbStoveNo.Value.ToString() + "'||'%'";
  442. }
  443. if (chkStoreNo.Checked)
  444. {
  445. strWhere1 += " and t.STORAGE_NO like '%'||'" + this.cmbStoreNo.Value.ToString() + "'||'%'";
  446. strWhere2 += " and t.STORAGE_NO like '%'||'" + this.cmbStoreNo.Value.ToString() + "'||'%'";
  447. strWhere3 += " and t.STORAGE_NO like '%'||'" + this.cmbStoreNo.Value.ToString() + "'||'%'";
  448. strWhere4 += " and s.STORAGE_NO like '%'||'" + this.cmbStoreNo.Value.ToString() + "'||'%'";
  449. }
  450. //上期期初
  451. DataTable table1 = null;
  452. if (!this.GetOriginalLast(yearMothTim, strWhere1, out table1, arr))
  453. {
  454. }
  455. //本期入库量
  456. DataTable table2 = null;
  457. if (!this.GetThisIn(yearMothTim, strWhere1, out table2, arr))
  458. {
  459. //return;
  460. }
  461. //本期出库量
  462. DataTable table3 = null;
  463. if (!this.GetThisOut(yearMothTim, strWhere1, out table3, arr))
  464. {
  465. //return;
  466. }
  467. //调差
  468. DataTable table4 = null;
  469. if (!this.GetAdjust(yearMothTim, strWhere1, out table4, arr))
  470. {
  471. }
  472. DataTable table = new DataTable();
  473. string[] strMergeColumns = new string[] { "JUDGE_STOVE_NO", "BATCH_NO", "BATCH_GROUD_NO" };
  474. if (table1 != null)
  475. {
  476. table = table1.DefaultView.ToTable(true, strMergeColumns);
  477. if (table2 != null)
  478. {
  479. table.Merge(table2.DefaultView.ToTable(true, strMergeColumns));
  480. }
  481. if (table3 != null)
  482. {
  483. table.Merge(table3.DefaultView.ToTable(true, strMergeColumns));
  484. }
  485. }
  486. else
  487. {
  488. if (table2 != null)
  489. {
  490. table = table2.DefaultView.ToTable(true, strMergeColumns);
  491. if (table3 != null)
  492. {
  493. table.Merge(table3.DefaultView.ToTable(true, strMergeColumns));
  494. }
  495. }
  496. else
  497. {
  498. if (table3 != null)
  499. {
  500. table = table3.DefaultView.ToTable(true, strMergeColumns);
  501. if (table4 != null)
  502. {
  503. table.Merge(table4.DefaultView.ToTable(true, strMergeColumns));
  504. }
  505. }
  506. else
  507. {
  508. if (table4 != null)
  509. {
  510. table = table4.DefaultView.ToTable(true, strMergeColumns);
  511. }
  512. }
  513. }
  514. }
  515. if (table != null)
  516. {
  517. table.DefaultView.Sort = "JUDGE_STOVE_NO, BATCH_NO, BATCH_GROUD_NO";
  518. table = table.DefaultView.ToTable(true, strMergeColumns);
  519. }
  520. else
  521. {
  522. return;
  523. }
  524. string strSort = "", strHeatNo = "", strBactchNo = "", strGroupNo = "", strPro = "", strStdStyle = "", strSteel = "",strSpec = "",strModel = "" ;
  525. DataRow newrow;
  526. DataRow[] rows;
  527. this.dataTable1.Rows.Clear();
  528. decimal dWgt = 0.0M,dAjust = 0.0M;
  529. int dCount = 0;
  530. decimal dThisIn_Month = 0.0M, dThisOut_Month = 0.00M;
  531. int dThisIn_MonthCount = 0, dThisOut_MonthCount = 0;
  532. string strRowFilters = "";
  533. for (int i = 0; i < table.Rows.Count; i++)
  534. {
  535. newrow = this.dataTable1.NewRow();
  536. try
  537. {
  538. strHeatNo = Convert.ToString(table.Rows[i]["JUDGE_STOVE_NO"]);//炉号
  539. strBactchNo = Convert.ToString(table.Rows[i]["BATCH_NO"]);//批号
  540. strGroupNo = Convert.ToString(table.Rows[i]["BATCH_GROUD_NO"]);//组号
  541. strPro = Convert.ToString(table.Rows[i]["PRODUCNAME"]);
  542. strStdStyle = Convert.ToString(table.Rows[i]["STD_STYLE_DESC"]);
  543. strSteel = Convert.ToString(table.Rows[i]["STEELNAME"]);
  544. strSpec = Convert.ToString(table.Rows[i]["SPEC_NAME"]);
  545. strModel = Convert.ToString(table.Rows[i]["MODEL_DESC"]);
  546. strRowFilters = string.IsNullOrEmpty(strHeatNo) ? " JUDGE_STOVE_NO is null " : " JUDGE_STOVE_NO = '" + strHeatNo + "' ";
  547. strRowFilters += string.IsNullOrEmpty(strBactchNo) ? " and BATCH_NO is null " : " and BATCH_NO = '" + strBactchNo + "' ";
  548. strRowFilters += string.IsNullOrEmpty(strGroupNo) ? " and BATCH_GROUD_NO is null " : " and BATCH_GROUD_NO = '" + strGroupNo + "' ";
  549. strRowFilters += string.IsNullOrEmpty(strGroupNo) ? " and PRODUCNAME is null " : " and PRODUCNAME = '" + strPro + "' ";
  550. strRowFilters += string.IsNullOrEmpty(strGroupNo) ? " and STD_STYLE_DESC is null " : " and STD_STYLE_DESC = '" + strStdStyle + "' ";
  551. strRowFilters += string.IsNullOrEmpty(strGroupNo) ? " and STEELNAME is null " : " and STEELNAME = '" + strSteel + "' ";
  552. strRowFilters += string.IsNullOrEmpty(strGroupNo) ? " and SPEC_NAME is null " : " and SPEC_NAME = '" + strSpec + "' ";
  553. strRowFilters += string.IsNullOrEmpty(strGroupNo) ? " and MODEL_DESC is null " : " and MODEL_DESC = '" + strModel + "' ";
  554. try
  555. {
  556. table1.CaseSensitive = true;
  557. rows = table1.Select(strRowFilters);
  558. if (rows.Length > 0)
  559. {
  560. try
  561. {
  562. dWgt = decimal.Parse(Convert.ToString(rows[0]["WEIGHT"]));
  563. dCount = int.Parse(Convert.ToString(rows[0]["COUNT"]));
  564. }
  565. catch
  566. {
  567. dWgt = 0.0M;
  568. dCount = 0;
  569. }
  570. }
  571. else
  572. {
  573. dWgt = 0.0M;
  574. dCount = 0;
  575. }
  576. }
  577. catch
  578. {
  579. dWgt = 0.0M;
  580. dCount = 0;
  581. }
  582. try
  583. {
  584. table2.CaseSensitive = true;
  585. rows = table2.Select(strRowFilters);
  586. if (rows.Length > 0)
  587. {
  588. try
  589. {
  590. dThisIn_Month = decimal.Parse(Convert.ToString(rows[0]["WEIGHT_MONTH"]));
  591. dThisIn_MonthCount = int.Parse(Convert.ToString(rows[0]["WEIGHT_MONTHCOUNT"]));
  592. }
  593. catch
  594. {
  595. dThisIn_Month = 0.0M;
  596. dThisIn_MonthCount = 0;
  597. }
  598. }
  599. else
  600. {
  601. dThisIn_Month = 0.0M;
  602. dThisIn_MonthCount = 0;
  603. }
  604. }
  605. catch
  606. {
  607. dThisIn_Month = 0.0M;
  608. dThisIn_MonthCount = 0;
  609. }
  610. try
  611. {
  612. table3.CaseSensitive = true;
  613. rows = table3.Select(strRowFilters);
  614. if (rows.Length > 0)
  615. {
  616. try
  617. {
  618. dThisOut_Month = decimal.Parse(Convert.ToString(rows[0]["WEIGHT_MONTH"]));
  619. dThisOut_MonthCount = int.Parse(Convert.ToString(rows[0]["weight_monthcount"]));
  620. }
  621. catch
  622. {
  623. dThisOut_Month = 0.0M;
  624. dThisOut_MonthCount = 0;
  625. }
  626. }
  627. else
  628. {
  629. dThisOut_Month = 0.0M;
  630. dThisOut_MonthCount = 0;
  631. }
  632. }
  633. catch
  634. {
  635. dThisOut_Month = 0.0M;
  636. dThisOut_MonthCount = 0;
  637. }
  638. try
  639. {
  640. table4.CaseSensitive = true;
  641. rows = table4.Select(strRowFilters);
  642. if (rows.Length > 0)
  643. {
  644. try
  645. {
  646. dAjust = decimal.Parse(Convert.ToString(rows[0]["AWEIGHT"]));
  647. }
  648. catch
  649. {
  650. dAjust = 0.0M;
  651. }
  652. }
  653. else
  654. {
  655. dAjust = 0.0M;
  656. }
  657. }
  658. catch
  659. {
  660. dAjust = 0.0M;
  661. }
  662. try
  663. {
  664. newrow["JUDGE_STOVE_NO"] = strHeatNo;
  665. newrow["BATCH_NO"] = strBactchNo;
  666. newrow["BATCH_GROUD_NO"] = strGroupNo;
  667. newrow["PRODUCNAME"] = strPro;
  668. newrow["STD_STYLE_DESC"] = strStdStyle;
  669. newrow["STEELNAME"] = strSteel;
  670. newrow["SPEC_NAME"] = strSpec;
  671. newrow["MODEL_DESC"] = strModel;
  672. newrow["ORIGINAL_AMOUNT"] = Convert.ToString(dWgt).Trim();
  673. newrow["ORIGINAL_COUNT"] = Convert.ToString(dCount).Trim();
  674. newrow["MONTH_1"] = dThisIn_Month.ToString().Trim();
  675. newrow["MONTH_1COUNT"] = dThisIn_MonthCount.ToString().Trim();
  676. newrow["MONTH_2"] = dThisOut_Month.ToString().Trim();
  677. newrow["MONTH_2COUNT"] = dThisOut_MonthCount.ToString().Trim();
  678. newrow["END_AMOUNT"] = Convert.ToString(dWgt + dThisIn_Month - dThisOut_Month + dAjust).Trim();
  679. newrow["END_COUNT"] = Convert.ToString(dCount + dThisIn_MonthCount - dThisOut_MonthCount).Trim();
  680. newrow["AWEIGHT"] = Convert.ToString(dAjust).Trim();
  681. try
  682. {
  683. if (ShapeRelation.Contains(strHeatNo))
  684. {
  685. strSort = ShapeRelation[strHeatNo].ToString();
  686. }
  687. else
  688. {
  689. strSort = "";
  690. }
  691. }
  692. catch
  693. {
  694. strSort = "";
  695. }
  696. this.dataSet1.Tables[0].Rows.Add(newrow);
  697. } catch { }
  698. }
  699. catch { }
  700. }
  701. this.SetStaticsInfo();
  702. CommonMethod.SetGridSumArea(this.ultraGrid1);
  703. this.Cursor = Cursors.Default;
  704. Constant.WaitingForm.ShowToUser = false;
  705. Constant.WaitingForm.Close();
  706. Constant.WaitingForm = null;
  707. }
  708. catch (Exception e)
  709. {
  710. this.Cursor = Cursors.Default;
  711. Constant.WaitingForm.ShowToUser = false;
  712. Constant.WaitingForm.Close();
  713. Constant.WaitingForm = null;
  714. }
  715. }
  716. private void SetStaticsInfo()
  717. {
  718. try
  719. {
  720. if (this.ultraGrid1.Rows.Count == 0)
  721. {
  722. this.ultraGrid1.DisplayLayout.Bands[0].Summaries.Clear();
  723. }
  724. else
  725. {
  726. ArrayList alist = new ArrayList();
  727. alist.Add("ORIGINAL_AMOUNT");
  728. alist.Add("ORIGINAL_COUNT");
  729. alist.Add("MONTH_1");
  730. alist.Add("MONTH_1COUNT");
  731. alist.Add("MONTH_2");
  732. alist.Add("MONTH_2COUNT");
  733. alist.Add("END_AMOUNT");
  734. alist.Add("END_COUNT");
  735. alist.Add("AWEIGHT");
  736. CommonMethod.SetStaticsInfoSum(ref this.ultraGrid1, alist, true);
  737. }
  738. }
  739. catch { }
  740. }
  741. //本期调差量
  742. private bool GetAdjust(string yearMothTim, string strWhere, out DataTable table, string[] arr)
  743. {
  744. table = null;
  745. DataSet set = new DataSet();
  746. DataTable ds = ServerHelper.GetData("com.steering.pss.ydm.Report.FrmRunTimeRpt.getAdjust", new object[] { yearMothTim, strWhere, arr }, this.ob);
  747. if (ds != null && ds.Rows.Count > 0)
  748. {
  749. set.Tables.Add(ds);
  750. table = set.Tables[0];
  751. return true;
  752. }
  753. return false;
  754. }
  755. //本期出库量
  756. private bool GetThisOut(string yearMothTim, string strWhere, out DataTable table, string[] arr)
  757. {
  758. table = null;
  759. DataSet set = new DataSet();
  760. DataTable ds = ServerHelper.GetData("com.steering.pss.ydm.Report.FrmRunTimeRpt.getThisOut", new object[] { yearMothTim, strWhere, arr }, this.ob);
  761. if (ds != null && ds.Rows.Count > 0)
  762. {
  763. set.Tables.Add(ds);
  764. table = set.Tables[0];
  765. return true;
  766. }
  767. return false;
  768. }
  769. //本期入库量
  770. private bool GetThisIn(string yearMothTim,string strWhere, out DataTable table, string[] arr)
  771. {
  772. table = null;
  773. DataSet set = new DataSet();
  774. DataTable ds = ServerHelper.GetData("com.steering.pss.ydm.Report.FrmRunTimeRpt.getThisIn", new object[] { yearMothTim, strWhere, arr }, this.ob);
  775. if (ds != null && ds.Rows.Count > 0)
  776. {
  777. set.Tables.Add(ds);
  778. table = set.Tables[0];
  779. return true;
  780. }
  781. return false;
  782. }
  783. //期初
  784. private bool GetOriginalLast(string yearMothTim, string strWhere, out DataTable table, string[] arr)
  785. {
  786. table = null;
  787. DataSet set = new DataSet();
  788. DataTable ds = ServerHelper.GetData("com.steering.pss.ydm.Report.FrmRunTimeRpt.getOriginalLast", new object[] { yearMothTim, strWhere, arr }, this.ob);
  789. if (ds != null && ds.Rows.Count > 0)
  790. {
  791. set.Tables.Add(ds);
  792. table = set.Tables[0];
  793. return true;
  794. }
  795. return false;
  796. }
  797. private void cmbStoveNo_KeyDown(object sender, KeyEventArgs e)
  798. {
  799. if (e.KeyValue == 13)
  800. {
  801. queryData();
  802. }
  803. }
  804. private void chkStove_CheckedChanged(object sender, EventArgs e)
  805. {
  806. this.cmbStoveNo.Enabled = chkStove.Checked;
  807. }
  808. private void ultraTabControl1_SelectedTabChanged(object sender, Infragistics.Win.UltraWinTabControl.SelectedTabChangedEventArgs e)
  809. {
  810. if (toolMenu == null)
  811. {
  812. return;
  813. }
  814. if (ultraTabControl1.SelectedTab.Key == "0")
  815. {
  816. if (toolMenu.Toolbars[0].Tools.Exists("Query1"))
  817. {
  818. toolMenu.Toolbars[0].Tools["Query1"].InstanceProps.Visible = DefaultableBoolean.False;
  819. }
  820. if (toolMenu.Toolbars[0].Tools.Exists("insertInital"))
  821. {
  822. toolMenu.Toolbars[0].Tools["insertInital"].InstanceProps.Visible = DefaultableBoolean.True;
  823. }
  824. if (toolMenu.Toolbars[0].Tools.Exists("Query"))
  825. {
  826. toolMenu.Toolbars[0].Tools["Query"].InstanceProps.Visible = DefaultableBoolean.True;
  827. }
  828. if (toolMenu.Toolbars[0].Tools.Exists("insertTal"))
  829. {
  830. toolMenu.Toolbars[0].Tools["insertTal"].InstanceProps.Visible = DefaultableBoolean.False;
  831. }
  832. if (toolMenu.Toolbars[0].Tools.Exists("Export"))
  833. {
  834. toolMenu.Toolbars[0].Tools["Export"].InstanceProps.Visible = DefaultableBoolean.True;
  835. }
  836. this.chkStoreNo.Visible = true;
  837. this.cmbStoreNo.Visible = true;
  838. }
  839. if (ultraTabControl1.SelectedTab.Key == "1")
  840. {
  841. if (toolMenu.Toolbars[0].Tools.Exists("Query"))
  842. {
  843. toolMenu.Toolbars[0].Tools["Query"].InstanceProps.Visible = DefaultableBoolean.False;
  844. }
  845. if (toolMenu.Toolbars[0].Tools.Exists("insertTal"))
  846. {
  847. toolMenu.Toolbars[0].Tools["insertTal"].InstanceProps.Visible = DefaultableBoolean.False;
  848. }
  849. if (toolMenu.Toolbars[0].Tools.Exists("Export"))
  850. {
  851. toolMenu.Toolbars[0].Tools["Export"].InstanceProps.Visible = DefaultableBoolean.False;
  852. }
  853. if (toolMenu.Toolbars[0].Tools.Exists("Query1"))
  854. {
  855. toolMenu.Toolbars[0].Tools["Query1"].InstanceProps.Visible = DefaultableBoolean.True;
  856. }
  857. if (toolMenu.Toolbars[0].Tools.Exists("insertInital"))
  858. {
  859. toolMenu.Toolbars[0].Tools["insertInital"].InstanceProps.Visible = DefaultableBoolean.True;
  860. }
  861. this.chkStoreNo.Visible = false;
  862. this.cmbStoreNo.Visible = false;
  863. }
  864. }
  865. private void FrmRunTimeRpt_Shown(object sender, EventArgs e)
  866. {
  867. if (toolMenu == null)
  868. {
  869. return;
  870. }
  871. if (toolMenu.Toolbars[0].Tools.Exists("Query1"))
  872. {
  873. toolMenu.Toolbars[0].Tools["Query1"].InstanceProps.Visible = DefaultableBoolean.False;
  874. }
  875. //if (toolMenu.Toolbars[0].Tools.Exists("insertInital"))
  876. //{
  877. // toolMenu.Toolbars[0].Tools["insertInital"].InstanceProps.Visible = DefaultableBoolean.False;
  878. //}
  879. if (toolMenu.Toolbars[0].Tools.Exists("Query"))
  880. {
  881. toolMenu.Toolbars[0].Tools["Query"].InstanceProps.Visible = DefaultableBoolean.True;
  882. }
  883. if (toolMenu.Toolbars[0].Tools.Exists("insertTal"))
  884. {
  885. toolMenu.Toolbars[0].Tools["insertTal"].InstanceProps.Visible = DefaultableBoolean.False;
  886. }
  887. if (toolMenu.Toolbars[0].Tools.Exists("Export"))
  888. {
  889. toolMenu.Toolbars[0].Tools["Export"].InstanceProps.Visible = DefaultableBoolean.True;
  890. }
  891. }
  892. private void chkStoreNo_CheckedChanged(object sender, EventArgs e)
  893. {
  894. this.cmbStoreNo.Enabled = this.chkStoreNo.Checked;
  895. }
  896. }
  897. }