private void buttonSave_Click(object sender, EventArgs e) { DishWishSelection dish = (DishWishSelection)comboBoxDishes.SelectedItem; FeelingType feelingtype = (FeelingType)comboBoxFeeling.SelectedItem; if ((dish != null) && (feelingtype != null)) { try { using (ProjetSGBDEntities context = new ProjetSGBDEntities()) { context.NewWishedDish(CurrentClient.Id, dish.DishId, feelingtype.Id, CurrentClient.Acronym); } } catch (Exception ex) { ModelError modelError = new ModelError(ex); MessageBox.Show(modelError.Message, "Erreur fatale!", MessageBoxButtons.OK, MessageBoxIcon.Error); DialogResult = DialogResult.None; } } }