/// <summary>
        /// Get Barcode and Sale
        /// </summary>
        /// <param name="barcode">The barcode of the product.</param>
        /// <param name="saleProductSupports">The Sale Product support collection.</param>
        /// <returns>Current sale product support</returns>
        public SaleProductSupport GetBarcodeAndSale(string barcode)
        {
            Product product = IoC.Resolve<IProductService>().GetProductByBarcode(barcode);
            List<SaleProductSupport> saleProductSupports = new List<SaleProductSupport>();
            SaleProductSupport saleProductSupport = new SaleProductSupport();
            int quantity = 1; int price = ApplicationSetting.Price;

            if (product == null)
                return null;

            if (ZuluContext.Current.SaleProductSupports != null && ZuluContext.Current.SaleProductSupports.Count != 0)
            {
                saleProductSupports = ZuluContext.Current.SaleProductSupports;
                var tempSaleproductSupport = saleProductSupports.FirstOrDefault(c => c.ProductBarcode == barcode);

                if (tempSaleproductSupport != null)
                {
                    quantity = quantity + tempSaleproductSupport.Quantity;
                    ZuluContext.Current.SaleProductSupports.Remove(tempSaleproductSupport);
                }
            }
            else
                ZuluContext.Current.SaleProductSupports = new List<SaleProductSupport>();

            saleProductSupport.ProductBarcode = barcode;
            saleProductSupport.ProductName = product.Name;
            saleProductSupport.UnitPrice = price;
            saleProductSupport.Quantity = quantity;

            ZuluContext.Current.SaleProductSupports.Add(saleProductSupport);

            return saleProductSupport;
        }
        private void BarcodeReceiver(string barcode)
        {
            SaleProductSupport saleProductSupport = new SaleProductSupport();
            Barcode = barcode;

            saleProductSupport = SaleService.GetBarcodeAndSale(barcode);

            if (saleProductSupport == null)
                MessageBox.Show("Your product is not valid.", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);

            txtProduct.Text = saleProductSupport.ProductName;
            spnUnitPrice.EditValue = ApplicationSetting.Price;
            spnTotal.EditValue = saleProductSupport.TotalCost;
            spnQty.EditValue = saleProductSupport.Quantity;
            spnQty.Focus();
            spnQty.SelectionStart = 0;
            spnQty.SelectionLength = spnQty.Text.Length;
            Quantity = saleProductSupport.Quantity;
        }
        private void AddSaleProducts(int quantity)
        {
            int Total = 0;
            grdSaleProducts.DataSource = null;

            SaleProductSupport saleProductSupport = new SaleProductSupport();

            saleProductSupport.ProductBarcode = Barcode;
            saleProductSupport.ProductName = txtProduct.Text;
            saleProductSupport.Quantity = quantity;
            saleProductSupport.UnitPrice = ZuluHelper.GetIntValue(spnUnitPrice.EditValue.ToString());

            var existingsaleProductSupport = ZuluContext.Current.SaleProductSupports.FirstOrDefault(c => c.ProductBarcode == Barcode);

            if (existingsaleProductSupport != null)
                ZuluContext.Current.SaleProductSupports.Remove(existingsaleProductSupport);

            ZuluContext.Current.SaleProductSupports.Add(saleProductSupport);

            if (ZuluContext.Current.SaleProductSupports != null && ZuluContext.Current.SaleProductSupports.Count != 0)
            {
                grdSaleProducts.DataSource = ZuluContext.Current.SaleProductSupports;

                foreach (var loopSaleProductSupport in ZuluContext.Current.SaleProductSupports)
                {
                    Total = Total + loopSaleProductSupport.TotalCost;
                }
                lblTotalAmount.Text = Total.ToString("#,##");
                lblNetAmount.Text = Total.ToString("#,##");
            }
        }
        public List<SaleProductSupport> GetSaleProductListSupportByCounter(int counterNumber)
        {
            List<SaleProductSupport> saleProductSupports = new List<SaleProductSupport>();
            List<Sale> sales = GetSalesByCounterNumber(counterNumber);
            List<SaleProduct> allSaleProducts = _context.SaleProducts.ToList();

            foreach (var sale in sales)
            {
                var saleProducts = allSaleProducts.Where(c => c.SaleID == sale.SaleID).ToList();
                foreach(var saleProduct in saleProducts)
                {
                    SaleProductSupport saleProductSupport = new SaleProductSupport();
                    saleProductSupport.ProductBarcode = saleProduct.ProductBarcode;
                    saleProductSupport.ProductName = saleProduct.ProductName;
                    saleProductSupport.UnitPrice = (int) saleProduct.UnitPrice;

                    var existingSaleProductSupport = saleProductSupports.FirstOrDefault(c => c.ProductBarcode == saleProduct.ProductBarcode);

                    if (existingSaleProductSupport != null)
                    {
                        saleProductSupports.Remove(existingSaleProductSupport);
                        saleProductSupport.Quantity = existingSaleProductSupport.Quantity + int.Parse(saleProduct.Quantity.ToString());
                    }
                    else
                        saleProductSupport.Quantity = int.Parse(saleProduct.Quantity.ToString());

                    saleProductSupports.Add(saleProductSupport);
                }
            }
            return saleProductSupports;
        }