PopFrmCkInBill.cs 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  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;using Pur.Entity;
  10. using Core.Mes.Client.Comm.Control;
  11. using Core.Mes.Client.Comm;
  12. using Pur.Entity.configureEntity;
  13. using Infragistics.Win.UltraWinGrid;
  14. using System.Collections;
  15. using Pur.Entity.pur_orderEntiy;
  16. using Pur.configure;
  17. using Pur.Pop_upWindow;
  18. using Pur.require_plan;
  19. using Core.Mes.Client.Comm.Tool;
  20. using com.hnshituo.pur.vo;
  21. using Pur.Entity.ck;
  22. using Infragistics.Win.UltraWinEditors;
  23. using Infragistics.Win;
  24. namespace Pur.ck
  25. {
  26. public partial class PopFrmCkInBill : FrmPmsBase
  27. {
  28. public PopFrmCkInBill(OpeBase ob)
  29. {
  30. InitializeComponent();
  31. this.ob = ob;
  32. }
  33. public PopFrmCkInBill(OpeBase ob, DataTable dt)
  34. {
  35. InitializeComponent();
  36. this.ob = ob;
  37. //GridHelper.SetExcludeColumnsActive(ultraGrid1.DisplayLayout.Bands[0], "INVINQTY");
  38. //按创建时间降序
  39. dt.DefaultView.Sort = "CREATETIME DESC";
  40. dt = dt.DefaultView.ToTable();
  41. GridHelper.CopyDataToDatatable(dt, dataTable1, true);
  42. for (int i = 0; i < ultraGrid1.Rows.Count; i++)
  43. {
  44. ultraGrid1.Rows[i].Cells["InvInQty"].Value = ultraGrid1.Rows[i].Cells["RECQTY"].Value;
  45. }
  46. }
  47. //菜单单击事件
  48. private void barsManagerButon_ToolClick(object sender, Infragistics.Win.UltraWinToolbars.ToolClickEventArgs e)
  49. {
  50. switch (e.Tool.Key.ToString())
  51. {
  52. case "Query":
  53. {
  54. }
  55. break;
  56. case "conFirmation":
  57. {
  58. AddCkInBill();
  59. this.Close();
  60. }
  61. break;
  62. case "ESC":
  63. {
  64. this.Close();
  65. }
  66. break;
  67. }
  68. }
  69. /// <summary>
  70. /// ultraGrid1激活行
  71. /// </summary>
  72. /// <param name="sender"></param>
  73. /// <param name="e"></param>
  74. private void ultraGrid1_AfterRowActivate(object sender, EventArgs e)
  75. {
  76. }
  77. /// <summary>
  78. /// 初始化界面
  79. /// </summary>
  80. /// <param name="sender"></param>
  81. /// <param name="e"></param>
  82. private void PopFrmCkInBill_Load(object sender, EventArgs e)
  83. {
  84. getRecAndStorage();
  85. }
  86. /// <summary>
  87. /// 查询收货单和库存关联表
  88. /// </summary>
  89. private void getRecAndStorage()
  90. {
  91. DataTable dt= this.execute<DataTable>("com.hnshituo.pur.ck.service.CkInBillService", "getRecAndStorage", new object[] { });
  92. ultraGrid1.DataSource = dt;
  93. }
  94. /// <summary>
  95. /// 入库
  96. /// </summary>
  97. private void AddCkInBill()
  98. {
  99. ultraGrid1.UpdateData();
  100. ArrayList al_CkInBillEntity = new ArrayList();//入库单表
  101. ArrayList al_CkStorageEntity = new ArrayList();//库存表
  102. ArrayList al_CkStatisticsEntity = new ArrayList();
  103. for (int i = 0; i < ultraGrid1.Rows.Count; i++)
  104. {
  105. PurCkRecBillEntity CkRecBillEntity = this.execute<PurCkRecBillEntity>("com.hnshituo.pur.ck.service.CkRecBillService", "findById", new object[] { ultraGrid1.Rows[i].Cells["RECID"].Value.ToString() });
  106. PurCkInBillEntity CkInBillEntity = new PurCkInBillEntity();//入库
  107. CkInBillEntity = EntityHelper.CopyEntity<PurCkInBillEntity>(CkRecBillEntity);//复制合同行号中相同的字段值
  108. CkInBillEntity.InvPos = CkRecBillEntity.TempPos;//临时库位赋值给库区储位
  109. CkInBillEntity.Status = "1";
  110. CkInBillEntity.Validflag = "1";
  111. if (ultraGrid1.Rows[i].Cells["INVINQTY"].Value.ToString().Trim() != "")
  112. {
  113. CkInBillEntity.InNum = double.Parse(ultraGrid1.Rows[i].Cells["INVINQTY"].Value.ToString());//入库量
  114. }
  115. else
  116. {
  117. MessageUtil.ShowTips("入库量不能为空");
  118. return;
  119. }
  120. CkInBillEntity.CreateUserid = UserInfo.GetUserID();
  121. CkInBillEntity.CreateName = UserInfo.GetUserName();
  122. CkInBillEntity.UpdateName = null;
  123. CkInBillEntity.UpdateUserid = null;
  124. CkInBillEntity.UpdateTime = null;
  125. al_CkInBillEntity.Add(CkInBillEntity);
  126. CkStorage CkStorageEntity = new CkStorage();//库存表
  127. CkStorageEntity = EntityHelper.CopyEntity<CkStorage>(CkRecBillEntity);//复制合同行号中相同的字段值
  128. CkStorageEntity = EntityHelper.CopyEntity<CkStorage>(CkInBillEntity);//复制合同行号中相同的字段值
  129. //CkStorageEntity.InvPos = CkInBillEntity.InvPos;
  130. CkStorageEntity.Validflag = "1";
  131. CkStorageEntity.CreateUserid = UserInfo.GetUserID();
  132. CkStorageEntity.CreateName = UserInfo.GetUserName();
  133. CkStorageEntity.UpdateName = null;
  134. CkStorageEntity.UpdateUserid = null;
  135. CkStorageEntity.UpdateTime = null;
  136. al_CkStorageEntity.Add(CkStorageEntity);
  137. CkStatistics CkStatisticsEntity = new CkStatistics();//库存收发存表
  138. CkStatisticsEntity = EntityHelper.CopyEntity<CkStatistics>(CkRecBillEntity);//复制合同行号中相同的字段值
  139. CkStatisticsEntity.Validflag = "1";
  140. CkStatisticsEntity.CreateUserid = UserInfo.GetUserID();
  141. CkStatisticsEntity.CreateName = UserInfo.GetUserName();
  142. CkStatisticsEntity.UpdateName = null;
  143. CkStatisticsEntity.UpdateUserid = null;
  144. CkStatisticsEntity.UpdateTime = null;
  145. if (ultraGrid1.Rows[i].Cells["INVINQTY"].Value.ToString().Trim() != "")
  146. {
  147. //修改库存收入量、期末库存数量,都加上入库量
  148. CkStatisticsEntity.InvInQty = double.Parse(ultraGrid1.Rows[i].Cells["INVINQTY"].Value.ToString());//修改库存收入量
  149. CkStatisticsEntity.InvEndingBalanceQty = double.Parse(ultraGrid1.Rows[i].Cells["INVINQTY"].Value.ToString());
  150. }
  151. else
  152. {
  153. MessageUtil.ShowTips("库存收入量不能为空");
  154. return;
  155. }
  156. al_CkStatisticsEntity.Add(CkStatisticsEntity);
  157. }
  158. if (al_CkInBillEntity.Count < 1)
  159. {
  160. MessageUtil.ShowTips("请至少选择一条收货行");
  161. return;
  162. }
  163. CoreResult crt = this.execute<CoreResult>("com.hnshituo.pur.ck.service.CkInBillService", "AddCkInBill", new object[] { al_CkInBillEntity, al_CkStorageEntity, al_CkStatisticsEntity });
  164. if (crt.Resultcode != 0)
  165. {
  166. MessageUtil.ShowTips("入库失败 " + crt.Resultmsg);
  167. return;
  168. }
  169. MessageUtil.ShowTips("入库成功,入库单号:" + crt.Resultmsg);
  170. }
  171. /// <summary>
  172. /// 初始化grid1
  173. /// </summary>
  174. /// <param name="sender"></param>
  175. /// <param name="e"></param>
  176. private void ultraGrid1_InitializeLayout(object sender, InitializeLayoutEventArgs e)
  177. {
  178. e.Layout.Override.MergedCellStyle = MergedCellStyle.Always;
  179. e.Layout.Bands[0].Columns["INSTOCKNO"].MergedCellEvaluator = new CustomMergedCellEvaluator();
  180. }
  181. }
  182. //自定义单元格合并类
  183. public class CustomMergedCellEvaluator : Infragistics.Win.UltraWinGrid.IMergedCellEvaluator
  184. {
  185. public CustomMergedCellEvaluator() { }
  186. public bool ShouldCellsBeMerged(UltraGridRow row1, UltraGridRow row2, UltraGridColumn column)//控件自带的方法,会自动进行调用,column为初始化中设置的列
  187. {
  188. DateTime date1 = (DateTime)row1.GetCellValue(column);
  189. DateTime date2 = (DateTime)row2.GetCellValue(column);
  190. return date1.Date == date2.Date;
  191. }
  192. }
  193. }