/// <summary> /// delete /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="RoutedEventArgs"/> instance containing the event data.</param> /// ===================================================================================== /// Modification : Initial : 25/10/2018 |N.Wilcké (SESA474351) /// XX/XX/XXXX | X.XXX (SESAXXXXX) /// ===================================================================================== private void MenuItem_Click(object sender, RoutedEventArgs e) { try { HotelsSet row = (HotelsSet)hotelsSetDataGrid.SelectedItems[0]; using (var db = new Model.Booking()) { if (!(from ch in db.ChambresSet where ch.keyHotel == row.Id select ch.Id).Any()) { var hotel = new HotelsSet() { Id = row.Id }; db.HotelsSet.Attach(hotel); db.HotelsSet.Remove(hotel); db.SaveChanges(); } else { MessageBox.Show("Votre hôtel possède des chambres." + Environment.NewLine + "Supression impossible."); } } DisplayHotels(); } catch (Exception ex) { MessageBox.Show("Internal error :" + Environment.NewLine + ex, "Alert", MessageBoxButton.OK, MessageBoxImage.Information); } }
/// <summary> /// Update /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="RoutedEventArgs"/> instance containing the event data.</param> /// ===================================================================================== /// Modification : Initial : 26/10/2018 |N.Wilcké (SESA474351) /// XX/XX/XXXX | X.XXX (SESAXXXXX) /// ===================================================================================== private void updateButton_Click(object sender, RoutedEventArgs e) { try { ReservationSet hereReservation = new ReservationSet(); hereReservation = this.reservation; //int idChambre = Util.GetComboId(comboChambre.Text); //int idClient = Util.GetComboId(comboClient.Text); using (var db = new Model.Booking()) { ReservationSet reservation = new ReservationSet() { Id = hereReservation.Id }; db.ReservationSet.Attach(reservation); //reservation.keyChambre = idChambre; //reservation.keyClient = idClient; reservation.dateDebut = dateDebutDatePicker.DisplayDate.Date; reservation.dateFin = dateFinDatePicker.DisplayDate.Date; db.SaveChanges(); } } catch (Exception ex) { MessageBox.Show("Internal error :" + Environment.NewLine + ex, "Alert", MessageBoxButton.OK, MessageBoxImage.Information); } }
/// <summary> /// add new record /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="RoutedEventArgs"/> instance containing the event data.</param> /// ===================================================================================== /// Modification : Initial : 25/10/2018 |N.Wilcké (SESA474351) /// XX/XX/XXXX | X.XXX (SESAXXXXX) /// ===================================================================================== private void validateReservation_Click(object sender, RoutedEventArgs e) { try { int idChambre = Util.GetComboId(comboChambre.Text); int idClient = Util.GetComboId(comboClient.Text); using (var db = new Model.Booking()) { ReservationSet reserv = new ReservationSet(); reserv.keyChambre = idChambre; reserv.keyClient = idClient; reserv.dateDebut = dateDebutDatePicker.DisplayDate.Date; reserv.dateFin = dateFinDatePicker.DisplayDate.Date; db.ReservationSet.Add(reserv); db.SaveChanges(); } DisplayReservations(); } catch (Exception ex) { MessageBox.Show("Internal error :" + Environment.NewLine + ex, "Alert", MessageBoxButton.OK, MessageBoxImage.Information); } }
/// <summary> /// delete /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="RoutedEventArgs"/> instance containing the event data.</param> /// ===================================================================================== /// Modification : Initial : 25/10/2018 |N.Wilcké (SESA474351) /// XX/XX/XXXX | X.XXX (SESAXXXXX) /// ===================================================================================== private void MenuItem_Click(object sender, RoutedEventArgs e) { try { ClientsSet row = (ClientsSet)clientsSetDataGrid.SelectedItems[0]; using (var db = new Model.Booking()) { var client = new ClientsSet() { Id = row.Id }; db.ClientsSet.Attach(client); db.ClientsSet.Remove(client); db.SaveChanges(); } DisplayClients(); } catch (Exception ex) { MessageBox.Show("Internal error :" + Environment.NewLine + ex, "Alert", MessageBoxButton.OK, MessageBoxImage.Information); } }
/// <summary> /// Update /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="RoutedEventArgs"/> instance containing the event data.</param> /// ===================================================================================== /// Modification : Initial : 26/10/2018 |N.Wilcké (SESA474351) /// XX/XX/XXXX | X.XXX (SESAXXXXX) /// ===================================================================================== private void updateButton_Click(object sender, RoutedEventArgs e) { try { using (var db = new Model.Booking()) { ClientsSet client = new ClientsSet() { Id = this.client.Id }; db.ClientsSet.Attach(client); client.Nom = nomTextBox.Text; client.Prenom = prenomTextBox.Text; client.DateNaissance = dateNaissanceDatePicker.DisplayDate; db.SaveChanges(); } ((MainWindow)Window.GetWindow(this))._mainFrame.Navigate(new Clients()); } catch (Exception ex) { MessageBox.Show("Internal error :" + Environment.NewLine + ex, "Alert", MessageBoxButton.OK, MessageBoxImage.Information); } }
/// <summary> /// Update /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="RoutedEventArgs"/> instance containing the event data.</param> /// ===================================================================================== /// Modification : Initial : 26/10/2018 |N.Wilcké (SESA474351) /// XX/XX/XXXX | X.XXX (SESAXXXXX) /// ===================================================================================== private void updateHotel_Click(object sender, RoutedEventArgs e) { try { HotelsSet hereHotel = new HotelsSet(); hereHotel = this.hotel; using (var db = new Model.Booking()) { HotelsSet hotel = new HotelsSet() { Id = hereHotel.Id }; db.HotelsSet.Attach(hotel); hotel.Nom = nomTextBox.Text; hotel.Capacite = Int32.Parse(capaciteTextBox.Text); hotel.Localisation = localisationTextBox.Text; hotel.Pays = paysTextBox.Text; db.SaveChanges(); } ((MainWindow)Window.GetWindow(this))._mainFrame.Navigate(new Hotels()); } catch (Exception ex) { MessageBox.Show("Internal error :" + Environment.NewLine + ex, "Alert", MessageBoxButton.OK, MessageBoxImage.Information); } }
/// <summary> /// Add new record /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="RoutedEventArgs"/> instance containing the event data.</param> /// ===================================================================================== /// Modification : Initial : 25/10/2018 |N.Wilcké (SESA474351) /// XX/XX/XXXX | X.XXX (SESAXXXXX) /// ===================================================================================== private void validateChambre_Click(object sender, RoutedEventArgs e) { try { using (var db = new Model.Booking() { Configuration = { ProxyCreationEnabled = false } }) { int id = Util.GetComboId(comboHotelID.Text); bool isClim = false; if (climatisationCheckBox.IsChecked.Value) { isClim = true; } ChambresSet chambre = new ChambresSet(); chambre.Nom = nomTextBox.Text; chambre.Climatisation = isClim; chambre.NbLits = Int32.Parse(nbLitsTextBox.Text); chambre.keyHotel = id; db.ChambresSet.Add(chambre); db.SaveChanges(); } DisplayChambres(); } catch (Exception ex) { MessageBox.Show("Internal error :" + Environment.NewLine + ex, "Alert", MessageBoxButton.OK, MessageBoxImage.Information); } }
/// <summary> /// Update /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="RoutedEventArgs"/> instance containing the event data.</param> /// ===================================================================================== /// Modification : Initial : 26/10/2018 |N.Wilcké (SESA474351) /// XX/XX/XXXX | X.XXX (SESAXXXXX) /// ===================================================================================== private void validateUpdate_Click(object sender, RoutedEventArgs e) { try { using (var db = new Model.Booking()) { ChambresSet hereChambre = new ChambresSet(); hereChambre = this.chambre; ChambresSet chambre = new ChambresSet() { Id = hereChambre.Id }; db.ChambresSet.Attach(chambre); if (chambre != null) { bool isClim = false; if (climatisationCheckBox.IsChecked.Value) { isClim = true; } chambre.Climatisation = isClim; chambre.NbLits = Int32.Parse(nbLitsTextBox.Text); chambre.Nom = nomTextBox.Text; chambre.keyHotel = comboHotelID.SelectedIndex; db.SaveChanges(); } } ((MainWindow)Window.GetWindow(this))._mainFrame.Navigate(new Chambres()); } catch (Exception ex) { MessageBox.Show("Internal error :" + Environment.NewLine + ex, "Alert", MessageBoxButton.OK, MessageBoxImage.Information); } }
/// <summary> /// add new record /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="RoutedEventArgs"/> instance containing the event data.</param> /// ===================================================================================== /// Modification : Initial : 25/10/2018 |N.Wilcké (SESA474351) /// XX/XX/XXXX | X.XXX (SESAXXXXX) /// ===================================================================================== private void validateHotel_Click(object sender, RoutedEventArgs e) { try { using (var db = new Model.Booking()) { HotelsSet hotel = new HotelsSet(); hotel.Nom = nomTextBox.Text; hotel.Capacite = Int32.Parse(capaciteTextBox.Text); hotel.Localisation = localisationTextBox.Text; hotel.Pays = paysTextBox.Text; db.HotelsSet.Add(hotel); db.SaveChanges(); } DisplayHotels(); } catch (Exception ex) { MessageBox.Show("Internal error :" + Environment.NewLine + ex, "Alert", MessageBoxButton.OK, MessageBoxImage.Information); } }
/// <summary> /// add new record /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="RoutedEventArgs"/> instance containing the event data.</param> /// ===================================================================================== /// Modification : Initial : 25/10/2018 |N.Wilcké (SESA474351) /// XX/XX/XXXX | X.XXX (SESAXXXXX) /// ===================================================================================== private void validateClient_Click(object sender, RoutedEventArgs e) { try { using (var db = new Model.Booking()) { ClientsSet client = new ClientsSet(); client.Nom = nomTextBox.Text; client.Prenom = prenomTextBox.Text; client.DateNaissance = dateNaissanceDatePicker.DisplayDate; db.ClientsSet.Add(client); db.SaveChanges(); } DisplayClients(); } catch (Exception ex) { MessageBox.Show("Internal error :" + Environment.NewLine + ex, "Alert", MessageBoxButton.OK, MessageBoxImage.Information); } }