UIJ070010.cs 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  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 CoreFS.CA06;
  10. using System.Collections;
  11. using Infragistics.Win.UltraWinGrid;
  12. using System.Reflection;
  13. namespace Core.LZMes.Client.UIJ
  14. {
  15. public partial class UIJ070010 : FrmBase
  16. {
  17. public UIJ070010()
  18. {
  19. InitializeComponent();
  20. }
  21. public override void ToolBar_Click(object sender, string ToolbarKey)
  22. {
  23. switch (ToolbarKey)
  24. {
  25. case "Query":
  26. this.DoQuery();
  27. break;
  28. case "Add":
  29. this.DoAdd();
  30. break;
  31. case "Update":
  32. this.DoUpdate();
  33. break;
  34. case "Delete":
  35. this.DoDelete();
  36. break;
  37. }
  38. }
  39. //查询
  40. private void DoQuery()
  41. {
  42. try
  43. {
  44. this.dataSet1.Clear();
  45. string forName = this.textBox1.Text.Trim();
  46. string proLine = this.textBox2.Text.Trim();
  47. CoreClientParam ccp = new CoreClientParam();
  48. ccp.ServerName = "UIJ.UIJ05.UIJ070010";
  49. ccp.MethodName = "Query";
  50. ccp.ServerParams = new object[]{ forName , proLine };
  51. ccp.SourceDataTable = this.dataSet1.Tables[0];
  52. this.ExecuteQueryToDataTable(ccp,CoreInvokeType.Internal);
  53. }
  54. catch (Exception ex)
  55. {
  56. System.Diagnostics.Debug.WriteLine(ex.ToString());
  57. MessageBox.Show("系统出错,请联系管理人员", "警告");
  58. }
  59. }
  60. //新增
  61. private void DoAdd()
  62. {
  63. try
  64. {
  65. ArrayList list = new ArrayList();
  66. foreach (UltraGridRow ugr in this.ultraGrid1.Rows)
  67. {
  68. if (ugr.Cells["CHK"].Text.ToString() == "True")
  69. {
  70. if (ugr.Cells["EGIS_ID"].Text == "") //没有id才加
  71. {
  72. list = new ArrayList();
  73. list.Add(ugr.Cells["FOR_NAME"].Text.ToString());
  74. list.Add(ugr.Cells["PRODUCTION_LINE"].Text.ToString());
  75. list.Add(ugr.Cells["NORM"].Text.ToString());
  76. list.Add(ugr.Cells["UNIT_PRICE"].Text.ToString());
  77. }
  78. }// if end
  79. }//foreach end
  80. if (list.Count == 0) return;
  81. if (list.Contains(""))
  82. {
  83. MessageBox.Show("请输入完整信息!", "警告");
  84. return;
  85. }
  86. CoreClientParam ccp = new CoreClientParam();
  87. ccp.ServerName = "UIJ.UIJ05.UIJ070010";
  88. ccp.MethodName = "add";
  89. ccp.ServerParams = new object[] { list };
  90. ccp = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  91. this.DoQuery();
  92. }
  93. catch (Exception ex)
  94. {
  95. System.Diagnostics.Debug.WriteLine(ex.ToString());
  96. MessageBox.Show("系统出错,请联系管理人员", "警告");
  97. }
  98. }
  99. //更新
  100. private void DoUpdate()
  101. {
  102. try
  103. {
  104. ArrayList list = null;
  105. ArrayList al = new ArrayList();
  106. foreach (UltraGridRow ugr in this.ultraGrid1.Rows)
  107. {
  108. if (ugr.Cells["CHK"].Text.ToString() == "True")
  109. {
  110. list = new ArrayList();
  111. if (ugr.Cells["EGIS_ID"].Text != "")//有id 即数据库有数据 才更新
  112. {
  113. list.Add(ugr.Cells["FOR_NAME"].Text.ToString());
  114. list.Add(ugr.Cells["PRODUCTION_LINE"].Text.ToString());
  115. list.Add(ugr.Cells["NORM"].Text.ToString());
  116. list.Add(ugr.Cells["UNIT_PRICE"].Text.ToString());
  117. list.Add(ugr.Cells["EGIS_ID"].Text.ToString());
  118. al.Add(list);
  119. }
  120. }// if end
  121. }//foreach end
  122. if (al.Count == 0) return;
  123. CoreClientParam ccp = new CoreClientParam();
  124. ccp.ServerName = "UIJ.UIJ05.UIJ070010";
  125. ccp.MethodName = "Save";
  126. ccp.ServerParams = new object[] { al };
  127. ccp = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  128. this.DoQuery();
  129. }
  130. catch (Exception ex)
  131. {
  132. System.Diagnostics.Debug.WriteLine(ex.ToString());
  133. MessageBox.Show("系统出错,请联系管理人员", "警告");
  134. }
  135. }
  136. //删除
  137. public void DoDelete()
  138. {
  139. try
  140. {
  141. if (MessageBox.Show("确定删除?", "提示", MessageBoxButtons.OKCancel) == DialogResult.Cancel)
  142. return;
  143. ArrayList al = new ArrayList();
  144. foreach (UltraGridRow ugr in this.ultraGrid1.Rows)
  145. {
  146. if (ugr.Cells["CHK"].Text.ToString() == "True")
  147. {
  148. if (ugr.Cells["EGIS_ID"].Text != "") //有id才能删
  149. {
  150. al.Add(ugr.Cells["EGIS_ID"].Text.ToString());
  151. }
  152. }//if end
  153. }//for end
  154. if (al.Count == 0) return; //没有选择数据 返回
  155. CoreClientParam ccp = new CoreClientParam();
  156. ccp.ServerName = "UIJ.UIJ05.UIJ070010";
  157. ccp.MethodName = "remove";
  158. ccp.ServerParams = new object[] { al[0] };
  159. ccp = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  160. this.DoQuery();
  161. }
  162. catch (Exception ex)
  163. {
  164. System.Diagnostics.Debug.WriteLine(ex.ToString());
  165. MessageBox.Show("系统出错,请联系管理人员", "警告");
  166. }
  167. }
  168. }
  169. }