示例#1
0
        /// <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>
        /// 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);
            }
        }
示例#3
0
        /// <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);
            }
        }
示例#4
0
        /// <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>
        /// refresh datagrid
        /// </summary>
        /// =====================================================================================
        /// Modification : Initial : 25/10/2018 |N.Wilcké (SESA474351)
        ///                          XX/XX/XXXX | X.XXX (SESAXXXXX)
        /// =====================================================================================
        private /*static async Task*/ void DisplayChambres(int?hotelId = null)
        {
            if (hotelId != null)
            {
                using (var db = new Model.Booking()
                {
                    Configuration = { ProxyCreationEnabled = false }
                })
                {
                    List <ChambresSet> chambreResult = (from chambre in db.ChambresSet where chambre.keyHotel == hotelId select chambre).ToList();

                    chambresSetDataGrid.ItemsSource = chambreResult;
                }
            }
            else
            {
                using (var db = new Model.Booking()
                {
                    Configuration = { ProxyCreationEnabled = false }
                })
                {
                    List <ChambresSet> chambreResult = (from chambre in db.ChambresSet select chambre).ToList();

                    chambresSetDataGrid.ItemsSource = chambreResult;
                }
            }
        }
示例#6
0
        /// <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);
            }
        }
示例#7
0
        public Chambres()
        {
            InitializeComponent();

            try
            {
                //Task task = new Task(async () => await DisplayChambres());
                //task.Start();
                DisplayChambres();

                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);
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Internal error :" + Environment.NewLine + ex, "Alert", MessageBoxButton.OK, MessageBoxImage.Information);
            }
        }
示例#8
0
        /// <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);
            }
        }
示例#9
0
        public Reservations()
        {
            InitializeComponent();
            try
            {
                DisplayReservations();

                using (var db = new Model.Booking())
                {
                    List <ChambresSet> chambreID = (from chambre in db.ChambresSet select chambre).ToList();


                    foreach (var item in chambreID)
                    {
                        comboChambre.Items.Add(item.Id + "-" + item.Nom);
                    }
                }

                using (var db = new Model.Booking())
                {
                    List <ClientsSet> clients = (from cli in db.ClientsSet select cli).ToList();


                    foreach (var item in clients)
                    {
                        comboClient.Items.Add(item.Id + "-" + item.Nom + "." + item.Prenom);
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Internal error :" + Environment.NewLine + ex, "Alert", MessageBoxButton.OK, MessageBoxImage.Information);
            }
        }
        private void UpdateChart()
        {
            try
            {
                SeriesCollection = new SeriesCollection();

                //adding series will update and animate the chart automatically
                using (var db = new Model.Booking())
                {
                    SeriesCollection.Add(new RowSeries
                    {
                        Title  = "Today",
                        Values = new ChartValues <double>
                        {
                            (from h in db.HotelsSet select h.Id).Count(), (from c in db.ClientsSet select c.Id).Count(),
                            (from c in db.ChambresSet select c.Id).Count(),
                            (from r in db.ReservationSet select r.Id).Count()
                        }
                    });
                }


                Labels    = new[] { "Hotels", "Clients", "Chambres", "Reservations" };
                Formatter = value => value.ToString("N");

                DataContext = this;
            }
            catch
            {
                Console.Write("Internal error");
            }
        }
示例#11
0
        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>
        /// 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);
            }
        }
示例#13
0
 /// <summary>
 /// refresh datagrid
 /// </summary>
 /// =====================================================================================
 /// Modification : Initial : 25/10/2018 |N.Wilcké (SESA474351)
 ///                          XX/XX/XXXX | X.XXX (SESAXXXXX)
 /// =====================================================================================
 private void DisplayReservations()
 {
     using (var db = new Model.Booking())
     {
         List <ReservationSet> reservationsResult = (from reserv in db.ReservationSet select reserv).ToList();
         reservationSetDataGrid.ItemsSource = reservationsResult;
     }
 }
 /// <summary>
 /// refresh datagrid
 /// </summary>
 /// =====================================================================================
 /// Modification : Initial : 25/10/2018 |N.Wilcké (SESA474351)
 ///                          XX/XX/XXXX | X.XXX (SESAXXXXX)
 /// =====================================================================================
 private void DisplayClients()
 {
     using (var db = new Model.Booking())
     {
         List <ClientsSet> clientsResult = (from clients in db.ClientsSet select clients).ToList();
         clientsSetDataGrid.ItemsSource = clientsResult;
     }
 }
示例#15
0
        /// <summary>
        /// refresh datagrid
        /// </summary>
        /// =====================================================================================
        /// Modification : Initial : 25/10/2018 |N.Wilcké (SESA474351)
        ///                          XX/XX/XXXX | X.XXX (SESAXXXXX)
        /// =====================================================================================
        private /*static async Task*/ void DisplayChambres()
        {
            using (var db = new Model.Booking()
            {
                Configuration = { ProxyCreationEnabled = false }
            })
            {
                List <ChambresSet> chambreResult = (from chambre in db.ChambresSet select chambre).ToList();

                chambresSetDataGrid.ItemsSource = chambreResult;
            }
        }
示例#16
0
 /// <summary>
 /// refresh datagrid
 /// </summary>
 /// =====================================================================================
 /// Modification : Initial : 25/10/2018 |N.Wilcké (SESA474351)
 ///                          XX/XX/XXXX | X.XXX (SESAXXXXX)
 /// =====================================================================================
 private void DisplayHotels()
 {
     try
     {
         using (var db = new Model.Booking())
         {
             List <HotelsSet> hotelResult = (from hotel in db.HotelsSet select hotel).ToList();
             hotelsSetDataGrid.ItemsSource = hotelResult;
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("Internal error :" + Environment.NewLine + ex, "Alert", MessageBoxButton.OK, MessageBoxImage.Information);
     }
 }
示例#17
0
        /// <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);
            }
        }
示例#18
0
        /// <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);
            }
        }
示例#20
0
 /// <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);
     }
 }