Example #1
0
        public static double GetNetPoundWeight(double poundWeight, OmsLabelType labelType, OrderDetail orderDetail, CaseSize customCase = null)
        {
            var tareWeight = GetTareWeight(customCase, labelType, orderDetail);

            poundWeight -= tareWeight;
            return(poundWeight < 1000
                ? poundWeight
                : Math.Round(poundWeight, MidpointRounding.AwayFromZero));
        }
Example #2
0
        public JsonResult WeightAndPrint(int id, OmsLabelType labelType)
        {
            var status = _scaleService.WeighAndLabel(id, labelType);

            if (status != OmsScaleWeighStatus.Success)
            {
                this.ShowNotification(NotificationType.Error, _scaleService.GetScaleStatusMessage(status));
            }

            return(Json(new { status }, JsonRequestBehavior.AllowGet));
        }
Example #3
0
        public int ProduceLabel(int orderDetailId, double poundWeight, OmsLabelType labelType)
        {
            var viewModel = GetLabelLayoutViewModel(orderDetailId, labelType);

            viewModel.PoundWeight = poundWeight < 1000
                ? poundWeight
                : Math.Round(poundWeight, MidpointRounding.AwayFromZero);
            viewModel.KilogramWeight = Math.Round(viewModel.PoundWeight * LbsKgConversionFactor, 2,
                                                  MidpointRounding.AwayFromZero);
            return(CreateLabel(viewModel));
        }
Example #4
0
        public void UpdateLabel(int labelId, double poundWeight, OmsLabelType labelType)
        {
            Label label = _labelRepository.Get(labelId);
            var   od    = _orderDetailRepository.Get(label.OrderDetailId);

            label.IsPrinted      = false;
            label.PoundWeight    = LabelCreateService.GetNetPoundWeight(poundWeight, labelType, od);
            label.KilogramWeight = LabelCreateService.GetCorrectKilogramWeight(label.PoundWeight);
            label.CreatedDate    = DateTime.Now;
            label.ProcessDate    = od.Order.ProcessDate.GetValueOrDefault().ToString("d");
            _labelRepository.Update(label);
            _labelRepository.Save();
        }
Example #5
0
        public void ProduceLabel(int orderDetailId, double poundWeight, OmsLabelType labelType, int quantity = 1, DateTime?processDate = null, QualityGrade qualityGrade = null, AnimalLabelsViewModel animalLabel = null, CaseSize customCaseSize = null)
        {
            var context = new OmsContext();

            _orderDetailRepository = new OrderDetailRepository(context);
            var orderDetail = _orderDetailRepository.GetLabelInfo(orderDetailId);
            var model       = GetLabelLayoutViewModel(poundWeight, orderDetail, labelType, false, qualityGrade, animalLabel, customCaseSize);

            for (var i = 0; i < quantity; i++)
            {
                ProduceLabel(labelType, model, orderDetail, false, processDate);
            }
            context.Dispose();
        }
Example #6
0
        private static double GetTareWeight(CaseSize customCaseSize, OmsLabelType labelType, OrderDetail orderDetail)
        {
            decimal tareWeight;

            switch (labelType)
            {
            // abs in case when value in db has negative sign
            case OmsLabelType.Bag: tareWeight = GetBagTareWeight(customCaseSize, orderDetail); break;

            case OmsLabelType.Box: tareWeight = GetBoxTareWeight(customCaseSize, orderDetail); break;

            default: tareWeight = 0; break;
            }
            return((double)tareWeight);
        }
Example #7
0
        private void DetectLabelTypeOrDefault(RadTabControl tabControl)
        {
            if (tabControl == null)
            {
                return;
            }

            switch (tabControl.SelectedIndex)
            {
            case 0:
                _activeLabelType = OmsLabelType.Bag;

                if (_viewModel.SelectedSide != null && _viewModel.SelectedCutItem != null)
                {
                    _labelTypeMode = LabelTypeMode.CustomBagLabel;
                }
                else
                {
                    _labelTypeMode = null;
                }
                break;

            case 1:
                //if (_viewModel != null && _viewModel.IsCustomOwner)
                //{
                //    _labelService = new LabelService();
                //    //_viewModel.BoxesCustomList = _labelService.GetBoxesCustomList(_viewModel.CurrentOrderId);
                //    _labelTypeMode = null;
                //}
                _activeLabelType = OmsLabelType.Tray; break;

            case 2:
                //if (_viewModel != null && _viewModel.IsCustomOwner)
                //{
                //    _labelService = new LabelService();
                //    //_viewModel.BoxesCustomList = _labelService.GetBoxesCustomList(_viewModel.CurrentOrderId);
                //    _labelTypeMode = null;
                //}
                _activeLabelType = OmsLabelType.Box; break;

            case 4:
                _activeLabelType = OmsLabelType.Box; break;
            }
        }
Example #8
0
        public OmsScaleWeighStatus WeighAndLabel(int orderDetailId, OmsLabelType labelType)
        {
            var scaleId = Convert.ToInt32(ConfigurationManager.AppSettings["ScaleId"]);

            if (SessionService.Get().BagScale == null)
            {
                SessionService.Get().BagScale = InitializeScale(scaleId);
            }

            var scaleWeight = SessionService.Get().BagScale.GetWeight();
            var status      = scaleWeight.Status;

            if (status == OmsScaleWeighStatus.Success)
            {
                _labelCreateService.ProduceLabel(orderDetailId, scaleWeight, labelType, null);
            }

            return(status);
        }
Example #9
0
 private void ProduceLabel(OmsLabelType labelType, LabelOutputViewModel model, OrderDetail orderDetail, bool isCustombagLabel, DateTime?processDate)
 {
     model.SerialNumber = GetSerialNumber();
     if (isCustombagLabel)
     {
         model.OrderDetailId = orderDetail.Id;
     }
     model.Printer   = SettingsManager.Current.Printer;
     model.LabelFile = SetLabelFile(labelType, orderDetail.Order.Customer, false);
     if (processDate.HasValue)
     {
         model.ProcessDate = processDate.GetValueOrDefault();
     }
     CreateLabel(model);
     if (SettingsManager.Current.IsSecondaryLabel)
     {
         model.Printer   = SettingsManager.Current.SecondaryPrinter;
         model.LabelFile = SetLabelFile(labelType, orderDetail.Order.Customer, true);
         CreateLabel(model);
     }
 }
Example #10
0
        private static string SetLabelFile(OmsLabelType labelType, Customer customer, bool isSecondaryLabel)
        {
            const string folderSeparator = "\\";
            string       baseDirectory;

            try
            {
                baseDirectory = SettingsManager.Current.LabelBaseFolder;
            }
            catch (Exception)
            {
                baseDirectory = ConfigurationManager.AppSettings["LabelBaseFolder"];
            }

            if (isSecondaryLabel)
            {
                return(baseDirectory + SettingsManager.Current.SecondLabel);
            }

            baseDirectory += baseDirectory.Trim().EndsWith(folderSeparator) ? string.Empty : folderSeparator;

            var bagLabel  = string.IsNullOrEmpty(customer.BagLabel) ? "bag.lbl" : customer.BagLabel;
            var boxLabel  = string.IsNullOrEmpty(customer.BoxLabel) ? "box.lbl" : customer.BoxLabel;
            var trayLabel = string.IsNullOrEmpty(customer.TrayLabel) ? "tray.lbl" : customer.TrayLabel;

            switch (labelType)
            {
            case OmsLabelType.Bag:
                return(string.Format("{0}{1}", baseDirectory, bagLabel));

            case OmsLabelType.Box:
                return(string.Format("{0}{1}", baseDirectory, boxLabel));

            case OmsLabelType.Tray:
                return(string.Format("{0}{1}", baseDirectory, trayLabel));

            default:
                return(string.Empty);
            }
        }
Example #11
0
        private static string SetLabelFile(OmsLabelType labelType, Customer customer)
        {
            const string folderSeparator = "\\";
            var          baseDirectory   = ConfigurationManager.AppSettings["LabelBaseFolder"].Trim();

            baseDirectory += baseDirectory.EndsWith(folderSeparator) ? string.Empty : folderSeparator;

            var bagLabel = string.IsNullOrEmpty(customer.BagLabel) ? "bag.lbl" : customer.BagLabel;
            var boxLabel = string.IsNullOrEmpty(customer.BoxLabel) ? "box.lbl" : customer.BoxLabel;

            switch (labelType)
            {
            case OmsLabelType.Bag:
                return(string.Format("{0}{1}", baseDirectory, bagLabel));

            case OmsLabelType.Box:
                return(string.Format("{0}{1}", baseDirectory, boxLabel));

            default:
                return(string.Empty);
            }
        }
Example #12
0
        private LabelOutputViewModel GetLabelLayoutViewModel(int orderDetailId, OmsLabelType labelType)
        {
            var orderDetail = _orderDetailRepository.Get(orderDetailId);
            var order       = orderDetail.Order;
            var product     = orderDetail.Product;

            _customerRepository.Detach(order.Customer);
            var customer = order.Customer;

            var model = new LabelOutputViewModel();
            var customerProductCode = product.CustomerProductCode.FirstOrDefault(cpc => cpc.CustomerId == orderDetail.Order.CustomerId);

            model.OrderDetailId  = orderDetailId;
            model.Type           = labelType;
            model.ItemCode       = product.Upc;
            model.LotNumber      = GetLotNumber(order);
            model.Description    = product.Description;
            model.ProcessDate    = order.ProcessDate ?? DateTime.Today;
            model.SlaughterDate  = order.SlaughterDate ?? DateTime.Today;
            model.BestBeforeDate = order.BestBeforeDate;
            model.SpeciesBugPath = GetSpeciesBugPath(product);

            switch (customer.LogoTypeId)
            {
            case OmsLogoType.None:
                model.LogoPath = SettingsManager.Current.NoLogoImageFileName;
                break;

            case OmsLogoType.Customer:
                model.LogoPath = customer.LogoFileName ?? SettingsManager.Current.NoLogoImageFileName;
                break;

            case OmsLogoType.DoubleJ:
                model.LogoPath = SettingsManager.Current.DoubleJLogoFileName;
                break;

            default:
                throw new IndexOutOfRangeException("Order.LogoTypeId");
            }
            model.BornInRegionName    = order.BornRegion.With(x => x.Name);
            model.RaisedInRegionName  = order.RaisedRegion.With(x => x.Name);
            model.ProductOfRegionName = order.ProductOfRegion.With(x => x.Name);
            model.DistributedBy       = customer.DistributedBy;

            model.LabelFile          = SetLabelFile(labelType, customer);
            model.GermanDescription  = product.GermanDescription;
            model.FrenchDescription  = product.FrenchDescription;
            model.ItalianDescription = product.ItalianDescription;
            model.SwedishDescription = product.SwedishDescription;

            model.Organic             = GetOrganicPath(product);
            model.SerialNumber        = GetSerialNumber();
            model.VarCustomerJobValue = order.AdditionalInfoOnLabel;

            model.Primal        = product.PrimalCut.Return(x => x.Name);
            model.SubPrimal     = product.SubPrimalCut.Return(x => x.Name);
            model.PackedFor     = customer.Name;
            model.Refrigeration = order.Refrigeration.Return(x => x.Name);
            model.Trim          = product.TrimCut.Return(x => x.Name);
            model.GradeName     = product.QualityGrade.Return(x => x.Name);

            model.CustomerProductCode = customerProductCode == null || customerProductCode.ProductCode == null
                ? product.Code
                : customerProductCode.ProductCode;

            model.VarCustomerProductValue = customerProductCode == null || customerProductCode.ProductDescription == null
                ? null
                : customerProductCode.ProductDescription;

            model.Customer = customer.Name;

            model.WeighedDate = DateTime.Now;
            return(model);
        }
Example #13
0
        public void ProduceCustomBagLabels(List <OrderDetail> orderDetails, double poundWeight, OmsLabelType labelType, DateTime?processDate, QualityGrade qualityGrade, AnimalLabelsViewModel animalLabel = null, CaseSize customCaseSize = null)
        {
            if (!orderDetails.Any())
            {
                return;
            }
            var model = GetLabelLayoutViewModel(poundWeight, orderDetails.First(), labelType, false, qualityGrade, animalLabel, customCaseSize);

            foreach (var orderDetail in orderDetails)
            {
                ProduceLabel(labelType, model, orderDetail, true, processDate);
            }
        }
Example #14
0
 public int ProduceLabel(int orderDetailId, ScaleWeight weight, OmsLabelType labelType)
 {
     return(ProduceLabel(orderDetailId, weight.Gross, labelType));
 }
Example #15
0
 public void ProduceLabel(int orderDetailId, ScaleWeight weight, OmsLabelType labelType, DateTime?processDate)
 {
     ProduceLabel(orderDetailId, weight.Gross, labelType, 1, processDate);
 }
Example #16
0
        private LabelOutputViewModel GetLabelLayoutViewModel(double poundWeight, OrderDetail orderDetail, OmsLabelType labelType, bool needSetSerialNumber = true, QualityGrade qualityGrade = null, AnimalLabelsViewModel animalLabel = null, CaseSize customCaseSize = null)
        {
            var model = new LabelOutputViewModel();


            model.PoundWeight    = GetNetPoundWeight(poundWeight, labelType, orderDetail);
            model.KilogramWeight = GetCorrectKilogramWeight(model.PoundWeight);

            var order    = orderDetail.Order;
            var product  = orderDetail.Product;
            var customer = order.Customer;

            var productData = GetCustomerProductData(product, order);

            model.CustomerStateCode = orderDetail.CustomerLocation.StateCode;
            model.CustomerAddress1  = orderDetail.CustomerLocation.Address1;
            model.CustomerAddress2  = orderDetail.CustomerLocation.Address2;
            model.CustomerCity      = orderDetail.CustomerLocation.City;
            model.CustomerEmail     = orderDetail.CustomerLocation.Email;
            model.CustomerFax       = orderDetail.CustomerLocation.Fax;
            model.CustomerZipCode   = orderDetail.CustomerLocation.ZipCode;
            model.CustomerPhone     = orderDetail.CustomerLocation.Phone;
            model.CustomerName      = orderDetail.CustomerLocation.Name;
            model.OrderDetailId     = orderDetail.Id;
            model.Type                      = labelType;
            model.ItemCode                  = product.Upc;
            model.LotNumber                 = GetLotNumber(order.Id);
            model.Description               = product.EnglishDescription;
            model.ProcessDate               = order.ProcessDate ?? DateTime.Today;
            model.SlaughterDate             = order.SlaughterDate ?? DateTime.Today;
            model.BestBeforeDate            = order.BestBeforeDate ?? DateTime.Today.AddDays(45);
            model.SpeciesBugPath            = GetSpeciesBugPath(product);
            model.LogoPath                  = GetLogoPath(customer);
            model.BornInRegionName          = order.BornRegion.With(x => x.Name);
            model.RaisedInRegionName        = order.RaisedRegion.With(x => x.Name);
            model.ProductOfRegionName       = order.ProductOfRegion.With(x => x.Name);
            model.SlaughteredInRegionName   = order.SlaughteredRegion.With(x => x.Name);
            model.DistributedBy             = customer.DistributedBy;
            model.LabelFile                 = SetLabelFile(labelType, customer, false);
            model.GermanDescription         = product.GermanDescription;
            model.FrenchDescription         = product.FrenchDescription;
            model.ItalianDescription        = product.ItalianDescription;
            model.SwedishDescription        = product.SwedishDescription;
            model.Organic                   = GetOrganicPath(animalLabel != null && animalLabel.IsOrganic);
            model.SerialNumber              = (needSetSerialNumber) ? GetSerialNumber() : null;
            model.JulianProductionDate      = DateTime.Now.DayOfYear.ToString(CultureInfo.InvariantCulture).PadLeft(3, '0');
            model.VarCustomerJobValue       = order.AdditionalInfoOnLabel;
            model.AnimalName                = animalLabel != null ? animalLabel.Name : "";
            model.Species                   = (animalLabel != null && animalLabel.Species != null) ? animalLabel.Species.Name : "";
            model.NutritionDescription      = product.NutritionDescription;
            model.NutritionServingSize      = product.NutritionServingSize;
            model.NutritionServingContainer = product.NutritionServingContainer;
            model.NutritionCalories         = product.NutritionCalories;
            model.NutritionCaloriesFat      = product.NutritionCaloriesFat;
            model.NutritionTotalFat         = product.NutritionTotalFat;
            model.NutritionSatFat           = product.NutritionSatFat;
            model.NutritionTransFat         = product.NutritionTransFat;
            model.NutritionPolyFat          = product.NutritionPolyFat;
            model.NutritionMonoFat          = product.NutritionMonoFat;
            model.NutritionCholesterol      = product.NutritionCholesterol;
            model.NutritionSodium           = product.NutritionSodium;
            model.NutritionCarbs            = product.NutritionCarbs;
            model.NutritionProtein          = product.NutritionProtein;
            model.NutritionVitA             = product.NutritionVitA;
            model.NutritionVitC             = product.NutritionVitC;
            model.NutritionCalcium          = product.NutritionCalcium;
            model.NutritionIron             = product.NutritionIron;

            model.PackedFor     = customer.Name;
            model.Refrigeration = order.Refrigeration.Return(x => x.Name);
            model.Trim          = product.TrimCut.Return(x => x.Name);
            model.GradeName     = qualityGrade != null? qualityGrade.Name: "";

            model.CustomerProductCode = productData == null || productData.ProductCode == null
                ? product.Code
                : productData.ProductCode;
            model.PricePerPound = productData == null || productData.PricePerPound == null
                ? product.PricePerPound
                : productData.PricePerPound;
            model.Price = model.PricePerPound != null
                ? model.PricePerPound.Value *Convert.ToDecimal(model.PoundWeight)
                : (decimal?)null;

            model.Gtin = productData == null || productData.Gtin == null
                ? product.Gtin
                : productData.Gtin.Value;
            model.VarCustomerProductValue = productData == null || productData.ProductDescription == null
                ? null
                : productData.ProductDescription;

            model.Customer    = customer.Name;
            model.CustomerPO  = order.POCustomer;
            model.Printer     = SettingsManager.Current.Printer;
            model.WeighedDate = DateTime.Now;

            // todo (alexm): should be checked
            model.TareWeight = labelType == OmsLabelType.Box? GetBoxTareWeight(customCaseSize, orderDetail) : GetBagTareWeight(customCaseSize, orderDetail);

            return(model);
        }
Example #17
0
 public static double GetGrossPoundWeight(double poundWeight, OmsLabelType labelType, OrderDetail orderDetail, CaseSize customCase = null)
 {
     return(poundWeight + GetTareWeight(customCase, labelType, orderDetail));
 }