FrmChangeLength.cs 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  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 System.Windows.Forms;
  9. using Core.Mes.Client.Comm.Format;
  10. using Core.Mes.Client.Comm.Server;
  11. using Core.Mes.Client.Comm.Tool;
  12. using Core.StlMes.Client.Mcp.Control;
  13. using Core.StlMes.Client.Mcp.VRP.Entity;
  14. using CoreFS.CA06;
  15. namespace Core.StlMes.Client.Mcp.VRP.Vrp
  16. {
  17. public partial class FrmChangeLength : FrmBase
  18. {
  19. private string _heatPlanID = "";
  20. public FrmChangeLength(string HeatPlanID, OpeBase _opeBase)
  21. {
  22. InitializeComponent();
  23. _heatPlanID = HeatPlanID;
  24. this.ob = _opeBase;
  25. Refresh();
  26. }
  27. private void utmMain_ToolClick(object sender, Infragistics.Win.UltraWinToolbars.ToolClickEventArgs e)
  28. {
  29. switch (e.Tool.Key)
  30. {
  31. case "Close": // ButtonTool
  32. // Place code here
  33. this.Close();
  34. break;
  35. case "ChangeLen": // ButtonTool
  36. // Place code here
  37. ugMain.UpdateData();
  38. List<ChangeLen> datasEntities = changeLenBindingSource.DataSource as List<ChangeLen>;
  39. if (datasEntities == null || !datasEntities.Any(p => p.check))
  40. {
  41. MessageBox.Show("请选择要修改的长度");
  42. return;
  43. }
  44. datasEntities = datasEntities.Where(p => p.check).ToList();
  45. if (datasEntities.Any(p => p.EditCount == null))
  46. {
  47. MessageBox.Show("请输入要修改的支数");
  48. return;
  49. }
  50. if (datasEntities.Any(p => p.EditLen == null))
  51. {
  52. MessageBox.Show("请输入要修改的长度");
  53. return;
  54. }
  55. if (datasEntities.Any(p => p.EditCount>p.OrCount))
  56. {
  57. MessageBox.Show("输入的支数不能大于原有的支数");
  58. return;
  59. }
  60. CoreClientParam ccp = new CoreClientParam();
  61. try
  62. {
  63. this.Cursor = Cursors.WaitCursor; //控制鼠标的样式为等待
  64. if (Constant.WaitingForm == null)
  65. {
  66. Constant.WaitingForm = new WaitingForm();
  67. }
  68. Constant.WaitingForm.ShowToUser = true;
  69. Constant.WaitingForm.Show();
  70. Constant.WaitingForm.Update();
  71. ccp.ServerName = "com.steering.mes.mcp.common.PlanService";
  72. ccp.MethodName = "ChangeLen";
  73. ccp.ServerParams = new Object[] { datasEntities.Select( JSONFormat.Format).ToList(),_heatPlanID, "E" };
  74. ccp = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  75. this.Cursor = Cursors.Default;
  76. Constant.WaitingForm.ShowToUser = false;
  77. Constant.WaitingForm.Close();
  78. Constant.WaitingForm = null;
  79. }
  80. catch (Exception ex)
  81. {
  82. this.Cursor = Cursors.Default;
  83. Constant.WaitingForm.ShowToUser = false;
  84. Constant.WaitingForm.Close();
  85. Constant.WaitingForm = null;
  86. }
  87. if (ccp.ReturnCode != -1)
  88. {
  89. MessageUtil.ShowTips(ccp.ReturnInfo);
  90. if (ccp.ReturnInfo.Equals("修改成功!"))
  91. {
  92. Refresh();
  93. }
  94. }
  95. break;
  96. case "Refresh": // ButtonTool
  97. // Place code here
  98. Refresh();
  99. break;
  100. }
  101. }
  102. private void Refresh()
  103. {
  104. List<PortVrpBatchSampleResultEntity> listSource = EntityHelper.GetData<PortVrpBatchSampleResultEntity>(
  105. "com.steering.mes.mcp.common.PlanService.getQueryDbkPortVrp", new object[] {_heatPlanID}, this.ob);
  106. List<ChangeLen> datasEntities = listSource.Where(p => p.MatStatus == "合格").GroupBy(p => p.ActLen).Select(p =>
  107. {
  108. ChangeLen data = new ChangeLen
  109. {
  110. OrLen = p.Key,
  111. OrCount = p.Count()
  112. };
  113. return data;
  114. }).ToList();
  115. changeLenBindingSource.DataSource = datasEntities;
  116. }
  117. private void ugMain_CellChange(object sender, Infragistics.Win.UltraWinGrid.CellEventArgs e)
  118. {
  119. if(e.Cell.Column.Key =="check") return;
  120. e.Cell.Row.Cells["check"].Value = true;
  121. }
  122. }
  123. }