Beispiel #1
0
Datei: Form1.cs Projekt: rkj/ieat
        private void addButton_Click(object sender, EventArgs e)
        {
            try
            {
                FridgeProduct fp = new FridgeProduct();

                fp.Description = productsNewDescription.Text;
                fp.Product = dataManager.ProductsList.getByName(productsNewName.Text);
                fp.Amount = float.Parse(productsNewQuantity.Text);
                fp.ExpireDate = productsNewExpire.Value;
                dataManager.Fridge.Add(fp);

                fridgeProductBindingSource.ResetBindings(false);

                productsNewName.Text = "";
                productsNewDescription.Text = "";
                productsNewQuantity.Text = "";
                productsNewExpire.Value = DateTime.Now;

                MessageBox.Show("Product added to the fridge!");
            }
            catch (Exception ex)
            {
                MessageBox.Show("An error occured. Cannot add a new product. Please try again");
            }
        }