Esempio n. 1
0
        public OPResult SaveBillStoring(BillBO <BillStoring, BillStoringDetails> bo)
        {
            using (var dbContext = new DistributionEntities())
            {
                using (TransactionScope scope = new TransactionScope())
                {
                    try
                    {
                        BillHelper.SaveBillStoring(bo, dbContext);
                        dbContext.SaveChanges();

                        scope.Complete();
                    }
                    catch (Exception e)
                    {
                        return(new OPResult {
                            IsSucceed = false, Message = "保存失败,失败原因:\n" + e.Message
                        });
                    }
                }
            }
            return(new OPResult {
                IsSucceed = true, Message = "保存成功!"
            });
        }
Esempio n. 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 = "入库成功!"
            });
        }
Esempio n. 3
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 = "保存成功!"
            });
        }
Esempio n. 4
0
        public OPResult <BillRetail> SaveBillRetail(BillRetailBO bo)
        {
            //bo.Bill.CreateTime = DateTime.Now;

            using (var dbContext = new DistributionEntities())
            {
                if (bo.RefrenseVIPUpTactics != null && bo.VIPPointRecord != null)
                {
                    IEnumerable <int> kindIDs = bo.RefrenseVIPUpTactics.Select(o => o.Tactic.FormerKindID).ToList();
                    IEnumerable <VIPCardKindMapping> mappings = dbContext.VIPCardKindMapping.Where(o => o.CardID == bo.VIPPointRecord.VIPID && kindIDs.Contains(o.KindID)).ToList();
                    foreach (var mapping in mappings)
                    {
                        var t = bo.RefrenseVIPUpTactics.First(o => o.Tactic.FormerKindID == mapping.KindID);
                        mapping.KindID = t.Tactic.AfterKindID;
                        if (t.Tactic.CutPoint != 0)
                        {
                            dbContext.VIPPointTrack.Add(new VIPPointTrack
                            {
                                CreateTime = DateTime.Now,
                                Point      = (-1 * t.Tactic.CutPoint),
                                VIPID      = bo.VIPPointRecord.VIPID,
                                Remark     = "VIP升级产生," + t.Description
                            });
                        }
                    }
                }
                using (TransactionScope scope = new TransactionScope())
                {
                    try
                    {
                        bo.Bill.Code = BillHelper.GenerateBillCode <BillRetail>(bo.Bill.OrganizationID, dbContext);
                        BillHelper.SaveBill <BillRetail, BillRetailDetails>(bo, dbContext, bo.SpecifcCreateTime);
                        foreach (var storeout in bo.BillStoreOuts)
                        {
                            storeout.Bill.CreateTime       = DateTime.Now;
                            storeout.Bill.RefrenceBillCode = bo.Bill.Code;
                            BillHelper.SaveBillStoreOut(storeout, dbContext);
                        }
                        foreach (var storing in bo.BillStorings)
                        {
                            storing.Bill.CreateTime       = DateTime.Now;
                            storing.Bill.RefrenceBillCode = bo.Bill.Code;
                            BillHelper.SaveBillStoring(storing, dbContext);
                        }
                        if (bo.VIPPointRecord != null)
                        {
                            bo.VIPPointRecord.Remark = "零售单产生,小票号" + bo.Bill.Code;
                            dbContext.VIPPointTrack.Add(bo.VIPPointRecord);

                            if (bo.Bill.PredepositPay != 0)
                            {
                                VIPPredepositTrack predepositTrack = new VIPPredepositTrack
                                {
                                    RefrenceBillCode = bo.Bill.Code,
                                    Kind             = false,
                                    OrganizationID   = bo.Bill.OrganizationID,
                                    CreatorID        = bo.Bill.CreatorID,
                                    CreateTime       = DateTime.Now,
                                    ConsumeMoney     = bo.Bill.PredepositPay,
                                    VIPID            = bo.VIPPointRecord.VIPID,
                                    Remark           = "零售单产生"
                                };
                                dbContext.VIPPredepositTrack.Add(predepositTrack);
                            }
                        }
                        if (bo.VIPBirthdayConsumption != null)
                        {
                            bo.VIPBirthdayConsumption.ConsumeDay = DateTime.Now.Date;
                            dbContext.VIPBirthdayConsumption.Add(bo.VIPBirthdayConsumption);
                        }

                        dbContext.SaveChanges();

                        scope.Complete();
                    }
                    catch (Exception e)
                    {
                        return(new OPResult <BillRetail> {
                            IsSucceed = false, Message = "保存失败,失败原因:\n" + e.Message
                        });
                    }
                }
            }
            return(new OPResult <BillRetail> {
                IsSucceed = true, Message = "保存成功!", Result = bo.Bill
            });
        }