public bool AddRdv(DateTime date, byte idMedecin, string nomPatient, string prenomPatient, bool important, string notes) { nomPatient = nomPatient.ToUpper(); prenomPatient = prenomPatient.ToUpper(); IQueryable <RendezVous> checkRdv = (from rdvCheck in Globals.DataClass.RendezVous where date == rdvCheck.Date select rdvCheck); if (checkRdv.Count() == 0) { IQueryable <Patient> patientRdv = (from personne in Globals.DataClass.Personne where nomPatient == personne.nom && prenomPatient == personne.prenom join patient in Globals.DataClass.Patient on personne.Id equals patient.IdPersonne select patient); if (patientRdv.Count() != 0) { Patient pers = patientRdv.First <Patient>(); RendezVous rdv = new RendezVous { Date = date, IdPatient = pers.Id, IdMedecin = idMedecin, Important = important, Fait = false, Note = notes, Notified = false }; Globals.DataClass.RendezVous.InsertOnSubmit(rdv); Globals.DataClass.SubmitChanges(); MPRendezVous mPRdv = new MPRendezVous { IdMedecin = idMedecin, IdPatient = pers.Id, IdRendezVous = rdv.Id }; Globals.DataClass.MPRendezVous.InsertOnSubmit(mPRdv); Globals.DataClass.SubmitChanges(); } else { PersonneClasse newPatient = new PersonneClasse(); newPatient.AddPatientPersonne(nomPatient, prenomPatient, "01/01/1998", "Indéfini", "0123456789", "Homme", "170", "60", "/", "Indéfini", "Indéfini"); Patient addedPatient = (from personne in Globals.DataClass.Personne where nomPatient == personne.nom && prenomPatient == personne.prenom join patient in Globals.DataClass.Patient on personne.Id equals patient.IdPersonne select patient).First <Patient>(); RendezVous rdv = new RendezVous { Date = date, IdPatient = addedPatient.Id, IdMedecin = idMedecin, Important = important, Fait = false, Note = notes, Notified = false }; Globals.DataClass.RendezVous.InsertOnSubmit(rdv); Globals.DataClass.SubmitChanges(); MPRendezVous mPRdv = new MPRendezVous { IdMedecin = idMedecin, IdPatient = addedPatient.Id, IdRendezVous = rdv.Id }; Globals.DataClass.MPRendezVous.InsertOnSubmit(mPRdv); Globals.DataClass.SubmitChanges(); } //System.IO.File.Copy($@"{Globals.CurrentDirectoryPath}\\MCDatabase.mdf", $@"{Globals.CurrentDirectoryPath}\\restauration\\MCDatabase.mdf", true); return(true); } else { return(false); } }