UIK020080.cs 17 KB

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