UIK020050.cs 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421
  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 System.Collections;
  10. using CoreFS.CA06;
  11. using Infragistics.Win.UltraWinGrid;
  12. namespace Core.LZMes.Client.UIK
  13. {
  14. public partial class UIK020050 : FrmBase
  15. {
  16. // public static UIK020050 s = null;
  17. public UIK020050()
  18. {
  19. InitializeComponent();
  20. // s = this;
  21. }
  22. private void UIK020050_Load(object sender, EventArgs e)
  23. {
  24. //CoreClientParam ccp = new CoreClientParam();
  25. //ccp.ServerName = "UIK.UIK02.UIK020040";
  26. //ccp.MethodName = "queryRollManaNo";
  27. //ccp = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  28. //ArrayList list = (ArrayList)(ccp.ReturnObject);
  29. //if (list != null)
  30. //{
  31. // int listSize = list.Count;
  32. // Infragistics.Win.ValueListItem[] valueListItems = new Infragistics.Win.ValueListItem[listSize];
  33. // for (int i = 0; i < listSize; i++)
  34. // {
  35. // Infragistics.Win.ValueListItem item = new Infragistics.Win.ValueListItem();
  36. // string[] param = (string[])list[i];
  37. // item.DataValue = param[1];
  38. // item.DisplayText = param[1]; ;
  39. // valueListItems[i] = item;
  40. // }
  41. // this.ultraComboEditor1.Items.AddRange(valueListItems);
  42. // this.ultraComboEditor1.SelectedIndex = 0;
  43. //}
  44. this.ultraComboEditor2.SelectedIndex = 0;
  45. }
  46. public override void ToolBar_Click(object sender, string ToolbarKey)
  47. {
  48. switch (ToolbarKey)
  49. {
  50. case "Query":
  51. this.DoQuery();
  52. break;
  53. case "Save":
  54. this.DoSave();
  55. break;
  56. case "Export":
  57. this.DoExport();
  58. break;
  59. case "Exit":
  60. this.Close();
  61. break;
  62. }
  63. }
  64. /// <summary>
  65. ///
  66. /// </summary>
  67. ///
  68. public void DoQuery()
  69. {
  70. //DateTime dt = DateTime.Parse("2015-03-02");
  71. //DateTime dt2 = DateTime.Now;
  72. //TimeSpan spanTime = (dt2 - dt);
  73. //string aa = spanTime.Days.ToString();
  74. // MessageBox.Show(aa);
  75. string rollManaNo = this.ultraComboEditor1.Text.Trim();
  76. string beginTime = ultraDateTimeEditor1.Value != null ? ultraDateTimeEditor1.DateTime.ToString("yyyyMMdd") : "";
  77. string endTime = ultraDateTimeEditor2.Value != null ? ultraDateTimeEditor2.DateTime.ToString("yyyyMMdd") : "";
  78. string coilNo = textBox9.Text.Trim();
  79. if ("".Equals(rollManaNo) && ("".Equals(beginTime) || "".Equals(endTime)) && "".Equals(coilNo))
  80. {
  81. MessageBox.Show("请选择查询条件!" , "提示");
  82. return;
  83. }
  84. //this.dataSet1.Tables[1].Clear();
  85. //this.dataSet1.Tables[2].Clear();
  86. this.dataSet1.Tables[0].Clear();
  87. CoreClientParam ccp1 = new CoreClientParam();
  88. ccp1.ServerName = "UIK.UIK02.UIK020050";
  89. ccp1.MethodName = "queryColdCoilResult";
  90. ccp1.ServerParams = new object[] { rollManaNo, beginTime,endTime,coilNo };
  91. ccp1.SourceDataTable = this.dataSet1.Tables[0];
  92. this.ExecuteQueryToDataTable(ccp1, CoreInvokeType.Internal);
  93. /*
  94. CoreClientParam ccp2 = new CoreClientParam();
  95. ccp2.ServerName = "UIK.UIK02.UIK020050";
  96. ccp2.MethodName = "queryAcidRollingResult";
  97. ccp2.ServerParams = new object[] { rollManaNo, beginTime, endTime, coilNo };
  98. ccp2.SourceDataTable = this.dataSet1.Tables[1];
  99. this.ExecuteQueryToDataTable(ccp2, CoreInvokeType.Internal);
  100. CoreClientParam ccp3 = new CoreClientParam();
  101. ccp3.ServerName = "UIK.UIK02.UIK020050";
  102. ccp3.MethodName = "queryRollingDefectResult";
  103. ccp3.ServerParams = new object[] { rollManaNo, beginTime, endTime, coilNo };
  104. ccp3.SourceDataTable = this.dataSet1.Tables[2];
  105. this.ExecuteQueryToDataTable(ccp3, CoreInvokeType.Internal);
  106. */
  107. double sumh = 0;
  108. for (int a = 0; a < this.ultraGrid1.Rows.Count; a++)
  109. { double b;
  110. if (this.ultraGrid1.Rows[a].Cells["COIL_WGT"].Text == "")
  111. b = 0;
  112. else
  113. b= double.Parse(this.ultraGrid1.Rows[a].Cells["COIL_WGT"].Text.ToString());
  114. string c = this.ultraGrid1.Rows[a].Cells["C_COIL_NO"].Text.ToString();
  115. double h = double.Parse(this.ultraGrid1.Rows[a].Cells["ENT_COIL_WGT"].Value.ToString());
  116. sumh=sumh+h;
  117. for (int d = a + 1; d <= this.ultraGrid1.Rows.Count - 1; d++)
  118. {
  119. double e;
  120. if (this.ultraGrid1.Rows[d].Cells["COIL_WGT"].Text == "")
  121. e = 0;
  122. else
  123. e = double.Parse(this.ultraGrid1.Rows[d].Cells["COIL_WGT"].Text.ToString());
  124. string f = this.ultraGrid1.Rows[d].Cells["C_COIL_NO"].Text.ToString();
  125. if (f.Substring(0, 11) == c.Substring(0, 11))
  126. {
  127. b = b + e;
  128. a = d;
  129. }
  130. else break;
  131. }
  132. double g = b / h * 100;
  133. this.ultraGrid1.Rows[a].Cells["CHENGCAILV"].Value = g.ToString("f2");
  134. }
  135. }
  136. public void DoQuery1()
  137. {
  138. //DateTime dt = DateTime.Parse("2015-03-02");
  139. //DateTime dt2 = DateTime.Now;
  140. //TimeSpan spanTime = (dt2 - dt);
  141. //string aa = spanTime.Days.ToString();
  142. // MessageBox.Show(aa);
  143. string rollManaNo = this.ultraComboEditor1.Text.Trim();
  144. string beginTime = ultraDateTimeEditor1.Value != null ? ultraDateTimeEditor1.DateTime.AddDays(-1).ToString("yyyyMMdd") : "";
  145. string endTime = ultraDateTimeEditor2.Value != null ? ultraDateTimeEditor2.DateTime.ToString("yyyyMMdd") : "";
  146. string coilNo = textBox9.Text.Trim();
  147. if ("".Equals(rollManaNo) && ("".Equals(beginTime) || "".Equals(endTime)) && "".Equals(coilNo))
  148. {
  149. MessageBox.Show("请选择查询条件!", "提示");
  150. return;
  151. }
  152. //this.dataSet1.Tables[1].Clear();
  153. //this.dataSet1.Tables[2].Clear();
  154. this.dataSet1.Tables[0].Clear();
  155. CoreClientParam ccp2 = new CoreClientParam();
  156. ccp2.ServerName = "UIK.UIK02.UIK020050";
  157. ccp2.MethodName = "queryColdCoilResult";
  158. ccp2.ServerParams = new object[] { rollManaNo, beginTime, endTime, coilNo };
  159. ccp2.SourceDataTable = this.dataSet1.Tables[0];
  160. this.ExecuteQueryToDataTable(ccp2, CoreInvokeType.Internal);
  161. for (int a = 0; a < this.ultraGrid1.Rows.Count; a++)
  162. {
  163. double b;
  164. if (this.ultraGrid1.Rows[a].Cells["COIL_WGT"].Text == "")
  165. b = 0;
  166. else
  167. b = double.Parse(this.ultraGrid1.Rows[a].Cells["COIL_WGT"].Text.ToString());
  168. string c = this.ultraGrid1.Rows[a].Cells["C_COIL_NO"].Text.ToString();
  169. double h = double.Parse(this.ultraGrid1.Rows[a].Cells["ENT_COIL_WGT"].Value.ToString());
  170. for (int d = a + 1; d <= this.ultraGrid1.Rows.Count - 1; d++)
  171. {
  172. double e;
  173. if (this.ultraGrid1.Rows[d].Cells["COIL_WGT"].Text == "")
  174. e = 0;
  175. else e = double.Parse(this.ultraGrid1.Rows[d].Cells["COIL_WGT"].Text.ToString());
  176. string f = this.ultraGrid1.Rows[d].Cells["C_COIL_NO"].Text.ToString();
  177. if (f.Substring(0, 11) == c.Substring(0, 11))
  178. {
  179. b = b + e;
  180. a = d;
  181. }
  182. else break;
  183. }
  184. double g = b / h * 100;
  185. this.ultraGrid1.Rows[a].Cells["CHENGCAILV"].Value = g.ToString("f2");
  186. }
  187. // DateTime dt = DateTime.Parse("2015-03-02");
  188. // DateTime dt2 = DateTime.Now;
  189. // TimeSpan spanTime = (dt2 - dt);
  190. // int subday = int.Parse(spanTime.Days.ToString());
  191. // int day1 = subday % 8;
  192. //string millgroup="1";
  193. foreach (UltraGridRow ugr in this.ultraGrid1.Rows)
  194. {
  195. if (ugr.Cells["MILL_GROUP"].Text == "")
  196. {
  197. string tem = ugr.Cells["MILL_DTIME"].Text.ToString();//20150302142567
  198. //DateTime tem1 = DateTime.Parse(tem);
  199. string temcoilno = ugr.Cells["C_COIL_NO"].Text.ToString();
  200. DateTime tem1 = DateTime.ParseExact(tem, "yyyyMMddHHmmss", null);
  201. DateTime dt = DateTime.Parse("2015-03-02");
  202. DateTime dt2 = DateTime.Now;
  203. TimeSpan spanTime = (tem1 - dt);
  204. int subday = int.Parse(spanTime.Days.ToString());
  205. int day1 = subday % 8;
  206. string millgroup = "1";
  207. string millshift = "1";
  208. CoreClientParam ccp = new CoreClientParam();
  209. ccp.ServerName = "UIB.COM.ComDBSave";
  210. ccp.MethodName = "doXmlSave";
  211. ArrayList paramArray = new ArrayList();
  212. paramArray.Add("UIK020050_group.UPDATE");
  213. if (tem1.Hour >= 0 && tem1.Hour < 8)//晚班
  214. {
  215. if (day1 == 0 || day1 == 1) millgroup = "3";
  216. else if (day1 == 2 || day1 == 3) millgroup = "2";
  217. else if (day1 == 4 || day1 == 5) millgroup = "1";
  218. else if (day1 == 6 || day1 == 7) millgroup = "4";
  219. paramArray.Add(millgroup);
  220. millshift = "3";
  221. paramArray.Add(millshift);
  222. }
  223. else if
  224. (tem1.Hour >= 8 && tem1.Hour < 16)//早班
  225. {
  226. if (day1 == 0 || day1 == 1) millgroup = "4";
  227. else if (day1 == 2 || day1 == 3) millgroup = "3";
  228. else if (day1 == 4 || day1 == 5) millgroup = "2";
  229. else if (day1 == 6 || day1 == 7) millgroup = "1";
  230. millshift = "1";
  231. paramArray.Add(millgroup);
  232. paramArray.Add(millshift);
  233. }
  234. else //中班
  235. {
  236. if (day1 == 0 || day1 == 1) millgroup = "1";
  237. else if (day1 == 2 || day1 == 3) millgroup = "4";
  238. else if (day1 == 4 || day1 == 5) millgroup = "3";
  239. else if (day1 == 6 || day1 == 7) millgroup = "2";
  240. paramArray.Add(millgroup);
  241. millshift = "2";
  242. paramArray.Add(millshift);
  243. }
  244. paramArray.Add(temcoilno);
  245. ccp.ServerParams = new object[] { paramArray };
  246. this.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  247. }
  248. if (double.Parse(ugr.Cells["SUBWTH"].Text.ToString()) > 10 && ugr.Cells["CUT_EDGE_YN"].Value.ToString()=="False")
  249. {
  250. string temcoilno1 = ugr.Cells["C_COIL_NO"].Text.ToString();
  251. CoreClientParam ccp3 = new CoreClientParam();
  252. ccp3.ServerName = "UIB.COM.ComDBSave";
  253. ccp3.MethodName = "doXmlSave";
  254. ArrayList paramArray1 = new ArrayList();
  255. paramArray1.Add("UIK020050_CUT.UPDATE");
  256. //paramArray.Add(cutEdgeYN);
  257. paramArray1.Add(temcoilno1);
  258. ccp3.ServerParams = new object[] { paramArray1 };
  259. this.ExecuteNonQuery(ccp3, CoreInvokeType.Internal);
  260. }
  261. }
  262. DoQuery();
  263. }
  264. /// <summary>
  265. ///
  266. /// </summary>
  267. /// <param name="sender"></param>
  268. /// <param name="e"></param>
  269. private void DoSave()
  270. {
  271. string strQueryFlag = "Y";
  272. this.ultraGrid1.UpdateData();
  273. DataRow[] selectedRows = dataSet1.Tables[0].Select("CHK ='True'");
  274. for (int i = 0; i < selectedRows.Length; i++)
  275. {
  276. try
  277. {
  278. string regid = this.UserInfo.GetUserID();
  279. string reggroup = this.ultraComboEditor2.Value.ToString();//this.UserInfo.GetUserGroup();
  280. string regshift = this.UserInfo.GetUserOrder();
  281. string coilno = Convert.ToString(Common.FixDBManager.CheckNullStr(selectedRows[i]["C_COIL_NO"]));
  282. string cutEdgeYN = Convert.ToString(Common.FixDBManager.CheckNullStr(selectedRows[i]["CUT_EDGE_YN"]));
  283. string millDtime = Convert.ToString(Common.FixDBManager.CheckNullStr(selectedRows[i]["MILL_DTIME"]));
  284. if (millDtime.Length != 14)//长度
  285. {
  286. strQueryFlag = "N";
  287. MessageBox.Show("警告,钢卷" + coilno + "录入的日期长度" + millDtime + "错误,禁止保存", "提示");
  288. return;
  289. }
  290. if (Convert.ToInt16(millDtime.Substring(4, 2)) > 12) //月
  291. {
  292. strQueryFlag = "N";
  293. MessageBox.Show("警告,钢卷" + coilno + "录入的日期【月】" + millDtime + "错误,禁止保存", "提示");
  294. return;
  295. }
  296. if (Convert.ToInt16(millDtime.Substring(6, 2)) > 31) //日
  297. {
  298. strQueryFlag = "N";
  299. MessageBox.Show("警告,钢卷" + coilno + "录入的日期【日】" + millDtime + "错误,禁止保存", "提示");
  300. return;
  301. }
  302. if (Convert.ToInt16(millDtime.Substring(8, 2)) > 24) //小时
  303. {
  304. strQueryFlag = "N";
  305. MessageBox.Show("警告,钢卷" + coilno + "录入的日期【时】" + millDtime + "错误,禁止保存", "提示");
  306. return;
  307. }
  308. if (Convert.ToInt16(millDtime.Substring(10, 2)) > 59)//分
  309. {
  310. strQueryFlag = "N";
  311. MessageBox.Show("警告,钢卷" + coilno + "录入的日期【分】" + millDtime + "错误,禁止保存", "提示");
  312. return;
  313. }
  314. if (Convert.ToInt16(millDtime.Substring(12, 2)) > 59)//秒
  315. {
  316. strQueryFlag = "N";
  317. MessageBox.Show("警告,钢卷" + coilno + "录入的日期【秒】" + millDtime + "错误,禁止保存", "提示");
  318. return;
  319. }
  320. CoreClientParam ccp = new CoreClientParam();
  321. ccp.ServerName = "UIB.COM.ComDBSave";
  322. ccp.MethodName = "doXmlSave";
  323. ArrayList paramArray = new ArrayList();
  324. paramArray.Add("UIK020050_SHIFT.UPDATE");
  325. paramArray.Add(regid);
  326. paramArray.Add(regshift);
  327. paramArray.Add(reggroup);
  328. paramArray.Add(cutEdgeYN);
  329. paramArray.Add(millDtime);
  330. paramArray.Add(coilno);
  331. ccp.ServerParams = new object[] { paramArray };
  332. this.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  333. }
  334. catch (Exception EX)
  335. {
  336. MessageBox.Show(EX.ToString());
  337. }
  338. }
  339. if (strQueryFlag == "Y")
  340. {
  341. this.DoQuery();
  342. }
  343. }
  344. private void DoExport()
  345. {
  346. try
  347. {
  348. if (this.saveFileDialog1.ShowDialog(this) == DialogResult.OK)
  349. {
  350. string fileName = this.saveFileDialog1.FileName;
  351. ultraGridExcelExporter1.Export(ultraGrid1, fileName);
  352. //System.Diagnostics.Process.Start(fileName);
  353. }
  354. }
  355. catch (Exception EX)
  356. {
  357. MessageBox.Show(EX.ToString());
  358. }
  359. }
  360. private void ultraGrid1_ClickCell(object sender, Infragistics.Win.UltraWinGrid.ClickCellEventArgs e)
  361. {
  362. try
  363. {
  364. ultraGrid1.ActiveCell.SelectAll();
  365. }
  366. catch
  367. {
  368. }
  369. }
  370. private void button1_Click(object sender, EventArgs e)
  371. {
  372. this.DoQuery1();
  373. }
  374. }
  375. }