UIB100202.cs 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396
  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 System.Text.RegularExpressions;//正则表达式所在空间
  12. using Infragistics.Win.UltraWinGrid;
  13. namespace Core.LZMes.Client.UIB
  14. {
  15. public partial class UIB100202 : FrmBase
  16. {
  17. public UIB100202()
  18. {
  19. InitializeComponent();
  20. }
  21. public override void ToolBar_Click(object sender, string ToolbarKey)
  22. {
  23. switch (ToolbarKey)
  24. {
  25. case "Query":
  26. this.DoQuery();
  27. break;
  28. case "Save":
  29. this.DoSave();
  30. break;
  31. case "Get":
  32. this.GetCoil();
  33. break;
  34. case "Rcv":
  35. this.recvdata();
  36. break;
  37. }
  38. }
  39. string prodline = null;
  40. public void DoQuery()
  41. {
  42. OperateConditionRecode.WriteCondition("UIB100202_1", this.comboBox1.Text);
  43. this.dataSet1.Clear();
  44. ArrayList al = new ArrayList();
  45. if (this.comboBox1.Text == "热轧")
  46. {
  47. al.Add("UIB100202_01.SELECT");
  48. }
  49. else if (this.comboBox1.Text == "连退")
  50. {
  51. al.Add("UIB100202_02.SELECT");
  52. }
  53. else if (this.comboBox1.Text == "酸洗")
  54. {
  55. al.Add("UIB100202_02.SELECT");
  56. }
  57. else if (this.comboBox1.Text == "中厚板")
  58. {
  59. al.Add("UIB100202_03.SELECT");
  60. }
  61. else if (this.comboBox1.Text == "优特钢")
  62. {
  63. al.Add("UIB100202_04.SELECT");
  64. }
  65. al.Add(this.ultraDateTimeEditor1.DateTime.ToString("yyyyMMdd") + "000000");
  66. al.Add(this.ultraDateTimeEditor2.DateTime.ToString("yyyyMMdd") + "999999");
  67. if (this.checkBox2.Checked)
  68. {
  69. al.Add(this.textBox1.Text.Trim());
  70. al.Add(this.textBox2.Text.Trim() == "" ? this.textBox1.Text.Trim() : this.textBox2.Text.Trim());
  71. }
  72. else
  73. {
  74. al.Add("");
  75. al.Add("");
  76. }
  77. CoreClientParam ccp = new CoreClientParam();
  78. ccp.ServerName = "UIB.JHY.JHYComQuery";
  79. ccp.MethodName = "doSimpleQuery";
  80. ccp.ServerParams = new object[] { al };
  81. ccp.SourceDataTable = this.dataSet1.Tables[0];
  82. this.ExecuteQueryToDataTable(ccp, CoreInvokeType.Internal);
  83. }
  84. //钢印号确定
  85. public void DoSave()
  86. {
  87. try
  88. {
  89. prodline = this.comboBox1.Text;
  90. if (MessageBox.Show("确认进行" + prodline + "钢印号确定?", "提示", MessageBoxButtons.OKCancel) == DialogResult.Cancel)
  91. return;
  92. Hashtable ht = ht = new Hashtable();
  93. ArrayList alSMPNO = new ArrayList();//存储试样号
  94. ArrayList alSMPCUTLOC = new ArrayList();//存储试样位置
  95. string strSMPNO = null;
  96. string strSMPCUTLOC = null;
  97. string str = null;
  98. if (prodline == "热轧")
  99. str = "R";
  100. else if (prodline == "连退" || prodline == "酸洗")
  101. str = "L";
  102. else if (prodline == "中厚板")
  103. str = "Z";
  104. else if (prodline == "优特钢")
  105. str = "Y";
  106. foreach (UltraGridRow ugr in this.ultraGrid1.Rows)
  107. {
  108. if (Convert.ToBoolean(ugr.Cells["CHK"].Text))
  109. {
  110. strSMPNO = strSMPNO + ugr.Cells["SMP_NO"].Text;
  111. strSMPCUTLOC = strSMPCUTLOC + ugr.Cells["SMP_CUT_LOC"].Text;
  112. //alSMPNO.Add(ugr.Cells["SMP_NO"].Text);
  113. //alSMPCUTLOC.Add(ugr.Cells["SMP_CUT_LOC"].Text);
  114. }
  115. }
  116. if (strSMPNO == null) return;
  117. CoreClientParam ccp = new CoreClientParam();
  118. ht.Add("i1", strSMPNO);
  119. ht.Add("i2", strSMPCUTLOC);
  120. ht.Add("i3", str);
  121. ht.Add("o4", "");
  122. ccp.ServerName = "UIB.JHY.JHyComCallProc";
  123. ccp.MethodName = "doSimpleProc";
  124. ccp.ServerParams = new object[] { "UIB100202_02.CALL", ht };
  125. CoreClientParam rccp = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  126. ArrayList al = rccp.ReturnObject as ArrayList;
  127. if (al[0].ToString() != "YY")//确认是否存在问题
  128. {
  129. MessageBox.Show(al[0].ToString() , "提示");
  130. return;
  131. }
  132. //ht.Add("i1:STRING_ARY_SMPNO", alSMPNO);
  133. //ht.Add("i2:STRING_ARY_SMPLOC", alSMPCUTLOC);
  134. //ht.Add("i3", str);
  135. //ht.Add("o4", "");
  136. //CoreClientParam ccp = new CoreClientParam();
  137. //ccp.ServerName = "UIB.JHY.JHyComCallProc";
  138. //ccp.MethodName = "doCoreProc";
  139. //ccp.ServerParams = new object[] { "UIB100202_02.CALL", ht };
  140. //this.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  141. this.DoQuery();
  142. }
  143. catch (Exception ex)
  144. {
  145. MessageBox.Show("系统异常,请与技术中心联系");
  146. }
  147. }
  148. //接口数据提取
  149. public void GetCoil()
  150. {
  151. try
  152. {
  153. string str = this.comboBox1.Text;
  154. if (MessageBox.Show("确定进行" + str + "对象数据提取?", "提示", MessageBoxButtons.OKCancel) == DialogResult.Cancel)
  155. return;
  156. Hashtable ht = new Hashtable();
  157. ht.Add("i1", str);
  158. ht.Add("o2", "");
  159. CoreClientParam ccp = new CoreClientParam();
  160. ccp.ServerName = "UIB.JHY.JHyComCallProc";
  161. ccp.MethodName = "doSimpleProc";
  162. ccp.ServerParams = new object[] { "UIB100202_01.CALL", ht };
  163. this.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  164. this.DoQuery();
  165. }
  166. catch (Exception ex)
  167. {
  168. MessageBox.Show("系统异常,请与技术中心联系");
  169. }
  170. }
  171. public void recvdata()
  172. {
  173. try
  174. {
  175. string str = this.comboBox1.Text;
  176. if (MessageBox.Show("确定进行" + str + "中厚板数据提取?", "提示", MessageBoxButtons.OKCancel) == DialogResult.Cancel)
  177. return;
  178. Hashtable ht = new Hashtable();
  179. ht.Add("o1", "");
  180. CoreClientParam ccp = new CoreClientParam();
  181. ccp.ServerName = "UIB.JHY.JHyComCallProc";
  182. ccp.MethodName = "doSimpleProc";
  183. ccp.ServerParams = new object[] { "UIB100202_03.CALL", ht };
  184. // this.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  185. CoreClientParam rccp = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  186. ArrayList al = rccp.ReturnObject as ArrayList;
  187. if (al[0].ToString() != "YY")//确认是否存在问题
  188. {
  189. MessageBox.Show(al[0].ToString(), "提示");
  190. return;
  191. }
  192. }
  193. catch (Exception ex)
  194. {
  195. MessageBox.Show("系统异常,请与技术中心联系");
  196. }
  197. }
  198. private void UIB100202_Load(object sender, EventArgs e)
  199. {
  200. try
  201. {
  202. this.comboBox1.Text = OperateConditionRecode.ReadCondition("UIB100202_1");
  203. }
  204. catch (Exception ex)
  205. {
  206. }
  207. // this.comboBox1.SelectedIndex = 0;
  208. }
  209. private void ultraGrid1_KeyDown(object sender, KeyEventArgs e)
  210. {
  211. try
  212. {
  213. if (e.KeyCode != Keys.Enter) return;//回车时,才保存数据
  214. if (this.ultraGrid1.ActiveCell == null) return;
  215. if (this.ultraGrid1.ActiveCell.Column.Key != "COIL_STEEL_NO")
  216. return;
  217. string str = this.ultraGrid1.ActiveRow.Cells["COIL_STEEL_NO"].Text;
  218. //钢印号格式验证
  219. Regex r = new Regex(@"^\d{4}$+");
  220. Match m = r.Match(str);
  221. if (!m.Success && str != "" )//str为空则表示清除钢印号
  222. {
  223. MessageBox.Show("钢印号格式错误(4位数字)", "提示");
  224. return;
  225. }
  226. ArrayList al = new ArrayList();
  227. al.Add("UIB100202_01.UPDATE");
  228. al.Add(this.ultraGrid1.ActiveRow.Cells["COIL_STEEL_NO"].Text);//钢印号
  229. al.Add(this.ultraGrid1.ActiveRow.Cells["SMP_NO"].Text);//试样号
  230. al.Add(this.ultraGrid1.ActiveRow.Cells["SMP_CUT_LOC"].Text);//试样位置
  231. //this.ultraGrid1.ActiveRow.Index
  232. CoreClientParam ccp = new CoreClientParam();
  233. ccp.ServerName = "UIB.JHY.JHYComSave";
  234. ccp.ServerParams = new object[] { al };
  235. ccp.MethodName = "doSimpleSave";
  236. this.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  237. //if (str != "")
  238. //{
  239. // //下一行钢印号值+1
  240. // int steelNo = Convert.ToInt32(str);//钢印号
  241. // this.ultraGrid1.Rows[this.ultraGrid1.ActiveRow.Index + 1].Cells["COIL_STEEL_NO"].Value = Convert.ToString(steelNo + 1);
  242. //}
  243. ////跳转到下一行,并编辑钢印号
  244. //this.ultraGrid1.PerformAction(Infragistics.Win.UltraWinGrid.UltraGridAction.NextRow);
  245. //this.ultraGrid1.ActiveRow.Cells["COIL_STEEL_NO"].Activate();
  246. //this.ultraGrid1.PerformAction(Infragistics.Win.UltraWinGrid.UltraGridAction.EnterEditMode);
  247. //this.ultraGrid1.UpdateData();
  248. }
  249. catch (Exception ex)
  250. {
  251. MessageBox.Show("已到达行末!","提示");
  252. //System.Diagnostics.Debug.WriteLine(ex.ToString());
  253. }
  254. }
  255. private void checkBox1_CheckedChanged(object sender, EventArgs e)
  256. {
  257. try
  258. {
  259. foreach (UltraGridRow ugr in this.ultraGrid1.Rows)
  260. {
  261. ugr.Cells["CHK"].Value = this.checkBox1.Checked;
  262. ugr.Update();
  263. }
  264. }
  265. catch (Exception ex)
  266. {
  267. System.Diagnostics.Debug.WriteLine(ex.ToString());
  268. }
  269. }
  270. private void checkBox2_CheckedChanged(object sender, EventArgs e)
  271. {
  272. try
  273. {
  274. if (this.checkBox2.Checked)
  275. {
  276. this.textBox1.Enabled = true;
  277. this.textBox2.Enabled = true;
  278. }
  279. else
  280. {
  281. this.textBox1.Enabled = false;
  282. this.textBox2.Enabled = false;
  283. }
  284. }
  285. catch (Exception ex)
  286. {
  287. }
  288. }
  289. private void textBox3_KeyDown(object sender, KeyEventArgs e)
  290. {
  291. if (e.KeyCode != Keys.Enter) return;//回车时,才保存数据
  292. this.button1_Click(null, new System.EventArgs());
  293. this.textBox3.Focus();
  294. }
  295. private void button1_Click(object sender, EventArgs e)
  296. {
  297. try
  298. {
  299. if (this.ultraGrid1.ActiveCell == null) return;
  300. //if (this.ultraGrid1.ActiveCell.Column.Key != "COIL_STEEL_NO")
  301. // return;
  302. string str = this.textBox3.Text;
  303. //钢印号格式验证
  304. Regex r = new Regex(@"^\d{4}$+");
  305. Match m = r.Match(str);
  306. if (!m.Success && str != "")//str为空则表示清除钢印号
  307. {
  308. MessageBox.Show("钢印号格式错误(4位数字)", "提示");
  309. return;
  310. }
  311. ArrayList al = new ArrayList();
  312. al.Add("UIB100202_01.UPDATE");
  313. al.Add(str);//钢印号
  314. al.Add(this.ultraGrid1.ActiveRow.Cells["SMP_NO"].Text);//试样号
  315. al.Add(this.ultraGrid1.ActiveRow.Cells["SMP_CUT_LOC"].Text);//试样位置
  316. //this.ultraGrid1.ActiveRow.Index
  317. CoreClientParam ccp = new CoreClientParam();
  318. ccp.ServerName = "UIB.JHY.JHYComSave";
  319. ccp.ServerParams = new object[] { al };
  320. ccp.MethodName = "doSimpleSave";
  321. CoreClientParam rccp = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  322. string strRtn = rccp.ReturnInfo;
  323. //钢印号保存成功
  324. if (strRtn == "")
  325. {
  326. this.ultraGrid1.ActiveRow.Cells["COIL_STEEL_NO"].Value = str;
  327. }
  328. else
  329. {
  330. MessageBox.Show("钢印号输入失败!", "提示");
  331. }
  332. if (str != "")
  333. {
  334. this.ultraGrid1.ActiveRow.Cells["COIL_STEEL_NO"].Value = str;
  335. //下一行钢印号值+1
  336. int steelNo = Convert.ToInt32(str)+1;//钢印号
  337. this.textBox3.Text = Convert.ToString(steelNo);
  338. //this.ultraGrid1.Rows[this.ultraGrid1.ActiveRow.Index + 1].Activate();
  339. }
  340. //跳转到下一行,并编辑钢印号
  341. this.ultraGrid1.PerformAction(Infragistics.Win.UltraWinGrid.UltraGridAction.NextRow);
  342. this.ultraGrid1.ActiveRow.Cells["COIL_STEEL_NO"].Activate();
  343. this.ultraGrid1.PerformAction(Infragistics.Win.UltraWinGrid.UltraGridAction.EnterEditMode);
  344. this.ultraGrid1.UpdateData();
  345. }
  346. catch (Exception ex)
  347. {
  348. }
  349. }
  350. }
  351. }