FrmTpopi24.cs 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  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 FrmTpopi24 : FrmBase
  20. {
  21. public FrmTpopi24()
  22. {
  23. InitializeComponent();
  24. EntityHelper.ShowGridCaption<Tpopi24Entity>(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. doAdd();
  40. break;
  41. case "Update":
  42. doUpdate();
  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<Tpopi24Entity> listSource = EntityHelper.GetData<Tpopi24Entity>(
  64. "com.steering.lims.data.pipe.Tpopi24.doQuery", new object[] { text_code.Text, text_name.Text }, this.ob);
  65. Tpopi24bindingSource.DataSource = listSource;
  66. //for (int i = 0; i < ultraGrid1.Rows.Count; i++)
  67. //{
  68. // UltraGridRow row = ultraGrid1.Rows[i];
  69. //}
  70. }
  71. private void doAdd()
  72. {
  73. this.ultraGrid1.UpdateData();
  74. IQueryable<UltraGridRow> checkMagRows = this.ultraGrid1.Rows.AsQueryable().Where(" CHK = 'True'");
  75. if (checkMagRows.Count() == 0)
  76. {
  77. MessageUtil.ShowTips("请选择需要新增的信息!");
  78. return;
  79. }
  80. ArrayList parmList = new ArrayList();
  81. foreach (UltraGridRow row in checkMagRows)
  82. {
  83. Tpopi24Entity entity = row.ListObject as Tpopi24Entity;
  84. if (String.IsNullOrEmpty(entity.ElmCode))
  85. {
  86. MessageUtil.ShowTips("请输入试验号");
  87. return;
  88. }
  89. if (String.IsNullOrEmpty(entity.ElmName))
  90. {
  91. MessageUtil.ShowTips("请输入试验名称");
  92. return;
  93. }
  94. //if (!String.IsNullOrEmpty(entity.Id))
  95. // continue;
  96. entity.RecCreator = UserInfo.GetUserName();
  97. //entity.PhyDept = UserInfo.GetDeptid();
  98. // entity. = UserInfo.GetDepartment();
  99. string baseEntity = JSONFormat.Format(entity);
  100. parmList.Add(baseEntity);
  101. }
  102. if (parmList.Count > 0)
  103. {
  104. CoreClientParam ccp = new CoreClientParam();
  105. ccp.ServerName = "com.steering.lims.data.pipe.Tpopi24";
  106. ccp.MethodName = "doAdd";
  107. ccp.ServerParams = new object[] { parmList };
  108. ccp = ob.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  109. if (ccp.ReturnCode != -1)
  110. {
  111. doQuery();
  112. MessageUtil.ShowTips("新增成功!");
  113. }
  114. }
  115. }
  116. private void doUpdate()
  117. {
  118. this.ultraGrid1.UpdateData();
  119. IQueryable<UltraGridRow> checkMagRows = this.ultraGrid1.Rows.AsQueryable().Where(" CHK = 'True'");
  120. if (checkMagRows.Count() == 0)
  121. {
  122. MessageUtil.ShowTips("请选择需要修改的信息!");
  123. return;
  124. }
  125. ArrayList parmList = new ArrayList();
  126. foreach (UltraGridRow row in checkMagRows)
  127. {
  128. Tpopi24Entity entity = row.ListObject as Tpopi24Entity;
  129. if (String.IsNullOrEmpty(entity.ObjId))
  130. continue;
  131. entity.RecRevisor = UserInfo.GetUserName();
  132. string baseEntity = JSONFormat.Format(entity);
  133. parmList.Add(baseEntity);
  134. }
  135. if (parmList.Count > 0)
  136. {
  137. CoreClientParam ccp = new CoreClientParam();
  138. ccp.ServerName = "com.steering.lims.data.pipe.Tpopi24";
  139. ccp.MethodName = "doUpdate";
  140. ccp.ServerParams = new object[] { parmList };
  141. ccp = ob.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  142. if (ccp.ReturnCode != -1)
  143. {
  144. doQuery();
  145. MessageUtil.ShowTips("修改成功!");
  146. }
  147. }
  148. }
  149. private void doDelete()
  150. {
  151. this.ultraGrid1.UpdateData();
  152. IQueryable<UltraGridRow> checkMagRows = this.ultraGrid1.Rows.AsQueryable().Where(" CHK = 'True'");
  153. if (checkMagRows.Count() == 0)
  154. {
  155. MessageUtil.ShowTips("请选择需要删除的信息!");
  156. return;
  157. }
  158. ArrayList parmList = new ArrayList();
  159. foreach (UltraGridRow row in checkMagRows)
  160. {
  161. Tpopi24Entity entity = row.ListObject as Tpopi24Entity;
  162. if (String.IsNullOrEmpty(entity.ObjId))
  163. continue;
  164. // entity.RecRevisor = UserInfo.GetUserName();
  165. string baseEntity = JSONFormat.Format(entity);
  166. parmList.Add(baseEntity);
  167. }
  168. if (parmList.Count > 0)
  169. {
  170. CoreClientParam ccp = new CoreClientParam();
  171. ccp.ServerName = "com.steering.lims.data.pipe.Tpopi24";
  172. ccp.MethodName = "doDelete";
  173. ccp.ServerParams = new object[] { parmList };
  174. ccp = ob.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  175. if (ccp.ReturnCode != -1)
  176. {
  177. doQuery();
  178. MessageUtil.ShowTips("删除成功!");
  179. }
  180. }
  181. }
  182. private void FrmTpopi24_Load(object sender, EventArgs e)
  183. {
  184. doQuery();
  185. }
  186. }
  187. }