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; using Microsoft.Office.Interop.Excel; using Infragistics.Win; namespace Core.LZMes.Client.UIB { public partial class JHY02 : FrmBase { public JHY02() { InitializeComponent(); } public override void ToolBar_Click(object sender, string ToolbarKey) { switch (ToolbarKey) { case "Query": this.DoQuery(); break; case "Send": this.DoSend(); break; case "Export": this.DoExport(); break; case "OnFile": this.DoOnFile(); break; } } string strLine = null;//产线 string strArr = null;//地点 string strWtbh = null;//委托编号 string strQltyCD = null;//材质代码 string strQltyCD2 = null;//二级编码,如拉力,冲击等 string strQltyCD3 = null;//三级编码,如伸长率,屈服强度,抗拉强度等 string strSendTP = null;//是否已发送 int grid3ActiveRow = 0;//保存grid3(a,b,So等横向现实的grid)的当前活动行 string strSmpNo = null; string strSmpCutLoc = null; string strSmpNoType = null; public void DoQuery() { try { //if (this.comboBox1.Text.Trim() == "" || this.comboBox4.Text.Trim() == "") //{ // MessageBox.Show("请选择产线和实验地点","提示"); // return; //} //OperateConditionRecode.WriteCondition("JHY02_1", this.comboBox1.Text); //OperateConditionRecode.WriteCondition("UIB100203_2", this.comboBox2.Text); //OperateConditionRecode.WriteCondition("UIB100203_4", this.comboBox4.Text); this.dataSet1.Clear(); ArrayList al = new ArrayList(); al.Add("JHY02.SMP_D_SELECT"); strLine = "R"; //产线 if (this.checkBox5.Checked && !string.IsNullOrEmpty(comboBox1.Text) && comboBox1.Text != "全部") { al.Add(comboBox1.Text); } else { al.Add(""); } //委托时间 if (this.checkBox2.Checked) { al.Add(this.ultraDateTimeEditor3.DateTime.ToString("yyyyMMdd") + "000000"); al.Add(this.ultraDateTimeEditor4.DateTime.ToString("yyyyMMdd") + "999999"); } else { al.Add(""); al.Add(""); } //轧批号 if (this.checkBox4.Checked) { al.Add(this.textBox3.Text.Trim()); } else { al.Add(""); } this.dataSet1.Tables[0].Clear(); CoreClientParam ccp = new CoreClientParam(); ccp.ServerName = "UIB.JHY.ComQuery"; ccp.MethodName = "doSimpleQuery"; ccp.ServerParams = new object[] { "testDao", al }; ccp.SourceDataTable = this.dataSet1.Tables[0]; this.ExecuteQueryToDataTable(ccp, CoreInvokeType.Internal); //发送、完成状态颜色显示,发送状态优先 //foreach (UltraGridRow ugr in this.ultraGrid1.Rows) //{ // if (ugr.Cells["SEND_STAT"].Text.Substring(0, 1) == "0")//是否已发送,未发送则蓝色 // { // //ugr.RowSelectorAppearance.BackColor = Color.Blue; // ugr.Cells["SEND_STAT"].Appearance.BackColor = Color.Blue; // } // if (ugr.Cells["WORK_STATS"].Text == "XX")//是否已完成,未完成则显示黄色 // { // ugr.RowSelectorAppearance.BackColor = Color.Yellow; // } //} } catch (Exception ex) { } } /// /// 发送检测值到质检服务 /// public void DoSend() { try { int SPLITNUM = 3; string splitStr = null; int coilNum = 0; ArrayList specimen_noList = new ArrayList(); ArrayList al = new ArrayList(); string specimen_no = ""; foreach (UltraGridRow ugr in this.ultraGrid1.Rows) { if (ugr.Cells["CHK"].Text == "True") { specimen_noList.Add(ugr.Cells["SPECIMEN_NO"].Text); coilNum++; if (coilNum % SPLITNUM == 0) { splitStr = "\n"; } else { if (string.IsNullOrEmpty(specimen_no)) { splitStr = ""; } else { splitStr = ","; } } specimen_no = specimen_no + splitStr + ugr.Cells["SPECIMEN_NO"].Text; } // this.ultraGrid5.Rows[colNum].Cells["QLTY_VAL"].Value = al[0].ToString(); } if(specimen_noList.Count == 0) { return; } if (MessageBox.Show("确定发送以下取样编号:\n" + specimen_no, "提示", MessageBoxButtons.OKCancel) == DialogResult.Cancel) return; CoreClientParam ccp = new CoreClientParam(); ccp.ServerName = "UIB.JHY.JHY02"; ccp.MethodName = "doSendQltyValue"; al.Add(specimen_noList); al.Add(this.UserInfo.GetUserName()); ccp.ServerParams = new object[] { al }; ccp = this.ExecuteQueryToDataTable(ccp, CoreInvokeType.Internal); if (!ccp.ReturnObject.ToString().Equals("200")) { MessageBox.Show(ccp.ReturnObject.ToString(), "警告"); } else { MessageBox.Show("发送成功!", "提示"); } this.DoQuery(); } catch (Exception ex) { MessageBox.Show("系统异常,请联系技术中心", "警告"); } } //归档 public void DoOnFile() { try { //if (MessageBox.Show("确定对【" + this.comboBox1.Text.ToString(), "】数据进行归档?", MessageBoxButtons.OKCancel) == DialogResult.Cancel) // return; //Hashtable ht = new Hashtable(); //ht.Add("i1", this.comboBox1.Text.ToString()); //ht.Add("i2", this.UserInfo.GetUserName()); //ht.Add("o3", ""); //CoreClientParam ccp = new CoreClientParam(); //ccp.ServerName = "UIB.JHY.JHyComCallProc"; //ccp.MethodName = "doSimpleProc"; //ccp.ServerParams = new object[] { "UIB100203_COMM_05.CALL", ht }; //CoreClientParam rccp = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal); //ArrayList al = rccp.ReturnObject as ArrayList; //if (al[0] == null) return; //if (al[0].ToString() == "XX") //{ // MessageBox.Show("数据归档失败!" , "提示"); // return; //} //MessageBox.Show("数据归档成功!" , "提示"); } catch (Exception ex) { } } //导出 public void DoExport() { if (this.comboBox3.Text == "") { MessageBox.Show("请选择导出类别" , "提示"); return; } int SPLITNUM = 3; string splitStr = null; int coilNum = 0; string strspecimen_no_export = ""; string specimen_no = ""; foreach (UltraGridRow ugr in this.ultraGrid1.Rows) { if (ugr.Cells["CHK"].Text == "True") { coilNum++; if (coilNum % SPLITNUM == 0) { splitStr = "\n"; } else { if (string.IsNullOrEmpty(specimen_no)) { splitStr = ""; } else { splitStr = ","; } } strspecimen_no_export = strspecimen_no_export + ugr.Cells["SPECIMEN_NO"].Text; specimen_no = specimen_no + splitStr + ugr.Cells["SPECIMEN_NO"].Text; } } if (string.IsNullOrEmpty(strspecimen_no_export)) { return; } if (MessageBox.Show("确定导出以下取样编号:\n" + specimen_no, "提示", MessageBoxButtons.OKCancel) == DialogResult.Cancel) return; ApplicationClass ExcelApp = null; Microsoft.Office.Interop.Excel.Application excel = null; Microsoft.Office.Interop.Excel.Workbooks workbooks = null; Microsoft.Office.Interop.Excel._Workbook workbook = null; Microsoft.Office.Interop.Excel.Sheets sheets = null; Microsoft.Office.Interop.Excel.Worksheet sheet = null; try { ArrayList al = new ArrayList(); if (this.comboBox3.Text == "拉力原始记录(圆形)" || this.comboBox3.Text == "拉力原始记录(矩形)") { //查询出所需要导出卷的信息 this.dataSet3.Tables["lldc"].Clear(); al.Add("JHY02.EXPORT_PULL_SELECT"); al.Add(strspecimen_no_export); al.Add(strspecimen_no_export); al.Add(strspecimen_no_export); if (this.comboBox3.Text == "拉力原始记录(圆形)") { al.Add("C"); } else if (this.comboBox3.Text == "拉力原始记录(矩形)") { al.Add("S"); } CoreClientParam ccp = new CoreClientParam(); ccp.ServerName = "UIB.JHY.ComQuery"; ccp.MethodName = "doSimpleQuery"; ccp.ServerParams = new object[] { "testDao", al }; ccp.SourceDataTable = this.dataSet3.Tables["lldc"]; this.ExecuteQueryToDataTable(ccp, CoreInvokeType.Internal); //导出 if (this.dataSet3.Tables["lldc"].Rows.Count == 0) { return; } string strfile = ""; if (this.comboBox3.Text == "拉力原始记录(圆形)") { strfile = System.Windows.Forms.Application.StartupPath + "\\JHY02PullY.xls";//模板路径 } else { strfile = System.Windows.Forms.Application.StartupPath + "\\JHY02PullJ.xls";//模板路径 } ExcelApp = new ApplicationClass(); excel = new Microsoft.Office.Interop.Excel.Application(); workbooks = excel.Workbooks; workbook = workbooks.Add(strfile); sheets = workbook.Sheets; sheet = (Microsoft.Office.Interop.Excel.Worksheet)sheets[1]; int startRow = 5;//模板数据填充从第五行开始 Range range = null; int i = 0; int j = 1; for (i = 0; i < this.dataSet3.Tables["lldc"].Rows.Count; i++) { j = 1; sheet.Cells[startRow + i, j++] = this.dataSet3.Tables["lldc"].Rows[i]["gyh"].ToString();//钢印号 sheet.Cells[startRow + i, j++] = this.dataSet3.Tables["lldc"].Rows[i]["grade_name"].ToString();//牌号 sheet.Cells[startRow + i, j++] = this.dataSet3.Tables["lldc"].Rows[i]["batch_no"].ToString();//轧批号 sheet.Cells[startRow + i, j++] = this.dataSet3.Tables["lldc"].Rows[i]["material_thk"].ToString();//规格 sheet.Cells[startRow + i, j++] = this.dataSet3.Tables["lldc"].Rows[i]["a01"].ToString();//a sheet.Cells[startRow + i, j++] = this.dataSet3.Tables["lldc"].Rows[i]["b01"].ToString();//b sheet.Cells[startRow + i, j++] = this.dataSet3.Tables["lldc"].Rows[i]["a02"].ToString();//a sheet.Cells[startRow + i, j++] = this.dataSet3.Tables["lldc"].Rows[i]["b02"].ToString();//b sheet.Cells[startRow + i, j++] = this.dataSet3.Tables["lldc"].Rows[i]["a03"].ToString();//a sheet.Cells[startRow + i, j++] = this.dataSet3.Tables["lldc"].Rows[i]["b03"].ToString();//b sheet.Cells[startRow + i, j++] = this.dataSet3.Tables["lldc"].Rows[i]["FeL/FeH"].ToString();//Fe sheet.Cells[startRow + i, j++] = this.dataSet3.Tables["lldc"].Rows[i]["Fm"].ToString();//Fm sheet.Cells[startRow + i, j++] = this.dataSet3.Tables["lldc"].Rows[i]["Lo"].ToString();//Lo sheet.Cells[startRow + i, j++] = this.dataSet3.Tables["lldc"].Rows[i]["Lu"].ToString();//Lu // sheet.Cells[startRow + i, j++] = this.dataSet3.Tables["lldc"].Rows[i]["ZJ"].ToString();//直径 // sheet.Cells[startRow + i, j++] = this.dataSet3.Tables["lldc"].Rows[i]["CB"].ToString();//冷弯 } //Range ra = sheet.get_Range(sheet.Cells[5, 1], sheet.Cells[5, 1]); //ra.Select(); range = sheet.get_Range(sheet.Cells[startRow, 1], sheet.Cells[startRow+(i-1), j-1+3]);//(Range)sheet.Rows[6, 1]; range.Borders.LineStyle = 1; range.NumberFormatLocal = "@";//设置单元格格式为文本 range.RowHeight = 22.5; //range.HorizontalAlignment = XlHAlign.xlHAlignLeft;//字体左靠 // range.RowHeight = 24; // System.DateTime dt = System.DateTime.Now; // string TimeNow = string.Format("{0:yyyyMMddHHmmssffff}", dt); workbook.Saved = true; string path = null; if (this.folderBrowserDialog1.ShowDialog() == DialogResult.OK) { path = this.folderBrowserDialog1.SelectedPath; } else { return; } workbook.SaveCopyAs(path + "\\" + this.comboBox3.Text + DateTime.Now.ToString("yyyyMMddHHmmss") + ".xls"); excel.DisplayAlerts = false; excel.AlertBeforeOverwriting = false; workbooks.Close(); workbook = null; excel.Quit(); excel = null; ExcelApp.Quit(); ExcelApp = null; } else if (this.comboBox3.Text == "冲击原始记录") { //查询出所需要导出卷的信息 this.dataSet3.Tables["cjdc"].Clear(); //查询出所需要导出卷的信息 this.dataSet3.Tables["cjdc"].Clear(); al.Add("JHY02.EXPORT_CJ_SELECT"); al.Add(strspecimen_no_export); al.Add(strspecimen_no_export); CoreClientParam ccp = new CoreClientParam(); ccp.ServerName = "UIB.JHY.ComQuery"; ccp.MethodName = "doSimpleQuery"; ccp.ServerParams = new object[] { "testDao", al }; ccp.SourceDataTable = this.dataSet3.Tables["cjdc"]; this.ExecuteQueryToDataTable(ccp, CoreInvokeType.Internal); //导出 if (this.dataSet3.Tables["cjdc"].Rows.Count == 0) { return; } //导出 string strfile = System.Windows.Forms.Application.StartupPath + "\\JHY02CJ.xls";//模板路径 ExcelApp = new ApplicationClass(); excel = new Microsoft.Office.Interop.Excel.Application(); workbooks = excel.Workbooks; workbook = workbooks.Add(strfile); sheets = workbook.Sheets; sheet = (Microsoft.Office.Interop.Excel.Worksheet)sheets[1]; int startRow = 5;//模板数据填充从第五行开始 Range range = null; int i = 0; int j = 1; for (i = 0; i < this.dataSet3.Tables["cjdc"].Rows.Count; i++) { j = 1; sheet.Cells[startRow + i, j++] = this.dataSet3.Tables["cjdc"].Rows[i]["gyh"].ToString();//钢印号 sheet.Cells[startRow + i, j++] = this.dataSet3.Tables["cjdc"].Rows[i]["grade_name"].ToString();//牌号 sheet.Cells[startRow + i, j++] = this.dataSet3.Tables["cjdc"].Rows[i]["batch_no"].ToString();//轧批号 sheet.Cells[startRow + i, j++] = this.dataSet3.Tables["cjdc"].Rows[i]["material_thk"].ToString();//规格 sheet.Cells[startRow + i, j++] = this.dataSet3.Tables["cjdc"].Rows[i]["item_name_d"].ToString();//试样温度 sheet.Cells[startRow + i, j++] = this.dataSet3.Tables["cjdc"].Rows[i]["item_name_t"].ToString();//试验温度 sheet.Cells[startRow + i, j++] = this.dataSet3.Tables["cjdc"].Rows[i]["J1"].ToString();//J1 sheet.Cells[startRow + i, j++] = this.dataSet3.Tables["cjdc"].Rows[i]["J2"].ToString();//J2 sheet.Cells[startRow + i, j++] = this.dataSet3.Tables["cjdc"].Rows[i]["J3"].ToString();//J3 //sheet.Cells[startRow + i, j++] = this.dataSet3.Tables["lldc"].Rows[i]["FM"].ToString();//Fm //sheet.Cells[startRow + i, j++] = this.dataSet3.Tables["lldc"].Rows[i]["LO"].ToString();//Lo //sheet.Cells[startRow + i, j++] = this.dataSet3.Tables["lldc"].Rows[i]["LU"].ToString();//Lu //sheet.Cells[startRow + i, j++] = this.dataSet3.Tables["lldc"].Rows[i]["ZJ"].ToString();//直径 //sheet.Cells[startRow + i, j++] = this.dataSet3.Tables["lldc"].Rows[i]["CB"].ToString();//冷弯 } //设置样式 range = sheet.get_Range(sheet.Cells[startRow, 1], sheet.Cells[startRow + (i - 1), j - 1 + 1]);//(Range)sheet.Rows[6, 1]; range.Borders.LineStyle = 1; range.NumberFormatLocal = "@";//设置单元格格式为文本 range.RowHeight = 22.5; workbook.Saved = true; string path = null; if (this.folderBrowserDialog1.ShowDialog() == DialogResult.OK) { path = this.folderBrowserDialog1.SelectedPath; } else { return; } workbook.SaveCopyAs(path + "\\" + this.comboBox3.Text + DateTime.Now.ToString("yyyyMMddHHmmss") + ".xls"); excel.DisplayAlerts = false; excel.AlertBeforeOverwriting = false; workbooks.Close(); workbook = null; excel.Quit(); excel = null; ExcelApp.Quit(); ExcelApp = null; } else return; MessageBox.Show("导出成功!" , "提示"); } catch (Exception ex) { MessageBox.Show("导出失败!"+ex.ToString() , "提示"); } finally { try { if (workbooks != null) workbooks.Close(); if (excel != null) excel.Quit(); if (ExcelApp != null) ExcelApp.Quit(); } catch (Exception ex) { MessageBox.Show("error"); } GC.Collect(); } } //设置颜色 //若为A,判断值是否合格 public void SetColor(string flag , Infragistics.Win.UltraWinGrid.UltraGrid grid) { try { if (flag == "A") { Decimal minValue = 0; Decimal maxValue = 0; Decimal qltyValue = 0; foreach (UltraGridRow ugr in grid.Rows) { if (ugr.Cells["QLTY_VAL"].Text.Trim() == "") { ugr.RowSelectorAppearance.BackColor = Color.Yellow; continue; } else if (ugr.Cells["QLTY_VAL"].Text.Trim() == "不合格") { ugr.RowSelectorAppearance.BackColor = Color.Red; continue; } else if (ugr.Cells["QLTY_VAL"].Text.Trim() == "合格") { continue; } minValue = Convert.ToDecimal(ugr.Cells["QLTY_MIN"].Text == "" ? 0 : Convert.ToDecimal(ugr.Cells["QLTY_MIN"].Text)); maxValue = Convert.ToDecimal(ugr.Cells["QLTY_MAX"].Text == "" ? 9999 : Convert.ToDecimal(ugr.Cells["QLTY_MAX"].Text)); qltyValue = Convert.ToDecimal(ugr.Cells["QLTY_VAL"].Text.Trim()); if (qltyValue < minValue || qltyValue > maxValue) { ugr.RowSelectorAppearance.BackColor = Color.Red; } } } } catch (Exception ex) { } } //无计算公式,直接输入数据 public void DoUpdate(string flag, string column_name) { try { if (this.ultraGrid5.ActiveCell == null) return; if (this.ultraGrid5.ActiveCell.DataChanged == true) { //同步更新到dataset3的对应的单元中 for (int i = 0; i < this.dataSet3.Tables["yincang"].Rows.Count; i++) { if (this.ultraGrid5.ActiveRow.Cells["QLTY_OPE_CD"].Text == this.dataSet3.Tables["yincang"].Rows[i]["QLTY_OPE_CD"].ToString()) { this.dataSet3.Tables["yincang"].Rows[i][column_name] = this.ultraGrid5.ActiveRow.Cells[column_name].Text; // this.dataSet3.Tables["yincang"]. // MessageBox.Show(this.dataSet3.Tables["yincang"].Rows[i][column_name].ToString()); this.dataSet3.Tables["yincang"].AcceptChanges(); // this.dataSet3.AcceptChanges(); break; } } Hashtable ht = null; CoreClientParam ccp = null; string process_name = "JHY02_1.CALL"; if (column_name == "QLTY_VAL1") { process_name = "JHY02_1.CALL"; } else if (column_name == "QLTY_VAL2") { process_name = "JHY02_2.CALL"; } else if (column_name == "QLTY_VAL3") { process_name = "JHY02_3.CALL"; } ht = new Hashtable(); ht.Add("i1", this.ultraGrid3.ActiveRow.Cells["SMP_NO"].Text); ht.Add("i2", this.ultraGrid3.ActiveRow.Cells["SPECIMEN_NO"].Text); ht.Add("i3", this.ultraGrid3.ActiveRow.Cells["SMP_NO_TYPE"].Text); ht.Add("i4", this.strQltyCD2); ht.Add("i5", this.ultraGrid5.ActiveRow.Cells["QLTY_OPE_CD"].Text); ht.Add("i6", string.IsNullOrEmpty(this.ultraGrid5.ActiveRow.Cells["SMP_CUT_LOC"].Text) ? "0" : this.ultraGrid5.ActiveRow.Cells["SMP_CUT_LOC"].Text); ht.Add("i7", "");//计算公式 ht.Add("i8", this.ultraGrid5.ActiveRow.Cells["QLTY_DIS_LEN"].Text);//保留位数 ht.Add("i9", this.ultraGrid5.ActiveRow.Cells["CRCT_REG"].Text.ToUpper());//修约规则 ht.Add("i10", flag);//处理数据规则 ht.Add("i11", this.ultraGrid5.ActiveRow.Cells[column_name].Text); ht.Add("i12", this.UserInfo.GetUserName()); ht.Add("o13",""); ccp = new CoreClientParam(); ccp.ServerName = "UIB.JHY.ComCallProc"; ccp.MethodName = "doSimpleProc"; ccp.ServerParams = new object[] { "testDao", process_name, ht }; this.ExecuteNonQuery(ccp, CoreInvokeType.Internal); } } catch (Exception ex) { MessageBox.Show("系统异常,请与技术中心联系" , "提示"); } } //按公式进行计算 //colNum为需要计算的行 public void DoCompVal(int colNum, string column_name) { try { //判断该行是否存在,不存在则返回 if (colNum >= this.ultraGrid5.Rows.Count) return; string strCompVal = this.ultraGrid5.Rows[colNum].Cells["COMP_CAL"].Text;//计算公式 if (strCompVal == "") return; //若伸长率定标,则禁止计算 if (this.ultraGrid5.Rows[colNum].Cells["QLTY_OPE_CD"].Text == "Lo" && this.ultraGrid5.Rows[colNum].Cells["EDIT_TP"].Text == "X") { return; } for (int i = 0; i < this.dataSet3.Tables["yincang"].Rows.Count; i++) { strCompVal = strCompVal.Replace(this.dataSet3.Tables["yincang"].Rows[i]["QLTY_OPE_CD"].ToString()//this.ultraGrid5.Rows[i].Cells["QLTY_OPE_CD"].Text , this.dataSet3.Tables["yincang"].Rows[i][column_name].ToString());//this.ultraGrid5.Rows[i].Cells[column_name].Text); } Regex r = new Regex(@"[A-Z,a-z]"); Match m = r.Match(strCompVal); //判断公式的字符串是否已经替换完成,未替换完成,则不进行任何操作,直接返回 if (m.Success) return; string process_name = "JHY02_1.CALL"; if (column_name == "QLTY_VAL1") { process_name = "JHY02_1.CALL"; } else if (column_name == "QLTY_VAL2") { process_name = "JHY02_2.CALL"; } else if (column_name == "QLTY_VAL3") { process_name = "JHY02_3.CALL"; } strCompVal = strCompVal.Replace("√", "SQRT").Replace("=","");//开根号处理 Hashtable ht = new Hashtable(); ht.Add("i1", this.ultraGrid3.ActiveRow.Cells["SMP_NO"].Text); ht.Add("i2", this.ultraGrid3.ActiveRow.Cells["SPECIMEN_NO"].Text); ht.Add("i3", this.ultraGrid3.ActiveRow.Cells["SMP_NO_TYPE"].Text); ht.Add("i4", this.strQltyCD2); ht.Add("i5", this.ultraGrid5.Rows[colNum].Cells["QLTY_OPE_CD"].Text); ht.Add("i6", string.IsNullOrEmpty(this.ultraGrid5.Rows[colNum].Cells["SMP_CUT_LOC"].Text) ? "0" : this.ultraGrid5.Rows[colNum].Cells["SMP_CUT_LOC"].Text); ht.Add("i7", strCompVal);//计算公式 ht.Add("i8", this.ultraGrid5.Rows[colNum].Cells["QLTY_DIS_LEN"].Text);//保留位数 ht.Add("i9", this.ultraGrid5.Rows[colNum].Cells["CRCT_REG"].Text.ToUpper());//修约规则 ht.Add("i10", "");//处理数据规则 ht.Add("i11", ""); ht.Add("i12", this.UserInfo.GetUserName()); ht.Add("o13", ""); CoreClientParam ccp = new CoreClientParam(); ccp.ServerName = "UIB.JHY.ComCallProc"; ccp.MethodName = "doSimpleProc"; ccp.ServerParams = new object[] { "testDao", process_name, ht }; CoreClientParam rccp = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal); //计算结果返回 ArrayList al = rccp.ReturnObject as ArrayList; if (al[0] == null) return; if (al[0].ToString() == "XX") return; this.ultraGrid5.Rows[colNum].Cells[column_name].Value = al[0].ToString(); // this.ultraGrid3.ActiveRow.Cells[this.ultraGrid5.ActiveRow.Cells["QLTY_OPE_CD"].Text].Value = al[0].ToString(); this.ultraGrid5.UpdateData(); this.ultraGrid3.UpdateData(); //同步更新到dataset3的对应的单元中 for (int i = 0; i < this.dataSet3.Tables["yincang"].Rows.Count; i++) { // if (this.ultraGrid5.ActiveRow.Cells["QLTY_OPE_CD"].Text == this.dataSet3.Tables["yincang"].Rows[i]["QLTY_OPE_CD"].ToString()) if (this.ultraGrid5.Rows[colNum].Cells["QLTY_OPE_CD"].Text == this.dataSet3.Tables["yincang"].Rows[i]["QLTY_OPE_CD"].ToString()) //DefaultView { this.dataSet3.Tables["yincang"].Rows[i][column_name] = this.ultraGrid5.Rows[colNum].Cells[column_name].Text;//this.ultraGrid5.ActiveRow.Cells[column_name].Text; // MessageBox.Show(this.dataSet3.Tables["yincang"].Rows[i][column_name].ToString()); this.dataSet3.Tables["yincang"].AcceptChanges(); break; } } } catch (Exception ex) { MessageBox.Show("计算异常"); } } private void JHY02_Load(object sender, EventArgs e) { try { this.comboBox1.Text = "全部";//OperateConditionRecode.ReadCondition("UIB100203_1"); this.comboBox6.Text = "一组";//OperateConditionRecode.ReadCondition("UIB100203_1"); this.comboBox2.Text = OperateConditionRecode.ReadCondition("UIB100203_2"); this.comboBox4.Text = OperateConditionRecode.ReadCondition("UIB100203_4"); this.textBox5.Text = OperateConditionRecode.ReadCondition("UIB100203_PATH"); comboBox1.Enabled = false; ultraDateTimeEditor3.DateTime = ultraDateTimeEditor3.DateTime = DateTime.Today; this.comboBox3.SelectedIndex = 0;//导出 //this.comboBox2.SelectedIndex = 2; ArrayList list = new ArrayList(); //列名排序查询 // this.dataSet2.Tables[2].Clear(); ArrayList al = new ArrayList(); al.Add("UIB100203_01.INITSELECT");//页面初始化调用,用于编码的排序 list.Add(al); al = new ArrayList(); al.Add("UIB100203_02.INITSELECT");//材质代码与材质名称 list.Add(al); CoreClientParam ccp = new CoreClientParam(); ccp.ServerName = "UIB.JHY.JHYComQuery"; ccp.MethodName = "doContQluery"; ccp.ServerParams = new object[] { list }; CoreClientParam ccpList = this.ExecuteQuery(ccp, CoreInvokeType.Internal); if (ccpList.ReturnInfo.Length == 0) { ArrayList aList = ccpList.ReturnObject as ArrayList; if (aList[0] != null) { this.dataSet2.Tables["paixu"].Clear(); System.Data.DataTable tab0 = Common.FixDBManager.ConvertToDataTable(aList[0] as System.Collections.ArrayList, this.dataSet2.Tables["paixu"]); tab0.TableName = "paixu"; this.dataSet2.Tables["paixu"].Merge(tab0); } if (aList[1] != null) { this.dataSet2.Tables["qltycd"].Clear(); System.Data.DataTable tab0 = Common.FixDBManager.ConvertToDataTable(aList[1] as System.Collections.ArrayList, this.dataSet2.Tables["qltycd"]); tab0.TableName = "qltycd"; this.dataSet2.Tables["qltycd"].Merge(tab0); } } ValueList vlist = new ValueList(); vlist.ValueListItems.Add("A", "成分"); vlist.ValueListItems.Add("B", "材质"); SetGridValuelist(ref ultraGrid1, "SMP_CATG", ref vlist); vlist = new ValueList(); vlist.ValueListItems.Add("0", "无效"); vlist.ValueListItems.Add("1", "有效"); SetGridValuelist(ref ultraGrid1, "VALIDFLAG", ref vlist); vlist = new ValueList(); vlist.ValueListItems.Add("0", "未发送"); vlist.ValueListItems.Add("1", "已发送"); vlist.ValueListItems.Add("2", "已接收"); vlist.ValueListItems.Add("3", "已完成"); vlist.ValueListItems.Add("4", "检化验系统退回"); SetGridValuelist(ref ultraGrid1, "STATUS", ref vlist); vlist = new ValueList(); vlist.ValueListItems.Add("0", "正常组批"); vlist.ValueListItems.Add("1", "改判组批"); SetGridValuelist(ref ultraGrid1, "SOURCE", ref vlist); vlist = new ValueList(); vlist.ValueListItems.Add("0", "未发送"); vlist.ValueListItems.Add("1", "已发送"); SetGridValuelist(ref ultraGrid1, "SEND_FLAG", ref vlist); //CoreClientParam ccp1 = new CoreClientParam(); //ccp1.ServerName = "UIB.JHY.JHYComQuery"; //ccp1.MethodName = "doSimpleQuery"; //ccp1.ServerParams = new object[] { al }; //ccp1.SourceDataTable = this.dataSet2.Tables[2]; //this.ExecuteQueryToDataTable(ccp1, CoreInvokeType.Internal); } catch (Exception ex) { } } int grid1CurNum = 0; //点击上面的grid private void ultraGrid1_MouseDown(object sender, MouseEventArgs e) { try { if(this.ultraGrid1.ActiveRow == null) return; // if (this.ultraGrid1.ActiveCell.Column.Key == "CHK") // return; grid1CurNum = this.ultraGrid1.ActiveRow.Index; string smpno = this.ultraGrid1.ActiveRow.Cells["SMP_NO"].Text; ArrayList al = new ArrayList(); if (this.ultraTabControl1.Tabs[0].Selected)//检验结果查询 { al.Add("JHY02.QLTY_ITEM_VALUE_SELECT"); al.Add(this.ultraGrid1.ActiveRow.Cells["SMP_NO"].Text); //if (this.ultraGrid1.ActiveCell.Column.Key == "COIL_NO" // || this.ultraGrid1.ActiveCell.Column.Key == "CHK") //{ // al.Add("UIB100203_COMM_01_1.SELECT"); // al.Add(this.strArr);//检测中心和理化楼区分 // al.Add(this.ultraGrid1.ActiveRow.Cells["COIL_NO"].Text); // //al.Add(this.strArr);//力学或者金相 // //al.Add(this.strSendTP);//是否已发送 // al.Add(this.ultraGrid1.ActiveRow.Cells["SMP_NO"].Text); //} //else //{ // if (smpno.Substring(0, 1) == "X" || smpno.Substring(0, 1) == "Y") // { // al.Add("UIB100203_COMMZHB_01.SELECT"); // } // else // { // al.Add("UIB100203_COMM_01.SELECT"); // } // al.Add(this.strArr);//检测中心和理化楼区分 // al.Add(this.ultraGrid1.ActiveRow.Cells["WEITO_NO"].Text); // // al.Add(this.strArr);//力学或者金相 // // al.Add(this.strSendTP);//是否已发送 //} this.dataSet1.Tables[1].Clear(); CoreClientParam ccp = new CoreClientParam(); ccp.ServerName = "UIB.JHY.ComQuery"; ccp.MethodName = "doSimpleQuery"; ccp.ServerParams = new object[] { "testDao", al }; ccp.SourceDataTable = this.dataSet1.Tables[1]; this.ExecuteQueryToDataTable(ccp, CoreInvokeType.Internal); SetColor("A" , this.ultraGrid2);//不合格颜色为红色 } else if (this.ultraTabControl1.Tabs[1].Selected)//检验项目原始记录 { al.Add("JHY02.SMP_D_ITEM_SELECT"); al.Add(smpno); al.Add(smpno); this.dataSet2.Tables[0].Clear(); CoreClientParam ccp = new CoreClientParam(); ccp.ServerName = "UIB.JHY.ComQuery"; ccp.MethodName = "doSimpleQuery"; ccp.ServerParams = new object[] { "testDao", al }; ccp.SourceDataTable = this.dataSet2.Tables[0]; this.ExecuteQueryToDataTable(ccp, CoreInvokeType.Internal); if (this.ultraGrid4.Rows.Count> 0 && this.ultraGrid3.Rows.Count == 0) { this.ultraGrid4.Rows[0].Activate(); ultraGrid4_MouseDown(null, null); } } else if (this.ultraTabControl1.Tabs[2].Selected)//异常处理 { //this.strSmpNo = this.ultraGrid1.ActiveRow.Cells["SMP_NO"].Text; //this.strSmpCutLoc = this.ultraGrid1.ActiveRow.Cells["SMP_CUT_LOC"].Text; //this.strSmpNoType = this.ultraGrid1.ActiveRow.Cells["SMP_NO_TYPE"].Text; ////清除项目值 //al.Add("UIB100203_COMM_10.SELECT"); //al.Add(this.ultraGrid1.ActiveRow.Cells["SMP_NO"].Text); //al.Add(this.ultraGrid1.ActiveRow.Cells["SMP_CUT_LOC"].Text); //al.Add(this.ultraGrid1.ActiveRow.Cells["SMP_NO_TYPE"].Text); //al.Add(this.strArr); //this.dataSet3.Tables["Table1"].Clear(); //CoreClientParam ccp = new CoreClientParam(); //ccp.ServerName = "UIB.JHY.JHYComQuery"; //ccp.MethodName = "doSimpleQuery"; //ccp.ServerParams = new object[] { al }; //ccp.SourceDataTable = this.dataSet3.Tables["Table1"]; //this.ExecuteQueryToDataTable(ccp, CoreInvokeType.Internal); } } catch (Exception ex) { } } //鼠标点击检验项目名称触发事件 private void ultraGrid4_MouseDown(object sender, MouseEventArgs e) { try { if (this.ultraGrid4.ActiveRow == null) return; this.dataSet2.Tables[1].Clear(); this.dataSet2.Tables["yuanshi"].Clear(); int GRID3COLS = 26;//固定的有17列,包括隐藏列 string seq = this.ultraGrid4.ActiveRow.Cells["SEQ"].Text; string smp_no = this.ultraGrid4.ActiveRow.Cells["SMP_NO"].Text; string specimen_no = this.ultraGrid4.ActiveRow.Cells["SPECIMEN_NO"].Text; //strQltyCD = this.ultraGrid4.ActiveRow.Cells["QLTY_CD"].Text;//三期编码 strQltyCD2 = this.ultraGrid4.ActiveRow.Cells["QLTY_CD_2"].Text;//二级编码,如拉力,冲击 strQltyCD3 = this.ultraGrid4.ActiveRow.Cells["QLTY_CD_3"].Text;//三级编码,如屈服强度,伸长率 //清除datatable中查询时增加的列,即显示钢卷号等信息的grid的动态列 if (this.dataSet2.Tables[1].Columns.Count > GRID3COLS) { for (int i = this.dataSet2.Tables[1].Columns.Count; i > GRID3COLS; i--) this.dataSet2.Tables[1].Columns.Remove(this.dataSet2.Tables[1].Columns[i - 1]); } CoreClientParam ccp = new CoreClientParam(); ccp.ServerName = "UIB.JHY.JHY02"; ccp.MethodName = "doQltyCdQuery"; ccp.ServerParams = new object[] { smp_no, specimen_no, seq, strQltyCD2, strQltyCD3}; ccp.SourceDataTable = this.dataSet2.Tables["jilu"]; this.ExecuteQueryToDataTable(ccp, CoreInvokeType.Internal); //this.ultraGrid3.DisplayLayout.Bands[0].co //int ix = 0; //foreach (Infragistics.Win.UltraWinGrid.UltraGridColumn col in this.ultraGrid3.DisplayLayout.Bands[0].Columns) //{ // col.RowLayoutColumnInfo.OriginX = ix * 2; // col.RowLayoutColumnInfo.OriginY = 0; // ix++; //} //列排序 int index = GRID3COLS + 1; for (int i = 0; i < this.dataSet2.Tables[2].Rows.Count; i++) { string strColName = this.dataSet2.Tables[2].Rows[i]["QLTY_OPE_CFNM"].ToString();//a , b, So等 string strColSeq = this.dataSet2.Tables[2].Rows[i]["QLTY_DIS_SEQ"].ToString();//1,2,3等 string strColCD2 = this.dataSet2.Tables[2].Rows[i]["QLTY_CD_2"].ToString();//如拉力,冲击等二级编码 for (int nextCol = GRID3COLS; nextCol < this.ultraGrid3.DisplayLayout.Bands[0].Columns.Count; nextCol++)//固定的有15列,包括隐藏的两列,从第12列开始排序 { this.ultraGrid3.DisplayLayout.Bands[0].Columns[nextCol].Width = 50;//设置列宽 this.ultraGrid3.DisplayLayout.Bands[0].Columns[nextCol].CellActivation = Infragistics.Win.UltraWinGrid.Activation.NoEdit;//不可编辑 if (this.ultraGrid3.DisplayLayout.Bands[0].Columns[nextCol].Header.Caption == strColName) { this.ultraGrid3.DisplayLayout.Bands[0].Columns[strColName].Header.VisiblePosition = index; //列排序 index++; break; } } } SetColor("A" , this.ultraGrid3);//设置颜色 } catch (Exception ex) { MessageBox.Show("系统异常,请联系技术中心","警告"); } } //横行记录a,b,So的grid,在进行鼠标点击时的操作 //******************************注意********************************* //grid3若新增字段,可能出现查询后字段显示异常的情况。。。。。。。。。。。。。。。注意处理 //若grid3增加了字段,并要移动字段位置,请通过Band and Column Settings -- >Column Arrangement Overview Use Groups and Levels中的字段移动来改变,否则可能出现某些字段无法显示的异常情况。 private void ultraGrid3_MouseDown(object sender, MouseEventArgs e) { try { if (this.ultraGrid3.ActiveRow == null) return; if (sender != null) grid3ActiveRow = this.ultraGrid3.ActiveRow.Index; this.strQltyCD = this.ultraGrid3.ActiveRow.Cells["QLTY_CD"].Text; this.strQltyCD2 = this.ultraGrid3.ActiveRow.Cells["QLTY_CD_2"].Text; if (!string.IsNullOrEmpty(strQltyCD) && strQltyCD != "0") { comboBox6.Text = "一组"; panel1.Hide(); } else { panel1.Show(); } this.dataSet2.Tables["yuanshi"].Clear(); this.dataSet2.Tables["shebei"].Clear(); ArrayList list = new ArrayList(); //a,b等值查询 ArrayList al = new ArrayList(); list.Add(al); al.Add("JHY02.QLTY_QCMVAL_IMPORT_SELECT"); al.Add(this.ultraGrid3.ActiveRow.Cells["SMP_NO"].Text); al.Add(this.ultraGrid3.ActiveRow.Cells["SPECIMEN_NO"].Text); al.Add(this.ultraGrid3.ActiveRow.Cells["SMP_NO_TYPE"].Text); al.Add(string.IsNullOrEmpty(this.ultraGrid3.ActiveRow.Cells["SMP_CUT_LOC"].Text) ? "0" : this.ultraGrid3.ActiveRow.Cells["SMP_CUT_LOC"].Text); //al.Add(this.ultraGrid3.ActiveRow.Cells["QLTY_CD_3"].Text); al.Add(this.strQltyCD2); al.Add(this.ultraGrid3.ActiveRow.Cells["QLTY_CD_AFTER"].Text); ////设备号、备注等查询 //al = new ArrayList(); //list.Add(al); //al.Add("UIB100203_COMM_06.SELECT"); //al.Add(this.ultraGrid3.ActiveRow.Cells["SMP_NO"].Text); //al.Add(this.ultraGrid3.ActiveRow.Cells["SMP_CUT_LOC"].Text); //al.Add(this.ultraGrid3.ActiveRow.Cells["SMP_NO_TYPE"].Text); //al.Add(strQltyCD); //隐藏的值和编码 al = new ArrayList(); list.Add(al); al.Add("JHY02.QLTY_QCMVAL_VALUE_SELECT"); al.Add(this.ultraGrid3.ActiveRow.Cells["SMP_NO"].Text); al.Add(this.ultraGrid3.ActiveRow.Cells["SPECIMEN_NO"].Text); al.Add(this.ultraGrid3.ActiveRow.Cells["SMP_NO_TYPE"].Text); //al.Add(string.IsNullOrEmpty(this.ultraGrid3.ActiveRow.Cells["SMP_CUT_LOC"].Text) ? "0" : this.ultraGrid3.ActiveRow.Cells["SMP_CUT_LOC"].Text); //al.Add(this.strQltyCD2); //al.Add(this.ultraGrid3.ActiveRow.Cells["QLTY_CD_AFTER"].Text); //隐藏的值和编码 al = new ArrayList(); list.Add(al); al.Add("JHY02.QLTY_QCMVAL_IMPORT_SELECT2"); al.Add(this.ultraGrid3.ActiveRow.Cells["SMP_NO"].Text); al.Add(this.ultraGrid3.ActiveRow.Cells["SPECIMEN_NO"].Text); al.Add(this.ultraGrid3.ActiveRow.Cells["SMP_NO_TYPE"].Text); al.Add(string.IsNullOrEmpty(this.ultraGrid3.ActiveRow.Cells["SMP_CUT_LOC"].Text) ? "0" : this.ultraGrid3.ActiveRow.Cells["SMP_CUT_LOC"].Text); //al.Add(this.ultraGrid3.ActiveRow.Cells["QLTY_CD_3"].Text); al.Add(this.strQltyCD2); al.Add(this.ultraGrid3.ActiveRow.Cells["QLTY_CD_AFTER"].Text); //隐藏的值和编码 al = new ArrayList(); list.Add(al); al.Add("JHY02.QLTY_QCMVAL_VALUE_SELECT2"); al.Add(this.ultraGrid3.ActiveRow.Cells["SMP_NO"].Text); al.Add(this.ultraGrid3.ActiveRow.Cells["SPECIMEN_NO"].Text); al.Add(this.ultraGrid3.ActiveRow.Cells["SMP_NO_TYPE"].Text); //al.Add(string.IsNullOrEmpty(this.ultraGrid3.ActiveRow.Cells["SMP_CUT_LOC"].Text) ? "0" : this.ultraGrid3.ActiveRow.Cells["SMP_CUT_LOC"].Text); //al.Add(this.strQltyCD2); //al.Add(this.ultraGrid3.ActiveRow.Cells["QLTY_CD_AFTER"].Text); CoreClientParam ccp = new CoreClientParam(); ccp.ServerName = "UIB.JHY.ComQuery"; ccp.MethodName = "doContQluery"; ccp.ServerParams = new object[] {"testDao", list }; CoreClientParam ccpList = this.ExecuteQuery(ccp, CoreInvokeType.Internal); if (ccpList.ReturnInfo.Length == 0) { ArrayList aList = ccpList.ReturnObject as ArrayList; if (aList[0] != null) { this.dataSet2.Tables["yuanshi"].Clear(); System.Data.DataTable tab0 = Common.FixDBManager.ConvertToDataTable(aList[0] as System.Collections.ArrayList, this.dataSet2.Tables["yuanshi"]); if (tab0 == null || tab0.Rows == null || tab0.Rows.Count == 0) { if (aList[2] != null) { tab0 = Common.FixDBManager.ConvertToDataTable(aList[2] as System.Collections.ArrayList, this.dataSet2.Tables["yuanshi"]); } } tab0.TableName = "yuanshi"; this.dataSet2.Tables["yuanshi"].Merge(tab0); } //if (aList[1] != null) //{ // this.dataSet2.Tables["shebei"].Clear(); // System.Data.DataTable tab0 = Common.FixDBManager.ConvertToDataTable(aList[1] as System.Collections.ArrayList, this.dataSet2.Tables["shebei"]); // tab0.TableName = "shebei"; // this.dataSet2.Tables["shebei"].Merge(tab0); //} if (aList[1] != null) { this.dataSet3.Tables["yincang"].Clear(); System.Data.DataTable tab0 = Common.FixDBManager.ConvertToDataTable(aList[1] as System.Collections.ArrayList, this.dataSet3.Tables["yincang"]); if (tab0 == null || tab0.Rows == null || tab0.Rows.Count == 0) { if (aList[3] != null) { tab0 = Common.FixDBManager.ConvertToDataTable(aList[3] as System.Collections.ArrayList, this.dataSet2.Tables["yuanshi"]); } } tab0.TableName = "yincang"; this.dataSet3.Tables["yincang"].Merge(tab0); } } //this.textBoxEqumtID.Text = this.dataSet2.Tables["shebei"].Rows[0]["EQUMT_ID"].ToString();//设备号 //this.textBoxSmpRmk.Text = this.dataSet2.Tables["shebei"].Rows[0]["SMP_RMK"].ToString();//名称 //记录上一次的CHK,以及下拉绑定 for (int i = 0; i < this.ultraGrid5.Rows.Count; i++) { //if (this.ultraGrid5.Rows[i].Cells["QLTY_OPE_CD"].Text == "Lo") //{ // string strChk = OperateConditionRecode.ReadCondition("UIB100203_CHKLO"); // if(strChk == "False") // { // this.ultraGrid5.Rows[i].Cells["CHK"].Value = "True"; // } // else // { // this.ultraGrid5.Rows[i].Cells["CHK"].Value = "False"; // } // //break; //} if (this.ultraGrid5.Rows[i].Cells["QLTY_OPE_CD"].Text == "FX")//与试样方向绑定 { this.ultraGrid5.Rows[i].Cells["QLTY_VAL"].EditorComponent = this.ultraComboEditor1; } else if (this.ultraGrid5.Rows[i].Cells["QLTY_OPE_CD"].Text == "MJGG")//与剪切面积绑定 { this.ultraGrid5.Rows[i].Cells["QLTY_VAL"].EditorComponent = this.ultraComboEditor2; } else if (this.ultraGrid5.Rows[i].Cells["QLTY_OPE_CD"].Text == "CB")//与冷弯绑定 { this.ultraGrid5.Rows[i].Cells["QLTY_VAL"].EditorComponent = this.ultraComboEditor3; } } } catch (Exception ex) { } } // int activteRowIndex = 0;//活动行 private void ultraGrid5_KeyDown(object sender, KeyEventArgs e) { try { if (e.KeyCode != Keys.Enter) return;//回车时,才保存数据 if (this.ultraGrid5.ActiveCell == null) return; if (this.ultraGrid5.ActiveCell.Column.Key == "QLTY_VAL1" || this.ultraGrid5.ActiveCell.Column.Key == "QLTY_VAL2" || this.ultraGrid5.ActiveCell.Column.Key == "QLTY_VAL3") { string column_name = this.ultraGrid5.ActiveCell.Column.Key; if (this.ultraGrid5.ActiveCell.DataChanged == true)//数据被修改时 { if ((this.ultraGrid5.ActiveRow.Cells["EDIT_TP"].Text == "N" || this.ultraGrid5.ActiveRow.Cells["EDIT_TP"].Text == "X") && this.ultraGrid5.ActiveRow.Cells["CHK"].Text != "True" )//若无计算公式,或者没有被选中的,禁止编辑 { MessageBox.Show("非可修改数据项,数据修改无效!", "提示"); return; } else { //******************************************************** if (this.ultraGrid5.ActiveRow.Cells["QLTY_OPE_CD"].Text == "Lo" && this.ultraGrid5.ActiveRow.Cells["EDIT_TP"].Text == "Y") { this.DoUpdate("Lo", column_name); //同步更新到dataset3的对应的单元中 for (int i = 0; i < this.dataSet3.Tables["yincang"].Rows.Count; i++) { if ("Lo" == this.dataSet3.Tables["yincang"].Rows[i]["QLTY_OPE_CD"].ToString()) { this.dataSet3.Tables["yincang"].Rows[i][column_name] = this.ultraGrid5.ActiveRow.Cells[column_name].Text; break; } } } else { this.DoUpdate("", column_name);//保存试验数据 } //从当前行的下一行开始,计算所有具有计算公式的行 int numCol = this.ultraGrid5.ActiveRow.Index; for (int i = numCol + 1; i < this.ultraGrid5.Rows.Count; i++) { this.DoCompVal(i, column_name);//按公式计算,当前行的下面第一行 } } } //换行,并编辑 int curRow = this.ultraGrid5.ActiveRow.Index;//当前行的行序号 for (int i = curRow; i <= (this.ultraGrid5.Rows.Count - 1); i++) { ////==========================未到行末========================== if (i < (this.ultraGrid5.Rows.Count - 1)) { if ((this.ultraGrid5.Rows[i + 1].Cells["EDIT_TP"].Text != "N" && this.ultraGrid5.Rows[i + 1].Cells["EDIT_TP"].Text != "X")//若下一行允许编辑 || (/*curRow < (this.ultraGrid5.Rows.Count - 1) && */this.ultraGrid5.Rows[i + 1].Cells["CHK"].Text == "True")//允许编辑 ) { this.ultraGrid5.Rows[i + 1].Activate(); this.ultraGrid5.ActiveRow.Cells[column_name].Activated = true; this.ultraGrid5.PerformAction(Infragistics.Win.UltraWinGrid.UltraGridAction.EnterEditMode); //this.ultraGrid5.DisplayLayout.Bands[0].Columns[column_name].CellActivation = Activation.AllowEdit; //this.ultraGrid5.ActiveRow.Cells[column_name].Column.CellActivation = Activation.AllowEdit; break; } } ////==========================到达行末========================== else if ((i == this.ultraGrid5.Rows.Count - 1) || (this.ultraGrid5.Rows[i].Cells["EDIT_TP"].Text == "N" && this.ultraGrid5.Rows[i].Cells["CHK"].Text != "True")//不允许编辑,有计算公式 ) { if (comboBox6.Text == "一组" || column_name == "QLTY_VAL3") { //***************************************** //////this.DoUpdate();//保存试验数据 //判断数据格式是否合格,为double类型 //if (JhyOpe.DcsDouble(this.ultraGrid3.Rows[grid3ActiveRow].Cells["QLTY_VAL"].Text)) //{ // //数据录入不合格提示 // Decimal minValue = this.ultraGrid3.Rows[grid3ActiveRow].Cells["QLTY_MIN"].Text == "" ? 0 : Convert.ToDecimal(this.ultraGrid3.Rows[grid3ActiveRow].Cells["QLTY_MIN"].Text); // Decimal maxValue = this.ultraGrid3.Rows[grid3ActiveRow].Cells["QLTY_MAX"].Text == "" ? 999 : Convert.ToDecimal(this.ultraGrid3.Rows[grid3ActiveRow].Cells["QLTY_MAX"].Text); ; // Decimal qltyValue = this.ultraGrid3.Rows[grid3ActiveRow].Cells["QLTY_VAL"].Text == "" ? minValue : Convert.ToDecimal(this.ultraGrid3.Rows[grid3ActiveRow].Cells["QLTY_VAL"].Text); // if (qltyValue < minValue || qltyValue > maxValue) // { // this.ultraGrid3.Rows[grid3ActiveRow].RowSelectorAppearance.BackColor = Color.Red; // this.ultraGrid3.Rows[grid3ActiveRow].Appearance.ForeColor = Color.Red;// add by mgp 2014/3/3 // MessageBox.Show("第" + (grid3ActiveRow+1) + "行不合格!", "提示"); // } //} //add by mgp 2014/3/3 注销下行代码 ultraGrid4_MouseDown(null, null);//鼠标点击项目名称触发的事件 grid3ActiveRow = grid3ActiveRow + 1; if (grid3ActiveRow < this.ultraGrid3.Rows.Count) { this.ultraGrid3.Rows[grid3ActiveRow].Activate(); ultraGrid3_MouseDown(null, null);//重新触发事件,调用查询方法 } else { grid3ActiveRow = 0;//到行末后,重新归0 if(ultraGrid4.ActiveRow.Index == ultraGrid4.Rows.Count -1) { MessageBox.Show("数据输入已完成!", "提示"); } else { if (MessageBox.Show("当前检验项目数据输入已完成!\n是否跳转到下一检验项目?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { this.ultraGrid4.Rows[ultraGrid4.ActiveRow.Index + 1].Activate(); ultraGrid4_MouseDown(null, null);//重新触发事件,调用查询方法 if (ultraGrid3.Rows.Count != 0) { this.ultraGrid3.Rows[0].Activate(); ultraGrid3_MouseDown(null, null);//重新触发事件,调用查询方法 } } } } //this.ultraGrid5.Rows[0].Activate(); //this.ultraGrid5.ActiveRow.Cells["QLTY_VAL"].Activate(); //this.ultraGrid5.PerformAction(Infragistics.Win.UltraWinGrid.UltraGridAction.EnterEditMode); //break; //this.ultraGrid5.PerformAction(Infragistics.Win.UltraWinGrid.UltraGridAction.FirstRowInBand); if (this.ultraGrid5.Rows.Count != 0)//grid3跳转到下一行循环时,可能存在查出无数据的情况 { this.ultraGrid5.Rows[0].Activate(); this.ultraGrid5.ActiveRow.Cells["QLTY_VAL1"].Activate(); this.ultraGrid5.PerformAction(Infragistics.Win.UltraWinGrid.UltraGridAction.EnterEditMode); //this.ultraGrid5.DisplayLayout.Bands[0].Columns["QLTY_VAL"].CellActivation = Activation.AllowEdit; break; } else { //MessageBox.Show("XXX"); } } else { if (column_name == "QLTY_VAL1") { this.ultraGrid5.Rows[0].Activate(); this.ultraGrid5.ActiveRow.Cells["QLTY_VAL2"].Activated = true; this.ultraGrid5.PerformAction(Infragistics.Win.UltraWinGrid.UltraGridAction.EnterEditMode); break; } else if (column_name == "QLTY_VAL2") { this.ultraGrid5.Rows[0].Activate(); this.ultraGrid5.ActiveRow.Cells["QLTY_VAL3"].Activated = true; this.ultraGrid5.PerformAction(Infragistics.Win.UltraWinGrid.UltraGridAction.EnterEditMode); break; } } } } } } catch (Exception ex) { MessageBox.Show("数据录入异常,可能存在数据格式错误,请检查!", "提示"); } } private void checkBox1_CheckedChanged(object sender, EventArgs e) { try { if (this.checkBox1.Checked) { this.textBox1.Enabled = true; this.textBox2.Enabled = true; } else { this.textBox1.Enabled = false; this.textBox2.Enabled = false; } } catch (Exception ex) { } } private void checkBox2_CheckedChanged(object sender, EventArgs e) { if (this.checkBox2.Checked) { this.ultraDateTimeEditor3.Enabled = true; this.ultraDateTimeEditor4.Enabled = true; } else { this.ultraDateTimeEditor3.Enabled = false; this.ultraDateTimeEditor4.Enabled = false; } } private void textBoxEqumtID_KeyDown(object sender, KeyEventArgs e) { try { // if (e.KeyCode != Keys.Enter) return; // if (this.ultraGrid3.ActiveRow == null) return; // ArrayList al = new ArrayList(); // al.Add("UIB100203_COMM_01.UPDATE"); // al.Add(this.textBoxEqumtID.Text.Trim()); // al.Add(this.ultraGrid3.ActiveRow.Cells["SMP_NO"].Text); // al.Add(this.ultraGrid3.ActiveRow.Cells["SMP_CUT_LOC"].Text); // al.Add(this.ultraGrid3.ActiveRow.Cells["SMP_NO_TYPE"].Text); // al.Add(this.strQltyCD2); // al.Add(this.strQltyCD); // CoreClientParam ccp = new CoreClientParam(); // ccp.ServerName = "UIB.JHY.JHYComSave"; // ccp.ServerParams = new object[] { al }; // ccp.MethodName = "doSimpleSave"; // this.ExecuteNonQuery(ccp, CoreInvokeType.Internal); //// this.textBoxSmpRmk.Focus(); // this.ultraGrid3.PerformAction(Infragistics.Win.UltraWinGrid.UltraGridAction.NextRow); } catch (Exception ex) { } } private void textBoxSmpRmk_KeyDown(object sender, KeyEventArgs e) { try { //if (e.KeyCode != Keys.Enter) return; //if (this.ultraGrid3.ActiveRow == null) return; //ArrayList al = new ArrayList(); //al.Add("UIB100203_COMM_02.UPDATE"); //al.Add(this.textBoxSmpRmk.Text.Trim()); //al.Add(this.ultraGrid3.ActiveRow.Cells["SMP_NO"].Text); //al.Add(this.ultraGrid3.ActiveRow.Cells["SMP_CUT_LOC"].Text); //al.Add(this.ultraGrid3.ActiveRow.Cells["SMP_NO_TYPE"].Text); //al.Add(this.strQltyCD2); //al.Add(this.strQltyCD); //CoreClientParam ccp = new CoreClientParam(); //ccp.ServerName = "UIB.JHY.JHYComSave"; //ccp.ServerParams = new object[] { al }; //ccp.MethodName = "doSimpleSave"; //this.ExecuteNonQuery(ccp, CoreInvokeType.Internal); ////this.textBoxEqumtID.Focus(); //this.ultraGrid3.PerformAction(Infragistics.Win.UltraWinGrid.UltraGridAction.NextRow); } catch (Exception ex) { } } private void ultraGrid5_MouseDown(object sender, MouseEventArgs e) { //try //{ // if (this.ultraGrid5.ActiveRow == null) return; // //只有Lo允许被选中,进行编辑 // if (this.ultraGrid5.ActiveCell.Column.Key == "CHK" ) // { // if (this.ultraGrid5.ActiveRow.Cells["EDIT_TP"].Text == "N") // { // this.ultraGrid5.ActiveRow.Cells["CHK"].Value = "True"; // this.ultraGrid5.UpdateData(); // } // else if(this.ultraGrid5.ActiveRow.Cells["QLTY_OPE_CD"].Text =="Lo" ) // { // OperateConditionRecode.WriteCondition("UIB100203_CHKLO", this.ultraGrid5.ActiveRow.Cells["CHK"].Text); // } // } //} //catch (Exception ex) //{ //} } private void checkBox3_CheckedChanged(object sender, EventArgs e) { try { foreach (UltraGridRow ugr in this.ultraGrid3.Rows) { ugr.Cells["CHK"].Value = this.checkBox3.Checked; ugr.Update(); } this.ultraGrid1.UpdateData(); } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex.ToString()); } } //Rt0.2,ReL变更 private void comboBox5_SelectedIndexChanged(object sender, EventArgs e) { try { //// if (this.ultraGrid3.ActiveRow == null) return; // if (MessageBox.Show("确定进行变更?", "提示", MessageBoxButtons.OKCancel) == DialogResult.Cancel) // return; // foreach (UltraGridRow ugr in this.ultraGrid3.Rows) // { // if (ugr.Cells["CHK"].Text == "True") // { // Hashtable ht = new Hashtable(); // ht.Add("i1", ugr.Cells["SMP_NO"].Text); // ht.Add("i2", ugr.Cells["SMP_CUT_LOC"].Text); // ht.Add("i3", ugr.Cells["SMP_NO_TYPE"].Text); // ht.Add("i4", ugr.Cells["QLTY_CD"].Text); // ht.Add("i5", this.comboBox5.Text.Trim()); // ht.Add("i6", this.UserInfo.GetUserName()); // ht.Add("o7", ""); // CoreClientParam ccp = new CoreClientParam(); // ccp.ServerName = "UIB.JHY.JHyComCallProc"; // ccp.MethodName = "doSimpleProc"; // ccp.ServerParams = new object[] { "UIB100203_COMM_03.CALL", ht }; // CoreClientParam rccp = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal); // ArrayList al = rccp.ReturnObject as ArrayList; // if (al[0] == null) return; // if (al[0].ToString() == "XX") return; // ugr.Cells["QLTY_CD_CFNM"].Value = al[0].ToString(); // } // } // if (al[0] == null) { MessageBox.Show("操作失败,请检查数据格式!", "提示"); } return; // if (al[0].ToString() == "XX") { MessageBox.Show("操作失败,请检查数据格式!", "提示"); } return; // this.ultraGrid5.ActiveRow.Cells["QLTY_CD_CFNM"].Value = al[0].ToString(); // this.ultraGrid3.PerformAction(Infragistics.Win.UltraWinGrid.UltraGridAction.NextRow); // this.ultraGrid2.ActiveRow.Cells["QLTY_VAL_WK"].Activate(); // this.ultraGrid3.PerformAction(Infragistics.Win.UltraWinGrid.UltraGridAction.EnterEditMode); } catch (Exception ex) { } } private void checkBox5_CheckedChanged(object sender, EventArgs e) { if (this.checkBox5.Checked) { this.comboBox1.Enabled = true; } else { this.comboBox1.Enabled = false; } } private void textBox6_KeyDown(object sender, KeyEventArgs e) { try { // if (e.KeyCode != Keys.Enter) return;//回车时,才保存数据 // if (this.textBox6.Text.ToString().Substring(0, 1) != "L" & this.textBox6.Text.ToString().Substring(0, 1) != "R" // & this.textBox6.Text.ToString().Length != 12) // { // MessageBox.Show("非法委托编号,请修改。(热轧-R,连退-L)" , "提示"); // return; // } //// if (this.textBox3.Text.ToString().Substring(0, 1) != this.textBox6.Text.ToString().Substring(0, 1)) // if (this.ultraGrid1.Rows[grid1CurNum].Cells["WEITO_NO"].Text.ToString().Substring(0, 1) != this.textBox6.Text.ToString().Substring(0, 1)) // { // MessageBox.Show("非法修改,请检查!", "提示"); // return; // } // ArrayList al = new ArrayList(); // al.Add("UIB100203_COMM_03.UPDATE"); // al.Add(this.textBox6.Text.ToString()); // al.Add(this.ultraGrid1.Rows[grid1CurNum].Cells["WEITO_NO"].Text); // CoreClientParam ccp = new CoreClientParam(); // ccp.ServerName = "UIB.JHY.JHYComSave"; // ccp.ServerParams = new object[] { al }; // ccp.MethodName = "doSimpleSave"; // this.ExecuteNonQuery(ccp, CoreInvokeType.Internal); } catch (Exception ex) { } } private void button1_Click(object sender, EventArgs e) { try { //string path = null; //if (this.folderBrowserDialog1.ShowDialog() == DialogResult.OK) //{ // path = this.folderBrowserDialog1.SelectedPath; // this.textBox5.Text = path; // OperateConditionRecode.WriteCondition("UIB100203_PATH", this.textBox5.Text); //} } catch (Exception ex) { } } //钢印号修改 private void textBox4_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode != Keys.Enter) return;//回车时,才保存数据 try { Hashtable ht = new Hashtable(); ht.Add("i1", this.ultraGrid1.Rows[grid1CurNum].Cells["COIL_NO"].Text); ht.Add("i2", this.ultraGrid1.Rows[grid1CurNum].Cells["SMP_NO"].Text); ht.Add("i3", this.ultraGrid1.Rows[grid1CurNum].Cells["SMP_CUT_LOC"].Text); ht.Add("i4", this.ultraGrid1.Rows[grid1CurNum].Cells["SMP_NO_TYPE"].Text); ht.Add("i5", this.textBox4.Text.Trim()); ht.Add("o6" ,"" ); CoreClientParam ccp = new CoreClientParam(); ccp.ServerName = "UIB.JHY.JHyComCallProc"; ccp.MethodName = "doSimpleProc"; ccp.ServerParams = new object[] { "UIB100203_COMM_04.CALL", ht }; CoreClientParam rccp = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal); //计算结果返回 ArrayList al = rccp.ReturnObject as ArrayList; if (al[0] == null) return; //if (al[0].ToString() == "XX") return; MessageBox.Show(al[0].ToString() , "提示"); } catch (Exception ex) { } } private void button2_Click(object sender, EventArgs e) { try { //if (MessageBox.Show("确定清除?", "提示", MessageBoxButtons.OKCancel) == DialogResult.Cancel) // return; //ArrayList al = new ArrayList(); //al.Add("UIB100203_COMM_04.UPDATE"); //al.Add(this.strSmpNo); //al.Add(this.strSmpCutLoc); //al.Add(this.strSmpNoType); //al.Add(this.ultraComboEditor4.Value.ToString()); //al.Add(this.ultraComboEditor4.Value.ToString()); //CoreClientParam ccp = new CoreClientParam(); //ccp.ServerName = "UIB.JHY.JHYComSave"; //ccp.ServerParams = new object[] { al }; //ccp.MethodName = "doSimpleSave"; //this.ExecuteNonQuery(ccp, CoreInvokeType.Internal); } catch (Exception ex) { } } private void checkBox4_CheckedChanged(object sender, EventArgs e) { try { if (this.checkBox4.Checked) { this.textBox3.Enabled = true; } else { this.textBox3.Enabled = false; } } catch (Exception ex) { } } private void comboBox6_SelectedIndexChanged(object sender, EventArgs e) { if (!string.IsNullOrEmpty(comboBox6.Text) && comboBox6.Text == "三组") { ultraGrid5.DisplayLayout.Bands[0].Columns["QLTY_VAL2"].Hidden = false; ultraGrid5.DisplayLayout.Bands[0].Columns["QLTY_VAL3"].Hidden = false; } else { ultraGrid5.DisplayLayout.Bands[0].Columns["QLTY_VAL2"].Hidden = true; ultraGrid5.DisplayLayout.Bands[0].Columns["QLTY_VAL3"].Hidden = true; } } public static void SetGridValuelist(ref UltraGrid myGrid, string strColumn, ref ValueList vlist) { SetGridValuelist(ref myGrid, 0, strColumn, ref vlist); } /// /// 设置UltraGrid指定列的ValueList,指定Band /// /// /// /// /// public static void SetGridValuelist(ref UltraGrid myGrid, int BandIndex, string strColumn, ref ValueList vlist) { bool Contains = GridContainsColumn(myGrid, BandIndex, strColumn); try { if (Contains) { myGrid.DisplayLayout.Bands[BandIndex].Columns[strColumn].ValueList = vlist; //myGrid.DisplayLayout.Bands[BandIndex].Columns[strColumn].Style = Infragistics.Win.UltraWinGrid.ColumnStyle.DropDown; } } catch { } } public static bool GridContainsColumn(UltraGrid grid, string strColumn) { return GridContainsColumn(grid, 0, strColumn); } public static bool GridContainsColumn(UltraGridBand band, string strColumn) { for (int i = 0; i < band.Columns.Count; i++) { if (band.Columns[i].Key.Equals(strColumn)) return true; } return false; } public static bool GridContainsColumn(UltraGrid grid, int BandIndex, string strColumn) { if (BandIndex <= grid.DisplayLayout.Bands.Count - 1) { for (int i = 0; i < grid.DisplayLayout.Bands[BandIndex].Columns.Count; i++) { if (grid.DisplayLayout.Bands[BandIndex].Columns[i].Key.Equals(strColumn)) return true; } } return false; } } }