frmEntrustBCData.cs 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Windows.Forms;
  5. using Core.Mes.Client.Comm.Control;
  6. using Core.Mes.Client.Comm.Tool;
  7. using Core.StlMes.Client.Mcp.Treatment.Entity;
  8. using CoreFS.CA06;
  9. using Infragistics.Win.UltraWinGrid;
  10. namespace Core.StlMes.Client.Mcp.Treatment.HeatTreatment
  11. {
  12. public partial class frmEntrustBCData : FrmBase
  13. {
  14. protected string _plineCode = "";
  15. private string[] plineCodes = {};
  16. public frmEntrustBCData()
  17. {
  18. InitializeComponent();
  19. IsLoadUserView = true;
  20. }
  21. public override void ToolBar_Click(object sender, string ToolbarKey)
  22. {
  23. switch (ToolbarKey)
  24. {
  25. case "Query":
  26. QueryOffline();
  27. break;
  28. case "Apply":
  29. Apply();
  30. break;
  31. case "CancelApply":
  32. CancelApply();
  33. break;
  34. case "Close":
  35. Close();
  36. break;
  37. case "Export":
  38. Export();
  39. break;
  40. }
  41. }
  42. private void Export()
  43. {
  44. string title = "";
  45. title += "半成品余材明细";
  46. GridHelper.ulGridToExcel(ultraGrid1, title);
  47. }
  48. protected override void OnLoad(EventArgs e)
  49. {
  50. base.OnLoad(e);
  51. StartTime.Value =
  52. DateTime.Parse(DateTime.Now.AddDays(1 - DateTime.Now.Day).AddDays(-1).ToString("yyyy-MM-dd 21:00"));
  53. EndTime.Value =
  54. DateTime.Parse(
  55. DateTime.Now.AddDays(1 - DateTime.Now.Day).AddMonths(1).AddDays(-1).ToString("yyyy-MM-dd 20:59"));
  56. plineCodes = comm.GetPlineCodeWithOther(ValidDataPurviewIds, ob);
  57. EntityHelper.ShowGridCaption<OfflineResultEntity>(ultraGrid1.DisplayLayout.Bands[0]);
  58. comm.RefreshAndAutoSize(ultraGrid1, true);
  59. }
  60. private void QueryOffline()
  61. {
  62. var wf = new WaitingForm2("正在查询,请稍候....");
  63. try
  64. {
  65. Cursor = Cursors.WaitCursor;
  66. var startTime = "";
  67. var endTime = "";
  68. var judgeNo = "";
  69. if (chkTim.Checked)
  70. if (DateTime.Parse(StartTime.Value.ToString()) > DateTime.Parse(EndTime.Value.ToString()))
  71. {
  72. MessageUtil.ShowTips("选择时间区间错误,请重新选择!");
  73. return;
  74. }
  75. else
  76. {
  77. startTime = StartTime.Value.ToString("yyyy-MM-dd HH:mm:ss");
  78. endTime = EndTime.Value.ToString("yyyy-MM-dd HH:mm:ss");
  79. }
  80. // else if (!chkJugeHeatNo.Checked)
  81. // if (MessageUtil.ShowYesNoAndQuestion("未加时间条件,查询时间可能比较长,请确定是否继续查询?") == DialogResult.No) return;
  82. if (chkJugeHeatNo.Checked)
  83. judgeNo = txtJugeNo.Text.Trim();
  84. List<OfflineResultEntity> listSource = EntityHelper.GetData<OfflineResultEntity>(
  85. "com.steering.mes.mcp.common.frmEntrust.doQueryBc",
  86. new object[] {startTime, endTime, judgeNo, plineCodes, upStatus0.CheckedItem.DataValue.ToString()}, ob);
  87. offlineResultEntityBindingSource.DataSource = listSource;
  88. comm.RefreshAndAutoSize(ultraGrid1, new[] {"StdName"});
  89. }
  90. catch (Exception ex)
  91. {
  92. if (ex.Message.ToString2() != "")
  93. MessageBox.Show(ex.Message);
  94. }
  95. finally
  96. {
  97. wf.Close();
  98. Cursor = Cursors.Default;
  99. }
  100. }
  101. private void Apply()
  102. {
  103. ultraGrid1.UpdateData();
  104. var list = offlineResultEntityBindingSource.DataSource as List<OfflineResultEntity>;
  105. list = list.Where(p => p.Chk).ToList();
  106. if (!list.Any())
  107. {
  108. MessageBox.Show("请选择需要申请的数据");
  109. return;
  110. }
  111. if (list.Select(p => p.Process).Distinct().Count() != 1)
  112. {
  113. MessageBox.Show("只能同时申请同工序的数据");
  114. return;
  115. }
  116. if (list.Select(p => p.PlineCode).Distinct().Count() != 1)
  117. {
  118. MessageBox.Show("只能同时申请同产线的数据");
  119. return;
  120. }
  121. if (
  122. list.Any(
  123. p =>
  124. (!string.IsNullOrWhiteSpace(p.Type) && (p.Type != "BC") && (p.Type != "ZC") && (p.Type != "20") && (p.Type != "40") && (p.Type != "60")) ||
  125. ((p.OfflineNum ?? 0) <= 0)))
  126. {
  127. MessageBox.Show("已申请的数据无法再次申请");
  128. return;
  129. }
  130. var FrmEntrustApply = new FrmEntrustApplyNew(ob, FrmEntrustApplyNew.ApplyType.ApplyProject,
  131. list, list[0].Process, list[0].PlineCode, null, null, this.CustomInfo.ToString());
  132. if (FrmEntrustApply.ShowDialog() == DialogResult.OK)
  133. {
  134. // var Type = FrmEntrustApply.Type;
  135. // var Note = FrmEntrustApply.Note;
  136. FrmEntrustApply.Dispose();
  137. QueryOffline();
  138. }
  139. }
  140. private void CancelApply()
  141. {
  142. ultraGrid1.UpdateData();
  143. var list = offlineResultEntityBindingSource.DataSource as List<OfflineResultEntity>;
  144. list = list.Where(p => p.Chk).ToList();
  145. if (!list.Any())
  146. {
  147. MessageBox.Show("请选择需要撤销申请的数据");
  148. return;
  149. }
  150. if (list.Select(p => p.Process).Distinct().Count() != 1)
  151. {
  152. MessageBox.Show("只能同时撤销申请同工序的数据");
  153. return;
  154. }
  155. if (list.Any(p => p.Type != "00"))
  156. {
  157. MessageBox.Show("只能撤销已申请的数据!");
  158. return;
  159. }
  160. if (MessageUtil.ShowYesNoAndQuestion("是否撤销申请委外?") == DialogResult.No)
  161. return;
  162. var ccp = new CoreClientParam();
  163. ccp.ServerName = "com.steering.mes.mcp.common.frmEntrust";
  164. ccp.MethodName = "CancelApply";
  165. ccp.ServerParams = new object[]
  166. {
  167. list.Select(p => p.SubcontractNo).Distinct().ToList(), list[0].Process
  168. };
  169. ccp = ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  170. if (ccp.ReturnCode != -1)
  171. {
  172. MessageUtil.ShowTips(ccp.ReturnInfo);
  173. if (ccp.ReturnInfo.Equals("撤销申请成功!"))
  174. QueryOffline();
  175. }
  176. }
  177. public void SetFillerHeaderCheck(UltraGrid ug, string name)
  178. {
  179. ug.DisplayLayout.Bands[0].Columns[name].Header.CheckBoxVisibility = HeaderCheckBoxVisibility.Always;
  180. ug.DisplayLayout.Bands[0].Columns[name].Header.CheckBoxSynchronization = HeaderCheckBoxSynchronization.None;
  181. var _isInCellChange = 0;
  182. ug.AfterHeaderCheckStateChanged += (sender, e) =>
  183. {
  184. if (_isInCellChange > 0) return; //更新状态时 不执行全选或全不选
  185. var isChecked = e.Column.GetHeaderCheckedState(e.Rows) == CheckState.Checked;
  186. foreach (var filteredInNonGroupByRow in e.Rows.GetFilteredInNonGroupByRows())
  187. filteredInNonGroupByRow.Cells[e.Column].SetValue(isChecked, false);
  188. };
  189. ug.CellChange += (sender, e) =>
  190. {
  191. ug.UpdateData();
  192. if (e.Cell.Column.Key == name)
  193. {
  194. _isInCellChange++;
  195. var allTrue = true;
  196. var allFalse = true;
  197. foreach (var row in ug.Rows.GetFilteredInNonGroupByRows())
  198. if ((bool) row.Cells[name].Value)
  199. allFalse = false;
  200. else
  201. allTrue = false;
  202. if (allFalse)
  203. ug.DisplayLayout.Bands[0].Columns[name].SetHeaderCheckedState(ug.Rows, false);
  204. else if (allTrue)
  205. ug.DisplayLayout.Bands[0].Columns[name].SetHeaderCheckedState(ug.Rows, true);
  206. else
  207. ug.DisplayLayout.Bands[0].Columns[name].SetHeaderCheckedState(ug.Rows, false); // 当前版本无法直接更新Indeterminate 状态 改成不勾选
  208. _isInCellChange--;
  209. }
  210. };
  211. ug.AfterRowFilterChanged += (sender, e) =>
  212. {
  213. _isInCellChange++;
  214. var allTrue = true;
  215. var allFalse = true;
  216. foreach (var row in ug.Rows.GetFilteredInNonGroupByRows())
  217. if ((bool) row.Cells[name].Value)
  218. allFalse = false;
  219. else
  220. allTrue = false;
  221. if (allFalse)
  222. ug.DisplayLayout.Bands[0].Columns[name].SetHeaderCheckedState(ug.Rows, false);
  223. else if (allTrue)
  224. ug.DisplayLayout.Bands[0].Columns[name].SetHeaderCheckedState(ug.Rows, true);
  225. else
  226. ug.DisplayLayout.Bands[0].Columns[name].SetHeaderCheckedState(ug.Rows, false); // 当前版本无法直接更新Indeterminate 状态 改成不勾选
  227. _isInCellChange--;
  228. };
  229. }
  230. }
  231. }