FrmSpitWgtZg.cs 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Windows.Forms;
  9. using Core.Mes.Client.Comm.Tool;
  10. using CoreFS.CA06;
  11. using Core.Mes.Client.Comm.Server;
  12. using Core.StlMes.Client.PlnSaleOrd.工序排产;
  13. using Core.StlMes.Client.PlnSaleOrd.窗体;
  14. namespace Core.StlMes.Client.PlnSaleOrd
  15. {
  16. public partial class FrmSpitWgtZg : FrmBase
  17. {
  18. /// <summary>
  19. /// 可分配重量
  20. /// </summary>
  21. private double waitSpitWgt;
  22. /// <summary>
  23. /// 可分配支数
  24. /// </summary>
  25. private int waitSpitNum;
  26. /// <summary>
  27. /// 已分配重量
  28. /// </summary>
  29. private double alreadySpitWgt = 0;
  30. /// <summary>
  31. /// 可分配剩余支数
  32. /// </summary>
  33. private int numF;
  34. public double AlreadySpitWgt
  35. {
  36. get { return alreadySpitWgt; }
  37. set { alreadySpitWgt = value; }
  38. }
  39. /// <summary>
  40. /// 已分配支数
  41. /// </summary>
  42. private int alreadySpitNum = 0;
  43. public int AlreadySpitNum
  44. {
  45. get { return alreadySpitNum; }
  46. set { alreadySpitNum = value; }
  47. }
  48. private string heatPlanNo = "";
  49. /// <summary>
  50. /// 炉计划ID
  51. /// </summary>
  52. public string HeatPlanNo
  53. {
  54. get { return heatPlanNo; }
  55. set { heatPlanNo = value; }
  56. }
  57. private string judgeStoveNo = "";
  58. /// <summary>
  59. /// 上料炉号
  60. /// </summary>
  61. public string JudgeStoveNo
  62. {
  63. get { return judgeStoveNo; }
  64. set { judgeStoveNo = value; }
  65. }
  66. /// <summary>
  67. /// 重量与支数比例
  68. /// </summary>
  69. private double spitRatio;
  70. private string procesCode;
  71. private OpeBase ob;
  72. private ProducEntity entity = null;
  73. public FrmSpitWgtZg(double waitSpitWgt, int waitSpitNum, double spitRatio, string _procesCode, int _numF, ProducEntity _entity, OpeBase _ob)
  74. {
  75. this.waitSpitWgt = waitSpitWgt;
  76. this.waitSpitNum = waitSpitNum;
  77. this.spitRatio = spitRatio;
  78. this.procesCode = _procesCode;
  79. numF = _numF;
  80. entity = _entity;
  81. ob = _ob;
  82. //窗体居中
  83. this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
  84. //取消窗体默认关闭按钮
  85. this.ControlBox = false;
  86. InitializeComponent();
  87. }
  88. private void FrmSpitWgt_Load(object sender, EventArgs e)
  89. {
  90. numEditorAllow.Value = waitSpitWgt;
  91. ultraNumericEditor1.Value = waitSpitNum;
  92. numEditorAlready.Value = 0;
  93. ultraNumericEditor2.Value = 0;
  94. if (procesCode.Equals("D")) {
  95. ultraLabel2.Text = "可分配需坯重量:";
  96. ultraLabel7.Text = "可分配需坯支数:";
  97. }
  98. else
  99. {
  100. ultraLabel2.Text = "可分配重量:";
  101. ultraLabel7.Text = "可分配支数:";
  102. }
  103. if (numF != 0)
  104. {
  105. int spitNum = int.Parse(waitSpitNum.ToString()) - numF;
  106. if (spitNum > 0)
  107. {
  108. ultraNumericEditor2.Value = spitNum;
  109. double spitWgt = spitNum * spitRatio;
  110. numEditorAlready.Value = spitWgt;
  111. }
  112. }
  113. double expectWt = 0;
  114. if (entity.ExpectWt != null && !entity.ExpectWt.Equals(""))
  115. {
  116. expectWt= double.Parse(entity.ExpectWt) ;
  117. }
  118. double reducedWt = 0;
  119. if (entity.ReducedWt != null && !entity.ReducedWt.Equals(""))
  120. {
  121. reducedWt = double.Parse(entity.ReducedWt);
  122. }
  123. if (double.Parse(entity.WeigthSMin) - expectWt > 0)
  124. {
  125. if (reducedWt> 0)
  126. {
  127. ultraLabel9.Visible = true;
  128. ultraTextEditor1.Visible = true;
  129. txtWeight.Visible = true;
  130. ultraLabel10.Visible = true;
  131. DoQuery();
  132. }
  133. else
  134. {
  135. ultraLabel9.Visible = false;
  136. ultraTextEditor1.Visible = false;
  137. txtWeight.Visible = false;
  138. ultraLabel10.Visible = false;
  139. }
  140. }
  141. else
  142. {
  143. ultraLabel9.Visible = true;
  144. ultraTextEditor1.Visible = true;
  145. txtWeight.Visible = true;
  146. ultraLabel10.Visible = true;
  147. DoQuery();
  148. }
  149. }
  150. /// <summary>
  151. /// 查询
  152. /// </summary>
  153. private void DoQuery()
  154. {
  155. double reducedWt = 0;
  156. double wtk = 0;
  157. DataTable dt = new DataTable();
  158. if (procesCode.Equals("D"))
  159. {
  160. dt = ServerHelper.GetData
  161. ("com.steering.pss.plnsaleord.processOrder.base.ProducHelper.doQueryActualM", new object[] { entity.ProPlanId, entity.GxPlanNo }, ob);
  162. if (dt.Rows.Count <= 0) return;
  163. for (int i = 0; i < dt.Rows.Count; i++)
  164. {
  165. reducedWt += double.Parse(dt.Rows[i]["REDUCED_WT"].ToString());
  166. if (JudgeStoveNo.Equals(""))
  167. {
  168. JudgeStoveNo = dt.Rows[i]["JUDGE_STOVE_NO"].ToString();
  169. }
  170. else
  171. {
  172. JudgeStoveNo = JudgeStoveNo + "," + dt.Rows[i]["JUDGE_STOVE_NO"].ToString();
  173. }
  174. }
  175. wtk = double.Parse(entity.GpreqWeight) - reducedWt;
  176. }
  177. else if (procesCode.Equals("H"))
  178. {
  179. dt = ServerHelper.GetData
  180. ("com.steering.pss.plnsaleord.processOrder.base.ProducHelper.doQueryStarM", new object[] { entity.ProPlanId, entity.GxPlanNo,"H" }, ob);
  181. if (dt.Rows.Count <= 0) return;
  182. for (int i = 0; i < dt.Rows.Count; i++)
  183. {
  184. reducedWt += double.Parse(dt.Rows[i]["PLAN_BL_NUM"].ToString());
  185. if (JudgeStoveNo.Equals(""))
  186. {
  187. JudgeStoveNo = dt.Rows[i]["JUDGE_STOVE_NO"].ToString();
  188. }
  189. else
  190. {
  191. JudgeStoveNo = JudgeStoveNo + "," + dt.Rows[i]["JUDGE_STOVE_NO"].ToString();
  192. }
  193. }
  194. wtk = double.Parse(entity.InWeightS) - reducedWt;
  195. }
  196. else
  197. {
  198. dt = ServerHelper.GetData
  199. ("com.steering.pss.plnsaleord.processOrder.base.ProducHelper.doQueryStarM", new object[] { entity.ProPlanId, entity.GxPlanNo, procesCode }, ob);
  200. if (dt.Rows.Count <= 0) return;
  201. for (int i = 0; i < dt.Rows.Count; i++)
  202. {
  203. reducedWt += double.Parse(dt.Rows[i]["PLN_OUTDOUBLE_W"].ToString());
  204. if (procesCode.Equals("E"))
  205. {
  206. if (JudgeStoveNo.Equals(""))
  207. {
  208. JudgeStoveNo = dt.Rows[i]["FEED_HEAT_NO"].ToString();
  209. }
  210. else
  211. {
  212. JudgeStoveNo = JudgeStoveNo + "," + dt.Rows[i]["FEED_HEAT_NO"].ToString();
  213. }
  214. }
  215. else
  216. {
  217. if (JudgeStoveNo.Equals(""))
  218. {
  219. JudgeStoveNo = dt.Rows[i]["JUDGE_STOVE_NO"].ToString();
  220. }
  221. else
  222. {
  223. JudgeStoveNo = JudgeStoveNo + "," + dt.Rows[i]["JUDGE_STOVE_NO"].ToString();
  224. }
  225. }
  226. }
  227. wtk = double.Parse(entity.InWeightS) - reducedWt;
  228. }
  229. ultraTextEditor1.Text = JudgeStoveNo;
  230. txtWeight.Text = reducedWt.ToString();
  231. int spitNum = (int)Math.Ceiling(wtk / spitRatio);
  232. ultraNumericEditor2.Value = spitNum;
  233. numEditorAlready.Value = spitNum * spitRatio;
  234. }
  235. private void buttonCommit_Click(object sender, EventArgs e)
  236. {
  237. string spitNum = ultraNumericEditor2.Value == null ? "0" : ultraNumericEditor2.Value.ToString();
  238. //string spitWgt = numEditorAlready.Value == null ? "0" : numEditorAlready.Value.ToString();
  239. if (int.Parse(spitNum) <= 0)
  240. {
  241. MessageUtil.ShowWarning("分配支数不能为0支!");
  242. return;
  243. }
  244. if (Convert.ToInt32(spitNum) >= waitSpitNum)
  245. {
  246. MessageUtil.ShowWarning("分配支数不能大于/等于可分配支数!");
  247. return;
  248. }
  249. double spitWgt = Convert.ToInt32(spitNum) * spitRatio;
  250. alreadySpitWgt = Convert.ToDouble(spitWgt);
  251. //通过重量与支数的比例计划 分配支数
  252. alreadySpitNum = Convert.ToInt32(spitNum);
  253. if (double.Parse(entity.WeigthSMin) - double.Parse(entity.ExpectWt) > 0)
  254. {
  255. if (double.Parse(entity.ReducedWt) > 0)
  256. {
  257. if (JudgeStoveNo.Equals(""))
  258. {
  259. if (MessageUtil.ShowYesNoAndQuestion("是否需要选择保留炉?") == DialogResult.Yes)
  260. {
  261. return;
  262. }
  263. }
  264. }
  265. else
  266. {
  267. ultraLabel9.Visible = false;
  268. ultraTextEditor1.Visible = false;
  269. txtWeight.Visible = false;
  270. ultraLabel10.Visible = false;
  271. }
  272. }
  273. else
  274. {
  275. if (JudgeStoveNo.Equals(""))
  276. {
  277. if (MessageUtil.ShowYesNoAndQuestion("是否需要选择保留炉?") == DialogResult.Yes)
  278. {
  279. return;
  280. }
  281. }
  282. }
  283. this.Close();
  284. }
  285. private void buttonCancel_Click(object sender, EventArgs e)
  286. {
  287. this.Close();
  288. }
  289. //输入支数
  290. private void ultraNumericEditor2_ValueChanged(object sender, EventArgs e)
  291. {
  292. if (ultraNumericEditor2 == null)
  293. {
  294. numEditorAlready.Value = 0;
  295. ultraNumericEditor2.Value = 0;
  296. return;
  297. }
  298. string spitNum = ultraNumericEditor2.Value.ToString();
  299. if (int.Parse(spitNum) > waitSpitNum)
  300. {
  301. numEditorAlready.Value = waitSpitWgt;
  302. ultraNumericEditor2.Value = waitSpitNum;
  303. return;
  304. }
  305. double spitWgt = int.Parse(spitNum) * spitRatio;
  306. numEditorAlready.Value = spitWgt;
  307. }
  308. private void ultraTextEditor1_EditorButtonClick(object sender, Infragistics.Win.UltraWinEditors.EditorButtonEventArgs e)
  309. {
  310. if (procesCode.Equals("D"))
  311. {
  312. FrmSpitPlanZgM frmSpitZgm = new FrmSpitPlanZgM(entity.ProPlanId, entity.GxPlanNo, ob);
  313. frmSpitZgm.ShowDialog();
  314. HeatPlanNo = frmSpitZgm.HeatPlanNo;
  315. JudgeStoveNo = frmSpitZgm.JudgeStoveNo;
  316. ultraTextEditor1.Text = JudgeStoveNo;
  317. txtWeight.Text = frmSpitZgm.ReducedWt.ToString();
  318. double wtk = 0;
  319. if (frmSpitZgm.ReducedWt == 0)
  320. {
  321. wtk = frmSpitZgm.ReducedWtKc;
  322. int spitNum = (int)(wtk / spitRatio);
  323. ultraNumericEditor2.Value = spitNum;
  324. numEditorAlready.Value = spitNum * spitRatio;
  325. }
  326. else
  327. {
  328. wtk = double.Parse(entity.GpreqWeight) - frmSpitZgm.ReducedWt;
  329. int spitNum = (int)Math.Ceiling(wtk / spitRatio);
  330. ultraNumericEditor2.Value = spitNum;
  331. numEditorAlready.Value = spitNum * spitRatio;
  332. }
  333. }
  334. else if (procesCode.Equals("H"))
  335. {
  336. FrmSpitPlanJg frmSpitZgm = new FrmSpitPlanJg(entity.ProPlanId, entity.GxPlanNo, ob);
  337. frmSpitZgm.ShowDialog();
  338. HeatPlanNo = frmSpitZgm.HeatPlanNo;
  339. JudgeStoveNo = frmSpitZgm.JudgeStoveNo;
  340. ultraTextEditor1.Text = JudgeStoveNo;
  341. txtWeight.Text = frmSpitZgm.ReducedWt.ToString();
  342. double wtk = 0;
  343. if (frmSpitZgm.ReducedWt == 0)
  344. {
  345. wtk = frmSpitZgm.ReducedWtKc;
  346. int spitNum = (int)(wtk / spitRatio);
  347. ultraNumericEditor2.Value = spitNum;
  348. numEditorAlready.Value = spitNum * spitRatio;
  349. }
  350. else
  351. {
  352. wtk = double.Parse(entity.InWeightS) - frmSpitZgm.ReducedWt;
  353. int spitNum = (int)Math.Ceiling(wtk / spitRatio);
  354. ultraNumericEditor2.Value = spitNum;
  355. numEditorAlready.Value = spitNum * spitRatio;
  356. }
  357. }
  358. else
  359. {
  360. FrmSpitPlanM frmSpitZgm = new FrmSpitPlanM(entity.ProPlanId, entity.GxPlanNo, ob, procesCode);
  361. frmSpitZgm.ShowDialog();
  362. HeatPlanNo = frmSpitZgm.HeatPlanNo;
  363. JudgeStoveNo = frmSpitZgm.JudgeStoveNo;
  364. ultraTextEditor1.Text = JudgeStoveNo;
  365. txtWeight.Text = frmSpitZgm.ReducedWt.ToString();
  366. double wtk = 0;
  367. if (frmSpitZgm.ReducedWt == 0)
  368. {
  369. wtk = frmSpitZgm.ReducedWtKc;
  370. int spitNum = (int)(wtk / spitRatio);
  371. ultraNumericEditor2.Value = spitNum;
  372. numEditorAlready.Value = spitNum * spitRatio;
  373. }
  374. else
  375. {
  376. wtk = double.Parse(entity.InWeightS) - frmSpitZgm.ReducedWt;
  377. int spitNum = (int)Math.Ceiling(wtk / spitRatio);
  378. ultraNumericEditor2.Value = spitNum;
  379. numEditorAlready.Value = spitNum * spitRatio;
  380. }
  381. }
  382. //if (wtk <= 0)
  383. //{
  384. // MessageUtil.ShowWarning("可分配量不能小于等于0!");
  385. // return;
  386. //}
  387. //double spitRatoR = double.Parse(entity.GpreqWeight) / double.Parse(entity.ReducedWt);
  388. }
  389. }
  390. }