/// <summary> /// Modifie la Visite sur la BDD /// </summary> /// <param name="visite"></param> public static void editVisite(Visite visite) { connexion(); MySqlCommand maCommande = maConnection.CreateCommand(); maCommande.CommandText = "UPDATE visite set dateVisite = @dateVisite, rdv = @rdv, idutilisateur = @idutilisateur, " + "idmedecin = @idmedecin, heureArrivee = @heureArrivee, heureDepart = @heureDepart, heureDebut = @heureDebut where visite.id = @id"; maCommande.Parameters.AddWithValue("@dateVisite", visite.getDateVisite()); maCommande.Parameters.AddWithValue("@rdv", visite.getRdv()); maCommande.Parameters.AddWithValue("@idutilisateur", visite.getVisiteur().getId()); maCommande.Parameters.AddWithValue("@idmedecin", visite.getmedecin().getId()); maCommande.Parameters.AddWithValue("@heureArrivee", visite.getHeureArrivee()); maCommande.Parameters.AddWithValue("@heureDepart", visite.getHeureDepart()); maCommande.Parameters.AddWithValue("@heureDebut", visite.getHeureDebut()); maCommande.Parameters.AddWithValue("@id", visite.getId()); maCommande.ExecuteNonQuery(); init(); }
/// <summary> /// Supprime une visite à la liste /// </summary> /// <returns></returns> public static void supprimeVisite(Visite visite) { connexion(); MySqlCommand maCommande = maConnection.CreateCommand(); maCommande.CommandText = "DELETE from visite WHERE visite.id = @idVisite;"; //maCommande.Parameters.AddWithValue("@id", cabinet.getId()); maCommande.Parameters.AddWithValue("@idVisite", visite.getId()); maCommande.Parameters.AddWithValue("@dateVisite", visite.getDateVisite()); maCommande.Parameters.AddWithValue("@rdv", visite.getRdv()); maCommande.Parameters.AddWithValue("@idutilisateur", visite.getVisiteur()); maCommande.Parameters.AddWithValue("@idmedecin", visite.getmedecin()); maCommande.Parameters.AddWithValue("@heureArrivee", visite.getHeureArrivee()); maCommande.Parameters.AddWithValue("@heureDepart", visite.getHeureDepart()); maCommande.Parameters.AddWithValue("@heureDebut", visite.getHeureDebut()); maCommande.ExecuteNonQuery(); int lastId = (int)maCommande.LastInsertedId; visite.setId(lastId); listeDesVisites.Remove(visite); }
public void testConstructeurVisite() { DateTime dateAttendu = new DateTime(2017, 02, 02); Utilisateur utilisateurObtenu = new Utilisateur("1", "david", "andre", "dandre", "oppg5", "106 rue victor hugo", "59000", "Lille", dateAttendu, "0", "*****@*****.**", 8); Cabinet cabinetObtenu = new Cabinet(1, "20 rue Jean Bono", "59000", "Lille", 25.78, 34.24); Medecin medecinObtenu = new Medecin(1, "Bernard", "Jean", cabinetObtenu, utilisateurObtenu); Visite visite1 = new Visite(1, dateAttendu, true, utilisateurObtenu, medecinObtenu, new DateTime(2017, 02, 02, 10, 20, 43), new DateTime(2017, 02, 02, 10, 30, 45), new DateTime(2017, 02, 02, 10, 42, 05)); Visite visite2 = new Visite(dateAttendu, false, utilisateurObtenu, medecinObtenu, new DateTime(2017, 02, 02, 10, 20, 43), new DateTime(2017, 02, 02, 15, 30, 45), new DateTime(2017, 02, 02, 10, 42, 05)); Assert.AreEqual(visite1.getDateVisite(), new DateTime(2017, 02, 02)); Assert.AreEqual(visite1.getHeureArrivee(), new DateTime(2017, 02, 02, 10, 20, 43)); Assert.AreEqual(visite1.getmedecin(), medecinObtenu); Assert.AreEqual(visite1.getVisiteur(), utilisateurObtenu); Assert.AreEqual(visite1.getId(), 1); Assert.AreEqual(visite1.getRdv(), true); //Assert.AreEqual(visite1.ToString(), ""); //String leString = this.getDateVisite().Day + "/" + this.getDateVisite().Month + "/" + getDateVisite().Year + ", " + this.getmedecin().ToString() + ", " + this.getVisiteur().ToString(); Assert.AreEqual(visite2.getDateVisite(), new DateTime(2017, 02, 02)); Assert.AreEqual(visite2.getHeureArrivee(), new DateTime(2017, 02, 02, 10, 20, 43)); Assert.AreEqual(visite2.getHeureDebut(), new DateTime(2017, 02, 02, 10, 42, 05)); }