public Dish(int dishID, string dishName, double dishPrice, dishSize dishSizeDish, dishHechser dishHechserDish) { this.dishID = dishID; this.dishName = dishName; this.dishPrice = dishPrice; this.dishSizeDish = dishSizeDish; this.dishHechserDish = dishHechserDish; }
private void buttonAdd_Click(object sender, RoutedEventArgs e) { try { int id = int.Parse(textBoxID.Text);//add id from txtbox if (id < 1) { throw new Exception("Inaccurate ID"); } string name = textBoxName.Text;//add name from txtbox if (name == "") { throw new Exception("Inaccurate Name"); } int price = int.Parse(textBoxPrice.Text);//add price from txtbox if (price < 1) { throw new Exception("Inaccurate Price"); } dishSize size = (dishSize)comboBoxSize.SelectedItem;//add size from combobox if ((int)size < 0) { throw new Exception("Lacking Size."); } dishHechser hechser = (dishHechser)comboBoxHechser.SelectedItem;//add hechsher from combobox if ((int)hechser < 0) { throw new Exception("Lacking Hechser."); } Dish currDish = new Dish(id, name, price, size, hechser);//adding dish //clear all fields textBoxName.Text = ""; textBoxID.Text = ""; textBoxPrice.Text = ""; comboBoxSize.SelectedItem = null; comboBoxHechser.SelectedItem = null; } catch (Exception ex) { MessageBox.Show(ex.Message); } }