private void labelLock_Click(object sender, EventArgs e) { try { PalletDTO palletDTO = this.fastBarcodes.SelectedObject as PalletDTO; if (palletDTO != null) { PalletViewModel palletViewModel = CommonNinject.Kernel.Get <PalletViewModel>(); PalletController palletController = new PalletController(CommonNinject.Kernel.Get <IPalletService>(), palletViewModel); palletController.Lock(palletDTO.PalletID); if (CustomMsgBox.Show(this, "Are you sure you want to " + (palletViewModel.Lockable ? "lock" : "un-lock") + " this entry data" + "?", "Warning", MessageBoxButtons.YesNo, (palletViewModel.Lockable ? MessageBoxIcon.Information : MessageBoxIcon.Warning)) == DialogResult.Yes) { if (palletController.LockConfirmed()) { ((PalletDTO)this.fastBarcodes.SelectedObject).Locked = !palletViewModel.Locked; this.fastBarcodes.RefreshObject(this.fastBarcodes.SelectedObject); } else { throw new Exception("Lỗi khóa hay mở khóa pallet: " + palletViewModel.Code + "\r\n\r\nVui lòng đóng phần mềm và thử lại sau."); } } } } catch (Exception exception) { ExceptionHandlers.ShowExceptionMessageBox(this, exception); } }
public virtual ActionResult Pallet(string context, bool forceQuery = false) { if (forceQuery) { // We force the query to execute // TC3: Click initiate update now on Pallet desktop page to force the query to execute try { _service.RefreshPullableCartons(); this.AddStatusMessage("Refresh has been initiated"); } catch (DbException ex) { ModelState.AddModelError("", "Some problem occurred, Could not update Replenishment requirements.<br/>" + ex.Message); } // We redirect because refresh of this page should not pass true again return(RedirectToAction(this.Actions.Pallet(context))); } var pvm = new PalletViewModel { Context = new ContextModel { Serialized = context, } }; pvm.GenerateStats += new EventHandler <GenerateStatsEventArgs>(pvm_OnGenerateStats); return(View(Views.Pallet, pvm)); }
/// <summary> /// Gets details of appointment for passed building and area. /// </summary> /// <param name="ivm"> /// AppointmentNo will be posted /// </param> /// <returns></returns> public virtual ActionResult Appointment(IndexViewModel ivm) { //TC1: Appointment number must be passed. if (ivm.AppointmentNo == null) { ModelState.AddModelError("", "Appointment Number is required."); ivm.Sound = (char)Sound.Error; return(View(Views.Index, ivm)); } var appoint = _service.GetAppointmentInfo(ivm.AppointmentNo.Value); //TC2: Scanned appointment does not exist. if (appoint == null) { AddStatusMessage(string.Format("Appointment does not exist {0}.", ivm.AppointmentNo)); return(View(Views.Index, ivm)); } var model = new PalletViewModel { AppointmentNumber = ivm.AppointmentNo.Value, UnPalletizeBoxCount = appoint.UnPalletizeBoxCount, TotalPalletCount = appoint.TotalPalletCount, LoadedBoxCount = appoint.LoadedBoxCount, TotalBoxCount = appoint.TotalBoxCount, LoadedPalletCount = appoint.LoadedPalletCount, PalletsInSuspenseCount = appoint.PalletsInSuspenseCount, DoorId = appoint.DoorId, CarrierId = appoint.CarrierId, AppointmentBuildingId = appoint.BuildingId, Sound = ivm.Sound }; // We try to make suggestions. try { //Suggests the pallets to load on truck. var palletSuggestionList = _service.GetPalletSuggestion(model.AppointmentNumber); model.PalletSuggestionList = from pallet in palletSuggestionList select new PalletModel { PalletId = pallet.PalletId, IaId = pallet.IaId, LocationId = pallet.LocationId, BoxesCount = pallet.BoxesCount }; model.SuggestedPallet = palletSuggestionList.Select(p => p.PalletId).FirstOrDefault(); } catch (DbException ex) { ModelState.AddModelError("", ex.InnerException.Message); model.Sound = (char)Sound.Error; } //TC3: If there is no pallet suggestion for passed appointment. if (!model.PalletSuggestionList.Any()) { AddStatusMessage(string.Format("No pallet suggestion found for appointment {0}", model.AppointmentNumber)); } return(View(Views.Pallet, model)); }
public IActionResult AddPallet(PalletViewModel model) { if (ModelState.IsValid) { var createdPallet = palletManager.Add(model); return(RedirectToAction("List")); } return(View(model)); }
/// <summary> /// Displays the Pallet or the Area view. Building mast be passed. If the building is not passed, then this is an error situation and the Building View is displayed. /// </summary> /// <param name="model"></param> /// <returns></returns> public virtual ActionResult PalletOrArea(BuildingViewModel model) { if (!ModelState.IsValid) { // Building not passed. Ask for building. return(Building()); } if (!_service.ValidateBuilding(model.BuildingId)) { ModelState.AddModelError("", string.Format("Building {0} does not exist", model.BuildingId)); return(Building()); } // Interested in building specific areas only var areas = _service.GetCartonAreas(model.BuildingId).Where(p => p.BuildingId == model.BuildingId); // Counting only building specific areas switch (areas.Count()) { case 0: // No building specific area. So ask for area return(View(Views.Area, PopulateAreaViewModel(model.BuildingId, null))); case 1: // Ask for pallet var avm = PopulateAreaViewModel(model.BuildingId, areas.First().AreaId); return(Pallet(avm)); case 2: //Common case. One area which needs replenishment, and another area which provides replenishment. //In this case destination is the area which needs replenishment. try { var destArea = areas.Single(p => !string.IsNullOrEmpty(p.ReplenishAreaId)); //This code will never be executed. var palletModel = new PalletViewModel(destArea) { SuggestedLocations = _service.GetReplenishmentSuggestions(destArea.BuildingId, destArea.AreaId, destArea.ReplenishAreaId, 300, true) .Select(p => new ReplenishmentSuggestionModel(p)) }; return(View(Views.Pallet, palletModel)); } catch (InvalidOperationException) { // Perhaps both areas do not need replenishment. Ask for area. return(View(Views.Area, PopulateAreaViewModel(model.BuildingId, null))); } default: // Multiple areas. Ask for area. return(View(Views.Area, PopulateAreaViewModel(model.BuildingId, null))); } }
public ActionResult EditPallet(PalletViewModel pallet) { var packingDataService = new PackingDataService(); var result = packingDataService.UpdatePallet(pallet); if (result) { return(Json(new AjaxResult("Palet başarıyla kaydedildi."))); } return(Json(new AjaxResult("Palet kaydedilemedi!"))); }
public virtual ActionResult AcceptPallet(PalletViewModel pvm) { if (string.IsNullOrEmpty(pvm.PalletId)) { //TC6: Enter pressed back to change the bldg/area return(RedirectToAction(Actions.Building())); } if (!ModelState.IsValid) { // TC7: When will the model state be invalid? pvm.GenerateStats += new EventHandler <GenerateStatsEventArgs>(pvm_OnGenerateStats); return(View(Views.Pallet, pvm)); } return(RedirectToAction(this.Actions.Carton(pvm.Context.Serialized, pvm.PalletId))); }
public IActionResult Edit(EditPalletViewModel model) { if (ModelState.IsValid) { var palletViewModel = new PalletViewModel() { ID = model.ID, IP = model.IP, NAME = model.NAME, STATUSID = statusManager.GetAll().FirstOrDefault(x => x.NAME == model.STATUS_NAME).ID, STATUS_NAME = model.STATUS_NAME }; palletViewModel = palletManager.Update(palletViewModel); return(RedirectToAction("List")); } return(View(model)); }
/// <summary> /// Displays Pallet view. Must pass and AreaShortName. /// </summary> /// <param name="model"></param> /// <returns></returns> /// <remarks> /// If building and/or area is not passed, the building screen is displayed. /// </remarks> public virtual ActionResult Pallet(AreaViewModel model) { if (string.IsNullOrEmpty(model.AreaId) && string.IsNullOrEmpty(model.AreaShortName)) { // Ask for building again ModelState.Clear(); return(Building()); } Area area = null; if (!string.IsNullOrEmpty(model.AreaId)) { area = _service.GetCartonArea(model.AreaId); } if (!string.IsNullOrEmpty(model.AreaShortName)) { area = _service.GetCartonArea(model.BuildingId, model.AreaShortName); } if (area == null) { //Get area of location, if location was scanned. area = _service.GetAreaFromLocationId(model.AreaShortName); } if (area == null) { ModelState.AddModelError("", string.Format("Area/Location {0} is not recognized for building {1}", model.AreaShortName, model.BuildingId)); return(View(Views.Area, PopulateAreaViewModel(model.BuildingId, null))); } var palletModel = new PalletViewModel(area) { SuggestedLocations = _service.GetReplenishmentSuggestions(area.BuildingId, area.AreaId, area.ReplenishAreaId, 300, model.UseSuggestionCache) .Select(p => new ReplenishmentSuggestionModel(p)) }; return(View(Views.Pallet, palletModel)); }
public virtual ActionResult Pallet(PalletViewModel model) { // TC4: Enter pressed, return to previous page to scan new appointment. if (string.IsNullOrEmpty(model.ScanText)) { return(RedirectToAction(this.Actions.Index())); } //TC5: 'S' pressed, skip suggested pallet by system. if (model.ScanText == "S") { return(Appointment(new IndexViewModel { AppointmentNo = model.AppointmentNumber }));; } // TC6: If scanned text is not a pallet. if (!__regexPallet.IsMatch(model.ScanText)) { ModelState.AddModelError("", string.Format("Scan text {0} is not recognized.", model.ScanText)); return(Appointment(new IndexViewModel { AppointmentNo = model.AppointmentNumber })); } try { var boxes = _service.GetBoxesOfPallet(model.ScanText); // TC7: Scanned pallet belongs to other appointment. if (boxes.Any() && model.AppointmentNumber != boxes.First().AppointmentNumber) { // Ensuring pallet belongs to same appointment. throw new ScanToTruckServiceException(ScanToTruckServiceErrorCode.AppointmentMisMatch); } var isPalletLoaded = boxes.Any(p => p.TruckLoadDate != null); // TC8: If pallet was not loaded, then load the pallet on truck. if (!isPalletLoaded) { _service.LoadPallet(model.ScanText); AddStatusMessage(string.Format("Pallet {0} having {1} boxes loaded.", model.ScanText, boxes.Count())); } // TC9: If user wants to unload pallet. else { //TC10: Ask confirmation for pallet to unload it. AddStatusMessage(string.Format("Please rescan Pallet {0} to confirm unload it.", model.ScanText)); var upvm = new UnloadPalletViewModel { AppointmentNumber = model.AppointmentNumber, //Context = model.Context, ConfirmScanText = model.ScanText, Sound = (char)Sound.Warning }; return(View(Views.UnloadPallet, upvm)); } } catch (DbException ex) { ModelState.AddModelError("", ex.InnerException); model.Sound = (char)Sound.Error; } catch (ScanToTruckServiceException ex) { switch (ex.ErrorCode) { case ScanToTruckServiceErrorCode.UnVerifiedBoxes: ModelState.AddModelError("", string.Format("{0} boxes of pallet {1} are unverified .", ex.Data["Data"], model.ScanText)); break; case ScanToTruckServiceErrorCode.StopProcess: ModelState.AddModelError("", string.Format("{0} boxes of pallet {1} are cancelled.", ex.Data["Data"], model.ScanText)); break; case ScanToTruckServiceErrorCode.AppointmentMisMatch: ModelState.AddModelError("", string.Format("Pallet {0} does not belongs to {1} appointment.", model.ScanText, model.AppointmentNumber)); break; case ScanToTruckServiceErrorCode.InvalidPallet: ModelState.AddModelError("", string.Format("No boxes exist in Pallet {0}.", model.ScanText)); break; case ScanToTruckServiceErrorCode.LoadedOnTruck: ModelState.AddModelError("", string.Format("{0} boxes of {1} pallet already loaded on truck.", ex.Data["Data"], model.ScanText)); break; } model.Sound = (char)Sound.Error; } return(Appointment(new IndexViewModel { AppointmentNo = model.AppointmentNumber })); }
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))); }
/// <summary> /// Renders the Location View. PalletId and Area id must be passed. /// </summary> /// <param name="model"></param> /// <returns></returns> /// <remarks>BuildingId is not required due to such Areas which are in multiple buildings</remarks> public virtual ActionResult Location(PalletViewModel model) { if (string.IsNullOrEmpty(model.AreaId) || string.IsNullOrEmpty(model.PalletOrCartonId)) { // If pallet not passed, then we must ask for area. this means user pressed a blank enter and he wishes to // specify a new area. ModelState.Clear(); return(View(Views.Area, PopulateAreaViewModel(model.BuildingId, null))); } var pallet = model.PalletOrCartonId.StartsWith("P") ? _service.GetPallet(model.PalletOrCartonId) : _service.GetPalletFromCartonId(model.PalletOrCartonId); //invalid pallet passed, returns pallet view to ask again a valid pallet. var destArea = _service.GetCartonArea(model.AreaId); ////////////////////////////// Orphan carton case ///////////////////////////////////// if (pallet == null) { // Orphan carton case. We will offer the user to put this carton on a pallet. var carton = _service.GetCarton(model.PalletOrCartonId); if (carton != null) { //Ask for new carton or pallet var palletModel = new PalletViewModel(destArea) { SuggestedLocations = _service.GetReplenishmentSuggestions(destArea.BuildingId, destArea.AreaId, destArea.ReplenishAreaId, 300, true) .Select(p => new ReplenishmentSuggestionModel(p)), //Store the carton in hidden field for C2P LastScan = carton.CartonId }; AddStatusMessage(string.Format("Scan Pallet to palletize carton {0}", carton.CartonId)); return(View(Views.Pallet, palletModel)); } //If scan was invalid then populate this view again. ModelState.AddModelError("", string.Format("Scan {0} is not recognized as Pallet or Carton.", model.PalletOrCartonId)); return(Pallet(PopulateAreaViewModel(model.BuildingId, model.AreaId))); } if (!string.IsNullOrEmpty(model.LastScan)) { //User scanned a pallet therefore try to the palletize carton. try { pallet = _service.PalletizeCarton(model.LastScan, pallet); AddStatusMessage(string.Format("Carton {0} successfully moved to Pallet {1}", model.LastScan, pallet.PalletId)); } catch (ProviderException ex) { ModelState.AddModelError("", ex.Message); } } if (!ModelState.IsValid) { return(Pallet(PopulateAreaViewModel(model.BuildingId, model.AreaId))); } ///////////////////////////////////////////////// End orphan carton case /////////////////////////////////////////////////////// // Multi SKU case, Error message to clean the pallet first before locate this. if (pallet.SkuCount > 1) { AddStatusMessage(string.Format("Pallet {0} contains {1} cartons of {2} different SKUs.Continue only if you are sure?", model.PalletOrCartonId, pallet.CartonCount, pallet.SkuCount)); model.Sound = 'E'; } if (destArea.IsNumbered) { var lvm = PopulateLocationViewModel(model.AreaId, model.BuildingId, pallet); lvm.Sound = model.Sound; return(View(Views.Location, lvm)); } //Locate and merge pallet _service.LocateandMergePallet(null, pallet.PalletId, destArea.AreaId, null); AddStatusMessage(string.Format("Pallet {0} successfully moved to {1}", pallet.PalletId, destArea.ShortName)); //If successfully updated, returns new PalletViewModel to Pallet View with previous state values like destination Area and Building return(RedirectToAction(MVC_PalletLocating.PalletLocating.Home.ActionNames.Pallet, new AreaViewModel { AreaId = destArea.AreaId, BuildingId = model.BuildingId, Sound = 'S' })); }