コード例 #1
0
        public bool UpdatePalletForceOrder(PalletForceOrder inputOrder, string userName)
        {
            foreach (Surcharge surcharge in inputOrder.Surcharges)
            {
                if (surcharge.IsSelected)
                {
                    AddSurcharge(inputOrder, surcharge.ExtraTypeID, userName);
                }
                else
                {
                    RemoveSurcharge(inputOrder, surcharge.ExtraTypeID, userName);
                }
            }

            Orchestrator.EF.DataContext DB = Orchestrator.EF.DataContext.Current;
            var order     = DB.OrderSet.Include("JobSubContract").FirstOrDefault(o => o.OrderId == inputOrder.OrderID);
            var vigoOrder = DB.VigoOrderSet.FirstOrDefault(o => o.OrderId == inputOrder.OrderID);
            List <Orchestrator.EF.VigoOrderExtra> surcharges = DB.VigoOrderExtraSet.Where(o => o.VigoOrder.OrderId == inputOrder.OrderID).ToList();

            // Update the Order
            order.NoPallets        = (int)inputOrder.NoPallets;
            order.PalletSpaces     = inputOrder.PalletSpaces;
            order.Weight           = inputOrder.Weight;
            order.LastUpdateUserID = userName;



            // Update the Vigo Order
            vigoOrder.FullPallets = inputOrder.FullPallets;
            vigoOrder.QtrPallets  = inputOrder.QtrPallets;
            vigoOrder.HalfPallets = inputOrder.HalfPallets;
            vigoOrder.OverPallets = inputOrder.OverPallets;


            // Update the Extras


            DB.SaveChanges();

            Facade.IJobSubContractor jobSubContractor = new Facade.Job();
            if (order != null && order.JobSubContract.JobSubContractID > 0)
            {
                Entities.JobSubContractor js = jobSubContractor.GetSubContractorForJobSubContractId(order.JobSubContract.JobSubContractID);
                jobSubContractor.UpdateSubContractorCostsForOrders(new List <int>()
                {
                    order.OrderId
                }, js, userName);
            }
            return(true);
        }
コード例 #2
0
        public bool AddSurcharge(PalletForceOrder order, int extraTypeID, string userName)
        {
            EF.DataContext DB         = EF.DataContext.Current;
            VigoOrder      vo         = DB.VigoOrderSet.Include("VigoOrderExtras").FirstOrDefault(o => o.OrderId == order.OrderID);
            var            extraTypes = DB.ExtraTypeSet.ToList();

            if (vo.VigoOrderExtras.FirstOrDefault(e => e.ExtraType.ExtraTypeId == extraTypeID) == null)
            {
                var extraType = extraTypes.FirstOrDefault(et => et.ExtraTypeId == extraTypeID);
                if (extraType != null)
                {
                    VigoOrderExtra extra = new VigoOrderExtra();
                    extra.ExtraType = extraType;
                    vo.VigoOrderExtras.Add(extra);
                }
            }
            DB.SaveChanges();
            return(true);
        }
コード例 #3
0
        public bool RemoveSurcharge(PalletForceOrder order, int extraTypeID, string userName)
        {
            try
            {
                EF.DataContext DB = EF.DataContext.Current;
                VigoOrder      vo = DB.VigoOrderSet.Include("VigoOrderExtras").Include("VigoOrderExtras.ExtraType").FirstOrDefault(o => o.OrderId == order.OrderID);

                if (vo.VigoOrderExtras.FirstOrDefault(e => e.ExtraType.ExtraTypeId == extraTypeID) != null)
                {
                    VigoOrderExtra extra = vo.VigoOrderExtras.FirstOrDefault(e => e.ExtraType.ExtraTypeId == extraTypeID);
                    vo.VigoOrderExtras.Remove(extra);
                    DB.DeleteObject(extra);
                }
                DB.SaveChanges();
                return(true);
            }
            catch (Exception ex)
            {
                throw;
            }
            return(true);
        }