FrmPopConfirmGoods.cs 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392
  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 Pur.Entity;
  11. using Pur.Entity.pur_orderEntiy;
  12. using Core.Mes.Client.Comm.Control;
  13. using Pur.Entity.configureEntity;
  14. using Infragistics.Win.UltraWinEditors;
  15. using com.hnshituo.pur.vo;
  16. using Core.Mes.Client.Comm.Tool;
  17. using System.Collections;
  18. using Infragistics.Win;
  19. using Pur.Entity.ck;
  20. using Infragistics.Win.UltraWinGrid;
  21. using Pur.configure;
  22. using Core.Mes.Client.Comm.Server;
  23. using Pur.PublicTools;
  24. namespace Pur.Pop_upWindow
  25. {
  26. public partial class FrmPopConfirmGoods : FrmBase
  27. {
  28. public string QstrInstockNo = "";
  29. public FrmPopConfirmGoods()
  30. {
  31. InitializeComponent();
  32. }
  33. /// <summary>
  34. ///
  35. /// </summary>
  36. /// <param name="sender"></param>
  37. /// <param name="e"></param>
  38. private void FrmPopConfirmGoods_Load(object sender, EventArgs e)
  39. {
  40. QcreateTime_BeginNoJL.Value = DateTime.Now.AddMonths(-1);
  41. QcreateTime_EndNoJL.Value = DateTime.Now.AddDays(2);
  42. QcreateTime_BeginNoJL.Enabled = true;
  43. QcreateTime_EndNoJL.Enabled = true;
  44. ck_createTimeNoJL.Checked = true;
  45. txt_status.SelectedIndex = 0;
  46. GridHelper.SetExcludeColumnsActive(ultraGrid4.DisplayLayout.Bands[0], new string[] {"Check"});
  47. PublicPur.InitCellEdit(new UltraGrid[] { ultraGrid1 }, new string[] {"remark2", "SHIPQTY", "RECQTY" });
  48. PublicPur.InitCellPositionRight(new UltraGrid[] { ultraGrid1 }, new string[] { "SHIPQTY", "RECQTY" });
  49. PublicPur.InitColumnShowLength(new UltraGrid[] { ultraGrid1 }, 0, new string[] { "SHIPQTY", "RECQTY" }, 3, false);
  50. }
  51. //菜单按钮事件
  52. #region toolbar工具
  53. public override void ToolBar_Click(object sender, string ToolbarKey)
  54. {
  55. switch (ToolbarKey)
  56. {
  57. case "Query":
  58. Get_PUR_EXC_DELIVERY_M();
  59. break;
  60. case "conFirmation":
  61. setRecList();//收货
  62. break;
  63. case "QuitCheckAgain"://撤销复检
  64. QuitCheckAgain();
  65. break;
  66. case "ESC":
  67. this.Close();
  68. break;
  69. }
  70. }
  71. /// <summary>
  72. /// 查询送货通知单主表
  73. /// </summary>
  74. private void Get_PUR_EXC_DELIVERY_M()
  75. {
  76. try
  77. {
  78. this.Cursor = Cursors.WaitCursor;
  79. //查询发货通知单行表
  80. dataSet1.Clear();
  81. Hashtable map = new Hashtable();
  82. map.Add("deliverySubId", txt_DELIVERY_ID.Text);
  83. map.Add("orderId", COP_OrderId.Text);
  84. map.Add("suppName", QsuppNameNoJL.Text.Trim());
  85. map.Add("statusFJ", txt_status.Value == null ? "" : txt_status.Value.ToString());
  86. map.Add("invPhysicName", QInphysicNoJL.Text.Trim());
  87. map.Add("deliveryLocation", QLocationNoJL.Text.Trim());
  88. if (ck_createTimeNoJL.Checked)
  89. {
  90. if (QcreateTime_BeginNoJL.Value != null)//创建开始时间
  91. {
  92. map.Add("createTimeBegin", Convert.ToDateTime(QcreateTime_BeginNoJL.Value));
  93. }
  94. if (QcreateTime_EndNoJL.Value != null)//创建结束时间
  95. {
  96. map.Add("createTimeEnd", Convert.ToDateTime(QcreateTime_EndNoJL.Value));
  97. }
  98. }
  99. DataTable dt = this.GetJsonService().execute<DataTable>("com.hnshituo.pur.ck.service.ExcDeliverySubMService", "doQueryDeliverySubMList", new object[] { map });
  100. GridHelper.CopyDataToDatatable(dt, dataTable1, true);
  101. GridHelper.RefreshAndAutoSize(ultraGrid4);
  102. }
  103. catch (Exception ex)
  104. {
  105. MessageUtil.ShowTips("加载数据异常:" + ex.Message);
  106. }
  107. finally
  108. {
  109. this.Cursor = Cursors.Default;
  110. }
  111. }
  112. /// <summary>
  113. /// 生成收货单,2016-6-6 收货界面跟换成编辑框形式,tips:0为收货,1为退货
  114. /// </summary>
  115. private void setRecList()
  116. {
  117. ultraGrid1.UpdateData();
  118. ArrayList al = new ArrayList();
  119. ArrayList al_ExcDeliveryException = new ArrayList();//送货单行
  120. ExcDeliverySubC subc=new ExcDeliverySubC();
  121. ExcDeliverySubM subM=new ExcDeliverySubM();
  122. for (int j = 0; j < ultraGrid1.Rows.Count; j++)
  123. {
  124. String strSubSqe = ultraGrid1.Rows[j].Cells["DeliverySubLineSqe"].Value.ToString().Trim();
  125. if (String.IsNullOrEmpty(strSubSqe))
  126. {
  127. MessageUtil.ShowTips("异常,送货单行号为空");
  128. }
  129. if (!testDeliveryStatus(strSubSqe,1,ref subc, ref subM))
  130. {
  131. return;
  132. }
  133. double b_Qty = 0; //送货量
  134. double.TryParse(ultraGrid1.Rows[j].Cells["QTY"].Value.ToString().Trim(), out b_Qty);
  135. double b_ReceivedQty = 0; //收货量
  136. double.TryParse(ultraGrid1.Rows[j].Cells["SHIPQTY"].Value.ToString().Trim(), out b_ReceivedQty);
  137. double b_RECQty = 0; //待处置量
  138. double.TryParse(ultraGrid1.Rows[j].Cells["RECQTY"].Value.ToString().Trim(), out b_RECQty);
  139. b_Qty = Math.Round(b_Qty,3);
  140. b_ReceivedQty = Math.Round(b_ReceivedQty,3);
  141. b_RECQty = Math.Round(b_RECQty,3);
  142. String strRemark = ultraGrid1.Rows[j].Cells["remark2"].Value.ToString().Trim();
  143. if (b_RECQty > 0 && String.IsNullOrEmpty(strRemark))
  144. {
  145. MessageUtil.ShowTips("若送货单行:" + strSubSqe + "存在待处置物料,请输入待处置原因或意见");
  146. ultraGrid1.Rows[j].Activate();
  147. return;
  148. }
  149. if (b_ReceivedQty<=0)
  150. {
  151. if(MessageUtil.ShowYesNoAndQuestion("送货单行:" + strSubSqe + "确定收货数量为0?若存在存在异常单,请填写异常单量")!=DialogResult.Yes)
  152. ultraGrid1.Rows[j].Activate();
  153. return;
  154. }
  155. ExcDeliverySubC EdC = new ExcDeliverySubC();
  156. EdC.DeliverySubLineSqe = strSubSqe;
  157. EdC.Status = "3";
  158. EdC.ShipQty = b_ReceivedQty;//收货量
  159. EdC.ReceivedQty = b_RECQty;//待处置
  160. EdC.Remark = strRemark;
  161. EdC.FjName = UserInfo.GetUserName();
  162. EdC.FjUserid = UserInfo.GetUserID();
  163. EdC.FjTime = System.DateTime.Now;
  164. al.Add(EdC);
  165. }
  166. if (al.Count < 1)
  167. {
  168. MessageUtil.ShowTips("没有需要仓储复检送货单");
  169. return;
  170. }
  171. if (MessageUtil.ShowYesNoAndQuestion("确认复检?若存在待处置量,请及时通知业务员进行异常单处理。").Equals(DialogResult.Yes))
  172. {
  173. CoreResult crt = this.GetJsonService().execute<CoreResult>("com.hnshituo.pur.ck.service.ExcDeliverySubMService", "AddCheckAgain", new object[] { al});
  174. if (crt.Resultcode == 0)
  175. {
  176. MessageUtil.ShowTips("复检成功");
  177. Get_PUR_EXC_DELIVERY_M();
  178. }
  179. else
  180. {
  181. MessageUtil.ShowTips("复检失败");
  182. }
  183. }
  184. }
  185. /// <summary>
  186. /// 撤销仓储复检
  187. /// </summary>
  188. private void QuitCheckAgain()
  189. {
  190. ExcDeliverySubC subc = new ExcDeliverySubC();
  191. ExcDeliverySubM subM = new ExcDeliverySubM();
  192. ArrayList al = new ArrayList();
  193. foreach (UltraGridRow ugr in ultraGrid1.Rows)
  194. {
  195. String strSubSqe = ugr.Cells["DeliverySubLineSqe"].Value.ToString().Trim();
  196. if (String.IsNullOrEmpty(strSubSqe))
  197. {
  198. MessageUtil.ShowTips("异常,送货单行号为空");
  199. }
  200. if (!testDeliveryStatus(strSubSqe,2, ref subc, ref subM))
  201. {
  202. return;
  203. }
  204. ExcDeliverySubC Edc = new ExcDeliverySubC();
  205. Edc.DeliverySubLineSqe = strSubSqe;
  206. Edc.FjName = UserInfo.GetUserName();
  207. Edc.FjUserid = UserInfo.GetUserID();
  208. Edc.FjTime = System.DateTime.Now;
  209. al.Add(Edc);
  210. }
  211. if (al.Count <= 0)
  212. {
  213. MessageUtil.ShowTips("没有找到须要撤销的送货单行");
  214. return;
  215. }
  216. if (MessageUtil.ShowYesNoAndQuestion("确认撤销?").Equals(DialogResult.Yes))
  217. {
  218. CoreResult cr = this.GetJsonService().execute<CoreResult>("com.hnshituo.pur.ck.service.ExcDeliverySubMService", "QuitCheckAgain", new object[] { al });
  219. if (cr.Resultcode == 0)
  220. {
  221. MessageUtil.ShowTips("撤销成功");
  222. Get_PUR_EXC_DELIVERY_M();
  223. }
  224. else
  225. {
  226. MessageUtil.ShowTips("撤销失败");
  227. return;
  228. }
  229. }
  230. }
  231. #endregion
  232. #region 界面事件
  233. /// <summary>
  234. /// 选择送货单主表
  235. /// </summary>
  236. /// <param name="sender"></param>
  237. /// <param name="e"></param>
  238. private void ultraGrid4_CellChange(object sender, CellEventArgs e)
  239. {
  240. try
  241. {
  242. if (e.Cell.Column.Key == "Check")
  243. {
  244. getSubM();
  245. }
  246. }
  247. catch (Exception ex)
  248. {
  249. MessageUtil.ShowTips("加载行信息异常:"+ex.Message);
  250. }
  251. }
  252. private void ultraGrid4_AfterHeaderCheckStateChanged(object sender, AfterHeaderCheckStateChangedEventArgs e)
  253. {
  254. try
  255. {
  256. if (e.Column.Key == "Check")
  257. {
  258. getSubM();
  259. }
  260. }
  261. catch (Exception ex)
  262. {
  263. MessageUtil.ShowTips("加载行信息异常:" + ex.Message);
  264. }
  265. }
  266. private void getSubM()
  267. {
  268. ultraGrid4.UpdateData();
  269. ExcDeliverySubC edsc = new ExcDeliverySubC();
  270. List<string> l = new List<string>();
  271. foreach (UltraGridRow ugr in ultraGrid4.Rows)
  272. {
  273. if ((bool)ugr.Cells["Check"].Value)
  274. {
  275. l.Add(ugr.Cells["DeliverySubId"].Value.ToString());
  276. }
  277. }
  278. edsc.Col = l.ToArray();
  279. Get_PUR_EXC_DELIVERY_C(edsc);
  280. }
  281. private void ck_createTimeNoJL_CheckedChanged(object sender, EventArgs e)
  282. {
  283. QcreateTime_BeginNoJL.Enabled = ck_createTimeNoJL.Checked;
  284. QcreateTime_EndNoJL.Enabled = ck_createTimeNoJL.Checked;
  285. }
  286. #endregion
  287. #region 公共函数
  288. /// <summary>
  289. /// 送货单行状态校验
  290. /// </summary>
  291. /// <param name="deliverySubId"></param>
  292. /// <param name="p"></param>
  293. /// <returns></returns>
  294. private bool testDeliveryStatus(String deliverySubId, int p, ref ExcDeliverySubC subc, ref ExcDeliverySubM subM)
  295. {
  296. if (String.IsNullOrEmpty(deliverySubId))
  297. {
  298. MessageUtil.ShowTips("送货单行号为空,无法校验数据有效性");
  299. return false;
  300. }
  301. subc = this.GetJsonService().execute<ExcDeliverySubC>("com.hnshituo.pur.ck.service.ExcDeliverySubCService", "findById", new object[] { deliverySubId });
  302. if (subc == null)
  303. {
  304. MessageUtil.ShowTips("未发现送货单行:" + deliverySubId + " 信息记录,可能已作废,或请刷新界面重试");
  305. return false;
  306. }
  307. if (subc.Validflag != "1")
  308. {
  309. MessageUtil.ShowTips("未发现送货单行:" + deliverySubId + " 信息记录,可能已作废,或请刷新界面重试");
  310. return false;
  311. }
  312. String testStatus = subc.Status;
  313. if (String.IsNullOrEmpty(subc.DeliverySubId))
  314. {
  315. MessageUtil.ShowTips("未找到送货单行的头信息");
  316. return false;
  317. }
  318. subM = this.GetJsonService().execute<ExcDeliverySubM>("com.hnshituo.pur.ck.service.ExcDeliverySubMService", "findById", new object[] { subc.DeliverySubId });
  319. if (subM == null)
  320. {
  321. MessageUtil.ShowTips("未发现送货单:" + subc.DeliverySubId + " 信息记录,可能已作废,或请刷新界面重试");
  322. return false;
  323. }
  324. if (subM.Validflag != "1")
  325. {
  326. MessageUtil.ShowTips("未发现送货单:" + subc.DeliverySubId + " 信息记录,可能已作废,或请刷新界面重试");
  327. return false;
  328. }
  329. if (subM.ReceiveType!= "110107")
  330. {
  331. MessageUtil.ShowTips("未发现送货单:" + subc.DeliverySubId + " 为非JIT送货单,无操作权限");
  332. return false;
  333. }
  334. //复检
  335. if (p == 1)
  336. {
  337. if (testStatus != "2")
  338. {
  339. MessageUtil.ShowTips("送货单行:" + deliverySubId + " 不在待复检状态");
  340. return false;
  341. }
  342. }
  343. //取消复检
  344. else if (p == 2)
  345. {
  346. if (testStatus != "3")
  347. {
  348. MessageUtil.ShowTips("送货单行:" + deliverySubId + " 不在已复检状态");
  349. return false;
  350. }
  351. }
  352. else
  353. {
  354. MessageUtil.ShowTips("未知参数:" + p);
  355. return false;
  356. }
  357. return true;
  358. }
  359. /// <summary>
  360. /// 查询送货通知单行表
  361. /// </summary>
  362. private void Get_PUR_EXC_DELIVERY_C(ExcDeliverySubC EdC)
  363. {
  364. EdC.Validflag = "1";
  365. dataTable2.Rows.Clear();
  366. EdC.CreateUserid = this.UserInfo.GetUserID();//控制当前仓库人员登录只能看到自己所维护的库区
  367. EdC.Status = txt_status.Value == null ? "" : txt_status.Value.ToString();
  368. if (EdC.Col.Length > 0)
  369. {
  370. DataTable dt = this.GetJsonService().execute<DataTable>("com.hnshituo.pur.ck.service.ExcDeliverySubCService", "Query_C", new object[] { EdC });
  371. GridHelper.CopyDataToDatatable(dt, dataTable2, true);
  372. GridHelper.RefreshAndAutoSize(ultraGrid1);
  373. }
  374. }
  375. #endregion
  376. }
  377. }