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 Infragistics.Win.UltraWinGrid; using Core.Mes.Client.Comm.Server; using System.Collections; using CoreFS.CA06; using Core.Mes.Client.Comm.Control; namespace Core.StlMes.Client.ZGMil.Popup { public partial class frmDefectManage :Form { OpeBase ob = null; public frmDefectManage(OpeBase ob) { InitializeComponent(); this.ob = ob; getDefectManage(ob); } //查询缺陷项信息 public void getDefectManage(OpeBase ob) { DataTable dt = ServerHelper.GetData("com.steering.mes.zgmil.coup.SurfaceInspectionResult.getMIL_BASE_DEFECT_ITEM", new object[] { }, ob); GridHelper.CopyDataToDatatable(ref dt, ref dt_Defect, true); ultraGrid1.DisplayLayout.Bands[0].PerformAutoResizeColumns(true, PerformAutoSizeType.AllRowsInBand); //绑定缺陷项到下拉列表 cbLever.Items.Clear(); string[] cbDefect={"常用","不常用"}; cbLever.Items.AddRange(cbDefect); cbLever.SelectedItem = "常用"; } /// /// 删除 /// /// /// private void ultraBtn_delete_Click(object sender, EventArgs e) { UltraGridRow ulgr = ultraGrid1.ActiveRow; if (ulgr != null) { int retnum = ServerHelper.SetData("com.steering.mes.zgmil.coup.SurfaceInspectionResult.DelMIL_BASE_DEFECT_ITEM", new object[] { ulgr.Cells["DEFECT_ITEM_CODE"].Value.ToString() }, this.ob); if (retnum > 0) { MessageBox.Show("删除成功", "提示", MessageBoxButtons.OK); getDefectManage(this.ob); } } else { MessageBox.Show("请选择要删除的行!", "提示",MessageBoxButtons.OK); } } /// /// 增加 /// /// /// private void ultraBtn_add_Click(object sender, EventArgs e) { if (txtName.Text.Trim() == "") { MessageBox.Show("请输入一个有效的名称", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } else { for (int i = 0; i < ultraGrid1.Rows.Count; i++) { if (ultraGrid1.Rows[i].Cells["DEFECT_ITEM_NAME"].Value.ToString() == txtName.Text) { MessageBox.Show("输入的名称已存在,请重新输入!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } } } if (txtCode.Text.Trim() == "") { MessageBox.Show("请输入一个有效的代码", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } else { for (int i = 0; i < ultraGrid1.Rows.Count; i++) { if (ultraGrid1.Rows[i].Cells["DEFECT_ITEM_CODE"].Value.ToString() == txtCode.Text) { MessageBox.Show("输入的代码已存在,请重新输入!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } } } int retnum = ServerHelper.SetData("com.steering.mes.zgmil.coup.SurfaceInspectionResult.AddMIL_BASE_DEFECT_ITEM", new object[] { txtCode.Text, txtName.Text, cbLever.SelectedIndex.ToString(),"" }, this.ob); if (retnum > 0) { MessageBox.Show("添加成功", "提示", MessageBoxButtons.OK); getDefectManage(this.ob); } } /// /// 修改 /// /// /// private void ultrabtn_upd_Click(object sender, EventArgs e) { UltraGridRow ulgr = ultraGrid1.ActiveRow; if (ulgr == null) { MessageBox.Show("请选中一行数据进行更新", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (ulgr.Cells["DEFECT_ITEM_NAME"].Value.ToString() == txtName.Text && ulgr.Cells["DEFECT_ITEM_CODE"].Value.ToString() == txtCode.Text && ulgr.Cells["DEFECT_LEVEL"].Value.ToString() == cbLever.SelectedItem.ToString()) { MessageBox.Show("信息未做任何修改!", "提示", MessageBoxButtons.OK); return; } if (txtName.Text.Trim() == "") { MessageBox.Show("请输入一个有效的名称", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } else { for (int i = 0; i < ultraGrid1.Rows.Count; i++) { if (ultraGrid1.Rows[i].Cells["DEFECT_ITEM_NAME"].Value.ToString() == txtName.Text && ulgr != ultraGrid1.Rows[i]) { MessageBox.Show("输入的名称已存在,请重新输入!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } } } if (txtCode.Text.Trim() == "") { MessageBox.Show("请输入一个有效的代码", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } else { for (int i = 0; i < ultraGrid1.Rows.Count; i++) { if (ultraGrid1.Rows[i].Cells["DEFECT_ITEM_CODE"].Value.ToString() == txtCode.Text && ulgr != ultraGrid1.Rows[i]) { MessageBox.Show("输入的代码已存在,请重新输入!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } } } int retnum = ServerHelper.SetData("com.steering.mes.zgmil.coup.SurfaceInspectionResult.UpdMIL_BASE_DEFECT_ITEM", new object[] { txtCode.Text, txtName.Text, cbLever.SelectedIndex.ToString(),"", ulgr.Cells["DEFECT_ITEM_CODE"].Value.ToString() }, this.ob); if (retnum > 0) { MessageBox.Show("更新成功", "提示", MessageBoxButtons.OK); getDefectManage(this.ob); } } /// /// 选中行激活事件 /// /// /// private void ultraGrid1_AfterRowActivate(object sender, EventArgs e) { UltraGridRow ugr = ultraGrid1.ActiveRow; txtCode.Text = ugr.Cells["DEFECT_ITEM_CODE"].Value.ToString(); txtName.Text = ugr.Cells["DEFECT_ITEM_NAME"].Value.ToString(); cbLever.SelectedItem = ugr.Cells["DEFECT_LEVEL"].Value; } } }