UIB010320.cs 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242
  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 Infragistics.Win.UltraWinGrid;
  9. using System.Collections;
  10. using System.Windows.Forms;
  11. using CoreFS.CA06;
  12. namespace Core.LZMes.Client.UIB
  13. {
  14. public partial class UIB010320 : FrmBase
  15. {
  16. public UIB010320()
  17. {
  18. InitializeComponent();
  19. }
  20. public override void ToolBar_Click(object sender, string ToolbarKey)
  21. {
  22. switch (ToolbarKey)
  23. {
  24. case "Query":
  25. this.DoQuery();
  26. break;
  27. case "Save":
  28. this.DoSave();
  29. break;
  30. case "Delete":
  31. this.DoDelete();
  32. break;
  33. }
  34. }
  35. //初始化下拉框数据
  36. public void init()
  37. {
  38. DataTable dt = new DataTable();
  39. ArrayList al = new ArrayList();
  40. al.Add("UIB010320_01.INITSELECT");
  41. CoreClientParam ccp = new CoreClientParam();
  42. ccp.ServerName = "UIB.COM.ComDBQuery";
  43. ccp.MethodName = "doSimpleQuery";
  44. ccp.ServerParams = new object[] { al };
  45. ccp.SourceDataTable = dt;
  46. this.ExecuteQueryToDataTable(ccp, CoreInvokeType.Internal);
  47. Init_ComboControl(this.ultraComboEditor1, ref dt);
  48. DoQuery();
  49. //DataTable dt = new DataTable();
  50. //CoreClientParam ccp = new CoreClientParam();
  51. //dt = new DataTable();
  52. //ccp = new CoreClientParam();
  53. //ccp.ServerName = "UIB.COM.ComDBQuery";
  54. //ccp.MethodName = "doSimpleQuery";
  55. //paramArray = new ArrayList();
  56. //paramArray.Add("UIECOMM00_SELECT.C_STL_GRD");
  57. //ccp.ServerParams = new object[] { paramArray };
  58. //ccp.SourceDataTable = dt;
  59. //this.ExecuteQueryToDataTable(ccp, CoreInvokeType.Internal);
  60. //Core.LZMes.Client.UIE.UIE041.UIEBase.Init_ComboControl(this.ComboColdStlGrd, ref dt, "C_STL_GRD");
  61. //dt = new DataTable();
  62. //ccp = new CoreClientParam();
  63. //ccp.ServerName = "UIB.COM.ComDBQuery";
  64. //ccp.MethodName = "doSimpleQuery";
  65. //paramArray = new ArrayList();
  66. //paramArray.Add("UIECOMM00_SELECT.H_STL_GRD");
  67. //ccp.ServerParams = new object[] { paramArray };
  68. //ccp.SourceDataTable = dt;
  69. //this.ExecuteQueryToDataTable(ccp, CoreInvokeType.Internal);
  70. //Core.LZMes.Client.UIE.UIE041.UIEBase.Init_ComboControl(this.ComboHotStlGrd, ref dt, "H_STL_GRD");
  71. }
  72. public void DoQuery()
  73. {
  74. try
  75. {
  76. this.dataSet1.Tables[0].Clear();
  77. ArrayList al = new ArrayList();
  78. al.Add("UIB010320_01.SELECT");
  79. CoreClientParam ccp = new CoreClientParam();
  80. ccp.ServerName = "UIB.COM.ComDBQuery";
  81. ccp.MethodName = "doSimpleQuery";
  82. ccp.ServerParams = new object[] { al };
  83. ccp.SourceDataTable = this.dataSet1.Tables[0];
  84. this.ExecuteQueryToDataTable(ccp, CoreInvokeType.Internal);
  85. }catch(Exception ex)
  86. {
  87. MessageBox.Show(ex.ToString());
  88. }
  89. }
  90. //public void DoInsert()
  91. //{
  92. // try
  93. // {
  94. // int num = this.ultraGrid1.Rows.Count;
  95. // this.ultraGrid1.Rows[num - 1].Cells["DISPLAY_SEQ"].Value.ToString();
  96. // this.ultraGrid1.Rows[num - 1].Cells["PROD_TYPE"].Text.ToString();
  97. // this.ultraGrid1.Rows[num - 1].Cells["PROD_CD_CFNM"].Text.ToString();
  98. // this.ultraGrid1.Rows[num - 1].Cells["DCS_SYM"].Text.ToString();
  99. // }
  100. // catch (Exception ex)
  101. // {
  102. // MessageBox.Show(ex.ToString());
  103. // }
  104. //}
  105. public void DoSave()
  106. {
  107. try
  108. {
  109. if (MessageBox.Show("确定保存?", "提示", MessageBoxButtons.OKCancel) == DialogResult.Cancel)
  110. return;
  111. ArrayList al = new ArrayList();
  112. ArrayList list = null;
  113. foreach (UltraGridRow ugr in this.ultraGrid1.Rows)
  114. {
  115. if (ugr.Cells["CHK"].Text == "True")
  116. {
  117. if (ugr.Cells["PROD_CD"].Text.ToString() == "")
  118. {
  119. MessageBox.Show("生产规范代码不允许为空!", "提示");
  120. return;
  121. }
  122. list = new ArrayList();
  123. if (ugr.Cells["EDIT_PROD"].Text == "")//插入
  124. {
  125. list.Add("UIB010320_01.INSERT");
  126. list.Add(ugr.Cells["PROD_CD"].Text.ToString());
  127. list.Add(ugr.Cells["DISPLAY_SEQ"].Text.ToString());
  128. list.Add(ugr.Cells["PROD_TYPE"].Text.ToString());
  129. list.Add(ugr.Cells["PROD_CD_CFNM"].Text.ToString());
  130. list.Add(ugr.Cells["DCS_SYM"].Text.ToString());
  131. list.Add(this.UserInfo.GetUserName());
  132. }
  133. else//更新
  134. {
  135. list.Add("UIB010320_01.UPDATE");
  136. list.Add(ugr.Cells["PROD_CD"].Text.ToString());
  137. list.Add(ugr.Cells["DISPLAY_SEQ"].Text.ToString());
  138. list.Add(ugr.Cells["PROD_TYPE"].Text.ToString());
  139. list.Add(ugr.Cells["PROD_CD_CFNM"].Text.ToString());
  140. list.Add(ugr.Cells["DCS_SYM"].Text.ToString());
  141. list.Add(this.UserInfo.GetUserName());
  142. list.Add(ugr.Cells["EDIT_PROD"].Text.ToString());
  143. }
  144. al.Add(list);
  145. }
  146. }
  147. if (al.Count == 0)
  148. {
  149. MessageBox.Show("请勾选数据再做保存操作!", "提示");
  150. return;
  151. }
  152. CoreClientParam ccp = new CoreClientParam();
  153. ccp.ServerName = "UIB.COM.ComDBSave";
  154. ccp.MethodName = "doXmlSave";
  155. ccp.ServerParams = new object[] { al };
  156. ccp = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  157. this.DoQuery();
  158. }
  159. catch (Exception ex)
  160. {
  161. MessageBox.Show(ex.ToString());
  162. }
  163. }
  164. public void DoDelete()
  165. {
  166. try
  167. {
  168. if (MessageBox.Show("确定删除?", "提示", MessageBoxButtons.OKCancel) == DialogResult.Cancel)
  169. return;
  170. ArrayList al = new ArrayList();
  171. ArrayList list = null;
  172. foreach (UltraGridRow ugr in this.ultraGrid1.Rows)
  173. {
  174. if (ugr.Cells["CHK"].Text == "True")
  175. {
  176. list = new ArrayList();
  177. list.Add("UIB010320_01.DELETE");
  178. list.Add(ugr.Cells["PROD_CD"].Text.ToString());
  179. al.Add(list);
  180. }
  181. }
  182. CoreClientParam ccp = new CoreClientParam();
  183. ccp.ServerName = "UIB.COM.ComDBSave";
  184. ccp.MethodName = "doXmlSave";
  185. ccp.ServerParams = new object[] { al };
  186. ccp = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  187. this.DoQuery();
  188. }
  189. catch (Exception ex)
  190. {
  191. MessageBox.Show(ex.ToString());
  192. }
  193. }
  194. public static void Init_ComboControl(System.Windows.Forms.Control ComboControl, ref System.Data.DataTable dt)
  195. {
  196. System.Data.DataView dtview = new System.Data.DataView(dt);
  197. ((Infragistics.Win.UltraWinEditors.UltraComboEditor)ComboControl).DataSource = dtview;
  198. ((Infragistics.Win.UltraWinEditors.UltraComboEditor)ComboControl).DisplayMember = "SM_CFNM";
  199. ((Infragistics.Win.UltraWinEditors.UltraComboEditor)ComboControl).ValueMember = "SM_CD";
  200. //try
  201. //{
  202. // switch (ComboControl.GetType().ToString())
  203. // {
  204. // case "Infragistics.Win.UltraWinEditors.UltraComboEditor":
  205. // break;
  206. // }
  207. //}
  208. //catch (System.Exception ex)
  209. //{
  210. // System.Diagnostics.Debug.WriteLine(ex.ToString());
  211. //}
  212. }
  213. private void UIB010320_Load(object sender, EventArgs e)
  214. {
  215. init();
  216. }
  217. //自定义单元格数据错误提示框
  218. private void ultraGrid1_CellDataError(object sender, CellDataErrorEventArgs e)
  219. {
  220. e.RaiseErrorEvent = false;
  221. e.StayInEditMode = true;
  222. MessageBox.Show("输入数据的格式不正确,请校验");
  223. }
  224. }
  225. }