FrmTpopi26.cs 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250
  1. using Core.Mes.Client.Comm.Format;
  2. using Core.Mes.Client.Comm.Server;
  3. using Core.Mes.Client.Comm.Tool;
  4. using Core.StlMes.Client.Lims.Data.PipeAndOutdec.封装类.实体类;
  5. using CoreFS.CA06;
  6. using Infragistics.Win.UltraWinEditors;
  7. using Infragistics.Win.UltraWinGrid;
  8. using System;
  9. using System.Collections;
  10. using System.Collections.Generic;
  11. using System.ComponentModel;
  12. using System.Data;
  13. using System.Drawing;
  14. using System.Linq;
  15. using System.Text;
  16. using System.Windows.Forms;
  17. namespace Core.StlMes.Client.Lims.Data.PipeAndOutdec
  18. {
  19. public partial class FrmTpopi26 : FrmBase
  20. {
  21. public FrmTpopi26()
  22. {
  23. InitializeComponent();
  24. EntityHelper.ShowGridCaption<Tpopi26Entity>(ultraGrid1.DisplayLayout.Bands[0]);
  25. }
  26. /// <summary>
  27. /// 重写基类方法
  28. /// </summary>
  29. /// <param name="sender"></param>
  30. /// <param name="ToolbarKey"></param>
  31. public override void ToolBar_Click(object sender, string ToolbarKey)
  32. {
  33. switch (ToolbarKey)
  34. {
  35. case "Query":
  36. doQuery();
  37. break;
  38. case "Add":
  39. doSave("ADD");
  40. break;
  41. case "Update":
  42. doSave("Update");
  43. break;
  44. case "Delete":
  45. doDelete();
  46. break;
  47. //case "Recover":
  48. // doNullifyOrRecover("0");
  49. // break;
  50. //case "StdCopy":
  51. // StdCopy();
  52. // break;
  53. case "Close":
  54. if (MessageUtil.ShowYesNoAndQuestion("是否确认关闭页面?") == DialogResult.Yes)
  55. {
  56. this.Close();
  57. }
  58. break;
  59. }
  60. }
  61. private void doQuery()
  62. {
  63. List<Tpopi26Entity> listSource = EntityHelper.GetData<Tpopi26Entity>(
  64. "com.steering.lims.data.pipe.Tpopi26.doQuery", new object[] { text_code.Text, text_name.Text,"" ,""}, this.ob);
  65. Tpopi26bindingSource.DataSource = listSource;
  66. //for (int i = 0; i < ultraGrid1.Rows.Count; i++)
  67. //{
  68. // UltraGridRow row = ultraGrid1.Rows[i];
  69. //}
  70. }
  71. private void doSave(string ToolbarKey)
  72. {
  73. if (text_inspectStandType.Text == null || text_inspectStandType.Text.Equals(""))
  74. {
  75. MessageUtil.ShowTips("质检标准类型不能为空!");
  76. return;
  77. }
  78. if (text_inspectStandName.Text == null || text_inspectStandName.Text.Equals(""))
  79. {
  80. MessageUtil.ShowTips("质检标准名称不能为空!");
  81. return;
  82. }
  83. if (text_standStartDate.Text == null || text_standStartDate.Text.Equals(""))
  84. {
  85. MessageUtil.ShowTips("标准开始日期不能为空!");
  86. return;
  87. }
  88. if (text_standEndDate.Text == null || text_standEndDate.Text.Equals(""))
  89. {
  90. MessageUtil.ShowTips("标准结束日期不能为空!");
  91. return;
  92. }
  93. if (text_elmCode.Text == null || text_elmCode.Text.Equals(""))
  94. {
  95. MessageUtil.ShowTips("元素代码不能为空!");
  96. return;
  97. }
  98. if (text_elmName.Text == null || text_elmName.Text.Equals(""))
  99. {
  100. MessageUtil.ShowTips("元素名称不能为空!");
  101. return;
  102. }
  103. Tpopi26Entity entity = new Tpopi26Entity();
  104. entity.InspectStandType = text_inspectStandType.Text;
  105. entity.InspectStandName = text_inspectStandName.Text;
  106. entity.StandStartDate = text_standStartDate.DateTime.ToString("yyyymmddHHmmss");
  107. entity.StandEndDate = text_standEndDate.DateTime.ToString("yyyymmddHHmmss");
  108. entity.ElmCode = text_elmCode.Text;
  109. entity.ElmName = text_elmName.Text;
  110. entity.InspectStandShort = text_inspectStandShort.Text;
  111. entity.InspectOperatType = text_InspectOperatType.Text;
  112. entity.JdeLevel = text_jdeLevel.Text;
  113. entity.InspectStandDesc = text_InspectStandDesc.Text;
  114. entity.RecCreator = UserInfo.GetUserName();
  115. entity.RecRevisor = UserInfo.GetUserName();
  116. entity.InspectStandCode = text_InspectStandCode.Text;
  117. string baseEntity = JSONFormat.Format(entity);
  118. if (ToolbarKey.Equals("ADD"))
  119. {
  120. CoreClientParam ccp = new CoreClientParam();
  121. ccp.ServerName = "com.steering.lims.data.pipe.Tpopi26";
  122. ccp.MethodName = "doAdd";
  123. ccp.ServerParams = new object[] { new ArrayList { baseEntity } };
  124. ccp = ob.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  125. if (ccp.ReturnCode != -1)
  126. {
  127. doQuery();
  128. MessageUtil.ShowTips("新增成功!");
  129. }
  130. }
  131. if (ToolbarKey.Equals("Update"))
  132. {
  133. CoreClientParam ccp = new CoreClientParam();
  134. ccp.ServerName = "com.steering.lims.data.pipe.Tpopi26";
  135. ccp.MethodName = "doUpdate";
  136. ccp.ServerParams = new object[] { new ArrayList { baseEntity } };
  137. ccp = ob.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  138. if (ccp.ReturnCode != -1)
  139. {
  140. doQuery();
  141. MessageUtil.ShowTips("保存成功!");
  142. }
  143. }
  144. }
  145. private void doUpdate()
  146. {
  147. this.ultraGrid1.UpdateData();
  148. IQueryable<UltraGridRow> checkMagRows = this.ultraGrid1.Rows.AsQueryable().Where(" CHK = 'True'");
  149. if (checkMagRows.Count() == 0)
  150. {
  151. MessageUtil.ShowTips("请选择需要修改的信息!");
  152. return;
  153. }
  154. ArrayList parmList = new ArrayList();
  155. foreach (UltraGridRow row in checkMagRows)
  156. {
  157. Tpopi26Entity entity = row.ListObject as Tpopi26Entity;
  158. if (String.IsNullOrEmpty(entity.InspectStandCode) || String.IsNullOrEmpty(entity.JdeLevel) || String.IsNullOrEmpty(entity.ElmCode))
  159. continue;
  160. //entity.RecRevisor = UserInfo.GetUserName();
  161. string baseEntity = JSONFormat.Format(entity);
  162. parmList.Add(baseEntity);
  163. }
  164. if (parmList.Count > 0)
  165. {
  166. CoreClientParam ccp = new CoreClientParam();
  167. ccp.ServerName = "com.steering.lims.data.pipe.Tpopi26";
  168. ccp.MethodName = "doUpdate";
  169. ccp.ServerParams = new object[] { parmList };
  170. ccp = ob.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  171. if (ccp.ReturnCode != -1)
  172. {
  173. doQuery();
  174. MessageUtil.ShowTips("修改成功!");
  175. }
  176. }
  177. }
  178. private void doDelete()
  179. {
  180. this.ultraGrid1.UpdateData();
  181. IQueryable<UltraGridRow> checkMagRows = this.ultraGrid1.Rows.AsQueryable().Where(" CHK = 'True'");
  182. if (checkMagRows.Count() == 0)
  183. {
  184. MessageUtil.ShowTips("请选择需要删除的信息!");
  185. return;
  186. }
  187. ArrayList parmList = new ArrayList();
  188. foreach (UltraGridRow row in checkMagRows)
  189. {
  190. Tpopi26Entity entity = row.ListObject as Tpopi26Entity;
  191. if (String.IsNullOrEmpty(entity.InspectStandCode) || String.IsNullOrEmpty(entity.JdeLevel) || String.IsNullOrEmpty(entity.ElmCode))
  192. continue;
  193. string baseEntity = JSONFormat.Format(entity);
  194. parmList.Add(baseEntity);
  195. }
  196. if (parmList.Count > 0)
  197. {
  198. CoreClientParam ccp = new CoreClientParam();
  199. ccp.ServerName = "com.steering.lims.data.pipe.Tpopi26";
  200. ccp.MethodName = "doDelete";
  201. ccp.ServerParams = new object[] { parmList };
  202. ccp = ob.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  203. if (ccp.ReturnCode != -1)
  204. {
  205. doQuery();
  206. MessageUtil.ShowTips("删除成功!");
  207. }
  208. }
  209. }
  210. private void ultraGrid1_AfterRowActivate(object sender, EventArgs e)
  211. {
  212. try
  213. {
  214. if (ultraGrid1.ActiveRow == null)
  215. return;
  216. Infragistics.Win.UltraWinGrid.UltraGridRow ulRow = ultraGrid1.ActiveRow;
  217. text_inspectStandType.Text = Convert.ToString(ulRow.Cells["InspectStandType"].Value);
  218. text_inspectStandName.Text = Convert.ToString(ulRow.Cells["InspectStandName"].Value);
  219. text_inspectStandShort.Text = Convert.ToString(ulRow.Cells["InspectStandShort"].Value);
  220. text_InspectStandCode.Text = Convert.ToString(ulRow.Cells["InspectStandCode"].Value);
  221. text_InspectOperatType.Text = Convert.ToString(ulRow.Cells["InspectOperatType"].Value);
  222. text_jdeLevel.Text = Convert.ToString(ulRow.Cells["JdeLevel"].Value);
  223. text_standStartDate.Text = Convert.ToString(ulRow.Cells["StandStartDate"].Value);
  224. text_standEndDate.Text = Convert.ToString(ulRow.Cells["StandEndDate"].Value);
  225. text_InspectStandDesc.Text = Convert.ToString(ulRow.Cells["InspectStandDesc"].Value);
  226. text_elmCode.Text = Convert.ToString(ulRow.Cells["ElmCode"].Value);
  227. text_elmName.Text = Convert.ToString(ulRow.Cells["ElmName"].Value);
  228. // text_inspectStandCode.Text = Convert.ToString(ulRow.Cells["InspectStandCode"].Value);
  229. }
  230. catch (Exception ex)
  231. {
  232. MessageBox.Show(ex.Message, "提示");
  233. }
  234. }
  235. }
  236. }