EGIS.cs 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  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.QCM
  14. {
  15. public partial class EGIS : FrmBase
  16. {
  17. public EGIS()
  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.MethodName = "Query";
  49. ccp.ServerName = "EGIS.QueryEgis";
  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.MethodName = "add";
  88. ccp.ServerName = "EGIS.addEgis";
  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 al = new ArrayList();
  105. foreach (UltraGridRow ugr in this.ultraGrid1.Rows)
  106. {
  107. if (ugr.Cells["CHK"].Text.ToString() == "True")
  108. {
  109. if (ugr.Cells["EGIS_ID"].Text != "")//有id 即数据库有数据 才更新
  110. {
  111. al.Add(ugr.Cells["FOR_NAME"].Text.ToString());
  112. al.Add(ugr.Cells["PRODUCTION_LINE"].Text.ToString());
  113. al.Add(ugr.Cells["NORM"].Text.ToString());
  114. al.Add(ugr.Cells["UNIT_PRICE"].Text.ToString());
  115. al.Add(ugr.Cells["EGIS_ID"].Text.ToString());
  116. }
  117. }// if end
  118. }//foreach end
  119. if (al.Count == 0) return;
  120. CoreClientParam ccp = new CoreClientParam();
  121. ccp.ServerName = "EGIS.SaveEgis";
  122. ccp.MethodName = "Save";
  123. ccp.ServerParams = new object[] { al };
  124. ccp = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  125. this.DoQuery();
  126. }
  127. catch (Exception ex)
  128. {
  129. System.Diagnostics.Debug.WriteLine(ex.ToString());
  130. MessageBox.Show("系统出错,请联系管理人员", "警告");
  131. }
  132. }
  133. //删除
  134. public void DoDelete()
  135. {
  136. try
  137. {
  138. if (MessageBox.Show("确定删除?", "提示", MessageBoxButtons.OKCancel) == DialogResult.Cancel)
  139. return;
  140. ArrayList al = new ArrayList();
  141. foreach (UltraGridRow ugr in this.ultraGrid1.Rows)
  142. {
  143. if (ugr.Cells["CHK"].Text.ToString() == "True")
  144. {
  145. if (ugr.Cells["EGIS_ID"].Text != "") //有id才能删
  146. {
  147. al.Add(ugr.Cells["EGIS_ID"].Text.ToString());
  148. }
  149. }//if end
  150. }//for end
  151. if (al.Count == 0) return; //没有选择数据 返回
  152. CoreClientParam ccp = new CoreClientParam();
  153. ccp.ServerName = "EGIS.removeEgis";
  154. ccp.MethodName = "remove";
  155. ccp.ServerParams = new object[] { al[0] };
  156. ccp = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  157. this.DoQuery();
  158. }
  159. catch (Exception ex)
  160. {
  161. System.Diagnostics.Debug.WriteLine(ex.ToString());
  162. MessageBox.Show("系统出错,请联系管理人员", "警告");
  163. }
  164. }
  165. }
  166. }