private void btnSupprimer_Click(object sender, RoutedEventArgs e)
        {
            using (NLHContext context = new NLHContext())
            {
                Medecin med = dataGridMedecins.SelectedItem as Medecin;

                var deleteMed = context.Medecins.Where(m => m.IdMedecin == med.IdMedecin).SingleOrDefault();

                var nbrDos = context.DossierAdmissions.Count(d => d.IdMedecin == deleteMed.IdMedecin);

                if (nbrDos > 0)
                {
                    MessageBox.Show("Ce médecin a déjà un patient", "Attention", MessageBoxButton.OK, MessageBoxImage.Warning);
                }
                else
                {
                    MessageBoxResult messageBoxResult = MessageBox.Show("Êtes-vous sûr ?", "Confirmation de suppression", MessageBoxButton.YesNo, MessageBoxImage.Warning);
                    if (messageBoxResult == MessageBoxResult.Yes)
                    {
                        context.Medecins.Remove(deleteMed);

                        dataGridMedecins.Items.Remove(med);

                        context.SaveChanges();

                        Clear();

                        MessageBox.Show("Médecin supprimé !", "Info", MessageBoxButton.OK, MessageBoxImage.Information);
                    }
                }
            }
        }
Exemplo n.º 2
0
        private void btnSavePatient_Click(object sender, RoutedEventArgs e)
        {
            string idComp    = GetNumero(comboAssurances.Text);
            string refParent = GetNumero(comboParents.Text);


            using (var context = new NLHContext())
            {
                var patient = new Patient
                {
                    DateNaissance = datePickerBirthdate.SelectedDate,
                    Nom           = txtNomPt.Text,
                    Prenom        = txtPrenomPt.Text,
                    Adresse       = txtAdressePt.Text,
                    Ville         = txtVillePt.Text,
                    Province      = txtProvincePt.Text,
                    CodePostal    = txtCodePostalPt.Text,
                    Telephone     = txtPhonePt.Text,
                    IdCompagnie   = Convert.ToInt32(idComp),
                    RefParent     = Convert.ToInt32(refParent)
                };

                context.Patients.Add(patient);
                context.SaveChanges();

                MessageBox.Show("Nouveau patient ajouté !", "Info", MessageBoxButton.OK, MessageBoxImage.Information);
            }
        }
        private void btnAjouter_Click(object sender, RoutedEventArgs e)
        {
            using (NLHContext context = new NLHContext())
            {
                // validate if fields are empty
                if (txtPrenom.Text == string.Empty || txtNom.Text == string.Empty || txtSpecialite.Text == string.Empty)
                {
                    MessageBox.Show("Une ou plus des champs est vide", "Erreur", MessageBoxButton.OK, MessageBoxImage.Error);
                }
                else if ((string)btnAjouter.Content == "Ajouter")
                {
                    Medecin medecin = new Medecin
                    {
                        Prenom     = txtPrenom.Text.Trim(),
                        Nom        = txtNom.Text.Trim(),
                        Specialite = txtSpecialite.Text.Trim()
                    };


                    context.Medecins.Add(medecin);

                    dataGridMedecins.Items.Add(medecin);

                    context.SaveChanges();

                    Clear();

                    MessageBox.Show("Nouveau médecin ajouté !", "Info", MessageBoxButton.OK, MessageBoxImage.Information);
                }
                else if ((string)btnAjouter.Content == "Modifier")
                {
                    var med = dataGridMedecins.SelectedItem as Medecin;

                    med.Prenom     = txtPrenom.Text;
                    med.Nom        = txtNom.Text;
                    med.Specialite = txtSpecialite.Text;

                    context.Entry(med).State = EntityState.Modified;

                    context.SaveChanges();

                    MessageBox.Show("Médecin modifié !", "Info", MessageBoxButton.OK, MessageBoxImage.Information);

                    LoadDataGrid();
                }
            }
        }
        private void btnDonneConge_Click(object sender, RoutedEventArgs e)
        {
            using (NLHContext context = new NLHContext())
            {
                var idDossier = (comboPatients.SelectedItem as DossierAdmission).IdAdmission;

                var dos = context.DossierAdmissions.Include(d => d.Lit).Where(d => d.IdAdmission == idDossier).Single();

                dos.DateConge  = DateTime.Now;
                dos.Lit.Occupe = false;

                context.Entry(dos).State = EntityState.Modified;

                context.SaveChanges();

                MessageBox.Show("Congé donné le " + dos.DateConge, "Info", MessageBoxButton.OK, MessageBoxImage.Information);

                MessageBox.Show("Lit " + dos.NumLit + " dans le département " + dos.Lit.IdDepartement + " est libéré !", "Info", MessageBoxButton.OK, MessageBoxImage.Information);
            }
        }
Exemplo n.º 5
0
        private void btnSaveParent_Click(object sender, RoutedEventArgs e)
        {
            using (var context = new NLHContext())
            {
                var parent = new Parent
                {
                    Nom        = txtNomPr.Text,
                    Prenom     = txtPrenomPr.Text,
                    Adresse    = txtAdressePr.Text,
                    Ville      = txtVillePr.Text,
                    Province   = txtProvincePr.Text,
                    CodePostal = txtCodePostalPr.Text,
                    Telephone  = txtPhonePr.Text
                };

                context.Parents.Add(parent);
                context.SaveChanges();

                MessageBox.Show("Nouveau parent ajouté !", "Info", MessageBoxButton.OK, MessageBoxImage.Information);
            }
        }
Exemplo n.º 6
0
        private void btnOk_Click(object sender, RoutedEventArgs e)
        {
            string nss   = GetNumero(comboNSS.Text);
            string idMed = GetNumero(comboMedecin.Text);

            using (NLHContext context = new NLHContext())
            {
                DossierAdmission dossier = new DossierAdmission()
                {
                    Chirurgie     = (bool)checkChirurgie.IsChecked,
                    NSS           = Convert.ToInt32(nss),
                    DateAdmission = DateTime.Now,
                    NumLit        = Convert.ToInt32(comboLit.Text),
                    IdMedecin     = Convert.ToInt32(idMed)
                };

                context.DossierAdmissions.Add(dossier);

                context.SaveChanges();

                MessageBox.Show("Ajouter!", "Info", MessageBoxButton.OK, MessageBoxImage.Information);
            }
        }