using Core.Mes.Client.Comm.Control; using Core.Mes.Client.Comm.Server; using CoreFS.CA06; using Infragistics.Win.UltraWinEditors; 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 FrmProductWater : FrmBase { //接箍码基础表数据 private DataTable dtSCJG = null; List list = new List(); int num = 0; public FrmProductWater() { InitializeComponent(); //cmb1.SelectedIndex = 0; } private void FrmProductWater_Load(object sender, EventArgs e) { //结箍码 InitDropList(ref dtSCJG, ultraSCJG, "com.steering.pss.qcm.ComBaseQuery.getComMSCJG", "SPEC_JG_DESC"); DataTable dt1 = new DataTable(); dt1.Columns.Add("xiaid"); DataRow dr4 = dt1.NewRow(); dr4["xiaid"] = ""; dt1.Rows.Add(dr4); 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); leixing.DataSource = dt1; leixing.ValueMember = "xiaid"; } public override void ToolBar_Click(object sender, string ToolbarKey) { switch (ToolbarKey) { case "doQuery": doQuery(false); break; case "QueryKey": doQuery(true); break; case "doSave": doSave(); break; case "doDelete": this.doDeleteOrResume(true); break; case "doResume": this.doDeleteOrResume(false); break; case "doClose": this.Close(); break; } } private void doSave() { int number = this.ultraGrid1.Rows.Count; num = 0; try { for (int i = 0; i < number; i++) { if (Convert.ToBoolean(ultraGrid1.Rows[i].Cells["UCCHOOSE"].Value)) { //判定勾选项是新增行,还是修改行。 if (ultraGrid1.Rows[i].Cells["XH"].Value.ToString() == "") { doAdd(); } else { doUpdate(); } } } if (num == 0) { MessageBox.Show("请选择需要处理的数据行!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if (num > 0) { doQuery(false); MessageBox.Show("保存成功!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } catch { MessageBox.Show("保存失败!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } } private void doAdd() { //获取新增加的行。 ultraGrid1.UpdateData(); ArrayList parms = new ArrayList(); //判断是否勾选。 for (int i = 0; i < ultraGrid1.Rows.Count; i++) { if (Convert.ToBoolean(ultraGrid1.Rows[i].Cells["UCCHOOSE"].Value) && num > -1 && ultraGrid1.Rows[i].Cells["XH"].Value.ToString() == "" && ultraGrid1.Rows[i].Cells["UnboundColumn2"].Value.ToString() == "tagtrue") { try { if (ultraGrid1.Rows[i].Cells["STDSTYLE"].Value.ToString() == "") { MessageBox.Show("标准类型不能为空!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Warning); num = -10; return; } if (ultraGrid1.Rows[i].Cells["SAVE_TIME"].Value.ToString() == "") { MessageBox.Show("请输入保压时间!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Warning); num = -10; return; } try { Double.Parse(ultraGrid1.Rows[i].Cells["SAVE_TIME"].Value.ToString()); } catch { MessageBox.Show("保压时间需填写数值类型!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Warning); num = -10; return; } if (ultraGrid1.Rows[i].Cells["MIN_D"].Value.ToString() != "" && ultraGrid1.Rows[i].Cells["MAX_D"].Value.ToString() != "") { if (ultraGrid1.Rows[i].Cells["SPEC_JG_DESC"].Value.ToString() != "") { MessageBox.Show("外径和接箍码不能同时存在", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Warning); num = -10; return; } if (double.Parse(ultraGrid1.Rows[i].Cells["MIN_D"].Value.ToString()) > double.Parse(ultraGrid1.Rows[i].Cells["MAX_D"].Value.ToString())) { MessageBox.Show("外径的最小值不能大于最大值", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Warning); num = -10; return; } } if (ultraGrid1.Rows[i].Cells["MIN_D"].Value.ToString() != "") { if (ultraGrid1.Rows[i].Cells["MAX_D"].Value.ToString() == "") { MessageBox.Show("外径的最大值没有填写!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Warning); num = -10; return; } } if (ultraGrid1.Rows[i].Cells["MAX_D"].Value.ToString() != "") { if (ultraGrid1.Rows[i].Cells["MIN_D"].Value.ToString() == "") { MessageBox.Show("外径的最小值没有填写!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Warning); num = -10; return; } } if (ultraGrid1.Rows[i].Cells["MIN_H"].Value.ToString() != "" && ultraGrid1.Rows[i].Cells["MAX_H"].Value.ToString() != "") { if (double.Parse(ultraGrid1.Rows[i].Cells["MIN_H"].Value.ToString()) > double.Parse(ultraGrid1.Rows[i].Cells["MAX_H"].Value.ToString())) { MessageBox.Show("壁厚的最小值不能大于最大值", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Warning); num = -10; return; } } if (ultraGrid1.Rows[i].Cells["MIN_H"].Value.ToString() != "") { if (ultraGrid1.Rows[i].Cells["MAX_H"].Value.ToString() == "") { MessageBox.Show("壁厚的最大值没有填写!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Warning); num = -10; return; } } if (ultraGrid1.Rows[i].Cells["MAX_H"].Value.ToString() != "") { if (ultraGrid1.Rows[i].Cells["MIN_H"].Value.ToString() == "") { MessageBox.Show("壁厚的最小值没有填写!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Warning); num = -10; return; } } //构建ArrayList,添加到parms当中。 ArrayList parm = new ArrayList(); parm.Add(Guid.NewGuid().ToString().Substring(0, 20)); switch (ultraGrid1.Rows[i].Cells["STDSTYLE"].Value.ToString()) { case "国标/国际/协议": parm.Add("G"); break; case "客户": parm.Add("K"); break; case "内控": parm.Add("N"); break; } parm.Add(ultraGrid1.Rows[i].Cells["MIN_D"].Value.ToString()); parm.Add(ultraGrid1.Rows[i].Cells["MAX_D"].Value.ToString()); parm.Add(ultraGrid1.Rows[i].Cells["MIN_H"].Value.ToString()); parm.Add(ultraGrid1.Rows[i].Cells["MAX_H"].Value.ToString()); parm.Add(ultraGrid1.Rows[i].Cells["SPEC_JG"].Text.ToString()); parm.Add(ultraGrid1.Rows[i].Cells["SPEC_JG_DESC"].Value.ToString()); parm.Add(ultraGrid1.Rows[i].Cells["MODEL_CODE"].Value.ToString()); parm.Add(ultraGrid1.Rows[i].Cells["MODEL_DESC"].Value.ToString()); parm.Add(ultraGrid1.Rows[i].Cells["PRESSURE_Y"].Value.ToString()); //创建人应为当前操作用户。 parm.Add(this.UserInfo.GetUserName()); //创建时间为当前时间。 parm.Add(DateTime.Now.ToString()); parm.Add(ultraGrid1.Rows[i].Cells["MEMO"].Value.ToString()); parm.Add(ultraGrid1.Rows[i].Cells["PRESSURE"].Value.ToString()); parm.Add(ultraGrid1.Rows[i].Cells["SAVE_TIME"].Value.ToString()); ultraGrid1.Rows[i].Cells["UnboundColumn2"].Value = ""; ServerHelper.SetData("com.steering.pss.qcm.CoreProducWater.doAdd", new Object[] { parm }, this.ob); num++; list.Add(i); } catch { MessageBox.Show("输入类型有误"); return; } } } } private void doDeleteOrResume(Boolean flag) { ultraGrid1.UpdateData(); string tishi = ""; int numb = 0; for (int i = 0; i < ultraGrid1.Rows.Count; i++) { if (Convert.ToBoolean(ultraGrid1.Rows[i].Cells["UCCHOOSE"].Value)) { if (flag) tishi = "删除"; else tishi = "恢复"; if (numb == 0) { if (MessageBox.Show(tishi + "勾选记录,您是否继续?", "提示信息", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) { return; } } numb++; ArrayList parm = new ArrayList(); if (flag == true) { parm.Add(UserInfo.GetUserName()); } parm.Add(ultraGrid1.Rows[i].Cells["MSC"].Value.ToString()); switch (ultraGrid1.Rows[i].Cells["STDSTYLE"].Value.ToString()) { case "国标/国际/协议": parm.Add("G"); break; case "客户": parm.Add("K"); break; case "内控": parm.Add("N"); break; } parm.Add(ultraGrid1.Rows[i].Cells["XH"].Value.ToString()); //主表删除 int count = ServerHelper.SetData("com.steering.pss.qcm.CoreProducWater.deleteLineInfo", new Object[] { parm, flag }, this.ob); } } if (numb == 0) { MessageBox.Show("请选择需要处理的数据行!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } doQuery(false); } private void doUpdate() { //需要实现批量修改功能。 ultraGrid1.UpdateData(); ArrayList parms = new ArrayList(); for (int i = 0; i < ultraGrid1.Rows.Count; i++) { //复选框是否已经选中 if ((Boolean)ultraGrid1.Rows[i].Cells["UCCHOOSE"].Value && num > -1 && ultraGrid1.Rows[i].Cells["XH"].Value.ToString() != "") { if (ultraGrid1.Rows[i].Cells["STDSTYLE"].Value.ToString() == "") { MessageBox.Show("标准类型不能为空!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Warning); num = -10; return; } if (ultraGrid1.Rows[i].Cells["SAVE_TIME"].Value.ToString() == "") { MessageBox.Show("请输入保压时间!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Warning); num = -10; return; } try { Double.Parse(ultraGrid1.Rows[i].Cells["SAVE_TIME"].Value.ToString()); } catch { MessageBox.Show("保压时间需填写数值类型!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Warning); num = -10; return; } if (ultraGrid1.Rows[i].Cells["MIN_D"].Value.ToString() != "" && ultraGrid1.Rows[i].Cells["MAX_D"].Value.ToString() != "") { if (ultraGrid1.Rows[i].Cells["SPEC_JG_DESC"].Value.ToString() != "") { MessageBox.Show("外径和接箍码不能同时存在", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Warning); num = -10; return; } if (double.Parse(ultraGrid1.Rows[i].Cells["MIN_D"].Value.ToString()) > double.Parse(ultraGrid1.Rows[i].Cells["MAX_D"].Value.ToString())) { MessageBox.Show("外径的最小值不能大于最大值", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Warning); num = -10; return; } } if (ultraGrid1.Rows[i].Cells["MIN_D"].Value.ToString() != "") { if (ultraGrid1.Rows[i].Cells["MAX_D"].Value.ToString() == "") { MessageBox.Show("外径的最大值没有填写!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Warning); num = -10; return; } } if (ultraGrid1.Rows[i].Cells["MAX_D"].Value.ToString() != "") { if (ultraGrid1.Rows[i].Cells["MIN_D"].Value.ToString() == "") { MessageBox.Show("外径的最小值没有填写!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Warning); num = -10; return; } } if (ultraGrid1.Rows[i].Cells["MIN_H"].Value.ToString() != "" && ultraGrid1.Rows[i].Cells["MAX_H"].Value.ToString() != "") { if (double.Parse(ultraGrid1.Rows[i].Cells["MIN_H"].Value.ToString()) > double.Parse(ultraGrid1.Rows[i].Cells["MAX_H"].Value.ToString())) { MessageBox.Show("壁厚的最小值不能大于最大值", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Warning); num = -10; return; } } if (ultraGrid1.Rows[i].Cells["MIN_H"].Value.ToString() != "") { if (ultraGrid1.Rows[i].Cells["MAX_H"].Value.ToString() == "") { MessageBox.Show("壁厚的最大值没有填写!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Warning); num = -10; return; } } if (ultraGrid1.Rows[i].Cells["MAX_H"].Value.ToString() != "") { if (ultraGrid1.Rows[i].Cells["MIN_H"].Value.ToString() == "") { MessageBox.Show("壁厚的最小值没有填写!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Warning); num = -10; return; } } ArrayList parm = new ArrayList(); parm.Add(ultraGrid1.Rows[i].Cells["MIN_D"].Value.ToString()); parm.Add(ultraGrid1.Rows[i].Cells["MAX_D"].Value.ToString()); parm.Add(ultraGrid1.Rows[i].Cells["MIN_H"].Value.ToString()); parm.Add(ultraGrid1.Rows[i].Cells["MAX_H"].Value.ToString()); parm.Add(ultraGrid1.Rows[i].Cells["SPEC_JG"].Text.ToString()); parm.Add(ultraGrid1.Rows[i].Cells["SPEC_JG_DESC"].Value.ToString()); parm.Add(ultraGrid1.Rows[i].Cells["MODEL_CODE"].Value.ToString()); parm.Add(ultraGrid1.Rows[i].Cells["MODEL_DESC"].Value.ToString()); parm.Add(ultraGrid1.Rows[i].Cells["PRESSURE_Y"].Value.ToString()); //创建人应为当前操作用户。 parm.Add(this.UserInfo.GetUserName()); //创建时间为当前时间。 parm.Add(DateTime.Now.ToString()); parm.Add(ultraGrid1.Rows[i].Cells["MEMO"].Value.ToString()); parm.Add(ultraGrid1.Rows[i].Cells["PRESSURE"].Value.ToString()); parm.Add(ultraGrid1.Rows[i].Cells["SAVE_TIME"].Value.ToString()); parm.Add(ultraGrid1.Rows[i].Cells["MSC"].Value.ToString()); switch (ultraGrid1.Rows[i].Cells["STDSTYLE"].Value.ToString()) { case "国标/国际/协议": parm.Add("G"); break; case "客户": parm.Add("K"); break; case "内控": parm.Add("N"); break; } parm.Add(ultraGrid1.Rows[i].Cells["XH"].Value.ToString()); //主表修改 ultraGrid1.Rows[i].Cells["UnboundColumn2"].Value = ""; int count = ServerHelper.SetData("com.steering.pss.qcm.CoreProducWater.doUpdate", new Object[] { parm }, this.ob); num++; list.Add(i); } } } /// /// 查询方法,比较通用的查询方法 /// private void doQuery(bool flag) { bool validFlag = flag; DataTable dt = ServerHelper.GetData("com.steering.pss.qcm.CoreProducWater.doQuery", new Object[] { validFlag }, this.ob); GridHelper.CopyDataToDatatable(ref dt, ref this.dataTable1, true); for (int i = 0; i < ultraGrid1.Rows.Count; i++) { for (int j = 0; j < ultraGrid1.Rows[i].Cells.Count; j++) { if (j == 19) break; ultraGrid1.Rows[i].Cells[j].Activation = Infragistics.Win.UltraWinGrid.Activation.ActivateOnly; } } UltraGridColumn[] col = new UltraGridColumn[] { this.ultraGrid1.DisplayLayout.Bands[0].Columns["MEMO"] }; GridHelper.RefreshAndAutoSizeExceptRows(ultraGrid1, col); //不同颜色区分是否有效数据 Infragistics.Win.UltraWinGrid.UltraGridRow row = null; for (int i = 0; i < ultraGrid1.Rows.Count; i++) { row = ultraGrid1.Rows[i]; if (row.Cells["VALIDFLAG"].Value.ToString().Equals("0")) { row.Appearance.ForeColor = Color.Red; } else { row.Appearance.ForeColor = Color.Black; } } foreach (int i in list) { ultraGrid1.Rows[i].Cells["UCCHOOSE"].Value = true; } list.Clear(); } /// /// 初始下拉框 /// /// 数据表 /// 下拉框 /// 方法名 /// 描述 /// 代码 private void InitDropList(ref DataTable dt, UltraComboEditor uce, string methodId, string desc) { DataTable dts = ServerHelper.GetData(methodId, null, this.ob); int num = dts.Rows.Count; DataTable dt2 = new DataTable(); dt2.Columns.Add("fenlei"); dt2.Columns.Add("fenname"); DataRow dr; for (int i = 0; i < num; i++) { dr = dt2.NewRow(); dr["fenlei"] = dts.Rows[i]["SPEC_JG_DESC"]; dr["fenname"] = dts.Rows[i]["SPEC_JG"]; dt2.Rows.Add(dr); } uce.DataSource = dt2; uce.ValueMember = "fenname"; uce.DisplayMember = "fenlei"; } /// /// 扣型选择后赋值给ultragrid1 /// /// 扣型代码 /// 扣型描述 public void SetModelText(string code, string desc) { this.ultraGrid1.DisplayLayout.ActiveRow.Cells["MODEL_CODE"].Value = code; this.ultraGrid1.DisplayLayout.ActiveRow.Cells["MODEL_DESC"].Value = desc; } private void ultraGrid1_ClickCellButton(object sender, CellEventArgs e) { if (e.Cell.Column.Key.Equals("MODEL_DESC") && Convert.ToBoolean(ultraGrid1.DisplayLayout.ActiveRow.Cells["UCCHOOSE"].Value)) { UltraGridRow row = this.ultraGrid1.DisplayLayout.ActiveRow; FrmModel frms = new FrmModel(); frms.Desc = row.Cells["MODEL_DESC"].Value.ToString(); frms.FrmOb = this.ob; frms.ShowDialog(); row.Cells["MODEL_CODE"].Value = frms.Code; row.Cells["MODEL_DESC"].Value = frms.Desc; } } private void ultraGrid1_CellChange(object sender, CellEventArgs e) { if (e.Cell.Column.Key.Equals("UCCHOOSE")) { this.ultraGrid1.UpdateData(); Activation activation = Activation.ActivateOnly; if (Convert.ToBoolean(e.Cell.Value)) { activation = Activation.AllowEdit; e.Cell.Row.Cells["UnboundColumn2"].Value = "tagtrue"; } CellsCollection cells = e.Cell.Row.Cells; for (int i = 0; i < cells.Count; i++) { if (!cells[i].Column.Key.Equals("UCCHOOSE")) //i!=9 { if (i == 22) break; e.Cell.Row.Cells[i].Activation = activation; } } } } private void ultraGrid1_AfterRowInsert(object sender, RowEventArgs e) { for (int i = 0; i < e.Row.Cells.Count; i++) { if (i == 22) break; e.Row.Cells[i].Activation = Activation.NoEdit; } } } }