public ChambreUpdate(ChambresSet row) { InitializeComponent(); try { using (var db = new Model.Booking()) { List <HotelsSet> hotelIds = (from hotel in db.HotelsSet select hotel).ToList(); foreach (var item in hotelIds) { comboHotelID.Items.Add(item.Id + "-" + item.Nom); } } // chambre = row; if (chambre.Climatisation) { climatisationCheckBox.IsChecked = true; } comboHotelID.SelectedItem = chambre.keyHotel; nomTextBox.Text = chambre.Nom; nbLitsTextBox.Text = chambre.NbLits.ToString(); } 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 MenuItem_Click(object sender, RoutedEventArgs e) { try { ChambresSet row = (ChambresSet)chambresSetDataGrid.SelectedItems[0]; ((MainWindow)Window.GetWindow(this))._mainFrame.Navigate(new ChambreUpdate(row)); } 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> /// 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 : 26/10/2018 |N.Wilcké (SESA474351) /// XX/XX/XXXX | X.XXX (SESAXXXXX) /// ===================================================================================== private void MenuItem_Click_1(object sender, RoutedEventArgs e) { try { ChambresSet row = (ChambresSet)chambresSetDataGrid.SelectedItems[0]; using (var db = new Model.Booking()) { var chambre = new ChambresSet() { Id = row.Id }; db.ChambresSet.Attach(chambre); db.ChambresSet.Remove(chambre); db.SaveChanges(); } DisplayChambres(); } catch (Exception ex) { MessageBox.Show("Internal error :" + Environment.NewLine + ex, "Alert", MessageBoxButton.OK, MessageBoxImage.Information); } }