using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using CoreFS.CA06; using System.Collections; using System.Text.RegularExpressions;//正则表达式所在空间 using Infragistics.Win.UltraWinGrid; namespace Core.LZMes.Client.UIB { public partial class JHY01 : FrmBase { public JHY01() { InitializeComponent(); } public override void ToolBar_Click(object sender, string ToolbarKey) { switch (ToolbarKey) { case "Query": this.DoQuery(); break; case "Save": this.DoSave(); break; case "Get": this.GetCoil(); break; case "Rcv": this.recvdata(); break; } } string prodline = null; public void DoQuery() { OperateConditionRecode.WriteCondition("UIB100202_1", this.comboBox1.Text); this.dataSet1.Clear(); ArrayList al = new ArrayList(); //if (this.comboBox1.Text == "热轧") //{ // al.Add("UIB100202_01.SELECT"); //} //else if (this.comboBox1.Text == "连退") //{ // al.Add("UIB100202_02.SELECT"); //} //else if (this.comboBox1.Text == "酸洗") //{ // al.Add("UIB100202_02.SELECT"); //} //else if (this.comboBox1.Text == "中厚板") //{ // al.Add("UIB100202_03.SELECT"); //} //else if (this.comboBox1.Text == "优特钢") //{ // al.Add("UIB100202_04.SELECT"); //} if (this.comboBox2.Text == "未收") { al.Add("JHY01.SELECT"); } else if (this.comboBox2.Text == "已收") { al.Add("JHY02.SELECT"); } al.Add(this.ultraDateTimeEditor1.DateTime.ToString("yyyyMMdd")); al.Add(this.ultraDateTimeEditor2.DateTime.ToString("yyyyMMdd")); CoreClientParam ccp = new CoreClientParam(); ccp.ServerName = "UIB.COM.ComDBQuery"; ccp.MethodName = "doSimpleQuery"; ccp.ServerParams = new object[] { al }; ccp.SourceDataTable = this.dataSet1.Tables[0]; this.ExecuteQueryToDataTable(ccp, CoreInvokeType.Internal); if (this.comboBox2.Text == "未收") { ultraGrid1.DisplayLayout.Bands[0].Columns["COIL_STEEL_NO"].Hidden = true; } else { ultraGrid1.DisplayLayout.Bands[0].Columns["COIL_STEEL_NO"].Hidden = false; } } //钢印号确定 public void DoSave() { try { prodline = this.comboBox1.Text; if (MessageBox.Show("确认进行" + prodline + "委托验收?", "提示", MessageBoxButtons.OKCancel) == DialogResult.Cancel) return; Hashtable ht = ht = new Hashtable(); ArrayList alSMPNO = new ArrayList();//存储试样号 ArrayList alSMPCUTLOC = new ArrayList();//存储试样位置 string strSMPNO = null; string strSMPCUTLOC = null; string cnt = "0"; string str = null; if (prodline == "热轧") str = "R"; else if (prodline == "连退" || prodline == "酸洗") str = "L"; else if (prodline == "中厚板") str = "Z"; else if (prodline == "优特钢") str = "Y"; foreach (UltraGridRow ugr in this.ultraGrid1.Rows) { if (Convert.ToBoolean(ugr.Cells["CHK"].Text)) { cnt += 1; strSMPNO = strSMPNO + ugr.Cells["SMP_NO"].Text; strSMPCUTLOC = strSMPCUTLOC + ugr.Cells["SPECIMEN_NO"].Text; } } if (strSMPNO == null) return; CoreClientParam ccp = new CoreClientParam(); ht.Add("i1", strSMPNO); ht.Add("i2", strSMPCUTLOC); ht.Add("i3", cnt); ht.Add("o4", ""); //ht.Add("i4", "R"); //ht.Add("i5", ""); //ht.Add("o6", ""); ccp.ServerName = "UIB.COM.ComDBProcedure"; ccp.MethodName = "doXmlProcedure"; ccp.ServerParams = new object[] { "JHY_01.CALL", ht }; CoreClientParam rccp = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal); ArrayList al = rccp.ReturnObject as ArrayList; if (al[0].ToString() != "YY")//确认是否存在问题 { MessageBox.Show(al[0].ToString() , "提示"); return; } this.DoQuery(); } catch (Exception ex) { MessageBox.Show("系统异常,请与技术中心联系"); } } //接口数据提取 public void GetCoil() { try { string str = this.comboBox1.Text; if (MessageBox.Show("确定进行" + str + "对象数据提取?", "提示", MessageBoxButtons.OKCancel) == DialogResult.Cancel) return; Hashtable ht = new Hashtable(); ht.Add("i1", str); ht.Add("o2", ""); CoreClientParam ccp = new CoreClientParam(); ccp.ServerName = "UIB.JHY.JHyComCallProc"; ccp.MethodName = "doSimpleProc"; ccp.ServerParams = new object[] { "UIB100202_01.CALL", ht }; this.ExecuteNonQuery(ccp, CoreInvokeType.Internal); this.DoQuery(); } catch (Exception ex) { MessageBox.Show("系统异常,请与技术中心联系"); } } public void recvdata() { try { string str = this.comboBox1.Text; if (MessageBox.Show("确定进行" + str + "中厚板数据提取?", "提示", MessageBoxButtons.OKCancel) == DialogResult.Cancel) return; Hashtable ht = new Hashtable(); ht.Add("o1", ""); CoreClientParam ccp = new CoreClientParam(); ccp.ServerName = "UIB.JHY.JHyComCallProc"; ccp.MethodName = "doSimpleProc"; ccp.ServerParams = new object[] { "UIB100202_03.CALL", ht }; // this.ExecuteNonQuery(ccp, CoreInvokeType.Internal); CoreClientParam rccp = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal); ArrayList al = rccp.ReturnObject as ArrayList; if (al[0].ToString() != "YY")//确认是否存在问题 { MessageBox.Show(al[0].ToString(), "提示"); return; } } catch (Exception ex) { MessageBox.Show("系统异常,请与技术中心联系"); } } private void UIB100202_Load(object sender, EventArgs e) { try { this.comboBox1.Text = OperateConditionRecode.ReadCondition("UIB100202_1"); } catch (Exception ex) { } // this.comboBox1.SelectedIndex = 0; } private void ultraGrid1_KeyDown(object sender, KeyEventArgs e) { try { if (e.KeyCode != Keys.Enter) return;//回车时,才保存数据 if (this.ultraGrid1.ActiveCell == null) return; if (this.ultraGrid1.ActiveCell.Column.Key != "COIL_STEEL_NO") return; string str = this.ultraGrid1.ActiveRow.Cells["COIL_STEEL_NO"].Text; //钢印号格式验证 Regex r = new Regex(@"^\d{4}$+"); Match m = r.Match(str); if (!m.Success && str != "" )//str为空则表示清除钢印号 { MessageBox.Show("钢印号格式错误(4位数字)", "提示"); return; } ArrayList al = new ArrayList(); al.Add("JHY_01.UPDATE"); al.Add(this.ultraGrid1.ActiveRow.Cells["COIL_STEEL_NO"].Text);//钢印号 al.Add(this.ultraGrid1.ActiveRow.Cells["SMP_NO"].Text);//试样号 CoreClientParam ccp = new CoreClientParam(); ccp.ServerName = "UIB.COM.ComDBSave"; ccp.ServerParams = new object[] { al }; ccp.MethodName = "doXmlSave"; this.ExecuteNonQuery(ccp, CoreInvokeType.Internal); //if (str != "") //{ // //下一行钢印号值+1 // int steelNo = Convert.ToInt32(str);//钢印号 // this.ultraGrid1.Rows[this.ultraGrid1.ActiveRow.Index + 1].Cells["COIL_STEEL_NO"].Value = Convert.ToString(steelNo + 1); //} ////跳转到下一行,并编辑钢印号 //this.ultraGrid1.PerformAction(Infragistics.Win.UltraWinGrid.UltraGridAction.NextRow); //this.ultraGrid1.ActiveRow.Cells["COIL_STEEL_NO"].Activate(); //this.ultraGrid1.PerformAction(Infragistics.Win.UltraWinGrid.UltraGridAction.EnterEditMode); //this.ultraGrid1.UpdateData(); } catch (Exception ex) { MessageBox.Show("已到达行末!","提示"); //System.Diagnostics.Debug.WriteLine(ex.ToString()); } } private void checkBox1_CheckedChanged(object sender, EventArgs e) { try { foreach (UltraGridRow ugr in this.ultraGrid1.Rows) { ugr.Cells["CHK"].Value = this.checkBox1.Checked; ugr.Update(); } } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex.ToString()); } } private void checkBox2_CheckedChanged(object sender, EventArgs e) { try { if (this.checkBox2.Checked) { this.textBox1.Enabled = true; this.textBox2.Enabled = true; } else { this.textBox1.Enabled = false; this.textBox2.Enabled = false; } } catch (Exception ex) { } } private void textBox3_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode != Keys.Enter) return;//回车时,才保存数据 this.button1_Click(null, new System.EventArgs()); this.textBox3.Focus(); } private void button1_Click(object sender, EventArgs e) { try { if (this.ultraGrid1.ActiveCell == null) return; //if (this.ultraGrid1.ActiveCell.Column.Key != "COIL_STEEL_NO") // return; string str = this.textBox3.Text; //钢印号格式验证 Regex r = new Regex(@"^\d{4}$+"); Match m = r.Match(str); if (!m.Success && str != "")//str为空则表示清除钢印号 { MessageBox.Show("钢印号格式错误(4位数字)", "提示"); return; } ArrayList al = new ArrayList(); al.Add("JHY_01.UPDATE"); al.Add(str);//钢印号 al.Add(this.ultraGrid1.ActiveRow.Cells["SMP_NO"].Text);//试样号 // al.Add(this.ultraGrid1.ActiveRow.Cells["SMP_CUT_LOC"].Text);//试样位置 //this.ultraGrid1.ActiveRow.Index CoreClientParam ccp = new CoreClientParam(); ccp.ServerName = "UIB.COM.ComDBQuery"; ccp.ServerParams = new object[] { al }; ccp.MethodName = "doSimpleSave"; CoreClientParam rccp = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal); string strRtn = rccp.ReturnInfo; //钢印号保存成功 if (strRtn == "") { this.ultraGrid1.ActiveRow.Cells["COIL_STEEL_NO"].Value = str; } else { MessageBox.Show("钢印号输入失败!", "提示"); } if (str != "") { this.ultraGrid1.ActiveRow.Cells["COIL_STEEL_NO"].Value = str; //下一行钢印号值+1 int steelNo = Convert.ToInt32(str)+1;//钢印号 this.textBox3.Text = Convert.ToString(steelNo); //this.ultraGrid1.Rows[this.ultraGrid1.ActiveRow.Index + 1].Activate(); } //跳转到下一行,并编辑钢印号 this.ultraGrid1.PerformAction(Infragistics.Win.UltraWinGrid.UltraGridAction.NextRow); this.ultraGrid1.ActiveRow.Cells["COIL_STEEL_NO"].Activate(); this.ultraGrid1.PerformAction(Infragistics.Win.UltraWinGrid.UltraGridAction.EnterEditMode); this.ultraGrid1.UpdateData(); } catch (Exception ex) { } } private void JHY01_Load(object sender, EventArgs e) { this.comboBox2.Text = "未做"; } } }