PortHttBatchControl.cs 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Drawing;
  4. using System.Linq;
  5. using System.Windows.Forms;
  6. using Core.Mes.Client.Comm.Format;
  7. using Core.Mes.Client.Comm.Server;
  8. using Core.Mes.Client.Comm.Tool;
  9. using Core.StlMes.Client.Mcp.Control.Entity;
  10. using CoreFS.CA06;
  11. using Infragistics.Win;
  12. using Infragistics.Win.UltraWinGrid;
  13. using ButtonDisplayStyle = Infragistics.Win.UltraWinGrid.ButtonDisplayStyle;
  14. using ColumnStyle = Infragistics.Win.UltraWinGrid.ColumnStyle;
  15. using System.Collections;
  16. namespace Core.StlMes.Client.Mcp.Control.Common
  17. {
  18. public delegate void HttWasteChange();
  19. public partial class PortHttBatchControl : UserControl
  20. {
  21. public HttWasteChange HttWasteChange = null;
  22. public PortHttBatchControl()
  23. {
  24. InitializeComponent();
  25. EntityHelper.ShowGridCaption<PortHttBatchSampleResultEntityTotal>(ultraGrid3.DisplayLayout.Bands[0]);
  26. EntityHelper.ShowGridCaption<PortHttBatchSampleResultEntity>(ultraGrid3.DisplayLayout.Bands[1]);
  27. commHelper.setOtherColumnReadOnly(ultraGrid3, new string[] { "DeleteReason", "DeleteNum" });
  28. commHelper.setOtherColumnReadOnly(ultraGrid3, new string[] { }, 1);
  29. ultraGrid3.DisplayLayout.Override.AllowRowFiltering = DefaultableBoolean.False;
  30. foreach (UltraGridColumn ugc in ultraGrid3.DisplayLayout.Bands[0].Columns)
  31. {
  32. ugc.SortIndicator = SortIndicator.Disabled;
  33. }
  34. foreach (UltraGridColumn ugc in ultraGrid3.DisplayLayout.Bands[1].Columns)
  35. {
  36. ugc.SortIndicator = SortIndicator.Disabled;
  37. }
  38. commHelper.RefreshAndAutoSize(ultraGrid3);
  39. datas = new List<PortHttBatchSampleResultEntity>();
  40. }
  41. public bool ShowTop
  42. {
  43. get { return ultraPanel9.Visible; }
  44. set { ultraPanel9.Visible = value; }
  45. }
  46. public bool Show1
  47. {
  48. get { return ultraPanel3.Visible; }
  49. set { ultraPanel3.Visible = value; }
  50. }
  51. public bool Show2
  52. {
  53. get { return ultraPanel2.Visible; }
  54. set { ultraPanel2.Visible = value; }
  55. }
  56. public bool Show4
  57. {
  58. get { return ultraPanel4.Visible; }
  59. set { ultraPanel4.Visible = value; }
  60. }
  61. public bool ShowDelete
  62. {
  63. get
  64. {
  65. return !ultraGrid3.DisplayLayout.Bands[1].Columns["DeleteReason"].Hidden;
  66. }
  67. set
  68. {
  69. ultraGrid3.DisplayLayout.Bands[1].Columns["DeleteReason"].Hidden = !value;
  70. ultraGrid3.DisplayLayout.Bands[0].Columns["DeleteReason"].Hidden = !value;
  71. ultraGrid3.DisplayLayout.Bands[0].Columns["DeleteNum"].Hidden = !value;
  72. }
  73. }
  74. public OpeBase ob { get; set; }
  75. public void SetDeleteReason(string failCode)
  76. {
  77. ultraGrid3.DisplayLayout.Bands[1].Columns["DeleteReason"].Hidden = !ShowDelete;
  78. var dt3 = ServerHelper.GetData("com.steering.mes.mcp.collarMaterial.ComBaseInfo.getBaseInfo",
  79. new object[] { failCode }, ob);
  80. reason.DataSource = dt3;
  81. reason.DisplayMember = "BASENAME";
  82. reason.ValueMember = "BASECODE";
  83. YdmBaseClass.SetComboItemHeight(reason);
  84. ultraGrid3.DisplayLayout.Bands[0].Columns["DeleteReason"].EditorComponent = reason;
  85. ultraGrid3.DisplayLayout.Bands[0].Columns["DeleteReason"].ButtonDisplayStyle = ButtonDisplayStyle.Always;
  86. ultraGrid3.DisplayLayout.Bands[0].Columns["DeleteReason"].Style = ColumnStyle.DropDownList;
  87. ultraGrid3.DisplayLayout.Bands[1].Columns["DeleteReason"].EditorComponent = reason;
  88. ultraGrid3.DisplayLayout.Bands[1].Columns["DeleteReason"].ButtonDisplayStyle = ButtonDisplayStyle.Always;
  89. ultraGrid3.DisplayLayout.Bands[1].Columns["DeleteReason"].Style = ColumnStyle.DropDownList;
  90. }
  91. private string heatPlanNo = "";
  92. private string plineCode = "";
  93. private int ProcessSeq = 1;
  94. private string GoWhere = "";
  95. public string userName { get; set; }
  96. private void Query()
  97. {
  98. Query(heatPlanNo, plineCode, ProcessSeq, GoWhere);
  99. }
  100. public void updateLen()
  101. {
  102. try
  103. {
  104. ArrayList parm = new ArrayList();
  105. UltraGridBand band = this.ultraGrid3.DisplayLayout.Bands[1];
  106. foreach (UltraGridRow row in band.GetRowEnumerator(GridRowType.DataRow))
  107. {
  108. String str = row.Cells["check"].Text.ToString();
  109. if (row.Cells["check"].Text.ToString() == "True")
  110. {
  111. PortHttBatchSampleResultEntity portHttBatchSampleResultEntity = new PortHttBatchSampleResultEntity();
  112. portHttBatchSampleResultEntity.MatNo = row.Cells["matNo"].Text.ToString();
  113. portHttBatchSampleResultEntity.ActLen = Decimal.Parse(row.Cells["actLen"].Text.ToString());
  114. portHttBatchSampleResultEntity.ActLenU = Decimal.Parse(row.Cells["actLenU"].Text.ToString() == null ? "0.00" : row.Cells["actLenU"].Text.ToString());
  115. string portHttBatchSampleResult = JSONFormat.Format(portHttBatchSampleResultEntity);
  116. parm.Add(portHttBatchSampleResult);
  117. }
  118. }
  119. CoreClientParam ccp = new CoreClientParam();
  120. ccp.ServerName = "com.steering.mes.mcp.common.PlanService";
  121. ccp.MethodName = "updateAcLen";
  122. ccp.ServerParams = new object[] { parm };
  123. ccp = ob.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  124. if (ccp.ReturnCode != -1)
  125. {
  126. if (ccp.ReturnInfo.Equals("操作成功"))
  127. {
  128. // DoQueryInList();
  129. Query();
  130. MessageUtil.ShowTips(ccp.ReturnInfo);
  131. }
  132. else
  133. {
  134. MessageUtil.ShowTips(ccp.ReturnInfo);
  135. }
  136. }
  137. }
  138. catch
  139. {
  140. return;
  141. }
  142. }
  143. public void Query(string HeatPlanNo, string PlineCode, int processSeq, string goWhere)
  144. {
  145. heatPlanNo = HeatPlanNo;
  146. plineCode = PlineCode;
  147. ProcessSeq = processSeq;
  148. GoWhere = goWhere;
  149. datas =
  150. EntityHelper.GetData<PortHttBatchSampleResultEntity>(
  151. "com.steering.mes.mcp.common.PlanService.getQueryDbkPortVrphot", new object[] { HeatPlanNo, processSeq }, ob);
  152. toltal = datas.GroupBy(p => p.PhyBatchNo).Select(p =>
  153. {
  154. return
  155. new PortHttBatchSampleResultEntityTotal
  156. {
  157. PhyBatchNo = p.Key,
  158. PortHttBatchSampleResultEntitys = p.ToList(),
  159. ActCount = p.Count(),
  160. ActWeight = p.Sum(q=>q.ActWeight),
  161. PassCount = p.Count(q => q.MatStatus == "00" || q.MatStatus == "合格"),
  162. PassWeight = p.Where(q => q.MatStatus == "00" || q.MatStatus == "合格").Sum(q => q.ActWeight),
  163. FailCount =
  164. p.Count(
  165. q =>
  166. q.MatStatus == "10" || q.MatStatus == "剔除" || q.MatStatus == "40" ||
  167. q.MatStatus == "委外废品"),
  168. FailWeight = p.Where(
  169. q =>
  170. q.MatStatus == "10" || q.MatStatus == "剔除" || q.MatStatus == "40" ||
  171. q.MatStatus == "委外废品").Sum(q=>q.ActWeight),
  172. OffLineCount = p.Count(q => q.MatStatus == "20" || q.MatStatus == "待处理"),
  173. OffLineWeight = p.Where(q => q.MatStatus == "20" || q.MatStatus == "待处理").Sum(q => q.ActWeight),
  174. NewStoveCount = p.Count(q => q.MatStatus == "30" || q.MatStatus == "另组炉"),
  175. NewStoveWeight = p.Where(q => q.MatStatus == "30" || q.MatStatus == "另组炉").Sum(q => q.ActWeight)
  176. };
  177. }
  178. ).OrderBy(p => p.PhyBatchNo).ToList();
  179. portHttBatchSampleResultEntityTotalBindingSource.DataSource = toltal;
  180. commHelper.RefreshAndAutoSize(ultraGrid3);
  181. Show4 = false;
  182. /* uceBatchNo.DataSource = toltal;
  183. uceBatchNo.ValueMember = "PhyBatchNo";
  184. uceBatchNo.DisplayMember = "PhyBatchNo";
  185. uceBatchNo.DataBind();
  186. if (toltal.Any()) uceBatchNo.SelectedIndex = 0;*/
  187. }
  188. public List<PortHttBatchSampleResultEntity> datas { get; set; }
  189. public List<PortHttBatchSampleResultEntityTotal> toltal { get; set; }
  190. private void ultraGrid3_InitializeRow(object sender, Infragistics.Win.UltraWinGrid.InitializeRowEventArgs e)
  191. {
  192. if (e.Row.HasParent())
  193. {
  194. if (e.Row.Cells["MatStatus"].Text.Equals("剔除") || e.Row.Cells["MatStatus"].Text.Equals("委外废品"))
  195. e.Row.Cells["MatStatus"].Appearance.ForeColor = Color.Red;
  196. if (e.Row.Cells["MatStatus"].Text.Equals("合格") && ShowDelete)
  197. {
  198. e.Row.Cells["MatStatus"].EditorComponent = utDelete;
  199. e.Row.Cells["MatStatus"].IgnoreRowColActivation = true;
  200. ultraGrid3.DisplayLayout.Bands[1].Columns["DeleteReason"].CellActivation = Activation.AllowEdit;
  201. }
  202. if (e.Row.Cells["MatStatus"].Text.Equals("剔除") && ShowDelete &&
  203. _gxs.Contains(e.Row.Cells["OpProcessCode"].Value))
  204. {
  205. e.Row.Cells["MatStatus"].EditorComponent = utCancelDelete;
  206. e.Row.Cells["MatStatus"].IgnoreRowColActivation = true;
  207. }
  208. }
  209. else
  210. {
  211. e.Row.Cells["DeleteNum"].EditorComponent = utDelete;
  212. e.Row.Cells["DeleteNum"].IgnoreRowColActivation = true;
  213. ultraGrid3.DisplayLayout.Bands[0].Columns["DeleteReason"].CellActivation = Activation.AllowEdit;
  214. ultraGrid3.DisplayLayout.Bands[0].Columns["DeleteNum"].ButtonDisplayStyle = ButtonDisplayStyle.Always;
  215. }
  216. ultraGrid3.DisplayLayout.Bands[1].Columns["check"].CellActivation = Activation.AllowEdit;
  217. ultraGrid3.DisplayLayout.Bands[1].Columns["ActLen"].CellActivation = Activation.AllowEdit;
  218. ultraGrid3.DisplayLayout.Bands[1].Columns["ActLenU"].CellActivation = Activation.AllowEdit;
  219. }
  220. private string[] _gxs;
  221. public void SetOfflineCode(string[] gxs)
  222. {
  223. _gxs = gxs;
  224. var dt5 = ServerHelper.GetData("com.steering.mes.mcp.heatTreatment.ScrapHelper.doQuery",
  225. new object[] {"6002", gxs }, ob);
  226. ultraComboEditor1.DataSource = dt5;
  227. ultraComboEditor1.DisplayMember = "BASENAME";
  228. ultraComboEditor1.ValueMember = "BASECODE";
  229. if (dt5.Rows.Count > 0)
  230. {
  231. ultraComboEditor1.SelectedIndex = 0; }
  232. Show2 = gxs.Length > 1;
  233. }
  234. private void officeNum_EditorButtonClick(object sender, Infragistics.Win.UltraWinEditors.EditorButtonEventArgs e)
  235. {
  236. if (ob == null || heatPlanNo == "") return;
  237. if (ultraComboEditor1.SelectedIndex < 0)
  238. {
  239. MessageBox.Show("请选择工序");
  240. }
  241. /* if (uceBatchNo.SelectedIndex < 0) return;*/
  242. FrmScrapNum matfrm = new FrmScrapNum(ob, heatPlanNo, toltal, ultraComboEditor1.SelectedItem.DataValue.ToString(), ProcessSeq,
  243. plineCode, _gxs, GoWhere);
  244. matfrm.ShowDialog();
  245. if (matfrm.DialogResult == DialogResult.OK)
  246. {
  247. var handler = HttWasteChange;
  248. if (handler != null) handler();
  249. }
  250. }
  251. private void utDelete_EditorButtonClick(object sender, Infragistics.Win.UltraWinEditors.EditorButtonEventArgs e)
  252. {
  253. try
  254. {
  255. if (ultraGrid3.ActiveRow.HasChild())
  256. {
  257. ultraGrid3.UpdateData();
  258. PortHttBatchSampleResultEntityTotal entity =
  259. ultraGrid3.ActiveRow.ListObject as PortHttBatchSampleResultEntityTotal;
  260. if (ultraGrid3.ActiveRow.Cells["DeleteReason"].Value.ToString2() == "")
  261. {
  262. MessageBox.Show("请选择废品原因");
  263. return;
  264. }
  265. int Num = 0;
  266. if (! int.TryParse(ultraGrid3.ActiveRow.Cells["DeleteNum"].Value.ToString3(),out Num) || Num<=0)
  267. {
  268. MessageBox.Show("请输入正确的废品数量");
  269. return;
  270. }
  271. var list =
  272. entity.PortHttBatchSampleResultEntitys.Where(p => p.MatStatus == "合格" && p.InstoreFlag == "未入库").OrderBy(p=>p.MatNo)
  273. .Take(Num).Select(p=>p.MatNo).ToList();
  274. var listW = list.Select(p => new HttWasteResultEntity()
  275. {
  276. MatNo = p,
  277. BatchNo = ultraGrid3.ActiveRow.Cells["PhyBatchNo"].Text,
  278. DefFillCode = ultraGrid3.ActiveRow.Cells["DeleteReason"].Value.ToString2(),
  279. DefFillNum = 1,
  280. DefFillName = ultraGrid3.ActiveRow.Cells["DeleteReason"].Text.ToString2(),
  281. DefFillWt = decimal.Parse(ultraGrid3.ActiveRow.Cells["ActWeight"].Value.ToString3())
  282. }).ToList();
  283. if (list.Count < Num)
  284. {
  285. MessageBox.Show("无足够可剔除的未下线合格管");
  286. return;
  287. }
  288. ServerHelper.SetData("com.steering.mes.mcp.heatTreatment.FrmHttBugD.AddHttWaste",
  289. new object[]
  290. {
  291. heatPlanNo,
  292. ultraComboEditor1.SelectedItem.DataValue.ToString(),
  293. plineCode,
  294. userName,
  295. ProcessSeq,
  296. list,
  297. listW.Select(JSONFormat.Format).ToList()
  298. },
  299. ob);
  300. }
  301. else
  302. {
  303. if (ultraGrid3.ActiveRow.Cells["DeleteReason"].Value.ToString2() == "")
  304. {
  305. MessageBox.Show("请选择废品原因");
  306. return;
  307. }
  308. ServerHelper.SetData("com.steering.mes.mcp.heatTreatment.FrmHttBugD.AddHttWaste",
  309. new object[]
  310. {
  311. heatPlanNo,
  312. ultraComboEditor1.SelectedItem.DataValue.ToString(),
  313. plineCode,
  314. userName,
  315. ProcessSeq,
  316. ultraGrid3.ActiveRow.Cells["MatNo"].Text.ToString2(),
  317. new List<HttWasteResultEntity>(){new HttWasteResultEntity()
  318. {
  319. MatNo = ultraGrid3.ActiveRow.Cells["MatNo"].Text.ToString2(),
  320. BatchNo = ultraGrid3.ActiveRow.Cells["PhyBatchNo"].Text,
  321. DefFillCode = ultraGrid3.ActiveRow.Cells["DeleteReason"].Value.ToString2(),
  322. DefFillNum = 1,
  323. DefFillName = ultraGrid3.ActiveRow.Cells["DeleteReason"].Text.ToString2(),
  324. DefFillWt = decimal.Parse(ultraGrid3.ActiveRow.Cells["ActWeight"].Value.ToString3())
  325. }}.Select(JSONFormat.Format).ToList()
  326. },
  327. ob);
  328. }
  329. MessageBox.Show("剔除成功");
  330. var handler = HttWasteChange;
  331. if (handler != null) handler();
  332. }
  333. catch (Exception)
  334. {
  335. }
  336. }
  337. private void utCancelDelete_EditorButtonClick(object sender, Infragistics.Win.UltraWinEditors.EditorButtonEventArgs e)
  338. {
  339. try
  340. {
  341. ServerHelper.SetData("com.steering.mes.mcp.heatTreatment.FrmHttBugD.DeleteHttWaste",
  342. new object[]
  343. {
  344. heatPlanNo,
  345. ultraGrid3.ActiveRow.Cells["MatNo"].Text.ToString2(),
  346. ultraComboEditor1.SelectedItem.DataValue.ToString(),
  347. plineCode,
  348. ProcessSeq
  349. },
  350. ob);
  351. MessageBox.Show("撤销成功");
  352. var handler = HttWasteChange;
  353. if (handler != null) handler();
  354. }
  355. catch (Exception)
  356. {
  357. }
  358. }
  359. }
  360. }