FrmProcessOrder.cs 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.ComponentModel;
  5. using System.Data;
  6. using System.Drawing;
  7. using System.Linq;
  8. using System.Text;
  9. using System.Windows.Forms;
  10. using Core.Mes.Client.Comm.Control;
  11. using Core.Mes.Client.Comm.Tool;
  12. using Core.StlMes.Client.PlnSaleOrd.BaseMethod;
  13. using Core.StlMes.Client.PlnSaleOrd.Entity;
  14. using CoreFS.CA06;
  15. using Infragistics.Win.UltraWinGrid;
  16. namespace Core.StlMes.Client.PlnSaleOrd
  17. {
  18. public partial class FrmProcessOrder : FrmBase
  19. {
  20. public FrmProcessOrder()
  21. {
  22. this.IsLoadUserView = true;
  23. InitializeComponent();
  24. System.Threading.Thread t = new System.Threading.Thread(setGridColunmName);
  25. t.Start();
  26. }
  27. private void setGridColunmName()
  28. {
  29. System.Threading.Thread.Sleep(3000);
  30. if (!this.IsDisposed)
  31. {
  32. EntityHelper.ShowGridCaption<PlnReqinfGpEntity>(ultraGridGP.DisplayLayout.Bands[0]);
  33. EntityHelper.ShowGridCaption<PlnOrderDzEntity>(ultraGridDZ.DisplayLayout.Bands[0]);
  34. EntityHelper.ShowGridCaption<PlnOrderZgEntity>(ultraGridZG.DisplayLayout.Bands[0]);
  35. EntityHelper.ShowGridCaption<PlnOrderDbkEntity>(ultraGridDBK.DisplayLayout.Bands[0]);
  36. EntityHelper.ShowGridCaption<PlnOrderRclEntity>(ultraGridRCL.DisplayLayout.Bands[0]);
  37. EntityHelper.ShowGridCaption<PlnOrderJgxEntity>(ultraGridJG.DisplayLayout.Bands[0]);
  38. }
  39. }
  40. private void FrmProcessOrder_Load(object sender, EventArgs e)
  41. {
  42. ultraComboFinishEditor.SelectedIndex = 0;
  43. EntityHelper.ShowGridCaption<PlnReqinfGpEntity>(ultraGridGP.DisplayLayout.Bands[0]);
  44. EntityHelper.ShowGridCaption<PlnOrderDzEntity>(ultraGridDZ.DisplayLayout.Bands[0]);
  45. EntityHelper.ShowGridCaption<PlnOrderZgEntity>(ultraGridZG.DisplayLayout.Bands[0]);
  46. EntityHelper.ShowGridCaption<PlnOrderDbkEntity>(ultraGridDBK.DisplayLayout.Bands[0]);
  47. EntityHelper.ShowGridCaption<PlnOrderRclEntity>(ultraGridRCL.DisplayLayout.Bands[0]);
  48. EntityHelper.ShowGridCaption<PlnOrderJgxEntity>(ultraGridJG.DisplayLayout.Bands[0]);
  49. //设置可读
  50. BaseHelper.setOtherColumnReadOnly(ultraGridGP, new string[] { "CHC" });
  51. BaseHelper.setOtherColumnReadOnly(ultraGridDZ, new string[] { "CHC" });
  52. BaseHelper.setOtherColumnReadOnly(ultraGridZG, new string[] { "CHC" });
  53. BaseHelper.setOtherColumnReadOnly(ultraGridDBK, new string[] { "CHC" });
  54. BaseHelper.setOtherColumnReadOnly(ultraGridRCL, new string[] { "CHC" });
  55. BaseHelper.setOtherColumnReadOnly(ultraGridJG, new string[] { "CHC" });
  56. InitUpTime();
  57. userControlSaleordProc1.UltraGridSaleordProc1.AfterRowActivate += UltraGridSaleordProc1_AfterRowActivate;
  58. PlanComm.setGridDigitalCol(ultraGridZG.DisplayLayout.Bands[0], 5, 0, "BacklogSeq",
  59. "OutnumSingle", "Ordernum", "MatchNum", "ReqProdNum");
  60. PlanComm.setGridDigitalCol(ultraGridZG.DisplayLayout.Bands[0], 5, 2, "Outdiameter",
  61. "Wallthick", "Aimwallthick", "Lengthmax", "Lengthmin", "Aimlength", "RollLength",
  62. "OutLength", "DiameterGp", "LengthGp");
  63. PlanComm.setGridDigitalCol(ultraGridZG.DisplayLayout.Bands[0], 7, 3, "Finishweight",
  64. "ReqProdWt", "BuyplanWt", "MatchWt", "Orderweight", "WeightGpOne", "Getrate");
  65. PlanComm.setGridDigitalCol(ultraGridJG.DisplayLayout.Bands[0], 5, 0, "BacklogSeq",
  66. "OutnumSingle", "Ordernum", "MatchNum", "ReqProdNum");
  67. PlanComm.setGridDigitalCol(ultraGridJG.DisplayLayout.Bands[0], 5, 2, "Outdiameter",
  68. "Wallthick", "Aimwallthick", "Lengthmax", "Lengthmin", "Aimlength");
  69. PlanComm.setGridDigitalCol(ultraGridJG.DisplayLayout.Bands[0], 7, 3, "Finishweight",
  70. "ReqProdWt", "BuyplanWt", "MatchWt", "Orderweight", "Getrate");
  71. PlanComm.setGridDigitalCol(ultraGridJG.DisplayLayout.Bands[0], 5, 0, "BacklogSeq",
  72. "OutnumSingle", "Ordernum", "MatchNum", "ReqProdNum");
  73. PlanComm.setGridDigitalCol(ultraGridJG.DisplayLayout.Bands[0], 5, 2, "Outdiameter",
  74. "Wallthick", "Aimwallthick", "Lengthmax", "Lengthmin", "Aimlength", "LengthmaxIn", "LengthminIn");
  75. PlanComm.setGridDigitalCol(ultraGridJG.DisplayLayout.Bands[0], 7, 3, "Finishweight",
  76. "ReqProdWt", "BuyplanWt", "MatchWt", "Orderweight", "Getrate");
  77. }
  78. /// <summary>
  79. /// 初始化时间
  80. /// </summary>
  81. private void InitUpTime()
  82. {
  83. BeginTime.Value = DateTime.Parse(DateTime.Now.AddMonths(-1).ToString());
  84. EndTime.Value = DateTime.Parse(DateTime.Now.AddDays(1).AddSeconds(-1).ToString());
  85. }
  86. private void Chc_CheckedChanged(object sender, EventArgs e)
  87. {
  88. if (ChcTime.Checked)
  89. { BeginTime.Enabled = true; EndTime.Enabled = true; }
  90. else
  91. { BeginTime.Enabled = false; EndTime.Enabled = false; }
  92. if (ChcOrderNo.Checked)
  93. { TxtOrderNo.ReadOnly = false; }
  94. else
  95. { TxtOrderNo.ReadOnly = true; }
  96. }
  97. /// <summary>
  98. /// 重写基类方法
  99. /// </summary>
  100. /// <param name="sender"></param>
  101. /// <param name="ToolbarKey"></param>
  102. public override void ToolBar_Click(object sender, string ToolbarKey)
  103. {
  104. switch (ToolbarKey)
  105. {
  106. case "Query":
  107. DoQuery();
  108. break;
  109. case "Export":
  110. if (TabControl1.SelectedTab.Key.Equals("1"))
  111. {
  112. userControlSaleordProc1.Export();
  113. }
  114. else
  115. {
  116. GridHelper.ulGridToExcel(UltraGirdBLInfo, "备料需求");
  117. }
  118. break;
  119. case "Close":
  120. this.Close();
  121. break;
  122. case "PLINECHANGE":
  123. MscPlineChange();
  124. break;
  125. }
  126. }
  127. private void DoQuery()
  128. {
  129. QueryOrderInfo();
  130. }
  131. /// <summary>
  132. /// 查询销售合同
  133. /// </summary>
  134. private void QueryOrderInfo()
  135. {
  136. String orderNo = "";
  137. String beginTime = "";
  138. String endTime = "";
  139. String isFinish = "";
  140. if (ChcOrderNo.Checked)
  141. {
  142. orderNo = TxtOrderNo.Text.Trim();
  143. }
  144. if (ChcTime.Checked && BeginTime.Value != null && EndTime.Value != null)
  145. {
  146. beginTime = BeginTime.Value.ToString();
  147. endTime = EndTime.Value.ToString();
  148. }
  149. if (checkBoxFinish.Checked)
  150. {
  151. isFinish = ultraComboFinishEditor.Value.ToString();
  152. }
  153. userControlSaleordProc1.Query(orderNo, beginTime, endTime, isFinish, this.ob);
  154. UltraGridRow ugr = userControlSaleordProc1.getActiveRow();
  155. if (ugr == null)
  156. {
  157. plnReqinfGpEntityBindingSource.Clear();
  158. plnOrderDzEntityBindingSource.Clear();
  159. plnOrderZgEntityBindingSource.Clear();
  160. plnOrderDbkEntityBindingSource.Clear();
  161. plnOrderRclEntityBindingSource.Clear();
  162. plnOrderJgxEntityBindingSource.Clear();
  163. }
  164. }
  165. /// <summary>
  166. /// 查询铸造工序
  167. /// </summary>
  168. /// <param name="ordLnDlyPk">交货行号</param>
  169. /// <param name="plnDivideId">排产流水号</param>
  170. //private void QueryGP(string ordLnDlyPk, string plnDivideId, string orderSource)
  171. //{
  172. // ArrayList param = new ArrayList();
  173. // param.Add(ordLnDlyPk);
  174. // param.Add(plnDivideId);
  175. // param.Add(orderSource);
  176. // //List<PlnOrderZgEntity> listZG = EntityHelper.GetData<PlnOrderZgEntity>
  177. // // ("com.steering.pss.plnsaleord.processOrder.CoreProcessOrder.queryGP", new object[] { param }, this.ob);
  178. // //plnReqinfGpEntityBindingSource.DataSource = listZG;
  179. //}
  180. /// <summary>
  181. /// 查询锻造工序
  182. /// </summary>
  183. /// <param name="ordLnDlyPk">交货行号</param>
  184. /// <param name="plnDivideId">排产流水号</param>
  185. //private void QueryDZ(string ordLnDlyPk, string plnDivideId, string orderSource)
  186. //{
  187. // ArrayList param = new ArrayList();
  188. // param.Add(ordLnDlyPk);
  189. // param.Add(plnDivideId);
  190. // param.Add(orderSource);
  191. // List<PlnOrderZgEntity> listZG = EntityHelper.GetData<PlnOrderZgEntity>
  192. // ("com.steering.pss.plnsaleord.processOrder.CoreProcessOrder.queryDZ", new object[] { param }, this.ob);
  193. // plnOrderDzEntityBindingSource.DataSource = listZG;
  194. //}
  195. /// <summary>
  196. /// 查询轧管工序
  197. /// </summary>
  198. /// <param name="ordLnDlyPk">交货行号</param>
  199. /// <param name="plnDivideId">排产流水号</param>
  200. private void QueryZG(string ordLnDlyPk, string plnDivideId, string orderSource)
  201. {
  202. ArrayList param = new ArrayList();
  203. param.Add(ordLnDlyPk);
  204. param.Add(plnDivideId);
  205. param.Add(orderSource);
  206. List<PlnOrderZgEntity> listZG = EntityHelper.GetData<PlnOrderZgEntity>
  207. ("com.steering.pss.plnsaleord.processOrder.CoreProcessOrder.queryZG", new object[] { param }, this.ob);
  208. plnOrderZgEntityBindingSource.DataSource = listZG;
  209. }
  210. /// <summary>
  211. /// 查询墩拔扩工序
  212. /// </summary>
  213. /// <param name="ordLnDlyPk">交货行号</param>
  214. /// <param name="plnDivideId">排产流水号</param>
  215. private void QueryDBK(string ordLnDlyPk, string plnDivideId, string orderSource)
  216. {
  217. ArrayList param = new ArrayList();
  218. param.Add(ordLnDlyPk);
  219. param.Add(plnDivideId);
  220. param.Add(orderSource);
  221. List<PlnOrderDbkEntity> listDBK = EntityHelper.GetData<PlnOrderDbkEntity>
  222. ("com.steering.pss.plnsaleord.processOrder.CoreProcessOrder.queryDBK", new object[] { param }, this.ob);
  223. plnOrderDbkEntityBindingSource.DataSource = listDBK;
  224. }
  225. /// <summary>
  226. /// 查询热处理工序
  227. /// </summary>
  228. /// <param name="ordLnDlyPk">交货行号</param>
  229. /// <param name="plnDivideId">排产流水号</param>
  230. private void QueryRCL(string ordLnDlyPk, string plnDivideId, string orderSource)
  231. {
  232. ArrayList param = new ArrayList();
  233. param.Add(ordLnDlyPk);
  234. param.Add(plnDivideId);
  235. param.Add(orderSource);
  236. List<PlnOrderRclEntity> listRCL = EntityHelper.GetData<PlnOrderRclEntity>
  237. ("com.steering.pss.plnsaleord.processOrder.CoreProcessOrder.queryRCL", new object[] { param }, this.ob);
  238. plnOrderRclEntityBindingSource.DataSource = listRCL;
  239. }
  240. /// <summary>
  241. /// 查询加工工序
  242. /// </summary>
  243. /// <param name="ordLnDlyPk">交货行号</param>
  244. /// <param name="plnDivideId">排产流水号</param>
  245. private void QueryJG(string ordLnDlyPk, string plnDivideId, string orderSource)
  246. {
  247. ArrayList param = new ArrayList();
  248. param.Add(ordLnDlyPk);
  249. param.Add(plnDivideId);
  250. param.Add(orderSource);
  251. List<PlnOrderJgxEntity> listJG = EntityHelper.GetData<PlnOrderJgxEntity>
  252. ("com.steering.pss.plnsaleord.processOrder.CoreProcessOrder.queryJG", new object[] { param }, this.ob);
  253. plnOrderJgxEntityBindingSource.DataSource = listJG;
  254. }
  255. private void checkBoxFinish_CheckedChanged(object sender, EventArgs e)
  256. {
  257. if (checkBoxFinish.Checked)
  258. {
  259. ultraComboFinishEditor.Enabled = true;
  260. }
  261. else
  262. {
  263. ultraComboFinishEditor.Enabled = false;
  264. }
  265. }
  266. /// <summary>
  267. /// 销售合同
  268. /// </summary>
  269. /// <param name="sender"></param>
  270. /// <param name="e"></param>
  271. void UltraGridSaleordProc1_AfterRowActivate(object sender, EventArgs e)
  272. {
  273. UltraGridRow ugr = userControlSaleordProc1.getActiveRow();
  274. if (ugr == null)
  275. {
  276. return;
  277. }
  278. string ordLnDlyPk = ugr.Cells["OrdLnDlyPk"].Text.Trim();
  279. string plnDivideId = ugr.Cells["PlnDivideId"].Text.Trim();
  280. string orderSource = "销售合同";
  281. #region 显示经过的工序
  282. string processSeq = ugr.Cells["ProcessSeq"].Value.ToString();
  283. if (processSeq.Contains("A") || processSeq.Contains("B"))
  284. {
  285. TabControl2.Tabs["1"].Enabled = true;
  286. }
  287. else
  288. {
  289. TabControl2.Tabs["1"].Enabled = false;
  290. }
  291. if (processSeq.Contains("C"))
  292. {
  293. TabControl2.Tabs["2"].Enabled = true;
  294. }
  295. else
  296. {
  297. TabControl2.Tabs["2"].Enabled = false;
  298. }
  299. if (processSeq.Contains("D"))
  300. {
  301. TabControl2.Tabs["3"].Enabled = true;
  302. }
  303. else
  304. {
  305. TabControl2.Tabs["3"].Enabled = false;
  306. }
  307. if (processSeq.Contains("E"))
  308. {
  309. TabControl2.Tabs["4"].Enabled = true;
  310. }
  311. else
  312. {
  313. TabControl2.Tabs["4"].Enabled = false;
  314. }
  315. if (processSeq.Contains("F"))
  316. {
  317. TabControl2.Tabs["5"].Enabled = true;
  318. }
  319. else
  320. {
  321. TabControl2.Tabs["5"].Enabled = false;
  322. }
  323. if (processSeq.Contains("G"))
  324. {
  325. TabControl2.Tabs["6"].Enabled = true;
  326. }
  327. else
  328. {
  329. TabControl2.Tabs["6"].Enabled = false;
  330. }
  331. #endregion
  332. //if (TabControl2.ActiveTab.Key.Equals("1"))
  333. //{
  334. // QueryGP(ordLnDlyPk, plnDivideId, orderSource);
  335. //}
  336. //else if (TabControl2.ActiveTab.Key.Equals("2"))
  337. //{
  338. // QueryDZ(ordLnDlyPk, plnDivideId, orderSource);
  339. //}
  340. //else
  341. if (TabControl2.ActiveTab.Key.Equals("3"))
  342. {
  343. QueryZG(ordLnDlyPk, plnDivideId, orderSource);
  344. }
  345. else if (TabControl2.ActiveTab.Key.Equals("4"))
  346. {
  347. QueryDBK(ordLnDlyPk, plnDivideId, orderSource);
  348. }
  349. else if (TabControl2.ActiveTab.Key.Equals("5"))
  350. {
  351. QueryRCL(ordLnDlyPk, plnDivideId, orderSource);
  352. }
  353. else
  354. {
  355. QueryJG(ordLnDlyPk, plnDivideId, orderSource);
  356. }
  357. }
  358. /// <summary>
  359. /// 备料需求
  360. /// </summary>
  361. /// <param name="sender"></param>
  362. /// <param name="e"></param>
  363. private void UltraGirdBLInfo_AfterRowActivate(object sender, EventArgs e)
  364. {
  365. UltraGridRow ugr = UltraGirdBLInfo.ActiveRow;
  366. if (ugr == null)
  367. { return; }
  368. string ordLnDlyPk = ugr.Cells["OrdLnDlyPk"].Text.Trim();
  369. string plnDivideId = ugr.Cells["PlnDivideId"].Text.Trim();
  370. string orderSource = "备料需求";
  371. //if (TabControl2.ActiveTab.Key.Equals("1"))
  372. //{
  373. // QueryGP(ordLnDlyPk, plnDivideId, orderSource);
  374. //}
  375. //else if (TabControl2.ActiveTab.Key.Equals("2"))
  376. //{
  377. // QueryDZ(ordLnDlyPk, plnDivideId, orderSource);
  378. //}
  379. //else
  380. if (TabControl2.ActiveTab.Key.Equals("3"))
  381. {
  382. QueryZG(ordLnDlyPk, plnDivideId, orderSource);
  383. }
  384. else if (TabControl2.ActiveTab.Key.Equals("4"))
  385. {
  386. QueryDBK(ordLnDlyPk, plnDivideId, orderSource);
  387. }
  388. else if (TabControl2.ActiveTab.Key.Equals("5"))
  389. {
  390. QueryRCL(ordLnDlyPk, plnDivideId, orderSource);
  391. }
  392. else
  393. {
  394. QueryJG(ordLnDlyPk, plnDivideId, orderSource);
  395. }
  396. }
  397. /// <summary>
  398. /// TAB页切换
  399. /// </summary>
  400. /// <param name="sender"></param>
  401. /// <param name="e"></param>
  402. private void TabControl2_SelectedTabChanged(object sender, Infragistics.Win.UltraWinTabControl.SelectedTabChangedEventArgs e)
  403. {
  404. UltraGridRow ugr = null;
  405. string orderSource = "";
  406. if (TabControl1.SelectedTab.Key.Equals("1"))
  407. {
  408. ugr = userControlSaleordProc1.getActiveRow();
  409. orderSource = "销售合同";
  410. }
  411. else
  412. {
  413. ugr = UltraGirdBLInfo.ActiveRow;
  414. orderSource = "备料需求";
  415. }
  416. if (ugr == null)
  417. { return; }
  418. string ordLnDlyPk = ugr.Cells["OrdLnDlyPk"].Text.Trim();
  419. string plnDivideId = ugr.Cells["PlnDivideId"].Text.Trim();
  420. //if (e.Tab.Key.Equals("1"))
  421. //{
  422. // QueryGP(ordLnDlyPk, plnDivideId, orderSource);
  423. //}
  424. //else if (e.Tab.Key.Equals("2"))
  425. //{
  426. // QueryDZ(ordLnDlyPk, plnDivideId, orderSource);
  427. //}
  428. //else
  429. if (e.Tab.Key.Equals("3"))
  430. {
  431. QueryZG(ordLnDlyPk, plnDivideId, orderSource);
  432. }
  433. else if (e.Tab.Key.Equals("4"))
  434. {
  435. QueryDBK(ordLnDlyPk, plnDivideId, orderSource);
  436. }
  437. else if (e.Tab.Key.Equals("5"))
  438. {
  439. QueryRCL(ordLnDlyPk, plnDivideId, orderSource);
  440. }
  441. else
  442. {
  443. QueryJG(ordLnDlyPk, plnDivideId, orderSource);
  444. }
  445. }
  446. /// <summary>
  447. /// 制程变更
  448. /// </summary>
  449. private void MscPlineChange()
  450. {
  451. //当前工序选择行
  452. IQueryable<UltraGridRow> ugrs = null;
  453. //当前工序
  454. string nowProcess = "";
  455. if (TabControl2.ActiveTab.Key.Equals("1"))
  456. {
  457. ultraGridGP.UpdateData();
  458. ugrs = ultraGridGP.Rows.AsQueryable().Where(" CHC = 'True' ");
  459. nowProcess = "B";
  460. }
  461. else if (TabControl2.ActiveTab.Key.Equals("2"))
  462. {
  463. ultraGridDZ.UpdateData();
  464. ugrs = ultraGridDZ.Rows.AsQueryable().Where(" CHC = 'True' ");
  465. nowProcess = "C";
  466. }
  467. else if (TabControl2.ActiveTab.Key.Equals("3"))
  468. {
  469. ultraGridZG.UpdateData();
  470. ugrs = ultraGridZG.Rows.AsQueryable().Where(" CHC = 'True' ");
  471. nowProcess = "D";
  472. }
  473. else if (TabControl2.ActiveTab.Key.Equals("4"))
  474. {
  475. ultraGridDBK.UpdateData();
  476. ugrs = ultraGridDBK.Rows.AsQueryable().Where(" CHC = 'True' ");
  477. nowProcess = "E";
  478. }
  479. else if (TabControl2.ActiveTab.Key.Equals("5"))
  480. {
  481. ultraGridRCL.UpdateData();
  482. ugrs = ultraGridRCL.Rows.AsQueryable().Where(" CHC = 'True' ");
  483. nowProcess = "F";
  484. }
  485. else
  486. {
  487. ultraGridJG.UpdateData();
  488. ugrs = ultraGridJG.Rows.AsQueryable().Where(" CHC = 'True' ");
  489. nowProcess = "G";
  490. }
  491. if (ugrs == null || ugrs.Count() == 0)
  492. {
  493. MessageUtil.ShowWarning("请选择一条工序记录进行制程变更!");
  494. return;
  495. }
  496. UltraGridRow ugr = ugrs.First();
  497. //交货行主键
  498. string ordLnDlyPk = ugr.Cells["OrdLnDlyPk"].Text;
  499. //排产流水号
  500. string plnDivideId = ugr.Cells["PlnDivideId"].Text;
  501. //联动组号
  502. string planGroupId = ugr.Cells["PlanGroupId"].Text;
  503. //工序完成量
  504. double finishWgtB = Convert.ToDouble(finishWeight.Value.ToString());
  505. UltraGridRow ugrProduc = userControlSaleordProc1.getActiveRow();
  506. //成品排产量
  507. double planWgt = double.Parse(ugrProduc.Cells["PlanWtD"].Text);
  508. string mscPline = ugrProduc.Cells["ProcessSeq"].Text;
  509. //合同行
  510. string orderNoSeq = ugrProduc.Cells["OrderNoSeq"].Text;
  511. //合同来源
  512. string orderSource = ugrProduc.Cells["OrderSource"].Text;
  513. //成品完成量
  514. double finishWgtE = 0;
  515. //判断是否为制程最后一道工序
  516. if (mscPline.Substring(mscPline.Length - 1).Equals(nowProcess))
  517. {
  518. finishWgtE = finishWgtB;
  519. }
  520. else
  521. {
  522. finishWgtE = finishWgtB;
  523. string[] processes = mscPline.Split('-');
  524. //标识(用于判断是否当前工序,如果还没有到当前工序,则继续循环,否则直接计划成品完成量)
  525. Boolean flag = false;
  526. for (int i = 0; i < processes.Length; i++)
  527. {
  528. if (!flag)
  529. {
  530. if (processes[i].Equals(nowProcess))
  531. {
  532. flag = true;
  533. }
  534. }
  535. else
  536. {
  537. double getRate = GetRate(processes[i], ordLnDlyPk, plnDivideId, planGroupId);
  538. finishWgtE = finishWgtE * getRate;
  539. }
  540. }
  541. }
  542. if (finishWgtE > planWgt)
  543. {
  544. MessageUtil.ShowWarning("工序成品完成量:" + finishWgtE + "吨大于排产分配量:" + planWgt + "吨");
  545. return;
  546. }
  547. FrmMscPlineChange frmMscPlineChange = new FrmMscPlineChange(ordLnDlyPk, nowProcess, plnDivideId,
  548. planGroupId, finishWgtB, finishWgtE, this.ob, orderNoSeq, orderSource);
  549. if (!getOrdFistProFinishWt(ordLnDlyPk, plnDivideId, this.ob) && finishWgtB <= 0)
  550. {
  551. frmMscPlineChange.ultraToolbarsManager1.Tools["修改"].SharedProps.Visible = true;
  552. frmMscPlineChange.ultraToolbarsManager1.Tools["新增"].SharedProps.Visible = false;
  553. frmMscPlineChange.ultraToolbarsManager1.Tools["下发"].SharedProps.Visible = false;
  554. frmMscPlineChange.ultraToolbarsManager1.Tools["删除"].SharedProps.Visible = false;
  555. }
  556. frmMscPlineChange.ShowDialog();
  557. DoQuery();
  558. ugrs = userControlSaleordProc1.UltraGridSaleordProc1.Rows.AsQueryable().Where(" OrdLnDlyPk = '" + ordLnDlyPk + "' ");
  559. ugrs = ugrs.AsQueryable().Where(" PlnDivideId = '" + plnDivideId + "' ");
  560. if (ugrs != null && ugrs.Count() > 0)
  561. {
  562. userControlSaleordProc1.UltraGridSaleordProc1.ActiveRow = ugrs.First();
  563. }
  564. }
  565. private void ultraGrid_AfterRowActivate(object sender, EventArgs e)
  566. {
  567. UltraGridRow ugrActive = null;
  568. UltraGrid ug = null;
  569. if (TabControl2.ActiveTab.Key.Equals("1"))
  570. {
  571. ug = ultraGridGP;
  572. ugrActive = ultraGridGP.ActiveRow;
  573. }
  574. else if (TabControl2.ActiveTab.Key.Equals("2"))
  575. {
  576. ug = ultraGridDZ;
  577. ugrActive = ultraGridDZ.ActiveRow;
  578. }
  579. else if (TabControl2.ActiveTab.Key.Equals("3"))
  580. {
  581. ug = ultraGridZG;
  582. ugrActive = ultraGridZG.ActiveRow;
  583. }
  584. else if (TabControl2.ActiveTab.Key.Equals("4"))
  585. {
  586. ug = ultraGridDBK;
  587. ugrActive = ultraGridDBK.ActiveRow;
  588. }
  589. else if (TabControl2.ActiveTab.Key.Equals("5"))
  590. {
  591. ug = ultraGridRCL;
  592. ugrActive = ultraGridRCL.ActiveRow;
  593. }
  594. else
  595. {
  596. ug = ultraGridJG;
  597. ugrActive = ultraGridJG.ActiveRow;
  598. }
  599. if (ugrActive == null)
  600. {
  601. return;
  602. }
  603. else
  604. {
  605. foreach (UltraGridRow ugr in ug.Rows)
  606. {
  607. ugr.Cells["CHC"].Value = false;
  608. }
  609. ugrActive.Cells["CHC"].Value = true;
  610. finishWeight.Value = ugrActive.Cells["FINISHWEIGHT"].Text == "" ? 0 : Convert.ToDouble(ugrActive.Cells["FINISHWEIGHT"].Text);
  611. }
  612. }
  613. private void ultraButton1_Click(object sender, EventArgs e)
  614. {
  615. MscPlineChange();
  616. }
  617. /// <summary>
  618. /// 控制工序完成量的输入
  619. /// </summary>
  620. /// <param name="sender"></param>
  621. /// <param name="e"></param>
  622. private void finishWeight_ValueChanged(object sender, EventArgs e)
  623. {
  624. IQueryable<UltraGridRow> ugrs = null;
  625. if (TabControl2.ActiveTab.Key.Equals("1"))
  626. {
  627. ugrs = ultraGridGP.Rows.AsQueryable().Where(" CHC = 'True' ");
  628. }
  629. else if (TabControl2.ActiveTab.Key.Equals("2"))
  630. {
  631. ugrs = ultraGridDZ.Rows.AsQueryable().Where(" CHC = 'True' ");
  632. }
  633. else if (TabControl2.ActiveTab.Key.Equals("3"))
  634. {
  635. ugrs = ultraGridZG.Rows.AsQueryable().Where(" CHC = 'True' ");
  636. }
  637. else if (TabControl2.ActiveTab.Key.Equals("4"))
  638. {
  639. ugrs = ultraGridDBK.Rows.AsQueryable().Where(" CHC = 'True' ");
  640. }
  641. else if (TabControl2.ActiveTab.Key.Equals("5"))
  642. {
  643. ugrs = ultraGridRCL.Rows.AsQueryable().Where(" CHC = 'True' ");
  644. }
  645. else
  646. {
  647. ugrs = ultraGridJG.Rows.AsQueryable().Where(" CHC = 'True' ");
  648. }
  649. UltraGridRow ugr = ugrs.First();
  650. //如果工序存在激活行,则工序完成量不能小于激活行的完成量
  651. if (ugr != null)
  652. {
  653. double finishWgt = ugr.Cells["FINISHWEIGHT"].Text == "" ? 0 : Convert.ToDouble(ugr.Cells["FINISHWEIGHT"].Text);
  654. double inWgt = finishWeight.Value == null ? 0 : Convert.ToDouble(finishWeight.Value.ToString());
  655. if (inWgt < finishWgt)
  656. {
  657. finishWeight.Value = finishWgt;
  658. }
  659. }
  660. }
  661. /// <summary>
  662. /// 查询成材率
  663. /// </summary>
  664. /// <param name="process">工序</param>
  665. /// <param name="ordLnDlyPk">交货行主键</param>
  666. /// <param name="plnDivideId">排产流水号</param>
  667. /// <param name="planGroupId">联动主号</param>
  668. /// <returns></returns>
  669. private double GetRate(string process, string ordLnDlyPk, string plnDivideId, string planGroupId)
  670. {
  671. double getRate = 1;
  672. CoreClientParam ccp = new CoreClientParam();
  673. ccp.ServerName = "com.steering.pss.plnsaleord.processOrder.CoreProcessOrder";
  674. ccp.MethodName = "getGetRate";
  675. ccp.ServerParams = new object[] { process, ordLnDlyPk, plnDivideId, planGroupId };
  676. ccp = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  677. if (ccp.ReturnCode != -1)
  678. {
  679. getRate = Double.Parse(ccp.ReturnInfo);
  680. }
  681. return getRate;
  682. }
  683. private void ultraButton2_Click(object sender, EventArgs e)
  684. {
  685. //DoReqProcOrd();
  686. }
  687. /// <summary>
  688. /// 工序 补量
  689. /// </summary>
  690. //private void DoReqProcOrd()
  691. //{
  692. // //当前工序选择行
  693. // IQueryable<UltraGridRow> ugrs = null;
  694. // //当前工序
  695. // string nowProcess = "";
  696. // if (TabControl2.ActiveTab.Key.Equals("2"))
  697. // {
  698. // ultraGridDZ.UpdateData();
  699. // ugrs = ultraGridDZ.Rows.AsQueryable().Where(" CHC = 'True' ");
  700. // nowProcess = "C";
  701. // }
  702. // else if (TabControl2.ActiveTab.Key.Equals("3"))
  703. // {
  704. // ultraGridZG.UpdateData();
  705. // ugrs = ultraGridZG.Rows.AsQueryable().Where(" CHC = 'True' ");
  706. // nowProcess = "D";
  707. // }
  708. // else if (TabControl2.ActiveTab.Key.Equals("4"))
  709. // {
  710. // ultraGridDBK.UpdateData();
  711. // ugrs = ultraGridDBK.Rows.AsQueryable().Where(" CHC = 'True' ");
  712. // nowProcess = "E";
  713. // }
  714. // else if (TabControl2.ActiveTab.Key.Equals("5"))
  715. // {
  716. // ultraGridRCL.UpdateData();
  717. // ugrs = ultraGridRCL.Rows.AsQueryable().Where(" CHC = 'True' ");
  718. // nowProcess = "F";
  719. // }
  720. // else
  721. // {
  722. // ultraGridJG.UpdateData();
  723. // ugrs = ultraGridJG.Rows.AsQueryable().Where(" CHC = 'True' ");
  724. // nowProcess = "G";
  725. // }
  726. // if (ugrs == null || ugrs.Count() == 0)
  727. // {
  728. // MessageUtil.ShowWarning("请选择一条工序记录进行制程变更!");
  729. // return;
  730. // }
  731. // if (ultraNumericReq.Value == null || (double)ultraNumericReq.Value == 0)
  732. // {
  733. // MessageUtil.ShowWarning("申请量有误!");
  734. // return;
  735. // }
  736. // UltraGridRow ugr = ugrs.First();
  737. // //交货行主键
  738. // string ordLnDlyPk = ugr.Cells["OrdLnDlyPk"].Text;
  739. // //排产流水号
  740. // string plnDivideId = ugr.Cells["PlnDivideId"].Text;
  741. // //联动组号
  742. // string planGroupId = ugr.Cells["PlanGroupId"].Text;
  743. // //工序合同号
  744. // string proOrderNo = ugr.Cells["ProOrderNo"].Text;
  745. // //补量申请量
  746. // double reqOrdQty = (double)ultraNumericReq.Value;
  747. // string createName = UserInfo.GetUserName();
  748. // if (MessageUtil.ShowQuestion("确认补投料" + reqOrdQty + "吨?") == DialogResult.No)
  749. // {
  750. // return;
  751. // }
  752. // CoreClientParam ccp = new CoreClientParam();
  753. // ccp.ServerName = "com.steering.pss.plnsaleord.processOrder.CoreProcessOrder";
  754. // ccp.MethodName = "addReqOrder";
  755. // ccp.ServerParams = new object[] { nowProcess, ordLnDlyPk, plnDivideId,
  756. // planGroupId, reqOrdQty, createName };
  757. // ccp = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  758. // if (ccp.ReturnCode != -1)
  759. // {
  760. // MessageUtil.ShowTips("操作成功!");
  761. // return;
  762. // }
  763. //}
  764. /// <summary>
  765. /// 获取首个工序完成量
  766. /// </summary>
  767. /// <returns></returns>
  768. public static bool getOrdFistProFinishWt(string ordLnDlyPk, string plnDivideId, OpeBase _ob)
  769. {
  770. CoreClientParam ccp = new CoreClientParam();
  771. ccp.ServerName = "com.steering.pss.plnsaleord.processOrder.CorePlnProcOrdFinish";
  772. ccp.MethodName = "getOrdFistProFinishWt";
  773. ccp.ServerParams = new object[] { ordLnDlyPk, plnDivideId };
  774. ccp = _ob.ExecuteSortResultByQueryToDataTable(ccp, CoreInvokeType.Internal);
  775. if (ccp == null || ccp.ReturnObject == null)
  776. {
  777. return false;
  778. }
  779. return (bool)ccp.ReturnObject;
  780. }
  781. }
  782. }