Esempio n. 1
0
        private void ClientsDataGrid_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            try
            {
                if (this.ClientsDataGrid.SelectedItem == null)
                {
                    return;
                }
                ClientsSet client = (ClientsSet)ClientsDataGrid.SelectedItem;
                if (client == null)
                {
                    return;
                }

                this.BtAjouterClient.IsEnabled   = true;
                this.BtSupprimerClient.IsEnabled = true;

                this.LbIdClient.Content           = client.Id.ToString();
                this.TbNomClient.Text             = client.Nom;
                this.TbPrenomClient.Text          = client.Prenom.ToString();
                this.DtDateNaissance.SelectedDate = client.DateNaissance;

                ActiverDesactiverControlesClients(true);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
Esempio n. 2
0
        public bool ValiderClient(int idClient, string prenom, string nom, DateTime dateNaissance)
        {
            try
            {
                ClientsSet client;

                if (idClient != 0) //si id!=0 alors l'hotel existe déjà
                {
                    client = GetClient(idClient);
                }
                else
                {
                    client = new ClientsSet();
                }
                client.Prenom        = prenom;
                client.Nom           = nom;
                client.DateNaissance = dateNaissance;

                if (idClient == 0)   //nouvel hotel
                {
                    this.ClientsSet.Add(client);
                }
                this.SaveChanges();
                return(true);
            }
            catch (Exception ex)
            {
                throw;
            }
        }
Esempio n. 3
0
        private void BtValiderClient_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                using (var db = new ModelBooking())
                {
                    bool       isNewClient;
                    ClientsSet client;

                    if ((string)this.LbIdClient.Content != "" && this.LbIdClient.Content != null)
                    {
                        isNewClient = false;
                        int idClient = Convert.ToInt32(this.LbIdClient.Content);

                        var resultQuery = (from clients in db.ClientsSet
                                           where clients.Id == idClient
                                           select clients);

                        if (resultQuery.Any())
                        {
                            client = resultQuery.First();
                        }
                        else
                        {
                            return;
                        }
                    }
                    else
                    {
                        isNewClient = true;
                        client      = new ClientsSet();
                    }
                    client.Nom           = this.TbNomClient.Text;
                    client.Prenom        = this.TbPrenomClient.Text;
                    client.DateNaissance = (DateTime)this.DtDateNaissance.SelectedDate;

                    if (isNewClient)
                    {
                        db.ClientsSet.Add(client);
                    }
                    db.SaveChanges();
                }
                MessageBox.Show("Enregistré !");

                LoadClients();
                ActiverDesactiverControlesClients(false);
            }
            catch (Exception ex)
            {
                throw;
            }
        }
Esempio n. 4
0
        public bool SupprimerClient(ClientsSet client)
        {
            try
            {
                var resultQuery = (from clients in this.ClientsSet
                                   where clients.Id == client.Id
                                   select clients);

                if (resultQuery.Any())
                {
                    this.ClientsSet.Remove(resultQuery.First());
                    this.SaveChanges();
                    return(true);
                }
                return(false);
            }
            catch (Exception ex)
            {
                throw;
            }
        }