예제 #1
0
        public virtual ActionResult Carton(string serializedContext, string palletId, char sound = '\0')
        {
            var ctx = new ContextModel
            {
                Serialized = serializedContext
            };
            int oldSuggestionCount;

            palletId = palletId.Trim().ToUpper();
            var cartons = _service.GetCartonSuggestions(ctx.BuildingId, ctx.PickAreaId, ctx.RestockAreaId, palletId, 5, out oldSuggestionCount);

            if (!cartons.Any())
            {
                // TC8: No cartons available for replenishing
                AddStatusMessage(string.Format("Nothing to pull for [{0}] {1} -> {2} -> {3}", ctx.BuildingId, ctx.CartonAreaId, ctx.RestockAreaId, ctx.ShortName));
                return(Pallet(serializedContext));
            }

            var pallet = _service.GetPallet(palletId);

            //If pallet already contains cartons, making sure that the puller is continuing with partially pulled pallet or any other random pallet.
            //If it is a random pallet, then aware the puller for case of aisle mixing.
            if (pallet.CartonCount > 0 && oldSuggestionCount == 0)
            {
                AddStatusMessage(string.Format("Pallet {0} already contains cartons {1}, Make sure that you are not mixing cartons of different aisles.", pallet.PalletId, pallet.CartonCount));
            }
            var cartonList = from carton in cartons
                             select new CartonModel
            {
                CartonId    = carton.CartonId,
                LocationId  = carton.LocationId,
                SkuInCarton = new SkuModel
                {
                    SkuId     = carton.SkuInCarton.SkuId,
                    Color     = carton.SkuInCarton.Color,
                    Style     = carton.SkuInCarton.Style,
                    Dimension = carton.SkuInCarton.Dimension,
                    SkuSize   = carton.SkuInCarton.SkuSize,
                    UpcCode   = carton.SkuInCarton.UpcCode
                },
                SkuReplenishmentPriority = carton.SkuPriority
            };

            var cvm = new CartonViewModel
            {
                PalletId   = palletId,
                CartonList = cartonList,
                Context    = new ContextModel
                {
                    Serialized = serializedContext,
                },
                RestockAisleId       = cartons.First().RestockAisleId,
                CountCartonsOnPallet = pallet.CartonCount,
                PriceSeasonCode      = pallet.PriceSeasonCode,
                Sound    = sound,
                IsPuller = AuthorizeExAttribute.IsSuperUser(HttpContext) || HttpContext.User.IsInRole(ROLE_PUL)
            };

            return(View(Views.Carton, cvm));
        }
예제 #2
0
        public ActionResult Edit([Bind(Include = "Id,CartonNumber")] CartonViewModel cartonViewModel)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    //existing issue allowed cartons to be named the same, assuming each carton name/number should be unique
                    //  added check for existing carton with same carton number
                    var existingCarton = db.Cartons.Where(c => c.CartonNumber == cartonViewModel.CartonNumber).Select(c => c.Id).FirstOrDefault();
                    if (existingCarton <= 0)
                    {
                        var carton = db.Cartons.Find(cartonViewModel.Id);
                        carton.CartonNumber = cartonViewModel.CartonNumber;
                        db.SaveChanges();
                        return(RedirectToAction("Index"));
                    }
                    else
                    {
                        ModelState.AddModelError("CartonNumber", "A carton with that name exists, please enter another name");
                        return(View());
                    }
                }

                return(View(cartonViewModel));
            }
            catch (Exception ex)
            {
                log.Error(ex.Message);
                throw ex;
            }
        }
예제 #3
0
        public virtual ActionResult ShowCartonHelp()
        {
            var model = new CartonViewModel(this.Session);

            model.AlternateLocations = _repos.Value.GetAlternateLocations(model.CartonIdToPick);
            return(View(Views.CartonHelp, model));
        }
예제 #4
0
        public virtual ActionResult SuspenseCarton(string scannedCartonId)
        {
            var cvm = new CartonViewModel(this.HttpContext.Session);

            cvm.ScannedCartonId = scannedCartonId;
            cvm.Sound           = 'W';
            return(View(Views.ConfirmSuspenseCarton, cvm));
        }
예제 #5
0
        public virtual ActionResult AcceptPalletInCarton(CartonViewModel model)
        {
            Contract.Requires(this.ModelState.IsValid, "Attributes should prevent invalid model from invoking this action");

            var fieldName = model.NameFor(m => m.ScannedCartonId);

            return(BeginPartialPickPallet(model, fieldName, Views.Carton));
        }
예제 #6
0
        public virtual ActionResult Carton(string lastCartonId)
        {
            var model = new CartonViewModel
            {
                CartonId = lastCartonId
            };

            return(View(Views.Carton, model));
        }
예제 #7
0
        public virtual ActionResult AcceptCarton(CartonViewModel model)
        {
            Contract.Requires(this.ModelState.IsValid, "Attributes should prevent invalid model from invoking this action");
            //TC12 : Scan null Or empty enter in Carton Text box on carton page.
            if (string.IsNullOrWhiteSpace(model.ScannedCartonId))
            {
                // Clear existing carton if any
                return(View(Views.Carton, model));
            }
            //TC13 : Enter S on textbox on carton page.
            if (model.ScannedCartonId == "S" || model.ScannedCartonId == "s")
            {
                return(RedirectToAction(MVC_BoxPick.BoxPick.Confirm.SkipUcc()));
            }
            model.ScannedCartonId = model.ScannedCartonId.ToUpper();
            // Validate carton. If box is returned as null then carton was not pickable.

            var box = _repos.Value.GetBoxForCarton(model.ScannedCartonId, model.CurrentPalletId, model.UccIdToPick);

            //TC14 : If no information of scanned carton found
            //  Check whether the scanned carton can be placed in current pallet.
            if (box == null)
            {
                ModelState.AddModelError(model.NameFor(m => m.ScannedCartonId), "Carton cannot be picked for this pallet");
            }
            if (!ModelState.IsValid)
            {
                //Bad carton
                return(View(Views.Carton, model));
            }

            //TODO : Needs to define
            if (!model.SuspenseFlag && model.CurrentLocationId != box.AssociatedCarton.LocationId && !string.IsNullOrEmpty(model.CartonIdToPick))
            {
                // Now carton is being picked from another location. Ask to mark it in suspense.
                return(RedirectToAction(MVC_BoxPick.BoxPick.Confirm.Actions.SuspenseCarton(model.ScannedCartonId)));
            }
            var uvm = new UccViewModel(this.HttpContext.Session);

            uvm.SetLastCartonAndLocation(box.AssociatedCarton.CartonId, box.AssociatedCarton.LocationId);

            switch (model.PickMode)
            {
            //TC16 : When Pickmode of pallet is ADR
            case PickModeType.ADR:
                uvm.ScannedUccId = box.UccId;
                return(AcceptUcc(uvm));

            //TC17 : When Pickmode of pallet is ADREPPWSS
            case PickModeType.ADREPPWSS:
                return(View(Views.Ucc, uvm));

            default:
                throw new NotImplementedException();
            }
        }
예제 #8
0
 public ActionResult Edit([Bind(Include = "Id,CartonNumber")] CartonViewModel cartonViewModel)
 {
     if (ModelState.IsValid)
     {
         var carton = db.Cartons.Find(cartonViewModel.Id);
         carton.CartonNumber = cartonViewModel.CartonNumber;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(cartonViewModel));
 }
예제 #9
0
        public virtual ActionResult AcceptUccInCarton(CartonViewModel model)
        {
            Contract.Requires(this.ModelState.IsValid, "Attributes should prevent invalid model from invoking this action");
            var fieldName = model.NameFor(m => m.ScannedCartonId);

            //TC18 : Scan a UCC to skip that is not expected to get picked.
            if (model.UccIdToPick != model.ScannedCartonId)
            {
                ModelState.AddModelError(fieldName, string.Format("Can only skip the current UCC {0}.", model.UccIdToPick));
                return(View(Views.Carton, model));
            }
            return(RedirectToAction(MVC_BoxPick.BoxPick.Confirm.SkipUcc()));
        }
예제 #10
0
 public virtual ActionResult ConfirmSuspenseCarton(CartonViewModel model)
 {
     //TC 32 : Scan ! on confir suspense screen
     if (model.ConfirmCartonId == "1")
     {
         this.AddStatusMessage(string.Format("Carton {0} put in suspense.", model.CartonIdToPick));
         _repos.Value.MarkCartonInSuspense(model.CartonIdToPick);
     }
     else
     {
         this.AddStatusMessage(string.Format("The carton {0} was not put in suspense.", model.CartonIdToPick));
     }
     model.SuspenseFlag = true;
     return(RedirectToAction(MVC_BoxPick.BoxPick.Home.AcceptCarton()
                             .AddRouteValue(model.NameFor(m => m.ScannedCartonId), model.ScannedCartonId)
                             .AddRouteValue(model.NameFor(m => m.SuspenseFlag), model.SuspenseFlag)));
 }
예제 #11
0
        public virtual ActionResult PullCarton(CartonViewModel cvm)
        {
            if (string.IsNullOrWhiteSpace(cvm.CartonId))
            {
                // TC9: Go back. Enter blank carton, to get prompted for pallet again
                return(RedirectToAction(this.Actions.Pallet(cvm.Context.Serialized)));
            }
            cvm.CartonId = cvm.CartonId.Trim().ToUpper();
            if (!ModelState.IsValid)
            {
                // TC10: When will this happen?
                return(View(this.Views.Carton, cvm));
            }
            try
            {
                int countSuggestions;
                var ispulled = _service.TryPullCarton(cvm.CartonId, cvm.PalletId, cvm.Context.RestockAreaId, cvm.RestockAisleId, out countSuggestions);

                if (ispulled)
                {
                    AddStatusMessage(string.Format("Carton {0} is now on Pallet {1}", cvm.CartonId, cvm.PalletId));
                    cvm.Sound = 'S';
                }
                else
                {
                    //DB,Ravneet: Not too happy writing this but works for now. Sorry.
                    ModelState.AddModelError("", string.Format("Carton {0} is either invalid or can not pull for aisle {1}", cvm.CartonId, cvm.RestockAisleId));
                    cvm.Sound = 'E';
                }


                if (countSuggestions == 0)
                {
                    // TC11: You have just pulled the last carton of the restock aisle.
                    AddStatusMessage(string.Format("Pulling of Pallet {0} is complete.", cvm.PalletId));
                    return(RedirectToAction(this.Actions.Pallet(cvm.Context.Serialized)));
                }
            }
            catch (OracleDataStoreException ex)
            {
                ModelState.AddModelError("", ex.Message);
                cvm.Sound = 'E';
                //return Carton(cvm.Context.Serialized, cvm.PalletId);
            }
            return(RedirectToAction(Actions.Carton(cvm.Context.Serialized, cvm.PalletId, cvm.Sound)));
        }
예제 #12
0
 public ActionResult Edit([Bind(Include = "Id,CartonNumber")] CartonViewModel cartonViewModel)
 {
     try
     {
         if (ModelState.IsValid)
         {
             var carton = db.Cartons.Find(cartonViewModel.Id);
             carton.CartonNumber = cartonViewModel.CartonNumber;
             db.SaveChanges();
             return(RedirectToAction("Index"));
         }
         return(View(cartonViewModel));
     }
     catch (Exception ex)
     {
         return(View("Error", new HandleErrorInfo(ex, "Carton", "Index")));
     }
 }
예제 #13
0
        /// <summary>
        /// This function invokes when we Scan Pallet from desktop view
        /// </summary>
        /// <returns></returns>
        public virtual ActionResult Carton(string palletId)
        {
            var boxes = _service.GetBoxesOnPallet(palletId);
            var model = new CartonViewModel
            {
                BoxesOnPallet = boxes == null ? null : boxes.Select(p => new BoxModel
                {
                    AssociatedCartonId = p.AssociatedCarton.CartonId == null ? null : p.AssociatedCarton.CartonId,
                    CartonLocationId   = p.AssociatedCarton.LocationId == null ? null : p.AssociatedCarton.LocationId,
                    IaId        = p.IaId,
                    Pieces      = p.Pieces,
                    QualityCode = p.QualityCode == null ? null : p.QualityCode,
                    SkuInBox    = p.SkuInBox.DisplayName == null ? null : p.SkuInBox.DisplayName,
                    SkuInCarton = p.AssociatedCarton.SkuInCarton == null ? null : p.AssociatedCarton.SkuInCarton.DisplayName,
                    UccId       = p.UccId,
                    VwhId       = p.VwhId
                }).ToArray()
            };

            return(PartialView(Views._cartonPartial, model));
        }