private void btnAjouterMed_Click(object sender, RoutedEventArgs e)
        {
            Medecin med = new Medecin();

            med.nomMedecin        = txtNom.Text;
            med.prenomMedecin     = txtPrenom.Text;
            med.specialiteMedecin = txtSpecialite.Text;
            Departement dep = cbDepartement.SelectedItem as Departement;

            med.departementMedecin = dep.idDepartement;

            Singleton.Instance.bd.Medecins.Add(med);

            try
            {
                Singleton.Instance.bd.SaveChanges();
                MessageBox.Show("Médecin ajouté avec succès.", "Confirmation", MessageBoxButton.OK, MessageBoxImage.Information);
                //J'utilise la méthode refresh() de la fenêtre "owner" (i.e. AdminWindow).
                ((AdminWindow)this.Owner).refresh();
            }

            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
        private void button1_Click(object sender, RoutedEventArgs e)
        {
            Departement dep = new Departement();

            dep.NomDepartement = txtNomDepartement.Text;

            MainWindow.db.Departements.Add(dep);

            try
            {
                MainWindow.db.SaveChanges();
            }

            catch (DbEntityValidationException ex)
            {
                Console.WriteLine(ex.ToString());
            }

            txtNomDepartement.Text = "";
            cbDept.DataContext     = MainWindow.db.Departements.ToList();
        }
Beispiel #3
0
        private void button1_Click(object sender, RoutedEventArgs e)
        {
            Departement dep = new Departement();

            dep.NomDepartement = txtNomDepartement.Text;

            MainWindow.db.Departements.Add(dep);

            try
            {
                MainWindow.db.SaveChanges();
                MessageBox.Show("Departement ajouté avec Succés", "Message", MessageBoxButton.OK, MessageBoxImage.Warning);
            }

            catch (DbEntityValidationException ex)
            {
                Console.WriteLine(ex.ToString());
            }

            txtNomDepartement.Text = "";
            cbDept.DataContext     = MainWindow.db.Departements.ToList();
        }
        private void btnChangerDpt_Click(object sender, RoutedEventArgs e)
        {
            Medecin     medecin     = cbMedecins.SelectedItem as Medecin;
            Departement departement = cbDepartementsChanger.SelectedItem as Departement;

            medecin.departementMedecin = departement.idDepartement;

            var reponse = MessageBox.Show("Vous souhaitez assigner le Dr. " + medecin.prenomMedecin + " " + medecin.nomMedecin + " au département " + departement.nomDepartement + "?", "Confirmation", MessageBoxButton.YesNo, MessageBoxImage.Question);

            if (reponse == MessageBoxResult.Yes)
            {
                try
                {
                    Singleton.Instance.bd.SaveChanges();
                    MessageBox.Show("Modification effectuée.", "Confirmation", MessageBoxButton.OK, MessageBoxImage.Information);
                }

                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
        }