private void buttonDeleteReservations_Click(object sender, EventArgs e) { if (dataGridViewReservations.SelectedRows.Count == 1) { GetReservedReception_Result selected = (GetReservedReception_Result)dataGridViewReservations.SelectedRows[0].DataBoundItem; DialogResult result = MessageBox.Show("Êtes-vous sûr de vouloir supprimer la réservation " + selected.ReceptionName + "?", "Confirmation de suppression", MessageBoxButtons.YesNo, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button2); if (result == DialogResult.Yes) { try { using (ProjetSGBDEntities context = new ProjetSGBDEntities()) { context.DeleteReservation(selected.ReceptionId, CurrentClient.Id, selected.ModifiedAt); } PopulateReceptions(); } 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); PopulateReceptions(); } else { MessageBox.Show(modelError.Message, "Erreur fatale!", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } } }
public FormReservationDetails() { InitializeComponent(); CurrentClient = null; CurrentReception = null; _starter = null; _mainCourse = null; _dessert = null; _starter_old = null; _mainCourse_old = null; _dessert_old = null; }
public void LoadReception(int id) { if (CurrentClient != null) { using (ProjetSGBDEntities context = new ProjetSGBDEntities()) { IQueryable <GetReservedReception_Result> recs = context.GetReservedReception(CurrentClient.Id); if (recs.Where(rec => rec.ReceptionId == id).Count() == 1) { CurrentReception = recs.Where(rec => rec.ReceptionId == id).First(); } } } }