frmEntrustOfflineData.cs 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296
  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 frmEntrustOfflineData : FrmBase
  13. {
  14. protected string _plineCode = "";
  15. private string[] plineCodes = {};
  16. public frmEntrustOfflineData()
  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. var flagStove = "";
  70. if (chkTim.Checked)
  71. if (DateTime.Parse(StartTime.Value.ToString()) > DateTime.Parse(EndTime.Value.ToString()))
  72. {
  73. MessageUtil.ShowTips("选择时间区间错误,请重新选择!");
  74. return;
  75. }
  76. else
  77. {
  78. startTime = StartTime.Value.ToString("yyyy-MM-dd HH:mm:ss");
  79. endTime = EndTime.Value.ToString("yyyy-MM-dd HH:mm:ss");
  80. }
  81. // else if (!chkJugeHeatNo.Checked)
  82. // if (MessageUtil.ShowYesNoAndQuestion("未加时间条件,查询时间可能比较长,请确定是否继续查询?") == DialogResult.No) return;
  83. if (chkJugeHeatNo.Checked)
  84. judgeNo = txtJugeNo.Text.Trim();
  85. if (chkFlagStove.Checked)
  86. flagStove = flagStoveNo.Text.Trim();
  87. List<OfflineResultEntity> listSource = EntityHelper.GetData<OfflineResultEntity>(
  88. "com.steering.mes.mcp.common.frmEntrust.doQueryOffline",
  89. new object[] {startTime, endTime, judgeNo, plineCodes, upStatus0.CheckedItem.DataValue.ToString(), flagStove }, ob);
  90. if (chkOrderNo.Checked)
  91. {
  92. offlineResultEntityBindingSource.DataSource = listSource.Where(p=>p.OrderNo.ToUpper().Contains(txtOrderNo.Text.ToUpper())).ToList();
  93. }
  94. else {
  95. offlineResultEntityBindingSource.DataSource = listSource;
  96. }
  97. comm.RefreshAndAutoSize(ultraGrid1, new[] {"StdName"});
  98. }
  99. catch (Exception ex)
  100. {
  101. if (ex.Message.ToString2() != "")
  102. MessageBox.Show(ex.Message);
  103. }
  104. finally
  105. {
  106. wf.Close();
  107. Cursor = Cursors.Default;
  108. }
  109. }
  110. private void Apply()
  111. {
  112. ultraGrid1.UpdateData();
  113. var list = offlineResultEntityBindingSource.DataSource as List<OfflineResultEntity>;
  114. list = list.Where(p => p.Chk).ToList();
  115. if (!list.Any())
  116. {
  117. MessageBox.Show("请选择需要申请的数据");
  118. return;
  119. }
  120. if (list.Select(p => p.Process).Distinct().Count() != 1)
  121. {
  122. MessageBox.Show("只能同时申请同工序的数据");
  123. return;
  124. }
  125. if (list.Select(p => p.PlineCode).Distinct().Count() != 1)
  126. {
  127. MessageBox.Show("只能同时申请同产线的数据");
  128. return;
  129. }
  130. if (
  131. list.Any(
  132. p =>
  133. (!string.IsNullOrWhiteSpace(p.Type) && (p.Type != "BC") && (p.Type != "ZC") && (p.Type != "20") && (p.Type != "40") && (p.Type != "60")) ||
  134. ((p.OfflineNum ?? 0) <= 0)))
  135. {
  136. MessageBox.Show("已申请的数据无法再次申请");
  137. return;
  138. }
  139. var FrmEntrustApply = new FrmEntrustApplyNew(ob, FrmEntrustApplyNew.ApplyType.ApplyProject,
  140. list, list[0].Process, list[0].PlineCode,null,null, this.CustomInfo.ToString());
  141. if (FrmEntrustApply.ShowDialog() == DialogResult.OK)
  142. {
  143. // var Type = FrmEntrustApply.Type;
  144. // var Note = FrmEntrustApply.Note;
  145. FrmEntrustApply.Dispose();
  146. QueryOffline();
  147. }
  148. }
  149. private void CancelApply()
  150. {
  151. ultraGrid1.UpdateData();
  152. var list = offlineResultEntityBindingSource.DataSource as List<OfflineResultEntity>;
  153. list = list.Where(p => p.Chk).ToList();
  154. if (!list.Any())
  155. {
  156. MessageBox.Show("请选择需要撤销申请的数据");
  157. return;
  158. }
  159. if (list.Select(p => p.Process).Distinct().Count() != 1)
  160. {
  161. MessageBox.Show("只能同时撤销申请同工序的数据");
  162. return;
  163. }
  164. if (list.Any(p => p.Type != "00"))
  165. {
  166. MessageBox.Show("只能撤销已申请的数据!");
  167. return;
  168. }
  169. if (MessageUtil.ShowYesNoAndQuestion("是否撤销申请委外?") == DialogResult.No)
  170. return;
  171. var ccp = new CoreClientParam();
  172. ccp.ServerName = "com.steering.mes.mcp.common.frmEntrust";
  173. ccp.MethodName = "CancelApply";
  174. ccp.ServerParams = new object[]
  175. {
  176. list.Select(p => p.SubcontractNo).Distinct().ToList(), list[0].Process
  177. };
  178. ccp = ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  179. if (ccp.ReturnCode != -1)
  180. {
  181. MessageUtil.ShowTips(ccp.ReturnInfo);
  182. if (ccp.ReturnInfo.Equals("撤销申请成功!"))
  183. QueryOffline();
  184. }
  185. }
  186. public void SetFillerHeaderCheck(UltraGrid ug, string name)
  187. {
  188. ug.DisplayLayout.Bands[0].Columns[name].Header.CheckBoxVisibility = HeaderCheckBoxVisibility.Always;
  189. ug.DisplayLayout.Bands[0].Columns[name].Header.CheckBoxSynchronization = HeaderCheckBoxSynchronization.None;
  190. var _isInCellChange = 0;
  191. ug.AfterHeaderCheckStateChanged += (sender, e) =>
  192. {
  193. if (_isInCellChange > 0) return; //更新状态时 不执行全选或全不选
  194. var isChecked = e.Column.GetHeaderCheckedState(e.Rows) == CheckState.Checked;
  195. foreach (var filteredInNonGroupByRow in e.Rows.GetFilteredInNonGroupByRows())
  196. filteredInNonGroupByRow.Cells[e.Column].SetValue(isChecked, false);
  197. };
  198. ug.CellChange += (sender, e) =>
  199. {
  200. ug.UpdateData();
  201. if (e.Cell.Column.Key == name)
  202. {
  203. _isInCellChange++;
  204. var allTrue = true;
  205. var allFalse = true;
  206. foreach (var row in ug.Rows.GetFilteredInNonGroupByRows())
  207. if ((bool) row.Cells[name].Value)
  208. allFalse = false;
  209. else
  210. allTrue = false;
  211. if (allFalse)
  212. ug.DisplayLayout.Bands[0].Columns[name].SetHeaderCheckedState(ug.Rows, false);
  213. else if (allTrue)
  214. ug.DisplayLayout.Bands[0].Columns[name].SetHeaderCheckedState(ug.Rows, true);
  215. else
  216. ug.DisplayLayout.Bands[0].Columns[name].SetHeaderCheckedState(ug.Rows, false); // 当前版本无法直接更新Indeterminate 状态 改成不勾选
  217. _isInCellChange--;
  218. }
  219. };
  220. ug.AfterRowFilterChanged += (sender, e) =>
  221. {
  222. _isInCellChange++;
  223. var allTrue = true;
  224. var allFalse = true;
  225. foreach (var row in ug.Rows.GetFilteredInNonGroupByRows())
  226. if ((bool) row.Cells[name].Value)
  227. allFalse = false;
  228. else
  229. allTrue = false;
  230. if (allFalse)
  231. ug.DisplayLayout.Bands[0].Columns[name].SetHeaderCheckedState(ug.Rows, false);
  232. else if (allTrue)
  233. ug.DisplayLayout.Bands[0].Columns[name].SetHeaderCheckedState(ug.Rows, true);
  234. else
  235. ug.DisplayLayout.Bands[0].Columns[name].SetHeaderCheckedState(ug.Rows, false); // 当前版本无法直接更新Indeterminate 状态 改成不勾选
  236. _isInCellChange--;
  237. };
  238. }
  239. }
  240. }