FrmEntrustedCheck.cs 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433
  1. using com.steering.mes.zgmil.entity;
  2. using Core.Mes.Client.Comm.Control;
  3. using Core.Mes.Client.Comm.Format;
  4. using Core.Mes.Client.Comm.Tool;
  5. using Core.StlMes.Client.ZGMil.Entity;
  6. using CoreFS.CA06;
  7. using Infragistics.Win.UltraWinEditors;
  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.ZGMil.Signature
  19. {
  20. public partial class FrmEntrustedCheck : FrmBase
  21. {
  22. public FrmEntrustedCheck()
  23. {
  24. InitializeComponent();
  25. }
  26. UltraComboEditor uceReson = new UltraComboEditor();
  27. private void FrmEntrustedCheck_Load(object sender, EventArgs e)
  28. {
  29. DateTime now = DateTime.Now;
  30. DateTime dt1 = new DateTime(now.Year, now.Month, 1);//当月第一天
  31. DateTime dt2 = dt1.AddMonths(1).AddDays(-1);//当月最后一天
  32. this.StartTime2.Value = DateTime.Parse(dt1.ToString("yyyy-MM-dd") + " 00:00:00");
  33. this.EndTime2.Value = DateTime.Parse(dt2.ToString("yyyy-MM-dd") + " 23:59:59");
  34. EntityHelper.ShowGridCaption<MilEntrustedBillEntity>(ultraGrid1.DisplayLayout.Bands[0]);
  35. initBase();
  36. PipeManageClass.InitComboEditor(uceReson, "com.steering.mes.signature.FrmEntrustedCheck.doQueryPline", "PLINE_CODE", this.ob, false);
  37. PipeManageClass.BindColumn(uceReson, "EntrustedPlineName", this.Controls, this.ultraGrid1, 0);
  38. }
  39. private void initBase()
  40. {
  41. this.ultraGrid1.DisplayLayout.ValueLists[0].ValueListItems.Add("0", "未审核");
  42. this.ultraGrid1.DisplayLayout.ValueLists[0].ValueListItems.Add("1", "审核通过");
  43. this.ultraGrid1.DisplayLayout.ValueLists[0].ValueListItems.Add("2", "审核未通过");
  44. this.ultraGrid1.DisplayLayout.ValueLists[1].ValueListItems.Add("0", "未完成");
  45. this.ultraGrid1.DisplayLayout.ValueLists[1].ValueListItems.Add("1", "已完成");
  46. }
  47. public override void ToolBar_Click(object sender, string ToolbarKey)
  48. {
  49. switch (ToolbarKey)
  50. {
  51. case "doQuerySubContract":
  52. doQuerySubContract();
  53. break;
  54. case"checkPass":
  55. checkcheckPass();
  56. break;
  57. case "noCheckPass":
  58. noCheckPass();
  59. break;
  60. case"cancelCheck":
  61. cancelCheck();
  62. break;
  63. case "subcontractComplete":
  64. subcontractComplete();
  65. break;
  66. case "cancelSubcontractComplete":
  67. cancelSubcontractComplete();
  68. break;
  69. case "Export":
  70. ExportData();
  71. break;
  72. case "Close":
  73. this.Close();
  74. break;
  75. }
  76. }
  77. /// <summary>
  78. /// 查询委托
  79. /// </summary>
  80. private void doQuerySubContract()
  81. {
  82. string subcontracNo = "";
  83. string startTim = "";
  84. string endTim = "";
  85. string entrustedFlag = "";
  86. string jugeNo = "";
  87. NativeMethodNew na = new NativeMethodNew(this.ob);
  88. string plinCode = na.GetPCode(this.UserInfo.GetDepartment());
  89. if (this.chkOrderNo.Checked && this.txtOrderNo.Text.Trim() != "")
  90. {
  91. subcontracNo = this.txtOrderNo.Text.Trim();
  92. }
  93. if(this.chkJugeNo.Checked&& this.txtJugeNo.Text.Trim() !="")
  94. {
  95. jugeNo = this.txtJugeNo.Text.Trim();
  96. }
  97. if (chkTim2.Checked)
  98. {
  99. if (DateTime.Parse(StartTime2.Value.ToString()) > DateTime.Parse(EndTime2.Value.ToString()))
  100. {
  101. MessageUtil.ShowTips("选择的前面时间不能大于后面的时间!");
  102. return;
  103. }
  104. else
  105. {
  106. startTim = this.StartTime2.Value.ToString("yyyy-MM-dd HH:mm:ss");
  107. endTim = this.EndTime2.Value.ToString("yyyy-MM-dd HH:mm:ss");
  108. }
  109. }
  110. entrustedFlag = this.ultraOptionSet1.CheckedItem.DataValue.ToString();
  111. ArrayList list = new ArrayList();
  112. list.Add(subcontracNo);
  113. list.Add(entrustedFlag);
  114. list.Add(jugeNo);
  115. List<MilEntrustedBillEntity> listSource = EntityHelper.GetData<MilEntrustedBillEntity>(
  116. "com.steering.mes.signature.FrmEntrustedCheck.doQuerySubContact", new object[] { list, startTim, endTim, plinCode }, this.ob);
  117. MilEntrustedBillEntitybindingSource.DataSource = listSource;
  118. }
  119. /// <summary>
  120. /// 审核通过
  121. /// </summary>
  122. private void checkcheckPass()
  123. {
  124. this.ultraGrid1.UpdateData();
  125. IQueryable<UltraGridRow> checkMagRows = this.ultraGrid1.Rows.AsQueryable().Where(" CHK = 'True'");
  126. if (checkMagRows.Count() == 0)
  127. {
  128. MessageUtil.ShowTips("请选择需要进行操作的主信息!");
  129. return;
  130. }
  131. ArrayList parm = new ArrayList();
  132. foreach (UltraGridRow uRow in checkMagRows)
  133. {
  134. MilEntrustedBillEntity milEntrustEntity = (MilEntrustedBillEntity)uRow.ListObject;
  135. if (uRow.Cells["EntrustedPlineName"].Text.ToString() == "")
  136. {
  137. MessageUtil.ShowTips("审核通过请指定委托产线!");
  138. return;
  139. }
  140. milEntrustEntity.EntrustedPlineCode = uRow.Cells["EntrustedPlineName"].Value.ToString();
  141. milEntrustEntity.EntrustedPlineName = uRow.Cells["EntrustedPlineName"].Text.ToString();
  142. string milEntrustTity = JSONFormat.Format(milEntrustEntity);
  143. parm.Add(milEntrustTity);
  144. }
  145. CoreClientParam ccp = new CoreClientParam();
  146. ccp.ServerName = "com.steering.mes.signature.FrmEntrustedCheck";
  147. ccp.MethodName = "checkPass";
  148. ccp.ServerParams = new object[] { parm };
  149. ccp = ob.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  150. if (ccp.ReturnCode != -1)
  151. {
  152. if (ccp.ReturnInfo.Equals("审核成功!"))
  153. {
  154. doQuerySubContract();
  155. MessageUtil.ShowTips(ccp.ReturnInfo);
  156. }
  157. else
  158. {
  159. MessageUtil.ShowTips(ccp.ReturnInfo);
  160. }
  161. }
  162. }
  163. /// <summary>
  164. /// 审核不通过
  165. /// </summary>
  166. private void noCheckPass()
  167. {
  168. this.ultraGrid1.UpdateData();
  169. int m = 0;
  170. IQueryable<UltraGridRow> checkMagRows = this.ultraGrid1.Rows.AsQueryable().Where(" CHK = 'True'");
  171. if (checkMagRows.Count() == 0)
  172. {
  173. MessageUtil.ShowTips("请选择需要进行操作的主信息!");
  174. return;
  175. }
  176. ArrayList parm = new ArrayList();
  177. foreach (UltraGridRow uRow in checkMagRows)
  178. {
  179. MilEntrustedBillEntity milEntrustEntity = (MilEntrustedBillEntity)uRow.ListObject;
  180. if (milEntrustEntity.EntrustedRemark.ToString() == "")
  181. {
  182. m = m + 1;
  183. }
  184. string milEntrustTity = JSONFormat.Format(milEntrustEntity);
  185. parm.Add(milEntrustTity);
  186. }
  187. if(m>0)
  188. {
  189. MessageUtil.ShowTips("审核不通过,请输入审核说明!");
  190. return;
  191. }
  192. CoreClientParam ccp = new CoreClientParam();
  193. ccp.ServerName = "com.steering.mes.signature.FrmEntrustedCheck";
  194. ccp.MethodName = "noCheckPass";
  195. ccp.ServerParams = new object[] { parm };
  196. ccp = ob.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  197. if (ccp.ReturnCode != -1)
  198. {
  199. if (ccp.ReturnInfo.Equals("审核成功!"))
  200. {
  201. doQuerySubContract();
  202. MessageUtil.ShowTips(ccp.ReturnInfo);
  203. }
  204. else
  205. {
  206. MessageUtil.ShowTips(ccp.ReturnInfo);
  207. }
  208. }
  209. }
  210. /// <summary>
  211. /// 撤销审核
  212. /// </summary>
  213. private void cancelCheck()
  214. {
  215. this.ultraGrid1.UpdateData();
  216. IQueryable<UltraGridRow> checkMagRows = this.ultraGrid1.Rows.AsQueryable().Where(" CHK = 'True'");
  217. if (checkMagRows.Count() == 0)
  218. {
  219. MessageUtil.ShowTips("请选择需要进行操作的主信息!");
  220. return;
  221. }
  222. ArrayList parm = new ArrayList();
  223. foreach (UltraGridRow uRow in checkMagRows)
  224. {
  225. MilEntrustedBillEntity milEntrustEntity = (MilEntrustedBillEntity)uRow.ListObject;
  226. string milEntrustTity = JSONFormat.Format(milEntrustEntity);
  227. parm.Add(milEntrustTity);
  228. }
  229. CoreClientParam ccp = new CoreClientParam();
  230. ccp.ServerName = "com.steering.mes.signature.FrmEntrustedCheck";
  231. ccp.MethodName = "cancelCheckPass";
  232. ccp.ServerParams = new object[] { parm };
  233. ccp = ob.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  234. if (ccp.ReturnCode != -1)
  235. {
  236. if (ccp.ReturnInfo.Equals("撤销成功!"))
  237. {
  238. doQuerySubContract();
  239. MessageUtil.ShowTips(ccp.ReturnInfo);
  240. }
  241. else
  242. {
  243. MessageUtil.ShowTips(ccp.ReturnInfo);
  244. }
  245. }
  246. }
  247. /// <summary>
  248. /// 委外加工完成
  249. /// </summary>
  250. private void subcontractComplete()
  251. {
  252. this.ultraGrid1.UpdateData();
  253. IQueryable<UltraGridRow> checkMagRows = this.ultraGrid1.Rows.AsQueryable().Where(" CHK = 'True'");
  254. if (checkMagRows.Count() == 0)
  255. {
  256. MessageUtil.ShowTips("请选择需要操作的主信息!");
  257. return;
  258. }
  259. ArrayList parm = new ArrayList();
  260. int m = 0;
  261. foreach (UltraGridRow uRow in checkMagRows)
  262. {
  263. //if (int.Parse(uRow.Cells["SubcontractcompleteNum"].Value.ToString3()) + int.Parse(uRow.Cells["SubcontractscrapNum"].Value.ToString3()) != int.Parse(uRow.Cells["SubcontractNum"].Value.ToString3()) * int.Parse(uRow.Cells["SubcontractCompleteCut"].Value.ToString3()))
  264. //{
  265. // m = m + 1;
  266. //}
  267. MilEntrustedBillEntity milEntrustTity = (MilEntrustedBillEntity)uRow.ListObject;
  268. string milEntrustEntity = JSONFormat.Format(milEntrustTity);
  269. parm.Add(milEntrustEntity);
  270. if (milEntrustTity.OfflinePro.Equals("XX"))
  271. {
  272. if (!getData(milEntrustTity))
  273. {
  274. return;
  275. }
  276. }
  277. else
  278. {
  279. if (!getDataS(milEntrustTity))
  280. {
  281. return;
  282. }
  283. }
  284. }
  285. //if (m > 1)
  286. //{
  287. // MessageUtil.ShowTips("委外回报实绩的支数与委外出去加工支数不符!");
  288. // return;
  289. //}
  290. if (MessageUtil.ShowYesNoAndQuestion("是否确认回报委外实绩?") == DialogResult.No) return;
  291. CoreClientParam ccp = new CoreClientParam();
  292. ccp.ServerName = "com.steering.mes.signature.FrmDownlineManage";
  293. ccp.MethodName = "subcontractComplete";
  294. ccp.ServerParams = new object[] { parm };
  295. ccp = ob.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  296. if (ccp.ReturnCode != -1)
  297. {
  298. if (ccp.ReturnInfo.Equals("委外加工完成!"))
  299. {
  300. doQuerySubContract();
  301. MessageUtil.ShowTips(ccp.ReturnInfo);
  302. }
  303. else
  304. {
  305. MessageUtil.ShowTips(ccp.ReturnInfo);
  306. }
  307. }
  308. }
  309. /// <summary>
  310. /// 撤销委外完成
  311. /// </summary>
  312. private void cancelSubcontractComplete()
  313. {
  314. this.ultraGrid1.UpdateData();
  315. IQueryable<UltraGridRow> checkMagRows = this.ultraGrid1.Rows.AsQueryable().Where(" CHK = 'True'");
  316. if (checkMagRows.Count() == 0)
  317. {
  318. MessageUtil.ShowTips("请选择需要操作的主信息!");
  319. return;
  320. }
  321. ArrayList parm = new ArrayList();
  322. int m = 0;
  323. foreach (UltraGridRow uRow in checkMagRows)
  324. {
  325. MilEntrustedBillEntity milEntrustTity = (MilEntrustedBillEntity)uRow.ListObject;
  326. string milEntrustEntity = JSONFormat.Format(milEntrustTity);
  327. parm.Add(milEntrustEntity);
  328. }
  329. if (MessageUtil.ShowYesNoAndQuestion("是否确认回报委外实绩?") == DialogResult.No) return;
  330. CoreClientParam ccp = new CoreClientParam();
  331. ccp.ServerName = "com.steering.mes.signature.FrmDownlineManage";
  332. ccp.MethodName = "cancelSubcontractComplete";
  333. ccp.ServerParams = new object[] { parm };
  334. ccp = ob.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  335. if (ccp.ReturnCode != -1)
  336. {
  337. if (ccp.ReturnInfo.Equals("撤销成功!"))
  338. {
  339. doQuerySubContract();
  340. MessageUtil.ShowTips(ccp.ReturnInfo);
  341. }
  342. else
  343. {
  344. MessageUtil.ShowTips(ccp.ReturnInfo);
  345. }
  346. }
  347. }
  348. /// <summary>
  349. /// 数据验证
  350. /// </summary>
  351. /// <param name="sender"></param>
  352. /// <param name="e"></param>
  353. private bool getData(MilEntrustedBillEntity milEntrustTity)
  354. {
  355. if (milEntrustTity.SubcontractCompleteCut.ToString2() == "")
  356. {
  357. MessageUtil.ShowTips("交库点离线外委的管子需回报分切数!");
  358. return false;
  359. }
  360. if (milEntrustTity.SubcontractCompleteLen.ToString2() == "")
  361. {
  362. MessageUtil.ShowTips("交库点离线外委的管子需回报分切定尺长度!");
  363. return false;
  364. }
  365. if (milEntrustTity.SubcontractCompleteWgt.ToString2() == "")
  366. {
  367. MessageUtil.ShowTips("交库点离线外委的管子需回报外委合格重量!");
  368. return false;
  369. }
  370. if (milEntrustTity.SubcontractcompleteNum.ToString2() == "")
  371. {
  372. MessageUtil.ShowTips("交库点离线外委的管子需回报外委合格支数!");
  373. return false;
  374. }
  375. return true;
  376. }
  377. /// <summary>
  378. /// 其他点委外数据验证
  379. /// </summary>
  380. /// <returns></returns>
  381. private bool getDataS(MilEntrustedBillEntity milEntrustTity)
  382. {
  383. if (milEntrustTity.SubcontractcompleteNum.ToString2() =="")
  384. {
  385. MessageUtil.ShowTips("离线外委的管子需回报外委合格支数!");
  386. return false;
  387. }
  388. return true;
  389. }
  390. /// <summary>
  391. /// 导出
  392. /// </summary>
  393. private void ExportData()
  394. {
  395. GridHelper.ulGridToExcel(ultraGrid1, "轧管委外审核信息");
  396. }
  397. private void chkTim2_CheckedChanged(object sender, EventArgs e)
  398. {
  399. this.StartTime2.Enabled = this.EndTime2.Enabled = this.chkTim2.Checked;
  400. }
  401. private void chkOrderNo_CheckedChanged(object sender, EventArgs e)
  402. {
  403. this.txtOrderNo.Enabled = this.chkOrderNo.Checked;
  404. }
  405. private void chkJugeNo_CheckedChanged(object sender, EventArgs e)
  406. {
  407. this.txtJugeNo.Enabled = this.chkJugeNo.Checked;
  408. }
  409. }
  410. }