示例#1
0
        public virtual ActionResult PartialPickPallet(MasterModelWithPallet model)
        {
            Contract.Requires(this.ModelState.IsValid, "Attributes should prevent invalid model from invoking this action");

            PartialPickPalletViewModel cpvm = new PartialPickPalletViewModel(this.Session);

            cpvm.Sound = 'W';
            return(View(cpvm));
        }
示例#2
0
        public virtual ActionResult StartSkipUcc(MasterModelWithPallet model)
        {
            Contract.Requires(this.ModelState.IsValid, "Attributes should prevent invalid model from invoking this action");

            SkipUccViewModel suvm = new SkipUccViewModel(this.HttpContext.Session);

            suvm.Sound = 'W';
            return(View(suvm));
        }
示例#3
0
        private ActionResult BeginPartialPickPallet(MasterModelWithPallet model, string fieldName, string viewName)
        {
            //Retrieve value from the model rather than from form based on fieldName
            PropertyInfo property = model.GetType().GetProperty(fieldName);
            string       palletId = property.GetValue(model, null).ToString();

            //TC23 : Scan a new pallet on Carton or UCC view.
            if (palletId == null || model.CurrentPalletId != palletId)
            {
                ModelState.AddModelError(fieldName, "Cannot start a new pallet until the current pallet has been completed.");
                return(View(viewName, model));
            }
            return(RedirectToAction(MVC_BoxPick.BoxPick.Confirm.PartialPickPallet()));
        }
示例#4
0
        public virtual ActionResult ConfirmADRPallet(ADRPalletViewModel model)
        {
            //Sent to pallet scan
            //TC 30 : Scan null in confirm screen to create new ADR pallet
            if (string.IsNullOrEmpty(model.Scan))
            {
                return(RedirectToAction(MVC_BoxPick.BoxPick.Home.AcceptPallet()));
            }

            //TC 31 : Enter different pallet Id in confirm screen to create new pallet
            if (model.ConfirmPalletId != model.Scan)
            {
                this.AddStatusMessage("The confirmation pallet did not match the original pallet.");
                return(RedirectToAction(MVC_BoxPick.BoxPick.Home.AcceptPallet()));
            }

            //Create pallet for ADR
            try
            {
                int rowsAffected = _repos.Value.CreateADRPallet(model.ConfirmPalletId, model.CurrentBuildingId, model.CurrentDestinationArea);
                if (rowsAffected == 0)
                {
                    this.AddStatusMessage(string.Format("No cartons to pick for building {0}{1}", model.CurrentBuildingId,
                                                        !string.IsNullOrEmpty(model.CurrentDestAreaShortName) ? string.Format(", area {0}", model.CurrentDestAreaShortName) : string.Empty));
                    return(RedirectToAction(MVC_BoxPick.BoxPick.Home.AcceptPallet()));
                }
                this.AddStatusMessage(string.Format("{0:d} carton to be picked", rowsAffected));
            }
            catch (DbException ex)
            {
                ModelState.AddModelError("", ex.Message);
            }

            //Sent to pallet scan, CreateADRPallet should return exception when not able to create pallet
            if (!ModelState.IsValid)
            {
                return(RedirectToAction(MVC_BoxPick.BoxPick.Home.AcceptPallet()));
            }

            Pallet pallet = null;

            try
            {
                pallet = _repos.Value.RetrievePalletInfo(model.ConfirmPalletId);
                if (pallet == null)
                {
                    ModelState.AddModelError("", "No cartons to pick");
                }
                else if (pallet.IsFull)
                {
                    //This is defensive check
                    this.AddStatusMessage(string.Format("Pallet {0} has been already picked. Please scan new pallet.", model.ConfirmPalletId));
                }
                else if (pallet.BuildingId != model.CurrentBuildingId)
                {
                    ModelState.AddModelError("", string.Format("Pallet {0} is for building {1} and not for current building {2}, Please scan new pallet",
                                                               model.ConfirmPalletId, pallet.BuildingId, model.CurrentBuildingId));
                }
                else if (string.IsNullOrEmpty(model.CurrentSourceArea))
                {
                    // We have chosen the area on user's behalf
                    model.CurrentSourceArea          = pallet.CartonSourceArea;
                    model.CurrentSourceAreaShortName = pallet.SourceAreaShortName;
                }
                else if (pallet.CartonSourceArea != model.CurrentSourceArea)
                {
                    // Pallet must be of the correct source area
                    ModelState.AddModelError("", string.Format("Pallet {0} is for area {1} and not for current area {2}, Please scan new pallet",
                                                               model.ConfirmPalletId, pallet.SourceAreaShortName, model.CurrentSourceAreaShortName));
                }
                //Showing cartons destination area in where the carton to picked
                model.CurrentDestinationArea   = pallet.DestinationArea;
                model.CurrentDestAreaShortName = pallet.DestAreaShortName;
            }
            catch (DbException ex)
            {
                ModelState.AddModelError("", ex.Message);
            }

            MasterModelWithPallet mm = new MasterModelWithPallet(this.HttpContext.Session);

            if (ModelState.IsValid)
            {
                mm.Map(pallet);
                TryValidateModel(mm);
            }

            if (!ModelState.IsValid || pallet.IsFull)
            {
                mm.Map(null);
                return(RedirectToAction(MVC_BoxPick.BoxPick.Home.AcceptPallet()));
            }
            return(RedirectToAction(MVC_BoxPick.BoxPick.Home.AcceptCarton()));
        }
示例#5
0
        public virtual ActionResult AcceptPallet(PalletViewModel mm)
        {
            //TC5 : Scan null or empty in textbox on Pallet page.
            if (string.IsNullOrEmpty(mm.ScannedPalletId))
            {
                return(RedirectToAction(Actions.AcceptBuilding()));
            }
            mm.ScannedPalletId = mm.ScannedPalletId.ToUpper();
            //TC6 : Scan a invalid pallet i.e. a pallet that do not starts with P
            if (!ModelState.IsValid)
            {
                return(View(Views.Pallet, mm));
            }

            Pallet pallet = null;
            var    fieldScannedPalletId = mm.NameFor(m => m.ScannedPalletId);

            try
            {
                pallet = _repos.Value.RetrievePalletInfo(mm.ScannedPalletId);
                //TC7 : Scan a new pallet to create ADR pallet.
                if (pallet == null)
                {
                    return(RedirectToAction(MVC_BoxPick.BoxPick.Confirm.Actions.ADRPallet(mm.ScannedPalletId)));
                }
                //TC8 : Scan a pallet for which TotalBoxes are equal to PickedBoxes
                else if (pallet.IsFull)
                {
                    this.AddStatusMessage(string.Format("Pallet {0} has been already picked.", mm.ScannedPalletId));
                    return(RedirectToAction(MVC_BoxPick.BoxPick.Confirm.Print(mm.ScannedPalletId)));
                }
                //TC9 : Scan a pallet that doesnot belongs to current scanned building
                else if (pallet.BuildingId != mm.CurrentBuildingId)
                {
                    ModelState.AddModelError(fieldScannedPalletId, string.Format("Pallet {0} is for building {1} and not for current building {2}, Please scan new pallet",
                                                                                 mm.ScannedPalletId, pallet.BuildingId, mm.CurrentBuildingId));
                }
                //TC10 : If we don't enter any area then scanned pallet area will be treated as current source area.
                else if (string.IsNullOrEmpty(mm.CurrentSourceArea))
                {
                    // We have chosen the area on user's behalf
                    mm.CurrentSourceArea          = pallet.CartonSourceArea;
                    mm.CurrentSourceAreaShortName = pallet.SourceAreaShortName;
                }
                //TC11 : If scanned palletArea is not same as currten pallet area
                else if (pallet.CartonSourceArea != mm.CurrentSourceArea)
                {
                    // Pallet must be of the correct destination area
                    ModelState.AddModelError(fieldScannedPalletId, string.Format("Pallet {0} is for area {1} and not for current area {2}, Please scan new pallet",
                                                                                 mm.ScannedPalletId, pallet.SourceAreaShortName, mm.CurrentSourceAreaShortName));
                }
                //Showing cartons destination area in where the carton to picked
                mm.CurrentDestinationArea   = pallet.DestinationArea;
                mm.CurrentDestAreaShortName = pallet.DestAreaShortName;
            }
            catch (DbException ex)
            {
                ModelState.AddModelError(fieldScannedPalletId, ex.Message);
            }

            var model = new MasterModelWithPallet(this.HttpContext.Session);

            if (ModelState.IsValid)
            {
                model.Map(pallet);
                TryValidateModel(model, fieldScannedPalletId);
            }

            if (!ModelState.IsValid || pallet.IsFull)
            {
                model.Map(null);
                return(View(Views.Pallet, mm));
            }

            return(View(Views.Carton, new CartonViewModel(this.HttpContext.Session)));
        }