private void Scanner_BarcodeScanned(object sender, BarcodeScannedEventArgs e)
 {
     try
     {
         double price = m_PriceLookup.GetPrice(e.Barcode);
         m_PriceDisplay.DisplayPrice(price);
     }
     catch (Exception)
     {
         m_PriceDisplay.ShowError();
     }
 }
Esempio n. 2
0
        private void Scanner_BarcodeScanned(object sender, BarcodeScannedEventArgs e)
        {
            Product product;

            using (var db = new MyContext())
            {
                product = db.Products.FirstOrDefault(p => p.Barcode == e.Barcode);
            }

            if (product != null)
            {
                ProductCode = product.CatalogCode;
                ProductName = product.CatalogName;

                decimal currentPrice = product.Price;

                bool regionalApplied = false;
                if (product.Taxes.HasFlag(TaxingType.RegionalTax))
                {
                    currentPrice    = currentPrice + product.Price * 0.1m;
                    regionalApplied = true;
                }

                if (product.Taxes.HasFlag(TaxingType.Tva) && !regionalApplied)
                {
                    currentPrice = currentPrice + product.Price * 0.22m;
                }

                if (product.Taxes.HasFlag(TaxingType.LuxuryTax))
                {
                    currentPrice = currentPrice + product.Price * 0.5m;
                }

                if (product.Taxes.HasFlag(TaxingType.Discount))
                {
                    currentPrice = currentPrice - currentPrice * 0.3m;
                }

                ProductPrice = string.Format("{0} $", currentPrice);
            }
            else
            {
                ProductCode  = string.Empty;
                ProductName  = "N/A";
                ProductPrice = string.Empty;
            }
        }
Esempio n. 3
0
        private void Scanner_BarcodeScanned(object sender, BarcodeScannedEventArgs e)
        {
            Product product;

            using (var db = new MyContext())
            {
                product = db.Products.FirstOrDefault(p => p.Barcode == e.Barcode);
            }

            if (product != null)
            {
                ProductCode  = product.CatalogCode;
                ProductName  = product.CatalogName;
                ProductPrice = string.Format("{0} $", product.Price);
            }
            else
            {
                ProductCode  = string.Empty;
                ProductName  = "N/A";
                ProductPrice = string.Empty;
            }
        }
Esempio n. 4
0
        private void Scanner_BarcodeScanned(object sender, BarcodeScannedEventArgs e)
        {
            string productCode = e.Barcode;

            if (string.IsNullOrEmpty(productCode))
            {
                 m_PriceDisplay.ShowScanError();
            }

            try
            {
                double price = m_ProductRepository.GetPrice(productCode);

                bool provincialTaxNeeded = m_ProductRepository.IsProvincial(productCode);

                double priceWithFederalTax = m_TaxCalculator.CalculateTax(price, provincialTaxNeeded);

                m_PriceDisplay.ShowPrice(priceWithFederalTax);
            }
            catch (ProductNotFoundException)
            {
                m_PriceDisplay.ShowProductNotFound(productCode);
            }
        }