FrmControlShift.cs 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328
  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.Mcp.Treatment.Entity;
  6. using CoreFS.CA06;
  7. using Infragistics.Win;
  8. using Infragistics.Win.UltraWinGrid;
  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.IO;
  16. using System.Linq;
  17. using System.Text;
  18. using System.Windows.Forms;
  19. namespace Core.StlMes.Client.Mcp.Treatment.HeatTreatment
  20. {
  21. public partial class FrmControlShift : FrmBase
  22. {
  23. public FrmControlShift()
  24. {
  25. InitializeComponent();
  26. }
  27. private string[] plineCode = null;
  28. private string fileName = "";//路径
  29. private void FrmControlShift_Load(object sender, EventArgs e)
  30. {
  31. EntityHelper.ShowGridCaption<HttControlShiftEntity>(ultraGrid1.DisplayLayout.Bands[0]);
  32. plineCode = Core.StlMes.Client.Mcp.Treatment.HeatTreatment.comm.GetPlineCode(ValidDataPurviewIds, CustomInfo, ob);
  33. comm.InitDropPlinePower(CustomInfo, txtPline, this.ValidDataPurviewIds, this.ob);
  34. }
  35. /// <summary>
  36. /// 重写基类方法
  37. /// </summary>
  38. /// <param name="sender"></param>
  39. /// <param name="ToolbarKey"></param>
  40. public override void ToolBar_Click(object sender, string ToolbarKey)
  41. {
  42. switch (ToolbarKey)
  43. {
  44. case "DoQuery":
  45. QuerySinglePlan();
  46. break;
  47. case "DoSave":
  48. doSave();
  49. break;
  50. case "DoUpdate":
  51. doUpdate();
  52. break;
  53. case "CancelSignature":
  54. cancelSignature();
  55. break;
  56. case "Close":
  57. this.Close();
  58. break;
  59. }
  60. }
  61. private void QuerySinglePlan()
  62. {
  63. List<HttControlShiftEntity> listSource = EntityHelper.GetData<HttControlShiftEntity>(
  64. "com.steering.mes.mcp.heatTreatment.HttControlShift.doQuery", new object[] { plineCode }, this.ob);
  65. HttControlShiftEntitybindingSource1.DataSource = listSource;
  66. GridHelper.RefreshAndAutoSize(this.ultraGrid1);
  67. foreach (UltraGridRow ugr in ultraGrid1.Rows)
  68. {
  69. ugr.Cells["PlineCode"].Appearance.BackColor = Color.Transparent;
  70. ugr.Cells["PlineCode"].Appearance.BackHatchStyle = BackHatchStyle.Default;
  71. ugr.Cells["PlineCode"].Activation = Infragistics.Win.UltraWinGrid.Activation.ActivateOnly;
  72. ugr.Cells["proBc"].Appearance.BackColor = Color.Transparent;
  73. ugr.Cells["proBc"].Appearance.BackHatchStyle = BackHatchStyle.Default;
  74. ugr.Cells["proBc"].Activation = Infragistics.Win.UltraWinGrid.Activation.ActivateOnly;
  75. }
  76. }
  77. /// <summary>
  78. /// 新增
  79. /// </summary>
  80. private void doSave()
  81. {
  82. this.ultraGrid1.UpdateData();
  83. ArrayList list = new ArrayList();
  84. IQueryable<UltraGridRow> checkRows = this.ultraGrid1.Rows.AsQueryable().Where(" CHK = 'True'");
  85. if (checkRows.Count() == 0)
  86. {
  87. MessageUtil.ShowTips("请勾选要新增的信息");
  88. return;
  89. }
  90. foreach (UltraGridRow row in checkRows)
  91. {
  92. HttControlShiftEntity hsEntity = (HttControlShiftEntity)row.ListObject;
  93. if (hsEntity.PlineCode.Equals(""))
  94. {
  95. MessageUtil.ShowTips("产线不能为空");
  96. return;
  97. }
  98. if (hsEntity.ProBc.Equals(""))
  99. {
  100. MessageUtil.ShowTips("班次不能为空");
  101. return;
  102. }
  103. //else if (hsEntity.ProBc.Equals("早"))
  104. //{
  105. // hsEntity.ProBc = "1";
  106. //}
  107. //else if (hsEntity.ProBc.Equals("中"))
  108. //{
  109. // hsEntity.ProBc = "2";
  110. //}
  111. //else if (hsEntity.ProBc.Equals("晚"))
  112. //{
  113. // hsEntity.ProBc = "3";
  114. //}
  115. if (hsEntity.LastBc.Equals(""))
  116. {
  117. MessageUtil.ShowTips("上一班次不能为空");
  118. return;
  119. }
  120. //else if (hsEntity.LastBc.Equals("早"))
  121. //{
  122. // hsEntity.LastBc = "1";
  123. //}
  124. //else if (hsEntity.LastBc.Equals("中"))
  125. //{
  126. // hsEntity.LastBc = "2";
  127. //}
  128. //else if (hsEntity.LastBc.Equals("晚"))
  129. //{
  130. // hsEntity.LastBc = "3";
  131. //}
  132. string httEntity = JSONFormat.Format(hsEntity);
  133. list.Add(httEntity);
  134. DataTable dt = ServerHelper.GetData("com.steering.mes.mcp.heatTreatment.HttControlShift.getSameData", new object[] { hsEntity.PlineCode, hsEntity.ProBc}, ob);
  135. if (dt.Rows.Count > 0) { MessageUtil.ShowTips("已存在数据,不能进行此操作!"); return; }
  136. }
  137. CoreClientParam ccp = new CoreClientParam();
  138. ccp.ServerName = "com.steering.mes.mcp.heatTreatment.HttControlShift";
  139. ccp.MethodName = "doSave";
  140. ccp.ServerParams = new object[] { list };
  141. ccp = ob.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  142. if (ccp.ReturnCode != -1)
  143. {
  144. if (ccp.ReturnInfo.Equals("新增成功!"))
  145. {
  146. QuerySinglePlan();
  147. MessageUtil.ShowTips(ccp.ReturnInfo);
  148. }
  149. else
  150. {
  151. MessageUtil.ShowTips(ccp.ReturnInfo);
  152. }
  153. }
  154. }
  155. /// <summary>
  156. /// 修改
  157. /// </summary>
  158. private void doUpdate()
  159. {
  160. this.ultraGrid1.UpdateData();
  161. ArrayList list = new ArrayList();
  162. IQueryable<UltraGridRow> checkRows = this.ultraGrid1.Rows.AsQueryable().Where(" CHK = 'True'");
  163. if (checkRows.Count() == 0)
  164. {
  165. MessageUtil.ShowTips("请勾选要修改的信息");
  166. return;
  167. }
  168. foreach (UltraGridRow row in checkRows)
  169. {
  170. HttControlShiftEntity hsEntity = (HttControlShiftEntity)row.ListObject;
  171. if (hsEntity.PlineCode.Equals(""))
  172. {
  173. MessageUtil.ShowTips("产线不能为空");
  174. return;
  175. }
  176. if (hsEntity.ProBc.Equals(""))
  177. {
  178. MessageUtil.ShowTips("班次不能为空");
  179. return;
  180. }
  181. //else if (hsEntity.ProBc.Equals("早"))
  182. //{
  183. // hsEntity.ProBc = "1";
  184. //}
  185. //else if (hsEntity.ProBc.Equals("中"))
  186. //{
  187. // hsEntity.ProBc = "2";
  188. //}
  189. //else if (hsEntity.ProBc.Equals("晚"))
  190. //{
  191. // hsEntity.ProBc = "3";
  192. //}
  193. if (hsEntity.LastBc.Equals(""))
  194. {
  195. MessageUtil.ShowTips("上一班次不能为空");
  196. return;
  197. }
  198. //else if (hsEntity.LastBc.Equals("早"))
  199. //{
  200. // hsEntity.LastBc = "1";
  201. //}
  202. //else if (hsEntity.LastBc.Equals("中"))
  203. //{
  204. // hsEntity.LastBc = "2";
  205. //}
  206. //else if (hsEntity.LastBc.Equals("晚"))
  207. //{
  208. // hsEntity.LastBc = "3";
  209. //}
  210. string httEntity = JSONFormat.Format(hsEntity);
  211. list.Add(httEntity);
  212. }
  213. CoreClientParam ccp = new CoreClientParam();
  214. ccp.ServerName = "com.steering.mes.mcp.heatTreatment.HttControlShift";
  215. ccp.MethodName = "doUpdate";
  216. ccp.ServerParams = new object[] { list };
  217. ccp = ob.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  218. if (ccp.ReturnCode != -1)
  219. {
  220. if (ccp.ReturnInfo.Equals("修改成功!"))
  221. {
  222. QuerySinglePlan();
  223. MessageUtil.ShowTips(ccp.ReturnInfo);
  224. }
  225. else
  226. {
  227. MessageUtil.ShowTips(ccp.ReturnInfo);
  228. }
  229. }
  230. }
  231. /// <summary>
  232. /// 删除
  233. /// </summary>
  234. private void cancelSignature()
  235. {
  236. this.ultraGrid1.UpdateData();
  237. ArrayList list = new ArrayList();
  238. IQueryable<UltraGridRow> checkRows = this.ultraGrid1.Rows.AsQueryable().Where(" CHK = 'True'");
  239. if (checkRows.Count() == 0)
  240. {
  241. MessageUtil.ShowTips("请勾选要删除的信息");
  242. return;
  243. }
  244. foreach (UltraGridRow row in checkRows)
  245. {
  246. HttControlShiftEntity hsEntity = (HttControlShiftEntity)row.ListObject;
  247. if (hsEntity.PlineCode.Equals(""))
  248. {
  249. MessageUtil.ShowTips("产线不能为空");
  250. return;
  251. }
  252. if (hsEntity.ProBc.Equals(""))
  253. {
  254. MessageUtil.ShowTips("班次不能为空");
  255. return;
  256. }
  257. else if (hsEntity.ProBc.Equals("早"))
  258. {
  259. hsEntity.ProBc = "1";
  260. }
  261. else if (hsEntity.ProBc.Equals("中"))
  262. {
  263. hsEntity.ProBc = "2";
  264. }
  265. else if (hsEntity.ProBc.Equals("晚"))
  266. {
  267. hsEntity.ProBc = "3";
  268. }
  269. if (hsEntity.LastBc.Equals(""))
  270. {
  271. MessageUtil.ShowTips("上一班次不能为空");
  272. return;
  273. }
  274. else if (hsEntity.LastBc.Equals("早"))
  275. {
  276. hsEntity.LastBc = "1";
  277. }
  278. else if (hsEntity.LastBc.Equals("中"))
  279. {
  280. hsEntity.LastBc = "2";
  281. }
  282. else if (hsEntity.LastBc.Equals("晚"))
  283. {
  284. hsEntity.LastBc = "3";
  285. }
  286. string httEntity = JSONFormat.Format(hsEntity);
  287. list.Add(httEntity);
  288. }
  289. CoreClientParam ccp = new CoreClientParam();
  290. ccp.ServerName = "com.steering.mes.mcp.heatTreatment.HttControlShift";
  291. ccp.MethodName = "doDelete";
  292. ccp.ServerParams = new object[] { list };
  293. ccp = ob.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  294. if (ccp.ReturnCode != -1)
  295. {
  296. if (ccp.ReturnInfo.Equals("删除成功!"))
  297. {
  298. QuerySinglePlan();
  299. MessageUtil.ShowTips(ccp.ReturnInfo);
  300. }
  301. else
  302. {
  303. MessageUtil.ShowTips(ccp.ReturnInfo);
  304. }
  305. }
  306. }
  307. private void ultraGrid1_CellChange(object sender, CellEventArgs e)
  308. {
  309. if (e.Cell.Column.Key == "PlineCode")
  310. {
  311. e.Cell.Row.Cells["PlineName"].Value = e.Cell.Text;
  312. }
  313. }
  314. }
  315. }