frmDefectManage.cs 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Windows.Forms;
  9. using Infragistics.Win.UltraWinGrid;
  10. using Core.Mes.Client.Comm.Server;
  11. using System.Collections;
  12. using CoreFS.CA06;
  13. using Core.Mes.Client.Comm.Control;
  14. namespace Core.StlMes.Client.ZGMil.Popup
  15. {
  16. public partial class frmDefectManage :Form
  17. {
  18. OpeBase ob = null;
  19. public frmDefectManage(OpeBase ob)
  20. {
  21. InitializeComponent();
  22. this.ob = ob;
  23. getDefectManage(ob);
  24. }
  25. //查询缺陷项信息
  26. public void getDefectManage(OpeBase ob)
  27. {
  28. DataTable dt =
  29. ServerHelper.GetData("com.steering.mes.zgmil.coup.SurfaceInspectionResult.getMIL_BASE_DEFECT_ITEM", new object[] { }, ob);
  30. GridHelper.CopyDataToDatatable(ref dt, ref dt_Defect, true);
  31. ultraGrid1.DisplayLayout.Bands[0].PerformAutoResizeColumns(true, PerformAutoSizeType.AllRowsInBand);
  32. //绑定缺陷项到下拉列表
  33. cbLever.Items.Clear();
  34. string[] cbDefect={"常用","不常用"};
  35. cbLever.Items.AddRange(cbDefect);
  36. cbLever.SelectedItem = "常用";
  37. }
  38. /// <summary>
  39. /// 删除
  40. /// </summary>
  41. /// <param name="sender"></param>
  42. /// <param name="e"></param>
  43. private void ultraBtn_delete_Click(object sender, EventArgs e)
  44. {
  45. UltraGridRow ulgr = ultraGrid1.ActiveRow;
  46. if (ulgr != null)
  47. {
  48. 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);
  49. if (retnum > 0)
  50. {
  51. MessageBox.Show("删除成功", "提示", MessageBoxButtons.OK);
  52. getDefectManage(this.ob);
  53. }
  54. }
  55. else
  56. {
  57. MessageBox.Show("请选择要删除的行!", "提示",MessageBoxButtons.OK);
  58. }
  59. }
  60. /// <summary>
  61. /// 增加
  62. /// </summary>
  63. /// <param name="sender"></param>
  64. /// <param name="e"></param>
  65. private void ultraBtn_add_Click(object sender, EventArgs e)
  66. {
  67. if (txtName.Text.Trim() == "")
  68. {
  69. MessageBox.Show("请输入一个有效的名称", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
  70. return;
  71. }
  72. else
  73. {
  74. for (int i = 0; i < ultraGrid1.Rows.Count; i++)
  75. {
  76. if (ultraGrid1.Rows[i].Cells["DEFECT_ITEM_NAME"].Value.ToString() == txtName.Text)
  77. {
  78. MessageBox.Show("输入的名称已存在,请重新输入!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
  79. return;
  80. }
  81. }
  82. }
  83. if (txtCode.Text.Trim() == "")
  84. {
  85. MessageBox.Show("请输入一个有效的代码", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
  86. return;
  87. }
  88. else
  89. {
  90. for (int i = 0; i < ultraGrid1.Rows.Count; i++)
  91. {
  92. if (ultraGrid1.Rows[i].Cells["DEFECT_ITEM_CODE"].Value.ToString() == txtCode.Text)
  93. {
  94. MessageBox.Show("输入的代码已存在,请重新输入!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
  95. return;
  96. }
  97. }
  98. }
  99. 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);
  100. if (retnum > 0)
  101. {
  102. MessageBox.Show("添加成功", "提示", MessageBoxButtons.OK);
  103. getDefectManage(this.ob);
  104. }
  105. }
  106. /// <summary>
  107. /// 修改
  108. /// </summary>
  109. /// <param name="sender"></param>
  110. /// <param name="e"></param>
  111. private void ultrabtn_upd_Click(object sender, EventArgs e)
  112. {
  113. UltraGridRow ulgr = ultraGrid1.ActiveRow;
  114. if (ulgr == null)
  115. { MessageBox.Show("请选中一行数据进行更新", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); return; }
  116. 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())
  117. {
  118. MessageBox.Show("信息未做任何修改!", "提示", MessageBoxButtons.OK);
  119. return;
  120. }
  121. if (txtName.Text.Trim() == "")
  122. {
  123. MessageBox.Show("请输入一个有效的名称", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
  124. return;
  125. }
  126. else
  127. {
  128. for (int i = 0; i < ultraGrid1.Rows.Count; i++)
  129. {
  130. if (ultraGrid1.Rows[i].Cells["DEFECT_ITEM_NAME"].Value.ToString() == txtName.Text && ulgr != ultraGrid1.Rows[i])
  131. {
  132. MessageBox.Show("输入的名称已存在,请重新输入!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
  133. return;
  134. }
  135. }
  136. }
  137. if (txtCode.Text.Trim() == "")
  138. {
  139. MessageBox.Show("请输入一个有效的代码", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
  140. return;
  141. }
  142. else
  143. {
  144. for (int i = 0; i < ultraGrid1.Rows.Count; i++)
  145. {
  146. if (ultraGrid1.Rows[i].Cells["DEFECT_ITEM_CODE"].Value.ToString() == txtCode.Text && ulgr != ultraGrid1.Rows[i])
  147. {
  148. MessageBox.Show("输入的代码已存在,请重新输入!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
  149. return;
  150. }
  151. }
  152. }
  153. 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);
  154. if (retnum > 0)
  155. {
  156. MessageBox.Show("更新成功", "提示", MessageBoxButtons.OK);
  157. getDefectManage(this.ob);
  158. }
  159. }
  160. /// <summary>
  161. /// 选中行激活事件
  162. /// </summary>
  163. /// <param name="sender"></param>
  164. /// <param name="e"></param>
  165. private void ultraGrid1_AfterRowActivate(object sender, EventArgs e)
  166. {
  167. UltraGridRow ugr = ultraGrid1.ActiveRow;
  168. txtCode.Text = ugr.Cells["DEFECT_ITEM_CODE"].Value.ToString();
  169. txtName.Text = ugr.Cells["DEFECT_ITEM_NAME"].Value.ToString();
  170. cbLever.SelectedItem = ugr.Cells["DEFECT_LEVEL"].Value;
  171. }
  172. }
  173. }