Пример #1
0
        public OPResult SaveBillStoreMove(BillBO <BillStoreMove, BillStoreMoveDetails> bo)
        {
            using (var dbContext = new DistributionEntities())
            {
                using (TransactionScope scope = new TransactionScope())
                {
                    try
                    {
                        BillHelper.SaveBill <BillStoreMove, BillStoreMoveDetails>(bo, dbContext);
                        var storeout = BillHelper.GenerateStoreOut(bo);
                        storeout.Bill.StorageID = bo.Bill.StorageIDOut;
                        BillHelper.SaveBillStoreOut(storeout, dbContext);
                        var storing = BillHelper.GenerateStoring(bo);
                        storing.Bill.StorageID = bo.Bill.StorageIDIn;
                        BillHelper.SaveBillStoring(storing, dbContext);

                        dbContext.SaveChanges();

                        scope.Complete();
                    }
                    catch (Exception e)
                    {
                        return(new OPResult {
                            IsSucceed = false, Message = "保存失败,失败原因:\n" + e.Message
                        });
                    }
                }
            }
            return(new OPResult {
                IsSucceed = true, Message = "保存成功!"
            });
        }
Пример #2
0
        public OPResult StoringReturnGoodReject(BillBO <BillGoodReturn, BillGoodReturnDetails> bo)
        {
            using (var dbContext = new DistributionEntities())
            {
                dbContext.Entry(bo.Bill).State = EntityState.Modified;
                using (TransactionScope scope = new TransactionScope())
                {
                    try
                    {
                        //BillHelper.SaveBill<BillGoodReturn, BillGoodReturnDetails>(bo, dbContext);
                        var storing = BillHelper.GenerateStoring(bo);
                        BillHelper.SaveBillStoring(storing, dbContext);
                        //if (bo.FundAccount != null && bo.FundAccount.AlreadyIn != 0)
                        //{
                        //    bo.FundAccount.RefrenceBillCode = bo.Bill.Code;
                        //    dbContext.OrganizationFundAccount.Add(bo.FundAccount);
                        //}
                        dbContext.SaveChanges();

                        scope.Complete();
                    }
                    catch (Exception e)
                    {
                        return(new OPResult {
                            IsSucceed = false, Message = "入库失败,失败原因:\n" + e.Message
                        });
                    }
                }
            }
            return(new OPResult {
                IsSucceed = true, Message = "入库成功!"
            });
        }