コード例 #1
0
 private void FormMain_Load(object sender, EventArgs e) {
   try {
     using(ProjetSGBDEntities context = new ProjetSGBDEntities()) {
       IQueryable<Reception> Receptions = from item in context.Reception select item;
       IQueryable<Client> Clients = from item in context.Client select item;
       IQueryable<Dish> Dishes = from item in context.Dish select item;
       dataGridViewReceptions.DataSource = Receptions.ToList();
       dataGridViewReceptions.Columns[6].Visible = false;
       dataGridViewReceptions.Columns[7].Visible = false;
       dataGridViewReceptions.Columns[8].Visible = false;
       dataGridViewClients.DataSource = Clients.ToList();
       dataGridViewClients.Columns[0].Visible = false;
       dataGridViewClients.Columns[6].Visible = false;
       dataGridViewClients.Columns[7].Visible = false;
       dataGridViewClients.Columns[8].Visible = false;
       dataGridViewDish.DataSource = Dishes.OrderBy(dish => dish.DishTypeId).ThenBy(dish => dish.Name).ToList();
       dataGridViewDish.Columns[2].Visible = false;
       dataGridViewDish.Columns[3].Visible = false;
       dataGridViewDish.Columns[4].Visible = false;
       dataGridViewDish.Columns[5].Visible = false;
     }
   } catch(Exception ex) {
     ModelError modelError = new ModelError(ex);
     MessageBox.Show(modelError.Message,"Erreur fatale!",MessageBoxButtons.OK,MessageBoxIcon.Error);
   }
 }
コード例 #2
0
 private void FormReceptionDetail_Load(object sender, EventArgs e) {
   if(currentReception != null) {
     textBoxId.Text = currentReception.ReceptionId.ToString();
     textBoxName.Text = currentReception.Name;
     dateTimePickerBookingClosingDate.Value = currentReception.BookingClosingDate;
     dateTimePickerDate.Value = currentReception.Date;
     numericUpDownCapacity.Value = currentReception.Capacity;
     numericUpDownSeatsPerTable.Value = currentReception.SeatsPerTable;
     checkBoxValid.Checked = currentReception.IsValid;
     textBoxModifiedBy.Text = currentReception.ModifiedBy;
     dateTimePickerModifiedAt.Value = (DateTime)currentReception.ModifiedAt;
     try {
       PopulateDesserts();
       PopulateMainCourses();
       PopulateStarters();
       PopulateReservations();
       PopulateTablesMap();
       if(tablesMap.Count == 0) {
         buttonTablesMapGenerate.Enabled = true;
       }
     } catch(Exception ex) {
       ModelError modelError = new ModelError(ex);
       MessageBox.Show(modelError.Message, "Erreur fatale!", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
   }
 }
コード例 #3
0
 private void FormReservationDetails_Load(object sender, EventArgs e) {
   if((CurrentClient != null) && (CurrentReception != null)) {
     textBoxDate.Text = CurrentReception.ReceptionDate.ToString("dd MMMM yyyy");
     textBoxName.Text = CurrentReception.ReceptionName;
     try {
       using(ProjetSGBDEntities context = new ProjetSGBDEntities()) {
         IQueryable<GetReservedDish_Result> _reservedDishes = context.GetReservedDish(CurrentReception.ReceptionId, CurrentClient.Id);
         if(_reservedDishes.Where(dish => dish.DishTypeId == DishTypeStarter).Count() == 1) {
           _starter_old = _reservedDishes.Where(dish => dish.DishTypeId == DishTypeStarter).First();
           _starter = context.Dish.Where(dish => dish.DishId == _starter_old.DishId).First();
           textBoxStarter.Text = _starter.Name;
         }
         if(_reservedDishes.Where(dish => dish.DishTypeId == DishTypeMainDish).Count() == 1) {
           _mainCourse_old = _reservedDishes.Where(dish => dish.DishTypeId == DishTypeMainDish).First();
           _mainCourse = context.Dish.Where(dish => dish.DishId == _mainCourse_old.DishId).First();
           textBoxMainCourse.Text = _mainCourse.Name;
         }
         if(_reservedDishes.Where(dish => dish.DishTypeId == DishTypeDessert).Count() == 1) {
           _dessert_old = _reservedDishes.Where(dish => dish.DishTypeId == DishTypeDessert).First();
           _dessert = context.Dish.Where(dish => dish.DishId == _dessert_old.DishId).First();
           textBoxDessert.Text = _dessert.Name;
         }
       }
     } catch(Exception ex) {
       ModelError modelError = new ModelError(ex);
       MessageBox.Show(modelError.Message, "Erreur fatale!", MessageBoxButtons.OK, MessageBoxIcon.Error);
       DialogResult = DialogResult.Abort;
       Close();
     }
   }
 }
コード例 #4
0
 private void comboBoxReception_SelectedIndexChanged(object sender, EventArgs e) {
   ReceptionSelection selected = (ReceptionSelection)comboBoxReception.SelectedItem;
   if(selected != null) {
     try {
       PopulateMenu(selected.Id);
     } catch(Exception ex) {
       ModelError modelError = new ModelError(ex);
       MessageBox.Show(modelError.Message, "Erreur fatale!", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
   }
 }
コード例 #5
0
 private void FormNewFeeling_Load(object sender, EventArgs e) {
   try {
     PopulateClients();
     PopulateFeeling();
   } catch(Exception ex) {
     ModelError modelError = new ModelError(ex);
     MessageBox.Show(modelError.Message, "Erreur fatale!", MessageBoxButtons.OK, MessageBoxIcon.Error);
     DialogResult = DialogResult.Abort;
     Close();
   }
 }
コード例 #6
0
 private void PopulateGrids() {
   if(CurrentClient != null) {
     try {
       PopulateReceptions();
       PopulateDishWishes();
       PopulateFeelings();
     } catch(Exception ex) {
       ModelError modelError = new ModelError(ex);
       MessageBox.Show(modelError.Message, "Erreur fatale!", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
   }
 }
コード例 #7
0
 private void FormEditFeeling_Load(object sender, EventArgs e) {
   if(CurrentClient != null && ClientTo != null) {
     textBoxClient.Text = ClientTo.DisplayName();
     try {
       PopulateFeeling();
     } catch(Exception ex) {
       ModelError modelError = new ModelError(ex);
       MessageBox.Show(modelError.Message, "Erreur fatale!", MessageBoxButtons.OK, MessageBoxIcon.Error);
       DialogResult = DialogResult.Abort;
       Close();
     }
   }
 }
コード例 #8
0
 private void buttonSave_Click(object sender, EventArgs e) {
   ClientSelection client = (ClientSelection)comboBoxClients.SelectedItem;
   FeelingType feelingtype = (FeelingType)comboBoxFeeling.SelectedItem;
   if((client != null) && (feelingtype != null)) {
     try {
       using(ProjetSGBDEntities context = new ProjetSGBDEntities()) {
         context.NewFeeling(CurrentClient.Id, client.Id, 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;
     }
   }
 }
コード例 #9
0
 public FormMain() {
   InitializeComponent();
   try {
     using(ProjetSGBDEntities context = new ProjetSGBDEntities()) {
       IQueryable<Client> Clients = from item in context.Client select item;
       foreach(Client client in Clients) {
         comboBoxCurrentClient.Items.Add(new ClientSelection(client.ClientId, client.DisplayName(), client.Acronym));
       }
       comboBoxCurrentClient.DisplayMember = "DisplayName";
     }
   } catch(Exception ex) {
     ModelError modelError = new ModelError(ex);
     MessageBox.Show(modelError.Message, "Erreur fatale!", MessageBoxButtons.OK, MessageBoxIcon.Error);
   }
 }
コード例 #10
0
 private void FormNewReservation_Load(object sender, EventArgs e) {
   if(CurrentClient != null) {
     try {
       using(ProjetSGBDEntities context = new ProjetSGBDEntities()) {
         IQueryable<GetReservableReception_Result> Receptions = context.GetReservableReception(CurrentClient.Id);
         foreach(GetReservableReception_Result rec in Receptions) {
           comboBoxReception.Items.Add(new ReceptionSelection(rec.ReceptionId, rec.DisplayName()));
         }
         comboBoxReception.DisplayMember = "DisplayName";
       }
     } catch(Exception ex) {
       ModelError modelError = new ModelError(ex);
       MessageBox.Show(modelError.Message, "Erreur fatale!", MessageBoxButtons.OK, MessageBoxIcon.Error);
       DialogResult = DialogResult.Abort;
       Close();
     }
   }
 }
コード例 #11
0
 private void buttonSave_Click(object sender, EventArgs e) {
   FeelingType feelingtype = (FeelingType)comboBoxFeeling.SelectedItem;
   if(ClientTo != null && feelingtype != null) {
     try {
       using(ProjetSGBDEntities context = new ProjetSGBDEntities()) {
         context.UpdateFeeling(CurrentClient.Id, ClientTo.ClientId, feelingtype.Id, ClientTo.ModifiedAt, CurrentClient.Acronym);
       }
     } 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);
         LoadFeeling(ClientTo.ClientId);
         DialogResult = DialogResult.None;
       } else {
         MessageBox.Show(modelError.Message, "Erreur fatale!", MessageBoxButtons.OK, MessageBoxIcon.Error);
       }
     }
   }
 }
コード例 #12
0
 private void buttonDelete_Click(object sender, EventArgs e) {
   DialogResult result = MessageBox.Show("Êtes-vous sûr de vouloir supprimer la réservation " + CurrentReception.ReceptionName + "?", "Confirmation de suppression", MessageBoxButtons.YesNo, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button2);
   if(result == DialogResult.Yes) {
     try {
       using(ProjetSGBDEntities context = new ProjetSGBDEntities()) {
         context.DeleteReservation(CurrentReception.ReceptionId, CurrentClient.Id, CurrentReception.ModifiedAt);
       }
     } catch(Exception ex) {
       ModelError modelError = new ModelError(ex);
       MessageBox.Show(modelError.Message, "Erreur fatale!", MessageBoxButtons.OK, MessageBoxIcon.Error);
       DialogResult = DialogResult.None;
     }
   } else {
     DialogResult = DialogResult.None;
   }
 }
コード例 #13
0
 private void buttonSave_Click(object sender, EventArgs e) {
   try {
     UpdateDish(_starter_old, _starter);
     UpdateDish(_mainCourse_old, _mainCourse);
     UpdateDish(_dessert_old, _dessert);
   } catch(Exception ex) {
     ModelError modelError = new ModelError(ex);
     MessageBox.Show(modelError.Message, "Erreur fatale!", MessageBoxButtons.OK, MessageBoxIcon.Error);
     DialogResult = DialogResult.None;
   }
 }
コード例 #14
0
 private void buttonDetailsReservations_Click(object sender, EventArgs e) {
   if(dataGridViewReservations.SelectedRows.Count == 1) {
     DialogResult result;
     FormReservationDetails form = new FormReservationDetails();
     form.CurrentClient = CurrentClient;
     try {
       form.LoadReception(((GetReservedReception_Result)dataGridViewReservations.SelectedRows[0].DataBoundItem).ReceptionId);
       result = form.ShowDialog();
       if(result == DialogResult.OK) {
         PopulateReceptions();
       }
     } catch(Exception ex) {
       ModelError modelError = new ModelError(ex);
       MessageBox.Show(modelError.Message, "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
   }
 }
コード例 #15
0
 private void buttonDeleteFeeling_Click(object sender, EventArgs e) {
   if(dataGridViewFeeling.SelectedRows.Count == 1) {
     GetFeeling_Result selected = (GetFeeling_Result)dataGridViewFeeling.SelectedRows[0].DataBoundItem;
     DialogResult result = MessageBox.Show("Êtes-vous sûr de vouloir supprimer la ressenti pour le client '" + selected.DisplayName() + "'?", "Confirmation de suppression", MessageBoxButtons.YesNo, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button2);
     if(result == DialogResult.Yes) {
       try {
         using(ProjetSGBDEntities context = new ProjetSGBDEntities()) {
           context.DeleteFeeling(CurrentClient.Id, selected.ClientId, selected.ModifiedAt);
         }
         PopulateFeelings();
       } 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);
           PopulateFeelings();
         } else {
           MessageBox.Show(modelError.Message, "Erreur fatale!", MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
       }
     }
   }
 }
コード例 #16
0
 private void buttonEditFeeling_Click(object sender, EventArgs e) {
   if(dataGridViewFeeling.SelectedRows.Count == 1) {
     GetFeeling_Result selected = (GetFeeling_Result)dataGridViewFeeling.SelectedRows[0].DataBoundItem;
     FormEditFeeling form = new FormEditFeeling();
     form.CurrentClient = CurrentClient;
     try {
       form.LoadFeeling(selected.ClientId);
       DialogResult result = form.ShowDialog();
       if(result == DialogResult.OK) {
         PopulateFeelings();
       }
     } catch(Exception ex) {
       ModelError modelError = new ModelError(ex);
       MessageBox.Show(modelError.Message, "Erreur fatale!", MessageBoxButtons.OK, MessageBoxIcon.Error);
       if(modelError.Number == ModelError.INVALID_OPERATION) {
         PopulateFeelings();
       }
     }
   }
 }
コード例 #17
0
 private void buttonSave_Click(object sender, EventArgs e) {
   ReceptionSelection selectedRec = (ReceptionSelection)comboBoxReception.SelectedItem;
   GetMenu_Result selectedMenu;
   if(selectedRec != null) {
     try {
       using(ProjetSGBDEntities context = new ProjetSGBDEntities()) {
         context.NewReservation(selectedRec.Id, CurrentClient.Id, CurrentClient.Acronym);
         if(dataGridViewDessert.SelectedRows.Count == 1) {
           selectedMenu = (GetMenu_Result)dataGridViewDessert.SelectedRows[0].DataBoundItem;
           context.NewReservedDish(CurrentClient.Id, selectedMenu.DishId, selectedRec.Id, CurrentClient.Acronym);
         }
         if(dataGridViewMainCourse.SelectedRows.Count == 1) {
           selectedMenu = (GetMenu_Result)dataGridViewMainCourse.SelectedRows[0].DataBoundItem;
           context.NewReservedDish(CurrentClient.Id, selectedMenu.DishId, selectedRec.Id, CurrentClient.Acronym);
         }
         if(dataGridViewStarter.SelectedRows.Count == 1) {
           selectedMenu = (GetMenu_Result)dataGridViewStarter.SelectedRows[0].DataBoundItem;
           context.NewReservedDish(CurrentClient.Id, selectedMenu.DishId, selectedRec.Id, CurrentClient.Acronym);
         }
       }
       Close();
     } catch(Exception ex) {
       ModelError modelError = new ModelError(ex);
       MessageBox.Show(modelError.Message, "Erreur fatale!", MessageBoxButtons.OK, MessageBoxIcon.Error);
       DialogResult = DialogResult.None;
     }
   }
 }
コード例 #18
0
 private void buttonStarter_Click(object sender, EventArgs e) {
   FormSelectDish form = new FormSelectDish();
   DialogResult result;
   try {
     form.PopulateList(CurrentReception.ReceptionId, DishTypeStarter, CurrentClient);
     result = form.ShowDialog();
     if((result == DialogResult.OK) && (form.SelectedDishId != null)) {
       using(ProjetSGBDEntities context = new ProjetSGBDEntities()) {
         _starter = context.Dish.Where(dish => dish.DishId == form.SelectedDishId).First();
         textBoxStarter.Text = _starter.Name;
       }
     }
   } catch(Exception ex) {
     ModelError modelError = new ModelError(ex);
     MessageBox.Show(modelError.Message, "Erreur fatale!", MessageBoxButtons.OK, MessageBoxIcon.Error);
   }
 }
コード例 #19
0
 private void buttonTablesMapSave_Click(object sender, EventArgs e) {
   if(tablesMapGenerator != null) {
     try {
       tablesMapGenerator.Save(Acronym);
     } catch(Exception ex) {
       ModelError modelError = new ModelError(ex);
       MessageBox.Show(modelError.Message, "Erreur fatale!", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
     buttonTablesMapSave.Enabled = false;
     PopulateTablesMap();
   }
 }