コード例 #1
0
        public OPResult SendBack(BillStoringProductExchangeEntity entity)
        {
            if (entity.Status == (int)BillProductExchangeStatusEnum.已入库)
            {
                return(new OPResult {
                    IsSucceed = false, Message = "已入库单据不能退回."
                });
            }
            if (entity.Status == (int)BillProductExchangeStatusEnum.被退回)
            {
                return(new OPResult {
                    IsSucceed = false, Message = "该单已退回."
                });
            }
            BillProductExchange pe = VMGlobal.ManufacturingQuery.LinqOP.GetById <BillProductExchange>(entity.ID);

            pe.Status = (int)BillProductExchangeStatusEnum.被退回;
            pe.Remark = entity.Remark;
            try
            {
                VMGlobal.ManufacturingQuery.LinqOP.Update <BillProductExchange>(pe);
            }
            catch (Exception e)
            {
                return(new OPResult {
                    IsSucceed = false, Message = "退回失败\n失败原因:" + e.Message
                });
            }
            entity.Status = (int)BillProductExchangeStatusEnum.被退回;
            ((ObservableCollection <BillStoringProductExchangeEntity>) this.Entities).Remove(entity);
            return(new OPResult {
                IsSucceed = true, Message = "退回成功."
            });
        }
コード例 #2
0
        public OPResult Storing(BillStoringProductExchangeEntity entity)
        {
            if (entity.Status == (int)BillProductExchangeStatusEnum.已入库)
            {
                return(new OPResult {
                    IsSucceed = false, Message = "该单已经入库."
                });
            }
            if (entity.Status == (int)BillProductExchangeStatusEnum.被退回)
            {
                return(new OPResult {
                    IsSucceed = false, Message = "被退回单据不能入库."
                });
            }
            if (entity.StorageID == default(int))
            {
                return(new OPResult {
                    IsSucceed = false, Message = "请选择入库仓库."
                });
            }
            BillStoringVM       storingvm = this.GenerateStoring(entity);
            BillProductExchange pe        = VMGlobal.ManufacturingQuery.LinqOP.GetById <BillProductExchange>(entity.ID);

            pe.Status = (int)BillProductExchangeStatusEnum.已入库;
#if UniqueCode
            var uniqueCodes = BillStoringVM.GetSnapshotDetails(pe.Code);
#endif
            using (TransactionScope scope = new TransactionScope())
            {
                try
                {
                    storingvm.SaveWithNoTran();
                    VMGlobal.ManufacturingQuery.LinqOP.Update <BillProductExchange>(pe);
#if UniqueCode
                    storingvm.SaveUniqueCodes(uniqueCodes);
#endif
                    scope.Complete();
                }
                catch (Exception e)
                {
                    return(new OPResult {
                        IsSucceed = false, Message = "入库失败\n失败原因:" + e.Message
                    });
                }
            }
            entity.Status = (int)BillProductExchangeStatusEnum.已入库;
            ((ObservableCollection <BillStoringProductExchangeEntity>) this.Entities).Remove(entity);
            return(new OPResult {
                IsSucceed = true, Message = "入库成功."
            });
        }
コード例 #3
0
        public OPResult SaveProductExchangeBill(BillProductExchange pe, IEnumerable <BillProductExchangeDetails> details, BillSnapshot snapshot, IEnumerable <BillSnapshotDetailsWithUniqueCode> snapshotDetails)
        {
            var manulp  = _queryManu.LinqOP;
            var distrlp = _queryDistr.LinqOP;

            using (TransactionScope scope = new TransactionScope())
            {
                try
                {
                    pe.ID = manulp.Add <BillProductExchange, int>(pe, b => b.ID);
                    foreach (var d in details)
                    {
                        d.BillID = pe.ID;
                    }
                    manulp.Add <BillProductExchangeDetails>(details);
                    snapshot.BillID = pe.ID;
                    snapshot.ID     = distrlp.Add <BillSnapshot, int>(snapshot, o => o.ID);
                    foreach (var snapshotDetail in snapshotDetails)
                    {
                        snapshotDetail.SnapshotID = snapshot.ID;
                    }
                    distrlp.Add <BillSnapshotDetailsWithUniqueCode>(snapshotDetails);
                    foreach (var d in details)
                    {
                        this.UpdateSubcontractWhenExchange(pe.OuterFactoryID, d.ProductID, d.Quantity);
                    }
                    scope.Complete();
                }
                catch (Exception e)
                {
                    return(new OPResult {
                        IsSucceed = false, Message = e.Message
                    });
                }
            }
            return(new OPResult {
                IsSucceed = true, Message = "保存成功."
            });
        }