UIN060120.cs 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490
  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 Infragistics.Win.UltraWinGrid;
  12. namespace Core.LZMes.Client.UIN
  13. {
  14. public partial class UIN060120 : FrmBase
  15. {
  16. public UIN060120()
  17. {
  18. InitializeComponent();
  19. }
  20. /// <summary>
  21. /// 初始化
  22. /// </summary>
  23. #region "Init"
  24. public void init()
  25. {
  26. DataTable dt = new DataTable();
  27. CoreClientParam ccp = new CoreClientParam();
  28. ccp.ServerName = "UIB.COM.ComDBQuery";
  29. ccp.MethodName = "doSimpleQuery";
  30. System.Collections.ArrayList paramArray = new ArrayList();
  31. paramArray.Add("UIECOMM00_SELECT.CAL_MANA_NO");
  32. ccp.ServerParams = new object[] { paramArray };
  33. ccp.SourceDataTable = dt;
  34. this.ExecuteQueryToDataTable(ccp, CoreInvokeType.Internal);
  35. Core.LZMes.Client.UIE.UIE041.UIEBase.Init_ComboControl(this.ComboCalNO, ref dt, "CAL_NO");
  36. this.ultraComboEditor2.SelectedIndex = 0;
  37. }
  38. #endregion
  39. /// <summary>
  40. /// 操作方法 查询
  41. /// </summary>
  42. private void DoQuery()
  43. {
  44. try
  45. {
  46. this.dataSet1.Tables[0].Clear();
  47. string calNO = Convert.ToString(Common.FixDBManager.CheckNullStr(this.ComboCalNO.Value));
  48. string DelToDateFrom = Convert.ToString(Common.FixDBManager.CheckNullStr(this.DelToDateFrom.DateTime.ToString("yyyyMMdd")));
  49. string DelToDateTo = Convert.ToString(Common.FixDBManager.CheckNullStr(this.DelToDateTo.DateTime.ToString("yyyyMMdd")));
  50. string coilNO = Convert.ToString(Common.FixDBManager.CheckNullStr(this.textOrdNO.Text));
  51. CoreClientParam ccp = new CoreClientParam();
  52. ccp.ServerName = "UIB.COM.ComDBQuery";
  53. ccp.MethodName = "doSimpleQuery";
  54. ArrayList paramArray = new ArrayList();
  55. paramArray.Add("UIN060120_COIL_NO.Select");
  56. paramArray.Add(calNO);
  57. paramArray.Add(DelToDateFrom);
  58. paramArray.Add(DelToDateTo);
  59. paramArray.Add(coilNO);
  60. ccp.ServerParams = new object[] { paramArray };
  61. ccp.SourceDataTable = this.dataSet1.Tables[0];
  62. this.ExecuteQueryToDataTable(ccp, CoreInvokeType.Internal);
  63. System.Diagnostics.Debug.WriteLine(this.dataSet1.Tables[0].ToString());
  64. //a为原料重量 b为成品重量
  65. double a1 = 0;
  66. double b1 = 0;
  67. double a2 = 0;
  68. double b2 = 0;
  69. double a3 = 0;
  70. double b3 = 0;
  71. double a4 = 0;
  72. double b4 = 0;
  73. double a5 = 0;
  74. double b5 = 0;
  75. double a6 = 0;
  76. double b6 = 0;
  77. double a7 = 0;
  78. double b7 = 0;
  79. double a8 = 0;
  80. double b8 = 0;
  81. for (int a = 0; a < this.ultraGrid1.Rows.Count; a++)
  82. {
  83. /*
  84. * author: zmz
  85. * 原料重量 成品重量根据订单厚度汇总
  86. * cc 订单厚度
  87. * aa 原料重量
  88. * bb 成品重量
  89. */
  90. double cc;
  91. double aa;
  92. double bb;
  93. if (this.ultraGrid1.Rows[a].Cells["INSTR_COIL_THK"].Text == "") cc = 0;
  94. else cc = double.Parse(this.ultraGrid1.Rows[a].Cells["INSTR_COIL_THK"].Value.ToString());
  95. if (this.ultraGrid1.Rows[a].Cells["ENT_COIL_WGT"].Text == "") aa = 0;
  96. else aa = double.Parse(this.ultraGrid1.Rows[a].Cells["ENT_COIL_WGT"].Value.ToString());
  97. if (this.ultraGrid1.Rows[a].Cells["COIL_WGT"].Text == "") bb = 0;
  98. else bb = double.Parse(this.ultraGrid1.Rows[a].Cells["COIL_WGT"].Value.ToString());
  99. if (cc < 0.3)
  100. {
  101. a1 = a1 + aa;
  102. b1 = b1 + bb;
  103. }
  104. else if (cc < 0.35)
  105. {
  106. a2 = a2 + aa;
  107. b2 = b2 + bb;
  108. }
  109. else if (cc < 0.4)
  110. {
  111. a3 = a3 + aa;
  112. b3 = b3 + bb;
  113. }
  114. else if (cc < 0.45)
  115. {
  116. a4 = a4 + aa;
  117. b4 = b4 + bb;
  118. }
  119. else if (cc < 0.5)
  120. {
  121. a5 = a5 + aa;
  122. b5 = b5 + bb;
  123. }
  124. else if (cc < 0.6)
  125. {
  126. a6 = a6 + aa;
  127. b6 = b6 + bb;
  128. }
  129. else if (cc < 1.0)
  130. {
  131. a7 = a7 + aa;
  132. b7 = b7 + bb;
  133. }
  134. else if (cc < 2.0)
  135. {
  136. a8 = a8 + aa;
  137. b8 = b8 + bb;
  138. }
  139. }
  140. this.textBox1.Text = (a1/1000).ToString();
  141. this.textBox2.Text = (b1/1000).ToString();
  142. this.textBox3.Text = (a2/1000).ToString();
  143. this.textBox4.Text = (b2/1000).ToString();
  144. this.textBox6.Text = (a3/1000).ToString();
  145. this.textBox7.Text = (b3/1000).ToString();
  146. this.textBox5.Text = (a4/1000).ToString();
  147. this.textBox8.Text = (b4/1000).ToString();
  148. this.textBox10.Text = (a5/1000).ToString();
  149. this.textBox9.Text = (b5/1000).ToString();
  150. this.textBox12.Text = (a6/1000).ToString();
  151. this.textBox11.Text = (b6/1000).ToString();
  152. this.textBox13.Text = (a7/1000).ToString();
  153. this.textBox14.Text = (b7/1000).ToString();
  154. this.textBox15.Text = (a8/1000).ToString();
  155. this.textBox16.Text = (b8/1000).ToString();
  156. for (int a = 0; a < this.ultraGrid1.Rows.Count; a++)
  157. {
  158. //double b = double.Parse(this.ultraGrid1.Rows[a].Cells["COIL_WGT"].Text.ToString());
  159. double b = double.Parse(this.ultraGrid1.Rows[a].Cells["COIL_WGT"].Text.ToString() != "" ? this.ultraGrid1.Rows[a].Cells["COIL_WGT"].Text.ToString() : "0");
  160. string c = this.ultraGrid1.Rows[a].Cells["OLD_SAMPL_NO"].Text.ToString();
  161. double h = double.Parse(this.ultraGrid1.Rows[a].Cells["ENT_COIL_WGT"].Value.ToString());
  162. for (int d = a + 1; d <= this.ultraGrid1.Rows.Count-1; d++)
  163. {
  164. //double e = double.Parse(this.ultraGrid1.Rows[d].Cells["COIL_WGT"].Text.ToString());
  165. double e = double.Parse(this.ultraGrid1.Rows[d].Cells["COIL_WGT"].Text.ToString() != "" ? this.ultraGrid1.Rows[d].Cells["COIL_WGT"].Text.ToString() : "0");
  166. string f = this.ultraGrid1.Rows[d].Cells["OLD_SAMPL_NO"].Text.ToString();
  167. if (f.Substring(0, 12) == c.Substring(0, 12))
  168. {
  169. b = b + e;
  170. a = d;
  171. }
  172. else break;
  173. }
  174. double g = b / h * 100;
  175. this.ultraGrid1.Rows[a].Cells["CHENGCAILV"].Value = g.ToString("f2");
  176. }
  177. }
  178. catch (Exception EX)
  179. {
  180. MessageBox.Show(EX.ToString());
  181. }
  182. }
  183. private void DoQuery1()
  184. {
  185. try
  186. {
  187. this.dataSet1.Tables[0].Clear();
  188. string calNO = Convert.ToString(Common.FixDBManager.CheckNullStr(this.ComboCalNO.Value));
  189. string DelToDateFrom = Convert.ToString(Common.FixDBManager.CheckNullStr(this.DelToDateFrom.DateTime.ToString("yyyyMMdd")));
  190. string DelToDateTo = Convert.ToString(Common.FixDBManager.CheckNullStr(this.DelToDateTo.DateTime.ToString("yyyyMMdd")));
  191. string coilNO = Convert.ToString(Common.FixDBManager.CheckNullStr(this.textOrdNO.Text));
  192. CoreClientParam ccp = new CoreClientParam();
  193. ccp.ServerName = "UIB.COM.ComDBQuery";
  194. ccp.MethodName = "doSimpleQuery";
  195. ArrayList paramArray = new ArrayList();
  196. paramArray.Add("UIN060120_COIL_NO.Select");
  197. paramArray.Add(calNO);
  198. paramArray.Add(DelToDateFrom);
  199. paramArray.Add(DelToDateTo);
  200. paramArray.Add(coilNO);
  201. ccp.ServerParams = new object[] { paramArray };
  202. ccp.SourceDataTable = this.dataSet1.Tables[0];
  203. this.ExecuteQueryToDataTable(ccp, CoreInvokeType.Internal);
  204. System.Diagnostics.Debug.WriteLine(this.dataSet1.Tables[0].ToString());
  205. for (int a = 0; a < this.ultraGrid1.Rows.Count; a++)
  206. {
  207. //double b = double.Parse(this.ultraGrid1.Rows[a].Cells["COIL_WGT"].Text.ToString());
  208. double b = double.Parse(this.ultraGrid1.Rows[a].Cells["COIL_WGT"].Text.ToString() != "" ? this.ultraGrid1.Rows[a].Cells["COIL_WGT"].Text.ToString() : "0");
  209. string c = this.ultraGrid1.Rows[a].Cells["OLD_SAMPL_NO"].Text.ToString();
  210. double h = double.Parse(this.ultraGrid1.Rows[a].Cells["ENT_COIL_WGT"].Value.ToString());
  211. for (int d = a + 1; d <= this.ultraGrid1.Rows.Count - 1; d++)
  212. {
  213. //double e = double.Parse(this.ultraGrid1.Rows[d].Cells["COIL_WGT"].Text.ToString());
  214. double e = double.Parse(this.ultraGrid1.Rows[d].Cells["COIL_WGT"].Text.ToString() != "" ? this.ultraGrid1.Rows[d].Cells["COIL_WGT"].Text.ToString() : "0");
  215. string f = this.ultraGrid1.Rows[d].Cells["OLD_SAMPL_NO"].Text.ToString();
  216. if (f.Substring(0, 12) == c.Substring(0, 12))
  217. {
  218. b = b + e;
  219. a = d;
  220. }
  221. else break;
  222. }
  223. double g = b / h * 100;
  224. this.ultraGrid1.Rows[a].Cells["CHENGCAILV"].Value = g.ToString("f2");
  225. }
  226. foreach (UltraGridRow ugr in this.ultraGrid1.Rows)
  227. {
  228. if (ugr.Cells["CAL_GROUP"].Text == "")
  229. {
  230. string tem = ugr.Cells["MILL_DTIME"].Text.ToString();//20150302142567
  231. //DateTime tem1 = DateTime.Parse(tem);
  232. string temcoilno = ugr.Cells["OLD_SAMPL_NO"].Text.ToString();
  233. DateTime tem1 = DateTime.ParseExact(tem, "yyyyMMddHHmmss", null);
  234. DateTime dt = DateTime.Parse("2015-03-02");
  235. DateTime dt2 = DateTime.Now;
  236. TimeSpan spanTime = (tem1 - dt);
  237. int subday = int.Parse(spanTime.Days.ToString());
  238. int day1 = subday % 8;
  239. string millgroup = "1";
  240. string millshift = "1";
  241. CoreClientParam ccp1 = new CoreClientParam();
  242. ccp1.ServerName = "UIB.COM.ComDBSave";
  243. ccp1.MethodName = "doXmlSave";
  244. ArrayList paramArray1 = new ArrayList();
  245. paramArray1.Add("UIN060120_GROUP.Update");
  246. if (tem1.Hour >= 0 && tem1.Hour < 8)//晚班
  247. {
  248. if (day1 == 0 || day1 == 1) millgroup = "3";
  249. else if (day1 == 2 || day1 == 3) millgroup = "2";
  250. else if (day1 == 4 || day1 == 5) millgroup = "1";
  251. else if (day1 == 6 || day1 == 7) millgroup = "4";
  252. paramArray1.Add(millgroup);
  253. millshift = "3";
  254. paramArray1.Add(millshift);
  255. }
  256. else if
  257. (tem1.Hour >= 8 && tem1.Hour < 16)//早班
  258. {
  259. if (day1 == 0 || day1 == 1) millgroup = "4";
  260. else if (day1 == 2 || day1 == 3) millgroup = "3";
  261. else if (day1 == 4 || day1 == 5) millgroup = "2";
  262. else if (day1 == 6 || day1 == 7) millgroup = "1";
  263. millshift = "1";
  264. paramArray1.Add(millgroup);
  265. paramArray1.Add(millshift);
  266. }
  267. else //中班
  268. {
  269. if (day1 == 0 || day1 == 1) millgroup = "1";
  270. else if (day1 == 2 || day1 == 3) millgroup = "4";
  271. else if (day1 == 4 || day1 == 5) millgroup = "3";
  272. else if (day1 == 6 || day1 == 7) millgroup = "2";
  273. paramArray1.Add(millgroup);
  274. millshift = "2";
  275. paramArray1.Add(millshift);
  276. }
  277. paramArray1.Add(temcoilno);
  278. ccp1.ServerParams = new object[] { paramArray1 };
  279. this.ExecuteNonQuery(ccp1, CoreInvokeType.Internal);
  280. }
  281. //if (double.Parse(ugr.Cells["SUBWTH"].Text.ToString()) > 10 && ugr.Cells["CUT_EDGE_YN"].Value.ToString() == "False")
  282. //{
  283. // string temcoilno1 = ugr.Cells["C_COIL_NO"].Text.ToString();
  284. // CoreClientParam ccp3 = new CoreClientParam();
  285. // ccp3.ServerName = "UIB.COM.ComDBSave";
  286. // ccp3.MethodName = "doXmlSave";
  287. // ArrayList paramArray1 = new ArrayList();
  288. // paramArray1.Add("UIK020030_CUT.UPDATE");
  289. // //paramArray.Add(cutEdgeYN);
  290. // paramArray1.Add(temcoilno1);
  291. // ccp3.ServerParams = new object[] { paramArray1 };
  292. // this.ExecuteNonQuery(ccp3, CoreInvokeType.Internal);
  293. //}
  294. }
  295. }
  296. catch (Exception EX)
  297. {
  298. MessageBox.Show(EX.ToString());
  299. }
  300. }
  301. /// <summary>
  302. /// 操作方法 保存班次组信息
  303. /// </summary>
  304. private void DoSave()
  305. {
  306. try
  307. {
  308. string strQueryFlag = "Y";
  309. this.ultraGrid1.UpdateData();
  310. DataRow[] selectedRows = dataSet1.Tables[0].Select("CHK ='True'");
  311. for (int i = 0; i < selectedRows.Length; i++)
  312. {
  313. string regid = this.UserInfo.GetUserID();
  314. string regshift = this.UserInfo.GetUserOrder();
  315. string reggroup = this.ultraComboEditor2.Value.ToString();//this.UserInfo.GetUserGroup();
  316. string coilno = Convert.ToString(Common.FixDBManager.CheckNullStr(selectedRows[i]["OLD_SAMPL_NO"]));
  317. string cutEdgeYN = Convert.ToString(Common.FixDBManager.CheckNullStr(selectedRows[i]["CUT_EDGE_YN"]));
  318. string isHead = Convert.ToString(Common.FixDBManager.CheckNullStr(selectedRows[i]["ISHEAD"]));
  319. string millDtime = Convert.ToString(Common.FixDBManager.CheckNullStr(selectedRows[i]["MILL_DTIME"]));
  320. if (millDtime.Length != 14)//长度
  321. {
  322. strQueryFlag = "N";
  323. MessageBox.Show("警告,钢卷" + coilno + "录入的日期长度" + millDtime + "错误,禁止保存", "提示");
  324. return;
  325. }
  326. if (Convert.ToInt16(millDtime.Substring(4, 2)) > 12) //月
  327. {
  328. strQueryFlag = "N";
  329. MessageBox.Show("警告,钢卷" + coilno + "录入的日期【月】" + millDtime + "错误,禁止保存", "提示");
  330. return;
  331. }
  332. if (Convert.ToInt16(millDtime.Substring(6, 2)) > 31) //日
  333. {
  334. strQueryFlag = "N";
  335. MessageBox.Show("警告,钢卷" + coilno + "录入的日期【日】" + millDtime + "错误,禁止保存", "提示");
  336. return;
  337. }
  338. if (Convert.ToInt16(millDtime.Substring(8, 2)) > 24) //小时
  339. {
  340. strQueryFlag = "N";
  341. MessageBox.Show("警告,钢卷" + coilno + "录入的日期【时】" + millDtime + "错误,禁止保存", "提示");
  342. return;
  343. }
  344. if (Convert.ToInt16(millDtime.Substring(10, 2)) > 59)//分
  345. {
  346. strQueryFlag = "N";
  347. MessageBox.Show("警告,钢卷" + coilno + "录入的日期【分】" + millDtime + "错误,禁止保存", "提示");
  348. return;
  349. }
  350. if (Convert.ToInt16(millDtime.Substring(12, 2)) > 59)//秒
  351. {
  352. strQueryFlag = "N";
  353. MessageBox.Show("警告,钢卷" + coilno + "录入的日期【秒】" + millDtime + "错误,禁止保存", "提示");
  354. return;
  355. }
  356. CoreClientParam ccp = new CoreClientParam();
  357. ccp.ServerName = "UIB.COM.ComDBSave";
  358. ccp.MethodName = "doXmlSave";
  359. ArrayList paramArray = new ArrayList();
  360. paramArray.Add("UIN060120_shift.Update");
  361. paramArray.Add(regid);
  362. paramArray.Add(regshift);
  363. paramArray.Add(reggroup);
  364. paramArray.Add(cutEdgeYN);//isHead
  365. paramArray.Add(isHead);//isHead
  366. paramArray.Add(millDtime);
  367. paramArray.Add(coilno);
  368. ccp.ServerParams = new object[] { paramArray };
  369. ccp.SourceDataTable = this.dataSet1.Tables[0];
  370. this.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  371. }
  372. if (strQueryFlag == "Y")
  373. {
  374. this.DoQuery();
  375. }
  376. }
  377. catch (Exception ex)
  378. {
  379. System.Diagnostics.Debug.WriteLine(ex.ToString());
  380. }
  381. }
  382. private void DoExport()
  383. {
  384. try
  385. {
  386. if (this.saveFileDialog1.ShowDialog(this) == DialogResult.OK)
  387. {
  388. string fileName = this.saveFileDialog1.FileName;
  389. ultraGridExcelExporter1.Export(ultraGrid1, fileName);
  390. //System.Diagnostics.Process.Start(fileName);
  391. }
  392. }
  393. catch (Exception EX)
  394. {
  395. MessageBox.Show(EX.ToString());
  396. }
  397. }
  398. /// <summary>
  399. /// 事件方法:
  400. /// </summary>
  401. /// <param name="sender"></param>
  402. /// <param name="e"></param>
  403. #region "EVENT 事件"
  404. private void UIN060120_Load(object sender, EventArgs e)
  405. {
  406. init();
  407. }
  408. public override void ToolBar_Click(object sender, string ToolbarKey)
  409. {
  410. switch (ToolbarKey)
  411. {
  412. case "Query":
  413. this.DoQuery();
  414. break;
  415. case "Save":
  416. this.DoSave();
  417. break;
  418. case "Export":
  419. this.DoExport();
  420. break;
  421. case "Exit":
  422. this.Close();
  423. break;
  424. }
  425. }
  426. private void ComboCalNO_ValueChanged(object sender, EventArgs e)
  427. {
  428. this.DoQuery();
  429. }
  430. private void checkBox1_CheckedChanged(object sender, EventArgs e)
  431. {
  432. try
  433. {
  434. foreach (UltraGridRow ugr in this.ultraGrid1.Rows)
  435. {
  436. ugr.Cells["CHK"].Value = this.checkBox1.Checked;
  437. ugr.Update();
  438. }
  439. }
  440. catch (Exception ex)
  441. {
  442. System.Diagnostics.Debug.WriteLine(ex.ToString());
  443. }
  444. }
  445. #endregion
  446. private void button1_Click(object sender, EventArgs e)
  447. {
  448. this.DoQuery1();
  449. }
  450. }
  451. }