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 Infragistics.Win.UltraWinGrid; namespace Core.LZMes.Client.QCM { public partial class QCM0102 : FrmBase { public QCM0102() { InitializeComponent(); } public override void ToolBar_Click(object sender, string ToolbarKey) { switch (ToolbarKey) { case "Query": this.DoQuery(); break; case "Add": this.DoAdd(); break; case "Update": this.DoUpdate(); break; case "Delete": this.DoDelete(); break; case "Close": this.Close(); break; } } private void DoQuery() { //查询 try { this.dataSet1.Tables[0].Clear(); string grpName = this.textBox1.Text.Trim();// 材质项目名称 CoreClientParam ccp = new CoreClientParam(); ccp.ServerName = "QCM.QCM01.QCM0102.QueryPhy"; ccp.MethodName = "Query"; ccp.ServerParams = new object[] { grpName }; ccp.SourceDataTable = this.dataSet1.Tables[0]; this.ExecuteQueryToDataTable(ccp, CoreInvokeType.Internal); } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex.ToString()); } } private void DoAdd() { try { if (this.UserInfo.GetUserGroup() == 0 + "") { MessageBox.Show("常白班人员禁止对数据进行操作", "警告"); return; } if ("" == this.textBox2.Text ) { MessageBox.Show("组合项目代码不能为空!", "警告"); this.textBox2.Focus(); return; } if ("" == this.textBox3.Text) { MessageBox.Show("组合项目名称不能为空!", "警告"); this.textBox3.Focus(); return; } if ("" == this.textBox4.Text) { MessageBox.Show("材质大类描述不能为空!", "警告"); this.textBox4.Focus(); return; } if ("" == this.textBox5.Text) { MessageBox.Show("缺陷类型不能为空!", "警告"); this.textBox5.Focus(); return; } if (MessageBox.Show("确认保存?", "提示", MessageBoxButtons.OKCancel) == DialogResult.Cancel) return; ArrayList al = new ArrayList(); al.Add(this.textBox2.Text.Trim()); //组合项目代码 al.Add(this.textBox3.Text.Trim()); //组合项目名称 al.Add(this.textBox4.Text.Trim()); //材质大类描述 al.Add("A"); //测试材质检验项代码 al.Add(this.textBox5.Text.Trim()); //缺陷分类描述 al.Add(this.textBox6.Text.Trim()); //备注 al.Add(this.UserInfo.GetUserID()); //创建人ID al.Add(this.UserInfo.GetUserName()); //创建人 CoreClientParam ccp = new CoreClientParam(); ccp.ServerName = "QCM.QCM01.QCM0102.addPhy"; ccp.MethodName = "add"; ccp.ServerParams = new object[] { al }; this.ExecuteNonQuery(ccp, CoreInvokeType.Internal); if (0 != ccp.ReturnCode) return; if (!"1".Equals(ccp.ReturnObject.ToString())) { MessageBox.Show(ccp.ReturnObject.ToString()); return; } DoQuery(); MessageBox.Show("创建成功!"); } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex.ToString()); MessageBox.Show("系统发生异常,请与管理员联系", "提示"); } } private void DoUpdate() { //更新 try { if (this.UserInfo.GetUserGroup() == 0 + "") { MessageBox.Show("常白班人员禁止对数据进行操作", "警告"); return; } if (this.ultraGrid1.Selected.Rows.Count == 0) { MessageBox.Show("请选择要修改的数据!"); return; } //选择一行数据 UltraGridRow ugr = this.ultraGrid1.ActiveRow; string grpCode = ugr.Cells["PHY_GRP_CODE"].Value.ToString(); if (MessageBox.Show("确认修改?", "提示", MessageBoxButtons.OKCancel) == DialogResult.Cancel) return; ArrayList al = new ArrayList(); al.Add(this.textBox3.Text.Trim()); //组合项目名称 al.Add(this.textBox4.Text.Trim()); //材质大类描述 al.Add(this.textBox5.Text.Trim()); //缺陷分类描述 al.Add(this.textBox6.Text.Trim()); //备注 al.Add(this.UserInfo.GetUserID()); //修改ID al.Add(this.UserInfo.GetUserName()); //修改人 al.Add(grpCode); //组合项目代码 CoreClientParam ccp = new CoreClientParam(); ccp.ServerName = "QCM.QCM01.QCM0102.SavePhy"; ccp.MethodName = "Save"; ccp.ServerParams = new object[] { al }; this.ExecuteNonQuery(ccp, CoreInvokeType.Internal); //if (0 != ccp.ReturnCode) return; if ("1" != ccp.ReturnObject.ToString()) { MessageBox.Show(ccp.ReturnObject.ToString(), "警告"); return; } this.textBox1.Text = al[0].ToString(); DoQuery(); MessageBox.Show("修改成功!"); } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex.ToString()); MessageBox.Show("系统发生异常,请与管理员联系", "提示"); } } private void DoDelete() { //删除 try { if (this.UserInfo.GetUserGroup() == 0 + "") { MessageBox.Show("常白班人员禁止对数据进行操作", "警告"); return; } if (this.ultraGrid1.ActiveRow.Cells.Count == 0) { MessageBox.Show("请选择要修改的数据!"); return; } //选择一行数据 UltraGridRow ugr = this.ultraGrid1.ActiveRow; string grpCode = ugr.Cells["PHY_GRP_CODE"].Value.ToString(); if (MessageBox.Show(this, "是否确认删除?", "删除", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.No) { return; } ArrayList al = new ArrayList(); al.Add(grpCode);//组合项目代码 al.Add(this.UserInfo.GetUserID()); al.Add(this.UserInfo.GetUserName()); CoreClientParam ccp = new CoreClientParam(); ccp.ServerName = "QCM.QCM01.QCM0102.removePhy"; ccp.MethodName = "remove"; ccp.ServerParams = new object[] {al }; this.ExecuteNonQuery(ccp,CoreInvokeType.Internal); if ("1" != ccp.ReturnObject.ToString()) { MessageBox.Show(ccp.ReturnObject.ToString(), "警告"); return; } this.textBox1.Text = ""; DoQuery(); MessageBox.Show("删除成功!"); } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex.ToString()); MessageBox.Show("系统发生异常,请与管理员联系", "提示"); } } private void ultraGrid1_AfterRowActivate(object sender, EventArgs e) { this.textBox2.Text = this.ultraGrid1.ActiveRow.Cells["PHY_GRP_CODE"].Value.ToString(); this.textBox3.Text = this.ultraGrid1.ActiveRow.Cells["PHY_GRP_DESC"].Value.ToString(); this.textBox4.Text = this.ultraGrid1.ActiveRow.Cells["PHY_DESC_L"].Value.ToString(); this.textBox5.Text = this.ultraGrid1.ActiveRow.Cells["DEFECT_TYPE_DESC"].Value.ToString(); this.textBox6.Text = this.ultraGrid1.ActiveRow.Cells["MEMO"].Value.ToString(); } } }