| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182 |
- 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 = "常用";
- }
- /// <summary>
- /// 删除
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- 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);
- }
- }
- /// <summary>
- /// 增加
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- 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);
- }
- }
- /// <summary>
- /// 修改
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- 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);
- }
- }
- /// <summary>
- /// 选中行激活事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- 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;
- }
- }
- }
|