public ActionResult Discard(int id, ProfileBoxModel boxdetail) { var userRoles = _workContext.User.Roles; var box = _profileBoxService.GetById(id); if (box.StatusId < (short)ABO.Core.ProfileBoxStatus.Stored) { ErrorNotification(_resourceManager.GetString("Profile.FailedToChangeStatusProfileBoxes")); return(Redirect(Request.RawUrl)); } if (userRoles.Contains(ABO.Core.UserRole.TeamLeader)) { // check profile var profiles = _profileService.SearchProfilesByStatus(id, 0, 1, int.MaxValue, null, null); if (profiles.Count != 0) { var count = profiles.Count(t => t.StatusId != (short)ProfileStatus.Deleted); if (count > 0) { ErrorNotification(_resourceManager.GetString("Profile.FailedToDiscardProfileBoxes2")); return(Redirect(Request.RawUrl)); } } var location = (boxdetail.ProfileBox.Location != null) ? boxdetail.ProfileBox.Location.Value : 0; _profileBoxService.UpdateStatus(id, (short)ABO.Core.ProfileBoxStatus.Discarded, location, null, null); SuccessNotification(_resourceManager.GetString("Profile.SuccessToDiscardProfileBoxes")); } else { ErrorNotification(_resourceManager.GetString("Profile.FailedToDiscardProfileBoxes")); } return(Redirect(Request.RawUrl)); }
private Stream CreateLabel(int id) { var model = new ProfileBoxModel(); var profileBox = _profileBoxService.GetById(id); string label = profileBox.Name.ToUpper(); string profileCount = ""; if (!profileBox.ProfileType.Scanned) { profileCount = profileBox.ProfileCount.ToString(); } else { var profiles = _profileService.SearchProfilesByStatus(id, 0, 1, int.MaxValue, null, null); profileCount = profiles.Count(x => x.StatusId != (short)ProfileStatus.Deleted).ToString(); } string filePath = Server.MapPath(Url.Content("~/Template/Label.docx")); DocX document = DocX.Load(filePath); var outputStream = new MemoryStream(); document.ReplaceText("{Label}", label); document.ReplaceText("{count}", profileCount); // get placeholder image Novacode.Image img = document.Images[0]; // create barcode encoder var barcodeWriter = new BarcodeWriter { Format = BarcodeFormat.CODE_128, Options = new EncodingOptions { PureBarcode = false, Height = 100, Width = 300, Margin = 10 } }; // create barcode image var bitmap = barcodeWriter.Write(label); // replace place holder image in document with barcode image bitmap.Save(img.GetStream(FileMode.Create, FileAccess.Write), ImageFormat.Png); document.SaveAs(outputStream); outputStream.Position = 0; document.Dispose(); return(outputStream); }
public ActionResult Detail(ProfileBoxModel boxdetail, int id, int statusId = 0, int page = 1, int pageSize = 5) { var model = new ProfileBoxModel(); var profileBox = _profileBoxService.GetById(id); if (profileBox == null) { return(PageNotFound()); } profileBox.WarehouseId = (boxdetail.ProfileBox == null) ? profileBox.WarehouseId : boxdetail.ProfileBox.Warehouse; model.ProfileBox = profileBox.ToModel <ProfileBoxDetailModel>(); model.ProfileBox.StatusList = WebUtility.ConvertEnumToSelectList <ABO.Core.ProfileBoxStatus>(false); Dictionary <string, string> warehouses = _warehouseService.GetAllWarehouses(); model.ProfileBox.WarehouseList = WebUtility.ConvertDictionaryToSelectList(warehouses, false); Dictionary <string, string> profileTypes = _profileTypeService.GetAllTypes(); model.ProfileBox.ProfileTypeList = WebUtility.ConvertDictionaryToSelectList(profileTypes, false); Dictionary <string, string> locations = _profileBoxService.GetLocationByWarehouseId(profileBox.WarehouseId); model.LocationList = WebUtility.ConvertDictionaryToSelectList(locations, false); Dictionary <string, string> openBoxes = _profileBoxService.GetProfileBoxByStatusType((short)ABO.Core.ProfileBoxStatus.Open, profileBox.TypeId, profileBox.Id); ViewBag.OpenBoxes = WebUtility.ConvertDictionaryToSelectList(openBoxes, false); // Get Profiles var profiles = _profileService.SearchProfilesByStatus(id, statusId, page, pageSize, null, null); model.Profiles = profiles.Select(x => x.ToModel <ProfileModel>()).ToList(); model.Pager = profiles.ToMvcPaging(model.Profiles); model.StatusList = WebUtility.ConvertEnumToSelectList <ABO.Core.ProfileStatus>(true); model.ProfileBox.ProfileCount = model.ProfileBox.ProfileCount; return(View(model)); }
public ActionResult Moved(int id, ProfileBoxModel boxdetail) { var userRoles = _workContext.User.Roles; var box = _profileBoxService.GetById(id); // Check whether status changes in order or not if (box.StatusId != (short)ABO.Core.ProfileBoxStatus.Packed && box.StatusId != (short)ABO.Core.ProfileBoxStatus.Stored) { ErrorNotification(_resourceManager.GetString("Profile.FailedToChangeStatusProfileBoxes")); return(Redirect(Request.RawUrl)); } if (userRoles.Contains(ABO.Core.UserRole.TeamLeader)) { var location = (boxdetail.ProfileBox.Location != null) ? boxdetail.ProfileBox.Location.Value : 0; _profileBoxService.UpdateStatus(id, (short)ABO.Core.ProfileBoxStatus.Moved, location, null, boxdetail.ProfileBox.Warehouse); SuccessNotification(_resourceManager.GetString("Profile.SuccessToMoveProfileBoxes")); } else { ErrorNotification(_resourceManager.GetString("Profile.FailedToMoveProfileBoxes")); } return(Redirect(Request.RawUrl)); }