FrmRunTimeRpt.cs 42 KB

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