private void buttonDeleteDishWish_Click(object sender, EventArgs e) { if (dataGridViewDishWish.SelectedRows.Count == 1) { GetWishedDish_Result selected = (GetWishedDish_Result)dataGridViewDishWish.SelectedRows[0].DataBoundItem; DialogResult result = MessageBox.Show("Êtes-vous sûr de vouloir supprimer la ressenti pour le plat '" + selected.DisplayName() + "'?", "Confirmation de suppression", MessageBoxButtons.YesNo, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button2); if (result == DialogResult.Yes) { try { using (ProjetSGBDEntities context = new ProjetSGBDEntities()) { context.DeleteDishWish(CurrentClient.Id, selected.DishId, selected.ModifiedAt); } PopulateDishWishes(); } catch (Exception ex) { ModelError modelError = new ModelError(ex); if (modelError.Number == ModelError.DATA_NOT_UP_TO_DATE) { MessageBox.Show(modelError.Message, "Information", MessageBoxButtons.OK, MessageBoxIcon.Information); PopulateDishWishes(); } else { MessageBox.Show(modelError.Message, "Erreur fatale!", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } } }