frmPopSetCkInBillOutNum.cs 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250
  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 CoreFS.CA06;
  10. using Core.Mes.Client.Comm.Control;
  11. using Infragistics.Win.UltraWinGrid;
  12. using System.Collections;
  13. using Core.Mes.Client.Comm.Tool;
  14. using Pur.Entity.configureEntity;
  15. using Pur.Entity.ck;
  16. using Pur.Entity.require_planEntiy;
  17. namespace Pur.Pop_upWindow
  18. {
  19. public partial class frmPopSetCkInBillOutNum : FrmBase
  20. {
  21. ArrayList al_ExcDeliverySubC = null;
  22. public Hashtable ht = null;
  23. DataTable oldDt = new DataTable();
  24. public string strTips = "0";
  25. public frmPopSetCkInBillOutNum(OpeBase ob, DataTable dt, ArrayList al_ExcDeliverySubC)
  26. {
  27. InitializeComponent();
  28. this.ob = ob;
  29. this.oldDt = dt;
  30. this.al_ExcDeliverySubC = al_ExcDeliverySubC;
  31. }
  32. /// <summary>
  33. /// 按钮控件
  34. /// </summary>
  35. /// <param name="sender"></param>
  36. /// <param name="e"></param>
  37. private void barsManagerButon_ToolClick(object sender, Infragistics.Win.UltraWinToolbars.ToolClickEventArgs e)
  38. {
  39. switch (e.Tool.Key.ToString())
  40. {
  41. case "Query":
  42. {
  43. }
  44. break;
  45. case "conFirmation":
  46. {
  47. conFirmation();
  48. }
  49. break;
  50. case "ESC":
  51. {
  52. this.Close();
  53. }
  54. break;
  55. }
  56. }
  57. /// <summary>
  58. /// 界面初始化
  59. /// </summary>
  60. /// <param name="sender"></param>
  61. /// <param name="e"></param>
  62. private void frmPopSetCkInBillOutNum_Load(object sender, EventArgs e)
  63. {
  64. PurCkInBillEntity CkInBillEntity = new PurCkInBillEntity();//入库单表
  65. string[] strs=new string[al_ExcDeliverySubC.Count];
  66. for (int i = 0; i < al_ExcDeliverySubC.Count; i++)
  67. {
  68. strs[i] = ((ExcDeliverySubC)al_ExcDeliverySubC[i]).DeliverySubLineSqe;
  69. }
  70. for (int i = oldDt.Rows.Count-1; i >= 0; i--)
  71. {
  72. if (!strs.Contains(oldDt.Rows[i]["DELIVERYSUBLINESQE"].ToString().Trim()))
  73. {
  74. oldDt.Rows.RemoveAt(i);
  75. }
  76. }
  77. GridHelper.CopyDataToDatatable(oldDt, dataTable4, true);
  78. ultraGrid3.DisplayLayout.Bands[0].PerformAutoResizeColumns(true, PerformAutoSizeType.AllRowsInBand);
  79. //CkInBillEntity.ReceiveType = "1";//1,JIT 2,非JIT
  80. CkInBillEntity.DeliverySubLineSqes = strs;
  81. DataTable dt = this.GetJsonService().execute<DataTable>("com.hnshituo.pur.ck.service.CkInBillService", "GetCkInBillOutNum", new object[] { CkInBillEntity });
  82. if (dt==null || dt.Rows.Count == 0)
  83. {
  84. MessageUtil.ShowTips("未能加载送货单行的关联需求计划,无法进行库存分配");
  85. strTips = "0";
  86. return;
  87. }
  88. GridHelper.CopyDataToDatatable(dt, dataTable1, true);
  89. ultraGrid3.UpdateData();
  90. //删除没有子行的送货单
  91. for(int i=0;i<ultraGrid3.Rows.Count;)
  92. {
  93. //if (!ultraGrid3.Rows[i].HasChild())
  94. //{
  95. // ultraGrid3.Rows[i].Delete(false);
  96. //}
  97. //else
  98. {
  99. double bweightqTY = 0;
  100. double bINNUM = 0;
  101. double.TryParse(ultraGrid3.Rows[i].Cells["INNUM"].Value.ToString(),out bINNUM);
  102. double.TryParse(ultraGrid3.Rows[i].Cells["weightqTY"].Value.ToString(), out bweightqTY);
  103. string strItemUom = ultraGrid3.Rows[i].Cells["itemUom"].Value.ToString().Trim();
  104. if ("基吨" == strItemUom)
  105. {
  106. bINNUM = bweightqTY;
  107. }
  108. double bsum = 0;
  109. string strReceivetype = "";//入库类型
  110. if (ultraGrid3.Rows[i].ChildBands[0].Rows.Count <= 1)
  111. {
  112. ultraGrid3.Rows[i].ChildBands[0].Rows[0].Cells["useQty"].Value = bINNUM;
  113. }
  114. else
  115. {
  116. foreach (UltraGridRow ugr in ultraGrid3.Rows[i].ChildBands[0].Rows)
  117. {
  118. double bUseQty = 0;
  119. double.TryParse(ugr.Cells["useQty"].Value.ToString(), out bUseQty);
  120. bsum += bUseQty;
  121. strReceivetype = ugr.Cells["receivetype"].Value.ToString();
  122. }
  123. double bsumR = Math.Round(bsum, 3);
  124. bINNUM = Math.Round(bINNUM, 3);
  125. if (bsumR != bINNUM)
  126. {
  127. if (strReceivetype == "110107")//JIT入库
  128. {
  129. ultraGrid3.Rows[i].CellAppearance.ForeColor = Color.Red;
  130. }
  131. }
  132. }
  133. i++;
  134. }
  135. }
  136. ultraGrid3.UpdateData();
  137. //控制输入
  138. GridHelper.SetExcludeColumnsActive(ultraGrid3.DisplayLayout.Bands[0]);
  139. //GridHelper.SetExcludeColumnsActive(ultraGrid3.DisplayLayout.Bands[0], "useQty");
  140. }
  141. /// <summary>
  142. /// 确认入库
  143. /// </summary>
  144. private void conFirmation()
  145. {
  146. ultraGrid3.UpdateData();
  147. Hashtable ht = new Hashtable();
  148. //获取领用和出库单
  149. foreach(UltraGridRow ugr in ultraGrid3.Rows)
  150. {
  151. if (ugr.CellAppearance.ForeColor == Color.Red)
  152. {
  153. MessageUtil.ShowTips("标记为红色的送货单表示入库数量和领用出库数量对应不上,需重新填写");
  154. return;
  155. }
  156. foreach (UltraGridRow ugrChid in ugr.ChildBands[0].Rows)
  157. {
  158. ArrayList al = new ArrayList();
  159. UsePlanD upd = new UsePlanD();
  160. upd.ReqOrgId = ugrChid.Cells["ReqOrgId"].Value.ToString();
  161. upd.Remark = ugrChid.Cells["reqorgname"].Value.ToString();
  162. if(String.IsNullOrEmpty(upd.ReqOrgId)||String.IsNullOrEmpty(upd.Remark))
  163. {
  164. MessageUtil.ShowTips("需求计划的:" + ugrChid.Cells["mrlineid"].Value.ToString() + "的申请单为空!");
  165. return;
  166. }
  167. double bUseQty = 0;
  168. double.TryParse(ugrChid.Cells["useQty"].Value.ToString(), out bUseQty);
  169. upd.QtyPur =Math.Round(bUseQty,3);
  170. upd.ReceiveId = ugrChid.Cells["id"].Value.ToString();
  171. upd.PurRequireLineId = ugrChid.Cells["mrlineid"].Value.ToString();
  172. if (bUseQty>0)
  173. {
  174. if (ht.ContainsKey(ugrChid.Cells["deliverysublinesqe"].Value.ToString()))
  175. {
  176. al = (ArrayList)ht[ugrChid.Cells["deliverysublinesqe"].Value.ToString()];
  177. al.Add(upd);
  178. ht[ugrChid.Cells["deliverysublinesqe"].Value.ToString()] = al;
  179. }
  180. else
  181. {
  182. al.Add(upd);
  183. ht.Add(ugrChid.Cells["deliverysublinesqe"].Value.ToString(), al);
  184. }
  185. }
  186. }
  187. }
  188. if (MessageUtil.ShowYesNoAndQuestion("确定入库?").Equals(DialogResult.No))
  189. {
  190. return;
  191. }
  192. strTips = "2";
  193. this.ht = ht;
  194. this.Close();
  195. }
  196. /// <summary>
  197. /// 改变值
  198. /// </summary>
  199. /// <param name="sender"></param>
  200. /// <param name="e"></param>
  201. private void ultraGrid3_CellChange(object sender, CellEventArgs e)
  202. {
  203. object o = e.Cell.Value;
  204. ultraGrid3.UpdateData();
  205. if (e.Cell.Column.Key == "useQty")
  206. {
  207. UltraGridRow ugr = e.Cell.Row.ParentRow;
  208. double bINNUM = 0;
  209. double bweightqTY = 0;
  210. double.TryParse(ugr.Cells["INNUM"].Value.ToString(), out bINNUM);
  211. double.TryParse(ugr.Cells["weightqTY"].Value.ToString(), out bweightqTY);
  212. string strItemUom = ugr.Cells["itemUom"].Value.ToString().Trim();
  213. if ("基吨" == strItemUom)
  214. {
  215. bINNUM = bweightqTY;
  216. }
  217. double bsum = 0;
  218. string strReceivetype = "";//入库类型
  219. foreach (UltraGridRow ugr1 in ugr.ChildBands[0].Rows)
  220. {
  221. double bUseQty = 0;
  222. double.TryParse(ugr1.Cells["useQty"].Value.ToString(), out bUseQty);
  223. bsum += bUseQty;
  224. }
  225. bsum = Math.Round(bsum, 3);
  226. bINNUM = Math.Round(bINNUM, 3);
  227. if (bsum != bINNUM)
  228. {
  229. if (strReceivetype == "110107")//JIT入库
  230. {
  231. ugr.CellAppearance.ForeColor = Color.Red;
  232. }
  233. }
  234. else
  235. {
  236. ugr.CellAppearance.ForeColor = Color.Black;
  237. }
  238. }
  239. }
  240. }
  241. }