FrmWeiTuo.cs 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423
  1. using Core.Mes.Client.Comm.Control;
  2. using Core.Mes.Client.Comm.Server;
  3. using Core.Mes.Client.Comm.Tool;
  4. using Core.StlMes.Client.Mcp.Common;
  5. using Core.StlMes.Client.Mcp.Control;
  6. using Core.StlMes.Client.Mcp.Entity;
  7. using CoreFS.CA06;
  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.Linq;
  16. using System.Text;
  17. using System.Windows.Forms;
  18. namespace Core.StlMes.Client.Mcp.Coupling
  19. {
  20. public partial class FrmWeiTuo : FrmBase
  21. {
  22. public FrmWeiTuo()
  23. {
  24. InitializeComponent();
  25. this.IsLoadUserView = true;
  26. }
  27. private void FrmWeiTuo_Load(object sender, EventArgs e)
  28. {
  29. EntityHelper.ShowGridCaption<CouplingOutsourcResultEntity>(ultraGrid1.DisplayLayout.Bands[0]);
  30. McpBaseHelper.InitPlineUnit(cmbPlinCode, this.ValidDataPurviewIds, ob, "H");
  31. }
  32. public override void ToolBar_Click(object sender, string ToolbarKey)
  33. {
  34. switch (ToolbarKey)
  35. {
  36. case "DoQuery":
  37. QuerySinglePlan();//查询计划
  38. break;
  39. case "DoComplete":
  40. DoComplete();//审批通过
  41. break;
  42. case "UnDoComplete":
  43. UnDoComplete();//审批不通过
  44. break;
  45. case "OutsourcReturn":
  46. DoOutsourcReturn();
  47. break;
  48. case "Close":
  49. this.Close();
  50. break;
  51. }
  52. }
  53. private void QuerySinglePlan()
  54. {
  55. string plnNo = "";
  56. string status = "";
  57. string plinCode = "";
  58. string judgeNo = "";
  59. if (chkwoId.Checked)
  60. {
  61. if (txtWoId.Text == "")
  62. {
  63. MessageUtil.ShowTips("委托单号不能为空!");
  64. return;
  65. }
  66. else
  67. {
  68. plnNo = txtWoId.Text.ToString().Trim();
  69. }
  70. }
  71. if (chkPlin.Checked)
  72. {
  73. if (cmbPlinCode.Text == "")
  74. {
  75. MessageUtil.ShowTips("生产产线不能为空!");
  76. return;
  77. }
  78. else
  79. {
  80. plinCode = cmbPlinCode.Text.Trim().ToString();
  81. }
  82. }
  83. if (chkJuNo.Checked)
  84. {
  85. if (txtStatus.Text == "")
  86. {
  87. MessageUtil.ShowTips("状态不能为空!");
  88. return;
  89. }
  90. else
  91. {
  92. status = txtStatus.Value.ToString();
  93. }
  94. }
  95. if (chkJugeHeatNo.Checked)
  96. {
  97. judgeNo = txtJugeNo.Text.ToString().Trim();
  98. }
  99. ArrayList list = new ArrayList();
  100. list.Add(plnNo);
  101. list.Add(plinCode);
  102. list.Add(status);
  103. list.Add(judgeNo);
  104. List<CouplingOutsourcResultEntity> listSource = EntityHelper.GetData<CouplingOutsourcResultEntity>(
  105. "com.steering.mes.mcp.coup.FrmWeiTuo.geQueryEntrusted", new object[] { list}, this.ob);
  106. CouplingOutEntitySource.DataSource = listSource;
  107. }
  108. private void chkStarts_CheckedChanged(object sender, EventArgs e)
  109. {
  110. if (chkwoId.Checked) { txtWoId.Enabled = true; } else { txtWoId.Enabled = false; }
  111. if (chkPlin.Checked) { cmbPlinCode.Enabled = true; } else { cmbPlinCode.Enabled = false; }
  112. if (chkJuNo.Checked) { txtStatus.Enabled = true; } else { txtStatus.Enabled = false; }
  113. if (chkJugeHeatNo.Checked) { txtJugeNo.Enabled = true; } else { txtJugeNo.Enabled = false; }
  114. }
  115. private void ContPublic_KeyDown(object sender, KeyEventArgs e)
  116. {
  117. if (e.KeyCode == Keys.Enter)
  118. {
  119. QuerySinglePlan();
  120. }
  121. }
  122. /// <summary>
  123. /// 审批通过
  124. /// </summary>
  125. private void DoComplete()
  126. {
  127. UltraGridRow row = ultraGrid1.ActiveRow;
  128. if (row == null) return;
  129. //ultraGridPlnWork.UpdateData();
  130. int AddCount = 0;
  131. ArrayList list = new ArrayList();
  132. foreach (UltraGridRow urg in ultraGrid1.Rows)
  133. {
  134. if (Convert.ToBoolean(urg.Cells["CHK"].Text) == true)
  135. {
  136. AddCount += 1;
  137. ArrayList list1 = new ArrayList();
  138. if (!row.Cells["EntrustedLog"].Text.ToString().Equals("已申请"))
  139. {
  140. MessageUtil.ShowTips("选中的委外单不是已申请状态,不能审批通过!");
  141. return;
  142. }
  143. list1.Add(urg.Cells["EntrustedNo"].Text.ToString());
  144. list.Add(list1);
  145. }
  146. }
  147. if (AddCount == 0) { MessageUtil.ShowTips("请选中要审批的委托单!"); return; }
  148. if (MessageUtil.ShowYesNoAndQuestion("是否审批委托?") == DialogResult.No)
  149. {
  150. return;
  151. }
  152. CoreClientParam ccp = new CoreClientParam();
  153. try
  154. {
  155. this.Cursor = Cursors.WaitCursor; //控制鼠标的样式为等待
  156. if (Constant.WaitingForm == null)
  157. {
  158. Constant.WaitingForm = new WaitingForm();
  159. }
  160. Constant.WaitingForm.ShowToUser = true;
  161. Constant.WaitingForm.Show();
  162. Constant.WaitingForm.Update();
  163. ccp.ServerName = "com.steering.mes.mcp.coup.FrmWeiTuo";
  164. ccp.MethodName = "commEntrustedResult";
  165. ccp.ServerParams = new object[] { list,this.UserInfo.GetUserName() };
  166. ccp = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  167. this.Cursor = Cursors.Default;
  168. Constant.WaitingForm.ShowToUser = false;
  169. Constant.WaitingForm.Close();
  170. Constant.WaitingForm = null;
  171. }
  172. catch (Exception ex)
  173. {
  174. this.Cursor = Cursors.Default;
  175. Constant.WaitingForm.ShowToUser = false;
  176. Constant.WaitingForm.Close();
  177. Constant.WaitingForm = null;
  178. }
  179. if (ccp.ReturnCode == -1) return;
  180. MessageUtil.ShowTips(ccp.ReturnInfo);
  181. if (ccp.ReturnInfo.Equals("审批通过!"))
  182. {
  183. QuerySinglePlan();
  184. }
  185. }
  186. /// <summary>
  187. /// 审批不通过
  188. /// </summary>
  189. private void UnDoComplete()
  190. {
  191. UltraGridRow row = ultraGrid1.ActiveRow;
  192. if (row == null) return;
  193. //ultraGridPlnWork.UpdateData();
  194. int AddCount = 0;
  195. ArrayList list = new ArrayList();
  196. foreach (UltraGridRow urg in ultraGrid1.Rows)
  197. {
  198. if (Convert.ToBoolean(urg.Cells["CHK"].Text) == true)
  199. {
  200. AddCount += 1;
  201. ArrayList list1 = new ArrayList();
  202. if (!row.Cells["EntrustedLog"].Text.ToString().Equals("已申请"))
  203. {
  204. MessageUtil.ShowTips("选中的委外单不是已申请状态,不能审批不通过!");
  205. return;
  206. }
  207. list1.Add(urg.Cells["EntrustedNo"].Text.ToString());
  208. list.Add(list1);
  209. }
  210. }
  211. if (AddCount == 0) { MessageUtil.ShowTips("请选中要审批的委托单!"); return; }
  212. if (MessageUtil.ShowYesNoAndQuestion("是否审批?") == DialogResult.No)
  213. {
  214. return;
  215. }
  216. CoreClientParam ccp = new CoreClientParam();
  217. try
  218. {
  219. this.Cursor = Cursors.WaitCursor; //控制鼠标的样式为等待
  220. if (Constant.WaitingForm == null)
  221. {
  222. Constant.WaitingForm = new WaitingForm();
  223. }
  224. Constant.WaitingForm.ShowToUser = true;
  225. Constant.WaitingForm.Show();
  226. Constant.WaitingForm.Update();
  227. ccp.ServerName = "com.steering.mes.mcp.coup.FrmWeiTuo";
  228. ccp.MethodName = "kownCommEntrustedResult";
  229. ccp.ServerParams = new object[] { list,this.UserInfo.GetUserName() };
  230. ccp = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  231. this.Cursor = Cursors.Default;
  232. Constant.WaitingForm.ShowToUser = false;
  233. Constant.WaitingForm.Close();
  234. Constant.WaitingForm = null;
  235. }
  236. catch (Exception ex)
  237. {
  238. this.Cursor = Cursors.Default;
  239. Constant.WaitingForm.ShowToUser = false;
  240. Constant.WaitingForm.Close();
  241. Constant.WaitingForm = null;
  242. }
  243. if (ccp.ReturnCode == -1) return;
  244. MessageUtil.ShowTips(ccp.ReturnInfo);
  245. if (ccp.ReturnInfo.Equals("审批不通过!"))
  246. {
  247. QuerySinglePlan();
  248. }
  249. }
  250. /// <summary>
  251. /// 委外回报
  252. /// </summary>
  253. private void DoOutsourcReturn()
  254. {
  255. this.ultraGrid1.UpdateData();
  256. IQueryable<UltraGridRow> checkMagRows = this.ultraGrid1.Rows.AsQueryable().Where(" CHK = 'True'");
  257. if (checkMagRows.Count() == 0)
  258. {
  259. MessageUtil.ShowTips("请勾选需要回报的委外信息!");
  260. return;
  261. }
  262. ArrayList parm2 = new ArrayList();
  263. foreach (UltraGridRow row in checkMagRows)
  264. {
  265. if (!row.Cells["EntrustedLog"].Text.ToString().Equals("审批通过"))
  266. {
  267. MessageUtil.ShowTips("选中的委外单不是审批通过状态,不能委外回报!");
  268. return;
  269. }
  270. //if (row.Cells["EntrustedLog"].Text.ToString().Equals("回报完毕"))
  271. //{
  272. // MessageUtil.ShowTips("选中的委外单已回报,不能重复委外回报!");
  273. // return;
  274. //}
  275. if (row.Cells["SubcontractcompleteNum"].Value.ToString().Equals("0"))
  276. {
  277. MessageUtil.ShowTips("请输入委外回报支数!");
  278. return;
  279. }
  280. if (row.Cells["SubcontractcompleteWt"].Value.ToString().Equals("0"))
  281. {
  282. MessageUtil.ShowTips("请输入委外回报重量!");
  283. return;
  284. }
  285. ArrayList parm = new ArrayList();
  286. parm.Add(row.Cells["SubcontractcompleteNum"].Value.ToString());
  287. parm.Add(row.Cells["SubcontractcompleteWt"].Value.ToString());
  288. parm.Add(row.Cells["HbFpNum"].Text.ToString());
  289. parm.Add(row.Cells["HbFpWt"].Text.ToString());
  290. parm.Add(row.Cells["EntrustedNo"].Text.ToString());
  291. parm2.Add(parm);
  292. }
  293. if (MessageUtil.ShowYesNoAndQuestion("是否确认委外回报?") == DialogResult.No) return;
  294. CoreClientParam ccp = new CoreClientParam();
  295. ccp.ServerName = "com.steering.mes.mcp.coup.FrmWeiTuo";
  296. ccp.MethodName = "doOutsourcReturn";
  297. ccp.ServerParams = new object[] { parm2,this.UserInfo.GetUserName() };
  298. ccp = ob.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  299. if (ccp.ReturnCode != -1)
  300. {
  301. MessageUtil.ShowTips(ccp.ReturnInfo);
  302. if (ccp.ReturnInfo.Equals("委外回报成功!"))
  303. {
  304. QuerySinglePlan();
  305. }
  306. }
  307. }
  308. private void ultraGrid1_CellChange(object sender, CellEventArgs e)
  309. {
  310. UltraGridRow row=ultraGrid1.ActiveRow;
  311. if(row==null)return;
  312. //委外回报合格支
  313. if (e.Cell.Column.Key.Equals("SubcontractcompleteNum"))
  314. {
  315. if (e.Cell.Row.Cells["SubcontractcompleteNum"].Value == null)
  316. {
  317. e.Cell.Row.Cells["SubcontractcompleteNum"].Value = "0";
  318. }
  319. else
  320. {
  321. ultraGrid1.UpdateData();
  322. string hbConNum = e.Cell.Row.Cells["SubcontractcompleteNum"].Value.ToString();
  323. if (!StringUtil.IsInt(hbConNum) || hbConNum == "0")
  324. {
  325. e.Cell.Row.Cells["SubcontractcompleteNum"].Value = "0";
  326. }
  327. if (int.Parse(e.Cell.Row.Cells["SubcontractcompleteNum"].Value.ToString()) > int.Parse(e.Cell.Row.Cells["EntrustedNum1"].Value.ToString()))
  328. {
  329. if (!row.Cells["StationCode"].Text.ToString().Equals("700301"))
  330. {
  331. e.Cell.Row.Cells["SubcontractcompleteNum"].Value = "0";
  332. }
  333. }
  334. if (!row.Cells["StationCode"].Text.ToString().Equals("700301"))
  335. {
  336. e.Cell.Row.Cells["SubcontractcompleteWt"].Value = ((double.Parse(e.Cell.Row.Cells["EntrustedWt1"].Value.ToString()) / int.Parse(e.Cell.Row.Cells["EntrustedNum1"].Value.ToString())) * int.Parse(e.Cell.Row.Cells["SubcontractcompleteNum"].Value.ToString())).ToString("f3");
  337. e.Cell.Row.Cells["HbFpNum"].Value = (int.Parse(e.Cell.Row.Cells["EntrustedNum1"].Value.ToString()) - int.Parse(e.Cell.Row.Cells["SubcontractcompleteNum"].Value.ToString())).ToString();
  338. e.Cell.Row.Cells["HbFpWt"].Value = (double.Parse(e.Cell.Row.Cells["EntrustedWt1"].Value.ToString()) - double.Parse(e.Cell.Row.Cells["SubcontractcompleteWt"].Value.ToString())).ToString("f3");
  339. }
  340. }
  341. }
  342. //委外回报合格吨
  343. if (e.Cell.Column.Key.Equals("SubcontractcompleteWt"))
  344. {
  345. if (e.Cell.Row.Cells["SubcontractcompleteWt"].Value == null)
  346. {
  347. e.Cell.Row.Cells["SubcontractcompleteWt"].Value = "0";
  348. }
  349. else
  350. {
  351. ultraGrid1.UpdateData();
  352. string hbConWt = e.Cell.Row.Cells["SubcontractcompleteWt"].Value.ToString();
  353. if (!StringUtil.IsFloat(hbConWt) || hbConWt == "0")
  354. {
  355. e.Cell.Row.Cells["SubcontractcompleteWt"].Value = "0";
  356. }
  357. if (double.Parse(e.Cell.Row.Cells["SubcontractcompleteWt"].Value.ToString()) > double.Parse(e.Cell.Row.Cells["EntrustedWt1"].Text.ToString()))
  358. {
  359. if (!row.Cells["StationCode"].Text.ToString().Equals("700301"))
  360. {
  361. e.Cell.Row.Cells["SubcontractcompleteWt"].Value = "0";
  362. }
  363. }
  364. if (!row.Cells["StationCode"].Text.ToString().Equals("700301"))
  365. {
  366. e.Cell.Row.Cells["HbFpWt"].Value = (double.Parse(e.Cell.Row.Cells["EntrustedWt1"].Text.ToString()) - double.Parse(e.Cell.Row.Cells["SubcontractcompleteWt"].Value.ToString())).ToString("f3");
  367. }
  368. }
  369. }
  370. //委外回报废品个
  371. if (e.Cell.Column.Key.Equals("HbFpNum"))
  372. {
  373. if (e.Cell.Row.Cells["HbFpNum"].Value == null)
  374. {
  375. e.Cell.Row.Cells["HbFpNum"].Value = "0";
  376. }
  377. else
  378. {
  379. ultraGrid1.UpdateData();
  380. string hbConWt = e.Cell.Row.Cells["HbFpNum"].Value.ToString();
  381. if (!StringUtil.IsFloat(hbConWt) || hbConWt == "0")
  382. {
  383. e.Cell.Row.Cells["HbFpNum"].Value = "0";
  384. }
  385. }
  386. }
  387. //委外回报废品吨
  388. if (e.Cell.Column.Key.Equals("HbFpWt"))
  389. {
  390. if (e.Cell.Row.Cells["HbFpWt"].Value == null)
  391. {
  392. e.Cell.Row.Cells["HbFpWt"].Value = "0";
  393. }
  394. else
  395. {
  396. ultraGrid1.UpdateData();
  397. string hbConWt = e.Cell.Row.Cells["HbFpWt"].Value.ToString();
  398. if (!StringUtil.IsFloat(hbConWt) || hbConWt == "0")
  399. {
  400. e.Cell.Row.Cells["HbFpWt"].Value = "0";
  401. }
  402. }
  403. }
  404. }
  405. }
  406. }