using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using UFSoft.UBF.Business; namespace UFIDA.U9.Cust.Kusi.CJJ.Plugin.BE.RcvLine { public class DeleteBarCodeUsed : UFSoft.UBF.Eventing.IEventSubscriber { public void Notify(params object[] args) { #region 从事件参数中取得当前业务实体 if (args == null || args.Length == 0 || !(args[0] is UFSoft.UBF.Business.EntityEvent)) return; BusinessEntity.EntityKey key = ((UFSoft.UBF.Business.EntityEvent)args[0]).EntityKey; if (key == null) return; UFIDA.U9.PM.Rcv.RcvLine holder = key.GetEntity() as UFIDA.U9.PM.Rcv.RcvLine; if (holder == null) return; #endregion BarCodeUpdater.Update(holder.ID, "UFIDA.U9.PM.Rcv.RcvLine"); //using (ISession session = Session.Open()) //{ // UFIDA.U9.BC.BaseData.BarCodeUsed.EntityList list = UFIDA.U9.BC.BaseData.BarCodeUsed.Finder.FindAll("UseDocLine.EntityID=@ID and UseDocLine.EntityType=@EntityType and CurQty>0 order by CreatedOn desc" // , new UFSoft.UBF.PL.OqlParam[] // { // new UFSoft.UBF.PL.OqlParam(holder.ID), // new UFSoft.UBF.PL.OqlParam("UFIDA.U9.PM.Rcv.RcvLine") // }); // if (list != null && list.Count > 0) // { // foreach (var barCodeUsed in list) // { // if (barCodeUsed.IsUpdateWh) // { // if (barCodeUsed.Direct == UFIDA.U9.BC.Common.DirectEnum.Rcv) // { // barCodeUsed.BarCodeMaster.WhQty = barCodeUsed.BarCodeMaster.WhQty - barCodeUsed.CurQty; // if (barCodeUsed.BarCodeMaster.WhQty < 0) // { // throw new Exception("不能删除,删除后条码现场量将小于0"); // } // } // else if (barCodeUsed.Direct == UFIDA.U9.BC.Common.DirectEnum.Shipment) // { // barCodeUsed.BarCodeMaster.WhQty = barCodeUsed.BarCodeMaster.WhQty + barCodeUsed.CurQty; // } // } // barCodeUsed.Remove(); // } // } // session.Commit(); //} } } }