/// <summary> /// Methos wich works when the user press on "update dish" button /// the method will update the dish details in the data base /// </summary> private void btnUpdateDish_Click(object sender, EventArgs e) { if (dgvDishList.SelectedRows.Count > 0)//check if the user choose dish from the list { if (InputCheckDishNameAndPrice()) { newDish.Price = int.Parse(nudDishPrice.Value.ToString()); if (cbDishInMenu.Text == "כן") { newDish.Status = 1; } else { newDish.Status = 0; } db.UpdateDish(newDish); UpdateProduct(); if (IngredientsToRemoveFromDish.Count > 0)//check if the user remove ingredeints from the dish { for (int i = 0; i < IngredientsToRemoveFromDish.Count; i++) { db.DeleteIngredientsOfDish(IngredientsToRemoveFromDish[i]); } } if (IngredientsToAddToDish.Count > 0)//check if the user add ingredeints to the dish { for (int i = 0; i < IngredientsToAddToDish.Count; i++) { db.InsertIngredientsOfDish(IngredientsToAddToDish[i]); } } MessageBox.Show(" !המנה עודכנה בהצלחה ", "Messgae", MessageBoxButtons.OK, MessageBoxIcon.Information); ClearingFields(); RefreshDishesList(); } } else { MessageBox.Show(" יש לבחור מנה מהרשימה! ", "Messgae", MessageBoxButtons.OK, MessageBoxIcon.Error); } }