Пример #1
0
        public void initialiserChamps(patient patient)
        {
            txtNom.Text           = patient.nom;
            txtPrenom.Text        = patient.prenom;
            txtParent.Text        = patient.proche_parent;
            dateNais.SelectedDate = patient.date_naissance;
            if (patient.sexe == "F")
            {
                rbFemme.IsChecked = true;
            }
            else if (patient.sexe == "H")
            {
                rbHomme.IsChecked = true;
            }
            assurance patAss = verifierAssurance(patient);

            if (patAss != null)
            {
                txtAssNom.Text    = patAss.nom_societe_assurance;
                txtAssNoPol.Text  = patAss.no_police.ToString();
                ckbxAss.IsChecked = true;
            }
        }
Пример #2
0
 private void btnValider_Click(object sender, RoutedEventArgs e)
 {
     if (champsRempli())
     {
         try
         {
             using (NorthenLightsHopitalEntities db = new NorthenLightsHopitalEntities())
             {
                 if (cePatient == null)
                 {
                     patient nouveauPatient = new patient
                     {
                         nom            = txtNom.Text,
                         prenom         = txtPrenom.Text,
                         date_naissance = (DateTime)dateNais.SelectedDate,
                         proche_parent  = txtParent.Text
                     };
                     db.patients.Add(nouveauPatient);
                     db.SaveChanges();
                     int idPatient = nouveauPatient.id;
                     if (ckbxAss.IsChecked == true)
                     {
                         assurance nouvellePolice = new assurance
                         {
                             no_police             = int.Parse(txtAssNoPol.Text),
                             nom_societe_assurance = txtAssNom.Text,
                             id_client             = idPatient
                         };
                         db.assurances.Add(nouvellePolice);
                         db.SaveChanges();
                     }
                 }
                 else
                 {
                     patient aModif = cePatient;
                     aModif.date_naissance = (DateTime)dateNais.SelectedDate;
                     aModif.nom            = txtNom.Text;
                     aModif.prenom         = txtPrenom.Text;
                     aModif.proche_parent  = txtParent.Text;
                     if (ckbxAss.IsChecked == true)
                     {
                         assurance nouvellePolice = new assurance
                         {
                             no_police             = int.Parse(txtAssNoPol.Text),
                             nom_societe_assurance = txtAssNom.Text,
                             id_client             = aModif.id
                         };
                         db.assurances.Add(nouvellePolice);
                     }
                     db.Entry(aModif).State = System.Data.Entity.EntityState.Modified;
                     db.SaveChanges();
                 }
             }
             succes();
         }
         catch (Exception ex)
         {
             MessageBox.Show("Une erreur s'est produite : \n" +
                             ex.Message.ToString(), "Attention"
                             , MessageBoxButton.OK, MessageBoxImage.Error);
             this.Close();
         }
     }
     else
     {
         MessageBox.Show("Veuillez remplir tous les champs.", "ATTENTION"
                         , MessageBoxButton.OK, MessageBoxImage.Error);
     }
 }