private void btnAdd_Click(object sender, RoutedEventArgs e)
        {
            SelectedProduct = cbProducts.SelectedItem as RegisteredProduct;
            if (SelectedProduct != null)
            {
                int quantity = Convert.ToInt32(UpDownQuantity.Value);
                if (ProductsOrdered.Count == 0 || SelectedProduct.Supplier.SupplierId == ProductsOrdered[0].Supplier.SupplierId)
                {
                    for (int i = 0; i < quantity; i++)
                    {
                        ProductsOrdered.Add(new Product()
                        {
                            RegisteredProduct = SelectedProduct,
                            BarCode           = SelectedProduct.BarCode,
                            Name            = SelectedProduct.Name,
                            Description     = SelectedProduct.Description,
                            Price           = SelectedProduct.Price,
                            Supplier        = SelectedSupplier,
                            Sold            = false,
                            ProductCategory = SelectedProduct.ProductCategory
                        });
                    }

                    tbPrice.Text = Convert.ToString(CalculateTotal());
                }
                else
                {
                    MessageBox.Show("Purchase orders for each supplier must be made seperately. You can only add products from one supplier.");
                }
            }
            else
            {
                MessageBox.Show("You must select a product");
            }
        }
Exemplo n.º 2
0
        public void AddProduct(IProduct productOrdered, int qtyOrdered)
        {
            IOrderItem currentProductOrdered;

            if (_tryGetProductOrdered(productOrdered.Id, out currentProductOrdered))
            {
                currentProductOrdered.AddQuantity(qtyOrdered);
                TotalQuantityOrdered += qtyOrdered;
                return;
            }

            var newOrderItem = new OrderItem(productOrdered, qtyOrdered);

            ProductsOrdered.Add(newOrderItem);
            TotalQuantityOrdered += qtyOrdered;
        }
        //====================================================================================================================
        private void DataGridProductsButtonclick(object obj)
        {
            //Console.WriteLine("datagrid doubleclick => " + SelectedProductFromAssortiment.ProductTitle);

            int maxCountToOrder = SelectedProductFromAssortiment.CountInStock -
                                  ProductsOrdered
                                  .Where(x => x.EAN == SelectedProductFromAssortiment.EAN)
                                  .Select(x => x.Count)
                                  .Sum();

            if (maxCountToOrder < 1)
            {
                MessageBox.Show("Je kan dit produkt niet verkopen, de stock is leeg");
                return;
            }


            FrmSetNumberOfProductsByOrdersOut frm = new FrmSetNumberOfProductsByOrdersOut(
                _transactionControl, SelectedProductFromAssortiment, maxCountToOrder);



            if (frm.ShowDialog() == true)
            {
                float prijsZonderBtw = frm.SelectedCount * SelectedProductFromAssortiment.SellingPriceRecommended;
                float btwToeslag     = prijsZonderBtw / 100 * SelectedProductFromAssortiment.BTWpercentage;
                ProductsOrdered.Add(new InternalOrderlineHelper()
                {
                    Count                      = frm.SelectedCount,
                    EAN                        = SelectedProductFromAssortiment.EAN,
                    _BTWaddition               = btwToeslag,
                    UnitPrice                  = SelectedProductFromAssortiment.SellingPriceRecommended,
                    _BtwPercentage             = SelectedProductFromAssortiment.BTWpercentage,
                    _calculatedPriceWithoutBTW = prijsZonderBtw,
                    _calculatedPriceWithBtw    = prijsZonderBtw + btwToeslag,
                    _ProduktTitle              = SelectedProductFromAssortiment.ProductTitle,
                });
                //Console.WriteLine("update" + ProductsOrdered.Count);
                CalculateTotals();
            }
            ;
        }
Exemplo n.º 4
0
        // adds selected products to observable collection which is shown in list view (order overview)
        private void btnAdd_Click(object sender, RoutedEventArgs e)
        {
            SelectedProduct = cbProducts.SelectedItem as Product;
            if (SelectedProduct != null)
            {
                int numberLeftinStock = ReturnQuantityInStock(SelectedProduct);

                int quantity = Convert.ToInt32(UpDownQuantity.Value);

                //mark products as sold in databse and add to order overview
                if (quantity <= numberLeftinStock)
                {
                    var orderedProducts = Ctx.Products.Where(p => p.BarCode == SelectedProduct.BarCode && p.Sold == false).Take(quantity).ToList();
                    foreach (var product in orderedProducts)
                    {
                        product.Sold = true;
                        Ctx.SaveChanges();
                    }

                    foreach (var product in orderedProducts)
                    {
                        ProductsOrdered.Add(product);
                    }

                    //update quantity left
                    lblLeft.Content = ReturnQuantityInStock(SelectedProduct).ToString() + " left in stock";
                }
                else
                {
                    MessageBox.Show("Products cannot be added. Not enough of this item in stock.");
                }


                tbPrice.Text = Convert.ToString(CalculateTotal());
            }
            else
            {
                MessageBox.Show("No product is selected. Select a product.");
            }
        }