/// <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 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); } }
public HotelChambres(HotelsSet row) { InitializeComponent(); try { DisplayChambres(row.Id); } 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 MenuItem_Click_1(object sender, RoutedEventArgs e) { try { HotelsSet row = (HotelsSet)hotelsSetDataGrid.SelectedItems[0]; ((MainWindow)Window.GetWindow(this))._mainFrame.Navigate(new HotelsUpdate(row)); } catch (Exception ex) { MessageBox.Show("Internal error :" + Environment.NewLine + ex, "Alert", MessageBoxButton.OK, MessageBoxImage.Information); } }
public HotelsUpdate(HotelsSet row) { InitializeComponent(); try { hotel = row; capaciteTextBox.Text = hotel.Capacite.ToString(); localisationTextBox.Text = hotel.Localisation; nomTextBox.Text = hotel.Nom; paysTextBox.Text = hotel.Pays; } 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> /// Display all chambres /// </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 MenuItem_Click_2(object sender, RoutedEventArgs e) { try { using (var db = new Model.Booking()) { HotelsSet row = (HotelsSet)hotelsSetDataGrid.SelectedItems[0]; if ((from ch in db.ChambresSet where ch.keyHotel == row.Id select ch).Any()) { ((MainWindow)Window.GetWindow(this))._mainFrame.Navigate(new HotelChambres(row)); } else { MessageBox.Show("Cet hotel n'as aucunes chambres...", "Alert", MessageBoxButton.OK, MessageBoxImage.Information); } } } catch (Exception ex) { MessageBox.Show("Internal error :" + Environment.NewLine + ex, "Alert", MessageBoxButton.OK, MessageBoxImage.Information); } }