using Core.Mes.Client.Comm.Control; using Core.Mes.Client.Comm.Server; using Core.Mes.Client.Comm.Tool; using CoreFS.CA06; using Infragistics.Win.UltraWinGrid; using System; using System.Collections; using System.Collections.Generic; using System.Data; using System.Drawing; using System.Windows.Forms; namespace Core.StlMes.Client.Qcm { public partial class FrmProductCHEMBIAS : FrmBase { int _cic = 1; //索引号 bool isflag = false; int isselect = 0; private List CicCode = new List(); //做过操作的CIC public FrmProductCHEMBIAS() { InitializeComponent(); } public FrmProductCHEMBIAS(string errMsg, OpeBase ob) : this() { this.ob = ob; ultraStatusBar1.Panels["ExMsg"].Text = errMsg; panel2.Visible = true; ultraStatusBar1.Visible = true; doQuery(isflag); } private void FrmProductCHEMBIAS_Load(object sender, EventArgs e) { BindcmbType(); } private void InitSteel(string cic) { DataTable dt = ServerHelper.GetData("com.steering.pss.qcm.CoreProductCHEMBIAS.getSteel", new object[] { cic }, this.ob); GridHelper.CopyDataToDatatable(ref dt, ref dataTable3, true); } private void BindcmbType() { #region 下拉列表 DataTable dt1 = new DataTable(); dt1.Columns.Add("xiaid"); DataRow dr1 = dt1.NewRow(); dr1["xiaid"] = ">"; dt1.Rows.Add(dr1); DataRow dr2 = dt1.NewRow(); dr2["xiaid"] = ">="; dt1.Rows.Add(dr2); DataRow dr3 = dt1.NewRow(); dr3["xiaid"] = "="; dt1.Rows.Add(dr3); DataRow dr4 = dt1.NewRow(); dr4["xiaid"] = " "; dt1.Rows.Add(dr4); dt1.Columns["xiaid"].Caption = "符号"; xiaxian.DataSource = dt1; xiaxian.ValueMember = "xiaid"; DataTable dts1 = new DataTable(); dts1.Columns.Add("xiaid"); DataRow drs1 = dts1.NewRow(); drs1["xiaid"] = "单一元素"; dts1.Rows.Add(drs1); DataRow drs2 = dts1.NewRow(); drs2["xiaid"] = "复合元素"; dts1.Rows.Add(drs2); DataRow drs4 = dts1.NewRow(); drs4["xiaid"] = " "; dts1.Rows.Add(drs4); dts1.Columns["xiaid"].Caption = "符号"; cmbdanyi.DataSource = dts1; cmbdanyi.ValueMember = "xiaid"; DataTable dt2 = new DataTable(); dt2.Columns.Add("shangid"); DataRow dr5 = dt2.NewRow(); dr5["shangid"] = "<"; dt2.Rows.Add(dr5); DataRow dr6 = dt2.NewRow(); dr6["shangid"] = "<="; dt2.Rows.Add(dr6); DataRow dr7 = dt2.NewRow(); dr7["shangid"] = " "; dt2.Rows.Add(dr7); dt2.Columns["shangid"].Caption = "符号"; shangxian.DataSource = dt2; shangxian.ValueMember = "shangid"; DataTable dt3 = ServerHelper.GetData("com.steering.pss.qcm.CoreDropList.GetSelectstd", new Object[] { }, this.ob);//标准表 int num = dt3.Rows.Count; DataTable dt4 = new DataTable(); dt4.Columns.Add("fenlei"); dt4.Columns.Add("fenname"); DataRow dr; for (int i = 0; i < num; i++) { dr = dt4.NewRow(); dr["fenlei"] = dt3.Rows[i]["STD_NAME"]; dr["fenname"] = dt3.Rows[i]["STD_CODE"]; dt4.Rows.Add(dr); } dt4.Columns["fenlei"].Caption = "名字"; dt4.Columns["fenname"].Caption = "代码"; fenleinumber.DataSource = dt4; fenleinumber.ValueMember = "fenname"; fenleinumber.DisplayMember = "fenlei"; DataTable dt5 = ServerHelper.GetData("com.steering.pss.qcm.CoreDropList.GetSelectinfo", new Object[] { }, this.ob); int num1 = dt5.Rows.Count; DataTable dt6 = new DataTable(); dt6.Columns.Add("id"); dt6.Columns.Add("name"); dr = dt6.NewRow(); dr["id"] = ""; dr["name"] = ""; dt6.Rows.Add(dr); for (int i = 0; i < num1; i++) { dr = dt6.NewRow(); dr["id"] = dt5.Rows[i]["BASECODE"]; dr["name"] = dt5.Rows[i]["BASENAME"]; dt6.Rows.Add(dr); } dt6.Columns["id"].Caption = "类型"; dt6.Columns["name"].Caption = "名字"; ClsBaseInfo.SetComboItemHeight(yuanfenlei); yuanfenlei.DataSource = dt6; yuanfenlei.DisplayMember = "name"; yuanfenlei.ValueMember = "id"; DataTable dt7 = ServerHelper.GetData("com.steering.pss.qcm.ComBaseQuery.getCombaseChemA", new Object[] { }, this.ob); int num2 = dt7.Rows.Count; DataTable dt8 = new DataTable(); dt8.Columns.Add("id"); dt8.Columns.Add("name"); for (int i = 0; i < num2; i++) { dr = dt8.NewRow(); dr["id"] = dt7.Rows[i]["CHEM_CODE"] + "," + dt7.Rows[i]["CHEM_TYPE"] + "," + dt7.Rows[i]["CHEM_FORMULA"]; dr["name"] = dt7.Rows[i]["CHEM_NAME"]; dt8.Rows.Add(dr); } dt8.Columns["id"].Caption = "类型"; dt8.Columns["name"].Caption = "名字"; cmbyuansu.DataSource = dt8; cmbyuansu.DisplayMember = "name"; cmbyuansu.ValueMember = "id"; #endregion } public override void ToolBar_Click(object sender, string ToolbarKey) { switch (ToolbarKey) { case "doQuery": doQuery(isflag); break; case "doSave": doSave(); break; case "doDelete": this.doDeleteOrResume(true); break; case "doResume": this.doDeleteOrResume(false); break; case "doClose": this.Close(); break; } } ArrayList parmPAdd = new ArrayList(); //主表新增 ArrayList parmPUpdate = new ArrayList(); //主表修改 ArrayList parmCAdd = new ArrayList(); //从表新增 ArrayList parmCUpdate = new ArrayList(); //从表修改 ArrayList Deletelist = new ArrayList(); //删除数据或恢复数据 ArrayList DeletelistC = new ArrayList(); //删除数据或恢复数据 ArrayList parmSteel = new ArrayList(); //勾选的钢级牌号信息 string deleteCic = ""; //用于钢级删除的CIC码 private void doQuery(Boolean flag) { string stdName = "%"; if (ultraCheckEditor1.Checked) stdName = ultraTextEditor1.Text.Trim(); dataTable3.Clear(); DataTable dt = ServerHelper.GetData("com.steering.pss.qcm.CoreProductCHEMBIAS.doQuery", new Object[] { flag, stdName }, this.ob); dataTable2.Clear(); GridHelper.CopyDataToDatatable(ref dt, ref this.dataTable1, true); //从表的记录也要查询出来。 DataTable mindt = ServerHelper.GetData("com.steering.pss.qcm.CoreProductCHEMBIAS.doQueryC", new Object[] { flag, stdName }, this.ob); GridHelper.CopyDataToDatatable(ref mindt, ref this.dataTable2, true); for (int i = 0; i < ultraGrid2.Rows.Count; i++) { for (int j = 0; j < ultraGrid2.Rows[i].Cells.Count; j++) { if (j == 7) break; ultraGrid2.Rows[i].Cells[j].Activation = Infragistics.Win.UltraWinGrid.Activation.ActivateOnly; } if (ultraGrid2.Rows[i].ChildBands[0].Rows.Count > 0) { for (int j = 0; j < ultraGrid2.Rows[i].ChildBands[0].Rows.Count; j++) { for (int k = 0; k < ultraGrid2.Rows[i].ChildBands[0].Rows[j].Cells.Count; k++) { if (k == 16) break; ultraGrid2.Rows[i].ChildBands[0].Rows[j].Cells[k].Activation = Infragistics.Win.UltraWinGrid.Activation.ActivateOnly; } } } } //不同颜色区分是否有效数据 Infragistics.Win.UltraWinGrid.UltraGridRow row = null; Infragistics.Win.UltraWinGrid.UltraGridRow minrow = null; for (int i = 0; i < ultraGrid2.Rows.Count; i++) { row = ultraGrid2.Rows[i]; if (row.ChildBands[0].Rows.Count > 0) { for (int j = 0; j < row.ChildBands[0].Rows.Count; j++) { minrow = row.ChildBands[0].Rows[j]; if (!minrow.Cells["VALIDFLAG"].Value.ToString().Equals("有效")) { minrow.Appearance.ForeColor = Color.Red; row.ExpandAll(); } else { minrow.Appearance.ForeColor = Color.Black; } } } if (!row.Cells["VALIDFLAG"].Value.ToString().Equals("有效")) { row.Appearance.ForeColor = Color.Red; } else { row.Appearance.ForeColor = Color.Black; } } //UltraGridColumn[] col = new UltraGridColumn[] { }; //GridHelper.RefreshAndAutoSizeExceptRows(ultraGrid2, col); } private void doSave() { ultraGrid2.UpdateData(); if (GetGridData() == 0 && (parmPAdd.Count > 0 || parmPUpdate.Count > 0 || parmCAdd.Count > 0 || parmCUpdate.Count > 0)) { if (isselect == 0) { MessageBox.Show("请选择记录", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if (MessageBox.Show("是否确认保存修改?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) { return; } if (ultraGrid2.ActiveRow != null) deleteCic = ultraGrid2.ActiveRow.Cells["CIC"].Value.ToString(); CoreClientParam ccp = new CoreClientParam(); //CoreClientParam是平台用来向服务端传递存放所有相关参数信息的。 ccp.ServerName = "com.steering.pss.qcm.CoreProductCHEMBIAS"; //服务名指的是服务端的包名+类名 ccp.MethodName = "doSave"; //方法名指的是服务名指定类里的方法 ccp.ServerParams = new object[] { parmPAdd, parmPUpdate, parmCAdd, parmCUpdate, parmSteel, deleteCic };//服务端方法的参数 //ExecuteNonQuery主要用来执行添加、修改、删除、存储过程的操作。 ccp = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal); if (ccp.ReturnCode == -1) return; MessageBox.Show("保存成功", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); doQuery(isflag); ExpandRow(); CicCode.Clear(); } } /// /// 删除或恢复 /// /// true删除 false恢复 private void doDeleteOrResume(bool flag) { if (GetDeleteData(flag) == -1) { return; } if (isselect == 0) { MessageBox.Show("请选择需要操作的记录", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if (MessageBox.Show("是否确认" + (flag ? "作废" : "恢复") + "数据", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) { return; } CoreClientParam ccp = new CoreClientParam(); //CoreClientParam是平台用来向服务端传递存放所有相关参数信息的。 ccp.ServerName = "com.steering.pss.qcm.CoreProductCHEMBIAS"; //服务名指的是服务端的包名+类名 ccp.MethodName = "doDelete"; //方法名指的是服务名指定类里的方法 ccp.ServerParams = new object[] { Deletelist, DeletelistC, flag };//服务端方法的参数 //ExecuteNonQuery主要用来执行添加、修改、删除、存储过程的操作。 ccp = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal); if (ccp.ReturnCode == -1) return; MessageBox.Show("数据" + (flag ? "作废" : "恢复") + "成功", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); doQuery(isflag); ExpandRow(); CicCode.Clear(); } private void ultraGrid2_CellChange(object sender, CellEventArgs e) { this.ultraGrid2.UpdateData(); if (e.Cell.Column.Key.Equals("MIN_SIGN")) { if (e.Cell.Value.ToString() == "=") { e.Cell.Row.Cells["MAX_SIGN"].Activation = Activation.ActivateOnly; e.Cell.Row.Cells["MAX_VAL"].Activation = Activation.ActivateOnly; } else { e.Cell.Row.Cells["MAX_SIGN"].Activation = Activation.AllowEdit; e.Cell.Row.Cells["MAX_VAL"].Activation = Activation.AllowEdit; } } else if (e.Cell.Column.Key.Equals("ASSORTMENT_NAME")) { e.Cell.Row.Cells["ASSORTMENT_CODE"].Value = e.Cell.Row.Cells["ASSORTMENT_NAME"].Value; } else if (e.Cell.Column.Key.Equals("STD_NAME")) { e.Cell.Row.Cells["STD_CODE"].Value = e.Cell.Row.Cells["STD_NAME"].Value; } else if (e.Cell.Column.Key.Equals("CHEM_NAME")) { String str = e.Cell.Row.Cells["CHEM_NAME"].Value.ToString(); string[] str1 = str.Split(','); e.Cell.Row.Cells["CHEM_CODE"].Value = str1[0]; e.Cell.Row.Cells["WHOLE_BACKLOG"].Value = str1[1]; e.Cell.Row.Cells["CHEM_FORMULA"].Value = str1[2]; } else if (e.Cell.Column.Key.Equals("cb")) { Activation activation = Activation.NoEdit; if (Convert.ToBoolean(e.Cell.Value)) { activation = Activation.AllowEdit; } CellsCollection cells = e.Cell.Row.Cells; for (int i = 0; i < cells.Count; i++) { if (!cells[i].Column.Key.Equals("cb")) //i!=9 { if (i == 6) break; e.Cell.Row.Cells[i].Activation = activation; } } // e.Cell.Value = !Convert.ToBoolean(e.Cell.Value); } else if (e.Cell.Column.Key.Equals("ck1")) { Activation activation = Activation.ActivateOnly; if (Convert.ToBoolean(e.Cell.Value)) { activation = Activation.AllowEdit; } CellsCollection cells = e.Cell.Row.Cells; for (int i = 0; i < cells.Count; i++) { if (!cells[i].Column.Key.Equals("ck1")) //i!=9 { if (i == 15) break; e.Cell.Row.Cells[i].Activation = activation; } } } SaveCic(e); ultraGrid2.UpdateData(); } private void ultraGrid2_AfterRowInsert(object sender, RowEventArgs e) { ultraGrid2.UpdateData(); UltraGridRow ugr = this.ultraGrid2.ActiveRow; if (ugr == null) return; if (!ugr.HasParent()) //主表 { string cicStr = ""; string cic = ""; DataRow[] dr = dataTable1.Select("", "CIC DESC"); if (dr.Length > 0) { cic = dr[0]["CIC"].ToString(); } if (!cic.Equals("")) { int number = int.Parse(cic.Substring(3, 6)); cicStr = "CIC" + string.Format("{0:000000}", number + 1); _cic = number + 1; } else { cicStr = "CIC" + string.Format("{0:000000}", _cic); _cic = _cic + 1; } //赋值理化索引号 ugr.Cells["CIC"].Value = cicStr; // ugr.Cells["cb"].Value = false; if (!Convert.ToBoolean(ugr.Cells["cb"].Value)) { for (int i = 0; i < ugr.Cells.Count; i++) { if (!ugr.Cells[i].Column.Key.Equals("cb")) ugr.Cells[i].Activation = Activation.ActivateOnly; } } } else { int indexSeq = 0; DataRow[] dr = dataTable2.Select("CIC='" + ugr.Cells["CIC"].Value.ToString() + "'", "INDEX_SEQ DESC"); if (dr.Length > 0) { indexSeq = Convert.ToInt32(dr[0]["INDEX_SEQ"]); } indexSeq += 1; //赋值序号 this.ultraGrid2.DisplayLayout.ActiveRow.Cells["INDEX_SEQ"].Value = indexSeq; if (!Convert.ToBoolean(ugr.Cells["ck1"].Value)) { for (int i = 0; i < ugr.Cells.Count; i++) { if (!ugr.Cells[i].Column.Key.Equals("ck1")) ugr.Cells[i].Activation = Activation.ActivateOnly; } } } } private int GetGridData() { this.ultraGrid2.UpdateData(); this.ultraGrid1.UpdateData(); parmPAdd = new ArrayList(); parmPUpdate = new ArrayList(); parmCAdd = new ArrayList(); parmCUpdate = new ArrayList(); UltraGridRow ugr = ultraGrid2.ActiveRow; isselect = 0; foreach (UltraGridRow row in ultraGrid2.Rows) { if (row.Cells["cb"].Value.ToString().ToUpper() == "TRUE") { ArrayList plistAdd = new ArrayList(); ArrayList plistUpdate = new ArrayList(); isselect += 1; if (row.Cells["STD_NAME"].Value.ToString() == "") { MessageBox.Show("请选择标准名称", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); //row.Activate(); return -1; } //if (row.Cells["ASSORTMENT_NAME"].Value.ToString() == "") //{ // MessageBox.Show("请选择品种名称", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); // row.Activate(); // return -1; //} string assortment = row.Cells["ASSORTMENT_NAME"].Value.ToString(); UltraGridRow[] arrRow = GridHelper.GetRowsWithKey(ultraGrid1, new string[] { "CHK" }, new string[] { "True" }); if (assortment != "" && arrRow.Length > 0) { MessageBox.Show("钢种分类和右边的钢级(牌号)不能同时存在!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); // row.Activate(); return -1; } else if (assortment == "" && arrRow.Length <= 0) { MessageBox.Show("请选择钢种分类或者右边钢级(牌号)", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); row.Activate(); return -1; } if (row.Cells["VALIDFLAG"].Value.ToString() == "") //新增 { plistAdd.Add(row.Cells["CIC"].Value.ToString()); plistAdd.Add(row.Cells["STD_CODE"].Value.ToString()); plistAdd.Add(row.Cells["STD_NAME"].Text); plistAdd.Add(row.Cells["ASSORTMENT_CODE"].Value.ToString()); plistAdd.Add(row.Cells["ASSORTMENT_NAME"].Text); plistAdd.Add(this.UserInfo.GetUserName()); parmPAdd.Add(plistAdd); } else { plistUpdate.Add(row.Cells["CIC"].Value.ToString()); plistUpdate.Add(row.Cells["STD_CODE"].Value.ToString()); plistUpdate.Add(row.Cells["STD_NAME"].Text); plistUpdate.Add(row.Cells["ASSORTMENT_CODE"].Value.ToString()); plistUpdate.Add(row.Cells["ASSORTMENT_NAME"].Text); plistUpdate.Add(this.UserInfo.GetUserName()); parmPUpdate.Add(plistUpdate); } } if (row.Cells["VALIDFLAG"].Value.ToString() != "" || (row.Cells["VALIDFLAG"].Value.ToString() == "" && row.Cells["cb"].Value.ToString().ToUpper() == "TRUE")) { if (row.ChildBands[0].Rows.Count > 0) { foreach (UltraGridRow crow in row.ChildBands[0].Rows) { if (crow.Cells["ck1"].Value.ToString().ToUpper() == "TRUE") { UltraGridRow pRow = crow.ParentRow; string assortment = pRow.Cells["ASSORTMENT_NAME"].Text; UltraGridRow[] arrRow = GridHelper.GetRowsWithKey(ultraGrid1, new string[] { "CHK" }, new string[] { "True" }); if (assortment != "" && arrRow.Length > 0) { MessageBox.Show("钢种分类和右边的钢级(牌号)不能同时存在!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); // row.Activate(); return -1; } else if (assortment == "" && arrRow.Length <= 0) { MessageBox.Show("请选择钢种分类或者右边钢级(牌号)", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); row.Activate(); return -1; } isselect += 1; if (crow.Cells["CHEM_NAME"].Value.ToString() == "") { MessageBox.Show("请选择化学元素描述", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); crow.Activate(); return -1; } string chem_type = ""; //化学元素类型 switch (crow.Cells["whole_backlog"].Value.ToString()) { case "单一元素": chem_type = "A"; break; case "复合元素": chem_type = "B"; break; } string min_sign = crow.Cells["MIN_SIGN"].Text.Trim(); string min_val = crow.Cells["MIN_VAL"].Value.ToString(); string max_sign = crow.Cells["MAX_SIGN"].Text.Trim(); string max_val = crow.Cells["MAX_VAL"].Value.ToString(); //string std_min_sign = crow.Cells["STD_MIN_SIGN"].Text.Trim(); string std_min_val = crow.Cells["STD_MIN_VAL"].Value.ToString(); //string std_max_sign = crow.Cells["STD_MAX_SIGN"].Text.Trim(); string std_max_val = crow.Cells["STD_MAX_VAL"].Value.ToString(); if (min_sign == "" && max_sign == "") { MessageBox.Show("化学成分上限符号和下限符号请至少选择一项", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); crow.Activate(); return -1; } if (min_sign != "" && min_val == "") { MessageBox.Show("请输入化学成分下限值", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); crow.Activate(); return -1; } if (min_sign == "" && min_val != "") { MessageBox.Show("化学成分下限值不为空,请选择化学元素下限符号", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); crow.Activate(); return -1; } if (max_sign != "" && max_val == "") { MessageBox.Show("请输入化学成分上限值", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); crow.Activate(); return -1; } if (max_sign == "" && max_val != "") { MessageBox.Show("化学成分上限值不为空,请选择化学元素上限符号", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); crow.Activate(); return -1; } if (min_sign != "=") { if (min_val != "" && !StringUtil.IsNumber(min_val)) { MessageBox.Show("化学成分下限值:请输入数字!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); crow.Activate(); return -1; } if (max_val != "" && !StringUtil.IsNumber(max_val)) { MessageBox.Show("化学成分上限值:请输入数字!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); crow.Activate(); return -1; } if (min_val != "" && max_val != "") { if (Convert.ToDouble(max_val) < Convert.ToDouble(min_val)) { MessageBox.Show("化学成分上限值不能小于下限值", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); crow.Activate(); return -1; } } } //if (min_sign != "" && max_sign == "") //{ // exsitchem = 1; //下限 //} //if (max_sign != "" && min_sign == "") // exsitchem = 2; //上限 //if (min_sign != "" && max_sign != "") // exsitchem = 3; //上下限存在 //if (std_min_sign != "" && std_min_val == "") //{ // MessageBox.Show("请输入允许偏差下限值", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); // crow.Activate(); // return -1; //} //if (std_min_sign == "" && std_min_val != "") //{ // MessageBox.Show("允许偏差下限值存在,请选择下限符号", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); // crow.Activate(); // return -1; //} //if (std_max_sign != "" && std_max_sign == "") //{ // MessageBox.Show("请输入允许偏差上限值", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); // crow.Activate(); // return -1; //} //if (std_max_sign == "" && std_max_val != "") //{ // MessageBox.Show("允许偏差上限值存在,请选择上限符号", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); // crow.Activate(); // return -1; //} //if (exsitchem == 1 && std_max_val != "") //{ // MessageBox.Show("化学成分不存在上限值,允许偏差也不能存在上偏差", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); // crow.Activate(); // return -1; //} //if (exsitchem == 2 && std_min_val != "") //{ // MessageBox.Show("化学成分不存在下限值,允许偏差也不能存在下偏差", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); // crow.Activate(); // return -1; //} if (std_min_val != "") { if (!StringUtil.IsNumber(std_min_val)) { MessageBox.Show("允许偏差下偏差:请输入数字!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); crow.Activate(); return -1; } } if (std_max_val != "") { if (!StringUtil.IsNumber(std_max_val)) { MessageBox.Show("允许偏差上偏差:请输入数字!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); crow.Activate(); return -1; } } //if (std_min_val != "" && std_max_val != "") //{ // if (Convert.ToDouble(std_max_val) < Convert.ToDouble(std_min_val)) // { // MessageBox.Show("允许偏差上限值不能小于下限值!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); // crow.Activate(); // return -1; // } //} ArrayList clistAdd = new ArrayList(); ArrayList clistUpdate = new ArrayList(); if (crow.Cells["VALIDFLAG"].Value.ToString() == "") { clistAdd.Add(crow.Cells["CIC"].Value.ToString()); clistAdd.Add(crow.Cells["INDEX_SEQ"].Value.ToString()); clistAdd.Add(crow.Cells["CHEM_CODE"].Value.ToString()); clistAdd.Add(crow.Cells["CHEM_NAME"].Text); clistAdd.Add(chem_type); clistAdd.Add(crow.Cells["CHEM_FORMULA"].Value.ToString()); clistAdd.Add(min_sign); clistAdd.Add(min_val); clistAdd.Add(max_sign); clistAdd.Add(max_val); // clistAdd.Add(std_min_sign); clistAdd.Add(std_min_val); //clistAdd.Add(std_max_sign); clistAdd.Add(std_max_val); clistAdd.Add(this.UserInfo.GetUserName()); parmCAdd.Add(clistAdd); } else { clistUpdate.Add(crow.Cells["CIC"].Value.ToString()); clistUpdate.Add(crow.Cells["INDEX_SEQ"].Value.ToString()); clistUpdate.Add(crow.Cells["CHEM_CODE"].Value.ToString()); clistUpdate.Add(crow.Cells["CHEM_NAME"].Text); clistUpdate.Add(chem_type); clistUpdate.Add(crow.Cells["CHEM_FORMULA"].Value.ToString()); clistUpdate.Add(min_sign); clistUpdate.Add(min_val); clistUpdate.Add(max_sign); clistUpdate.Add(max_val); //clistUpdate.Add(std_min_sign); clistUpdate.Add(std_min_val); //clistUpdate.Add(std_max_sign); clistUpdate.Add(std_max_val); clistUpdate.Add(this.UserInfo.GetUserName()); parmCUpdate.Add(clistUpdate); } } } } } } if (GetGrid1Data() == -1) return -1; return 0; } private int GetGrid1Data() { ultraGrid1.UpdateData(); ultraGrid2.UpdateData(); parmSteel = new ArrayList(); deleteCic = ""; UltraGridRow ugr = ultraGrid2.ActiveRow; if (ugr == null) return -1; foreach (UltraGridRow row in ultraGrid1.Rows) { if (row.Cells["CHK"].Value.ToString().ToUpper() == "TRUE") { ArrayList tmpList = new ArrayList(); tmpList.Add(ugr.Cells["CIC"].Value.ToString()); tmpList.Add(row.Cells["STEELCODE"].Value); tmpList.Add(row.Cells["STEELNAME"].Value); tmpList.Add(this.UserInfo.GetUserName()); parmSteel.Add(tmpList); } } return 0; } private void ultraCheckEditor1_CheckedChanged(object sender, EventArgs e) { if (this.ultraCheckEditor1.Checked) { this.ultraTextEditor1.ReadOnly = false; } else { this.ultraTextEditor1.ReadOnly = true; } } private void ultraCheckEditor4_CheckedChanged(object sender, EventArgs e) { if (this.ultraCheckEditor4.Checked) { isflag = true; } else { isflag = false; } } /// /// 得到删除或恢复的数据 /// /// true 删除 false 恢复 /// private int GetDeleteData(bool flag) { isselect = 0; this.ultraGrid2.UpdateData(); Deletelist = new ArrayList(); DeletelistC = new ArrayList(); foreach (UltraGridRow row in ultraGrid2.Rows) { if (row.Cells["cb"].Value.ToString().ToUpper() == "TRUE") { isselect += 1; if (flag) //删除 { if (row.Cells["VALIDFLAG"].Value.ToString() != "有效") { MessageBox.Show("无效数据,无法删除", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); row.Activate(); return -1; } ArrayList list = new ArrayList(); list.Add(this.UserInfo.GetUserName()); list.Add(row.Cells["CIC"].Value.ToString()); Deletelist.Add(list); } else //恢复 { if (row.Cells["VALIDFLAG"].Value.ToString() == "有效") { MessageBox.Show("有效数据,无法恢复", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); row.Activate(); return -1; } Deletelist.Add(row.Cells["CIC"].Value.ToString()); if (row.ChildBands[0].Rows.Count > 0) { foreach (UltraGridRow crow in row.ChildBands[0].Rows) { if (crow.Cells["VALIDFLAG"].Value.ToString() == "有效") { MessageBox.Show("有效数据,无法恢复", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); row.Activate(); return -1; } if (crow.Cells["ck1"].Value.ToString().ToUpper() == "TRUE") { ArrayList plist = new ArrayList(); plist.Add(crow.Cells["CIC"].Value.ToString()); plist.Add(crow.Cells["INDEX_SEQ"].Value.ToString()); DeletelistC.Add(plist); } } } } } else { if (row.ChildBands[0].Rows.Count > 0) { foreach (UltraGridRow crow in row.ChildBands[0].Rows) { if (crow.Cells["ck1"].Value.ToString().ToUpper() == "TRUE") { isselect += 1; if (flag) { if (crow.Cells["VALIDFLAG"].Value.ToString() != "有效") { MessageBox.Show("无效数据,无法作废", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); row.Activate(); return -1; } ArrayList clist = new ArrayList(); clist.Add(this.UserInfo.GetUserName()); clist.Add(crow.Cells["CIC"].Value.ToString()); clist.Add(crow.Cells["INDEX_SEQ"].Value.ToString()); DeletelistC.Add(clist); } else { if (crow.Cells["VALIDFLAG"].Value.ToString() == "有效") { MessageBox.Show("有效数据,无法恢复", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); row.Activate(); return -1; } if (row.Cells["cb"].Value.ToString().ToUpper() == "FALSE" && row.Cells["VALIDFLAG"].Value.ToString() != "有效") { MessageBox.Show("主记录无效,不能单独恢复从记录,\n请先恢复主记录或主从记录一起恢复", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); return -1; } ArrayList plist = new ArrayList(); plist.Add(crow.Cells["CIC"].Value.ToString()); plist.Add(crow.Cells["INDEX_SEQ"].Value.ToString()); DeletelistC.Add(plist); } } } } } } return 0; } private void SaveCic(CellEventArgs e) { if (e.Cell.Row.HasParent()) { if (e.Cell.Row.Cells["ck1"].Value.ToString().ToUpper() == "TRUE" && !CicCode.Contains(e.Cell.Row.Cells["CIC"].Value.ToString())) { CicCode.Add(e.Cell.Row.Cells["CIC"].Value.ToString()); } else if (e.Cell.Row.Cells["ck1"].Value.ToString().ToUpper() != "TRUE" && CicCode.Contains(e.Cell.Row.Cells["CIC"].Value.ToString())) { CicCode.Remove(e.Cell.Row.Cells["CIC"].Value.ToString()); //取消按钮 则取消保存的理化标准码 } } else if (e.Cell.Row.ChildBands[0].Rows.Count > 0) { if (e.Cell.Row.Cells["cb"].Value.ToString().ToUpper() == "TRUE" && !CicCode.Contains(e.Cell.Row.Cells["CIC"].Value.ToString())) { CicCode.Add(e.Cell.Row.Cells["CIC"].Value.ToString()); } } } private void ExpandRow() { foreach (UltraGridRow row in ultraGrid2.Rows) { if (CicCode.Contains(row.Cells["CIC"].Value.ToString())) { row.ExpandAll(); row.Activate(); } } } UltraGridRow oldActiveRow = null; //之前激活的主记录行 private void ultraGrid2_AfterRowActivate(object sender, EventArgs e) { try { this.Cursor = Cursors.WaitCursor; UltraGridRow ugr = ultraGrid2.ActiveRow; //当前激活行 if (ugr == null) return; UltraGridRow parentActiveRow = null; //主记录行 if (ugr.HasParent()) { parentActiveRow = ugr.ParentRow; //parentActiveRow.Cells["cb"].Value = true; } else { // ugr.Cells["cb"].Value = true; parentActiveRow = ugr; } if (oldActiveRow != parentActiveRow) { if (oldActiveRow != null) { oldActiveRow.Cells["cb"].Value = false; for (int i = 0; i < oldActiveRow.ChildBands[0].Rows.Count; i++) { oldActiveRow.ChildBands[0].Rows[i].Cells["ck1"].Value = false; } } string cic = parentActiveRow.Cells["CIC"].Value.ToString(); //主记录 子记录都有CIC字段 且主从关系的值一样 InitSteel(cic); ultraGrid2.UpdateData(); } oldActiveRow = parentActiveRow; } finally { this.Cursor = Cursors.Default; } } private void ultraGrid2_InitializeRow(object sender, InitializeRowEventArgs e) { if (!e.Row.HasParent()) { if (e.Row.Cells["cb"].Value.ToString().ToUpper() == "TRUE") { e.Row.Cells["STD_NAME"].Activation = Activation.AllowEdit; e.Row.Cells["ASSORTMENT_NAME"].Activation = Activation.AllowEdit; } } } private void ultraGrid1_CellChange(object sender, CellEventArgs e) { ultraGrid1.UpdateData(); } private void ultraToolbarsManager1_ToolClick(object sender, Infragistics.Win.UltraWinToolbars.ToolClickEventArgs e) { switch (e.Tool.Key) { case "查询": doQuery(isflag); break; case "保存": doSave(); break; case "确认": break; case "作废": doDeleteOrResume(true); break; case "恢复": doDeleteOrResume(false); break; case "关闭": this.Close(); break; } } } }