ComBaseWbsFrm.cs 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261
  1. using Core.Mes.Client.Comm.Control;
  2. using Core.Mes.Client.Comm.Format;
  3. using Core.Mes.Client.Comm.Server;
  4. using Core.Mes.Client.Comm.Tool;
  5. using Core.StlMes.Client.Qcm.model;
  6. using CoreFS.CA06;
  7. using Infragistics.Win.UltraWinGrid;
  8. using Newtonsoft.Json;
  9. using System;
  10. using System.Collections;
  11. using System.Collections.Generic;
  12. using System.ComponentModel;
  13. using System.Data;
  14. using System.Drawing;
  15. using System.Linq;
  16. using System.Text;
  17. using System.Windows.Forms;
  18. namespace Core.StlMes.Client.Qcm
  19. {
  20. public partial class ComBaseWbsFrm : FrmBase
  21. {
  22. ComBaseWbsEntity wbsEntity;
  23. public ComBaseWbsEntity WbsEntity
  24. {
  25. get { return wbsEntity; }
  26. set { wbsEntity = value; }
  27. }
  28. public ComBaseWbsFrm()
  29. {
  30. InitializeComponent();
  31. EntityHelper.ShowGridCaption<ComBaseWbsEntity>(ultraGrid1.DisplayLayout.Bands[0]);
  32. }
  33. public ComBaseWbsFrm(OpeBase ob)
  34. {
  35. this.ob = ob;
  36. InitializeComponent();
  37. EntityHelper.ShowGridCaption<ComBaseWbsEntity>(ultraGrid1.DisplayLayout.Bands[0]);
  38. ultraToolbarsManager1.Visible = true;
  39. GridHelper.HidenColumns(ultraGrid1.DisplayLayout.Bands[0], "CHK");
  40. }
  41. public override void ToolBar_Click(object sender, string ToolbarKey)
  42. {
  43. base.ToolBar_Click(sender, ToolbarKey);
  44. switch (ToolbarKey)
  45. {
  46. case "Query":
  47. Query();
  48. break;
  49. case "Add":
  50. Add();
  51. break;
  52. case "Modify":
  53. Modify();
  54. break;
  55. case "Delete":
  56. Delete();
  57. break;
  58. case "Resume":
  59. Resume();
  60. break;
  61. case "Close":
  62. this.Close();
  63. break;
  64. }
  65. }
  66. private void Resume()
  67. {
  68. this.ultraGrid1.UpdateData();
  69. IQueryable<UltraGridRow> checkRows = this.ultraGrid1.Rows.AsQueryable().Where(a => a.GetValue("CHK") == "True");
  70. ArrayList parms = new ArrayList();
  71. foreach (UltraGridRow row in checkRows)
  72. {
  73. ComBaseWbsEntity parm = row.ListObject as ComBaseWbsEntity;
  74. parm.UpdateName = this.UserInfo.GetUserName();
  75. parms.Add(JSONFormat.Format(parm));
  76. }
  77. if (MessageUtil.ShowYesNoAndQuestion("是否确认恢复记录?") == DialogResult.No)
  78. {
  79. return;
  80. }
  81. List<string> jsons = new List<string>();
  82. CoreClientParam ccp = new CoreClientParam();
  83. ccp.ServerName = "com.steering.pss.qcm.DAL.ComBaseWbsDAL";
  84. ccp.MethodName = "UpdateValidflag";
  85. ccp.ServerParams = new object[] { parms, "1" };
  86. ccp.IfShowErrMsg = false;
  87. ccp = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  88. if (ccp != null)
  89. {
  90. if (ccp.ReturnCode == -1)
  91. {
  92. MessageUtil.ShowWarning(ccp.ReturnInfo);
  93. return;
  94. }
  95. MessageUtil.ShowTips("作废成功!");
  96. Query();
  97. }
  98. }
  99. private void Delete()
  100. {
  101. this.ultraGrid1.UpdateData();
  102. IQueryable<UltraGridRow> checkRows = this.ultraGrid1.Rows.AsQueryable().Where(a => a.GetValue("CHK") == "True");
  103. ArrayList parms = new ArrayList();
  104. foreach (UltraGridRow row in checkRows)
  105. {
  106. ComBaseWbsEntity parm = row.ListObject as ComBaseWbsEntity;
  107. parm.DeleteName = this.UserInfo.GetUserName();
  108. parms.Add(JSONFormat.Format(parm));
  109. }
  110. if (MessageUtil.ShowYesNoAndQuestion("是否确认作废记录?") == DialogResult.No)
  111. {
  112. return;
  113. }
  114. List<string> jsons = new List<string>();
  115. CoreClientParam ccp = new CoreClientParam();
  116. ccp.ServerName = "com.steering.pss.qcm.DAL.ComBaseWbsDAL";
  117. ccp.MethodName = "UpdateValidflag";
  118. ccp.ServerParams = new object[] { parms,"0" };
  119. ccp.IfShowErrMsg = false;
  120. ccp = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  121. if (ccp != null)
  122. {
  123. if (ccp.ReturnCode == -1)
  124. {
  125. MessageUtil.ShowWarning(ccp.ReturnInfo);
  126. return;
  127. }
  128. MessageUtil.ShowTips("作废成功!");
  129. Query();
  130. }
  131. }
  132. private void Modify()
  133. {
  134. this.ultraGrid1.UpdateData();
  135. IQueryable<UltraGridRow> checkRows = this.ultraGrid1.Rows.AsQueryable().Where(a => a.GetValue("CHK") == "True");
  136. ArrayList parms = new ArrayList();
  137. foreach (UltraGridRow row in checkRows)
  138. {
  139. ComBaseWbsEntity parm = row.ListObject as ComBaseWbsEntity;
  140. List<ComBaseWbsEntity> list = EntityHelper.GetData<ComBaseWbsEntity>(
  141. "com.steering.pss.qcm.DAL.ComBaseWbsDAL.QueryByPk", new object[] { parm.WbsCode }, this.ob);
  142. if (list == null || list.Count <= 0)
  143. {
  144. MessageUtil.ShowWarning(parm.WbsCode + ",wbs号不存在,无法修改!");
  145. return;
  146. }
  147. parm.UpdateName = this.UserInfo.GetUserName();
  148. parms.Add(JSONFormat.Format(parm));
  149. }
  150. if (MessageUtil.ShowYesNoAndQuestion("是否确认修改记录?") == DialogResult.No)
  151. {
  152. return;
  153. }
  154. List<string> jsons = new List<string>();
  155. CoreClientParam ccp = new CoreClientParam();
  156. ccp.ServerName = "com.steering.pss.qcm.DAL.ComBaseWbsDAL";
  157. ccp.MethodName = "Update";
  158. ccp.ServerParams = new object[] { parms };
  159. ccp.IfShowErrMsg = false;
  160. ccp = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  161. if (ccp != null)
  162. {
  163. if (ccp.ReturnCode == -1)
  164. {
  165. MessageUtil.ShowWarning(ccp.ReturnInfo);
  166. return;
  167. }
  168. MessageUtil.ShowTips("修改成功!");
  169. Query();
  170. }
  171. }
  172. private void Add()
  173. {
  174. this.ultraGrid1.UpdateData();
  175. IQueryable<UltraGridRow> checkRows = this.ultraGrid1.Rows.AsQueryable().Where(a => a.GetValue("CHK") == "True");
  176. ArrayList parms = new ArrayList();
  177. foreach (UltraGridRow row in checkRows)
  178. {
  179. ComBaseWbsEntity parm = row.ListObject as ComBaseWbsEntity;
  180. List<ComBaseWbsEntity> list = EntityHelper.GetData<ComBaseWbsEntity>(
  181. "com.steering.pss.qcm.DAL.ComBaseWbsDAL.QueryByPk", new object[] { parm.WbsCode }, this.ob);
  182. if (list != null && list.Count > 0)
  183. {
  184. MessageUtil.ShowWarning(parm.WbsCode + ",wbs号已存在,无法新增!");
  185. return;
  186. }
  187. parm.CreateName = this.UserInfo.GetUserName();
  188. parms.Add(JSONFormat.Format(parm));
  189. }
  190. if (MessageUtil.ShowYesNoAndQuestion("是否确认新增记录?") == DialogResult.No)
  191. {
  192. return;
  193. }
  194. List<string> jsons = new List<string>();
  195. CoreClientParam ccp = new CoreClientParam();
  196. ccp.ServerName = "com.steering.pss.qcm.DAL.ComBaseWbsDAL";
  197. ccp.MethodName = "Insert";
  198. ccp.ServerParams = new object[] { parms };
  199. ccp.IfShowErrMsg = false;
  200. ccp = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  201. if (ccp != null)
  202. {
  203. if (ccp.ReturnCode == -1)
  204. {
  205. MessageUtil.ShowWarning(ccp.ReturnInfo);
  206. return;
  207. }
  208. MessageUtil.ShowTips("新增成功!");
  209. Query();
  210. }
  211. }
  212. private void Query()
  213. {
  214. string wbsName = labelTextBox1.Text.Trim();
  215. string flag = ultraCheckEditor1.Checked ? "0" : "1";
  216. List<ComBaseWbsEntity> listSource = EntityHelper.GetData<ComBaseWbsEntity>(
  217. "com.steering.pss.qcm.DAL.ComBaseWbsDAL.Query", new object[] { wbsName, flag }, this.ob);
  218. comBaseWbsEntityBindingSource.DataSource = listSource;
  219. }
  220. private void ComBaseWbsFrm_Load(object sender, EventArgs e)
  221. {
  222. Query();
  223. }
  224. private void ultraToolbarsManager1_ToolClick(object sender, Infragistics.Win.UltraWinToolbars.ToolClickEventArgs e)
  225. {
  226. switch (e.Tool.Key)
  227. {
  228. case "查询":
  229. Query();
  230. break;
  231. case "确认":
  232. Submit();
  233. break;
  234. case "关闭":
  235. this.Close();
  236. break;
  237. }
  238. }
  239. private void Submit()
  240. {
  241. WbsEntity = this.ultraGrid1.ActiveRow.ListObject as ComBaseWbsEntity;
  242. this.DialogResult = System.Windows.Forms.DialogResult.OK;
  243. }
  244. }
  245. }