//adding product to the quick order
        private void _btnAddProdQuick_Click(object sender, EventArgs e)
        {
            Client  client = (Client)_lstClients.SelectedItem;
            Product prod   = (Product)_lstProducts.SelectedItem;
            string  error  = "";

            if (!double.TryParse(_txtQOProdQty.Text, out double qty))
            {
                error += "Quantity must be a number.\n";
            }

            if (client == null)
            {
                error += "Client must be selected.\n";
            }
            if (prod == null)
            {
                error += "Product must be selected.\n";
            }

            if (error.Length > 0)
            {
                ShowError("Invalid Values", error);
                return;
            }

            //this point -> valid values
            if (_quickOrder == null)
            {
                _quickOrder = new Order {
                    Client       = client,
                    DeliveryDate = DateTime.Today,
                    OrderDate    = DateTime.Today
                };
            }

            _txtQOClient.Text = client.name;
            _quickOrder.AddProduct(prod, qty);

            ResetQuickOrderList(_quickOrder.OrderItems);
            UpdateTotal(_quickOrder);

            _pnlClients.Enabled = false;
            _txtQOProdQty.Clear();
        }
Ejemplo n.º 2
0
 //adds given product and to current order
 //resets totalcost and orderitemlist
 private void AddNewOrderItem(Product prod, double qty)
 {
     _currOrder.AddProduct(prod, qty);
     ResetOrderItemList();
     UpdateTotalCost();
 }