DeleteBarCode.cs 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using UFSoft.UBF.Business;
  7. namespace UFIDA.U9.Cust.Kusi.CJJ.Plugin.BE.InventSheetLine
  8. {
  9. public class DeleteBarCode : UFSoft.UBF.Eventing.IEventSubscriber
  10. {
  11. public void Notify(params object[] args)
  12. {
  13. #region 从事件参数中取得当前业务实体
  14. if (args == null || args.Length == 0 || !(args[0] is UFSoft.UBF.Business.EntityEvent))
  15. return;
  16. BusinessEntity.EntityKey key = ((UFSoft.UBF.Business.EntityEvent)args[0]).EntityKey;
  17. if (key == null)
  18. return;
  19. UFIDA.U9.InvDoc.InventorySheet.InventSheetLine holder = key.GetEntity() as UFIDA.U9.InvDoc.InventorySheet.InventSheetLine;
  20. if (holder == null)
  21. return;
  22. #endregion
  23. ////弃审时更新条码库位存储信息
  24. //if (holder.Status == UFIDA.U9.InvDoc.PrdEndCheck.CheckStatus.Opening
  25. // && holder.OriginalData != null
  26. // && holder.OriginalData.Status == UFIDA.U9.InvDoc.PrdEndCheck.CheckStatus.Approved)
  27. //{
  28. // foreach (var line in holder.InventSheetLine)
  29. // {
  30. // BarCodeUpdater.Update(line.ID, "UFIDA.U9.InvDoc.InventorySheet.InventSheetLine");
  31. // }
  32. //}
  33. using (ISession session = Session.Open())
  34. {
  35. UFIDA.U9.BC.BaseData.BarCodeUsed.EntityList tmp = UFIDA.U9.BC.BaseData.BarCodeUsed.Finder.FindAll("UseDocLine.EntityID=@ID and UseDocLine.EntityType=@EntityType order by CreatedOn desc"
  36. , new UFSoft.UBF.PL.OqlParam[]
  37. {
  38. new UFSoft.UBF.PL.OqlParam(holder.ID),
  39. new UFSoft.UBF.PL.OqlParam("UFIDA.U9.InvDoc.InventorySheet.InventSheetLine")
  40. });
  41. if (tmp != null && tmp.Count > 0)
  42. {
  43. foreach (var barCodeUsed in tmp)
  44. {
  45. string barCodeTmp = barCodeUsed.BarCode;
  46. barCodeUsed.Remove();
  47. session.Commit();
  48. var barCodeUsedTmp = UFIDA.U9.BC.BaseData.BarCodeUsed.Finder.Find(string.Format("BarCode='{0}' order by CreatedOn desc", barCodeTmp));
  49. string binid = "";
  50. string bincode = "";
  51. string binname = "";
  52. string whid = "";
  53. string whcode = "";
  54. string whname = "";
  55. if (barCodeUsedTmp != null)
  56. {
  57. binid = barCodeUsedTmp["Cust4Binid"].ToString();
  58. bincode = barCodeUsedTmp["Cust4Bincode"].ToString();
  59. binname = barCodeUsedTmp["Cust4Binname"].ToString();
  60. whid = barCodeUsedTmp["Cust4Whid"].ToString();
  61. whcode = barCodeUsedTmp["Cust4Whcode"].ToString();
  62. whname = barCodeUsedTmp["Cust4Whname"].ToString();
  63. }
  64. else
  65. {
  66. barCodeUsedTmp = barCodeUsed;
  67. }
  68. barCodeUsedTmp.BarCodeMaster.SetValue("Cust4Binid", binid);
  69. barCodeUsedTmp.BarCodeMaster.SetValue("Cust4Bincode", bincode);
  70. barCodeUsedTmp.BarCodeMaster.SetValue("Cust4Binname", binname);
  71. barCodeUsedTmp.BarCodeMaster.SetValue("Cust4Whcode", whcode);
  72. barCodeUsedTmp.BarCodeMaster.SetValue("Cust4Whname", whname);
  73. barCodeUsedTmp.BarCodeMaster.SetValue("Cust4Whid", whid);
  74. }
  75. }
  76. session.Commit();
  77. }
  78. ////审核时出入库单据审核控制条码仓--没有PDA审核,不需要管控,废弃。
  79. //if (holder.Status == UFIDA.U9.InvDoc.PrdEndCheck.CheckStatus.Approved
  80. // && holder.OriginalData != null
  81. // && holder.OriginalData.Status == UFIDA.U9.InvDoc.PrdEndCheck.CheckStatus.Approving)
  82. //{
  83. // if (holder.Wh != null)
  84. // {
  85. // if (holder.Wh.DescFlexField.PrivateDescSeg1.ToUpper().Equals("TRUE") && !Base.Context.LoginUser.Contains("PDA"))
  86. // {
  87. // throw new Exception(string.Format("单号{0}的存储地点为条码管理,请扫码出货。", holder.DocNo));
  88. // }
  89. // }
  90. //}
  91. }
  92. }
  93. }