private void SavePatient() { try { if (NomPatient == null) { throw new MessException("Entrez un nom de patient svp"); } if (PrenomPatient == null) { throw new MessException("Entrez un prénom de patient svp"); } if (SelJourNaiss == 0) { throw new MessException("Selctionez un jour de naissance svp"); } if (SelMoisNaiss == null) { throw new MessException("Selctionez un mois de naissance svp"); } if (SelAnneeNaiss == 0) { throw new MessException("Selctionez uue année de naissance svp"); } if (TaillePatient == 0) { throw new MessException("Entrez une taille pour le patient svp"); } if (PoidPatient == 0) { throw new MessException("Entrez un poid pour le patient svp"); } int mois = 0; string sexe; mois = NumMois(); DateTime dateNaiss = new DateTime(SelAnneeNaiss, mois, SelJourNaiss); if (Masculin == true) { sexe = "M"; } else { sexe = "F"; } if (MessageBox.Show("Voulez-vous vraiment modifier le patient?", "Confirmation", MessageBoxButton.YesNo) == MessageBoxResult.Yes) { PrenomPatient = PrenomPatient.Substring(0, 1).ToUpper() + PrenomPatient.Substring(1, PrenomPatient.Length - 1).ToLower(); NomPatient = NomPatient.ToUpper(); if (PatientValue.Nom != NomPatient || PatientValue.Prenom != PrenomPatient || PatientValue.DateDeNaissance != String.Format("{0:00}", SelJourNaiss) + "/" + String.Format("{0:00}", mois) + "/" + SelAnneeNaiss) { string dossier1 = PatientValue.Nom + PatientValue.Prenom + PatientValue.DateDeNaissance.Substring(0, 2) + PatientValue.DateDeNaissance.Substring(3, 2) + PatientValue.DateDeNaissance.Substring(6, 4); string dossier2 = NomPatient + PrenomPatient + String.Format("{0:00}", SelJourNaiss) + String.Format("{0:00}", mois) + SelAnneeNaiss; Patient p1 = new Patient(dossier1, dossier2, PatientValue.Nom, NomPatient, PatientValue.Prenom, PrenomPatient, PatientValue.DateDeNaissance, String.Format("{0:00}", SelJourNaiss) + "/" + String.Format("{0:00}", mois) + "/" + SelAnneeNaiss); PatientData.ChangeDirectory(p1); PatientValue.Nom = NomPatient; PatientValue.Prenom = PrenomPatient; PatientValue.DateDeNaissance = String.Format("{0:00}", SelJourNaiss) + "/" + String.Format("{0:00}", mois) + "/" + SelAnneeNaiss; } string dossier = NomPatient + PrenomPatient + String.Format("{0:00}", SelJourNaiss) + String.Format("{0:00}", mois) + SelAnneeNaiss; Patient p = new Patient(dossier, TaillePatient, PoidPatient, BrasPatient, sexe); PatientData.ModifPatientInfo(p); MessageBox.Show("Le patient a bien été modifié"); Messenger.Default.Send("0", "InscriptionViewModel"); } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
private void SavePatient() { try { string sexe; if (Masculin == true) { sexe = "M"; } else { sexe = "F"; } PrenomPatient = PrenomPatient.Substring(0, 1).ToUpper() + PrenomPatient.Substring(1, PrenomPatient.Length - 1).ToLower(); NomPatient = NomPatient.ToUpper(); int id1Int = Convert.ToInt32(ID1); int id2Int = Convert.ToInt32(ID2); Singleton singleUser = Singleton.getInstance(); Patient patient; if (singleUser.PatientSingleton != null) { patient = new Patient(singleUser.PatientSingleton.Nom, singleUser.PatientSingleton.Prenom, singleUser.PatientSingleton.DateNaiss, sexe, TaillePatient, PoidPatient, 0, 0); } else { patient = new Patient(NomPatient, PrenomPatient, DateNaiss, sexe, TaillePatient, PoidPatient, 0, 0); } Patient newPatient = new Patient(NomPatient, PrenomPatient, DateNaiss, sexe, TaillePatient, PoidPatient, 0, 0); singleUser.Patient = new ListePatientDataGrid(); singleUser.Patient.Nom = NomPatient; singleUser.Patient.Prenom = PrenomPatient; singleUser.Patient.DateDeNaissance = DateNaiss.ToShortDateString(); if (InscOuModif == 2) //Modification { if (MessageBox.Show(AxLanguage.Languages.REAplan_Modification_Demande_Confirmation, AxLanguage.Languages.REAplan_Confirmation, MessageBoxButton.YesNo) == MessageBoxResult.Yes) { PatientData.ModificationPatient(patient, newPatient); MessageBox.Show(AxLanguage.Languages.REAplan_Modification_Confirmation); } } else { PatientData.InscriptionPatient(patient); MessageBox.Show(AxLanguage.Languages.REAplan_Patient_Enregistre); NomPatient = null; PrenomPatient = null; DateNaiss = DateMax; sexe = null; TaillePatient = 0; PoidPatient = 0; firstTime = true; } Singleton singleUser2 = Singleton.getInstance(); singleUser2.PatientSingleton = patient; Messenger.Default.Send <Singleton>(singleUser2, "Singleton"); _nav.NavigateTo <HomeViewModel>(null, "ToLoad", null, false); } catch (Exception ex) { GestionErreur.GerrerErreur(ex); } }