/// <summary> /// methode setAdherents ajouter un adherents dans un base de donnée /// </summary> /// <param name="me">est un objet de la classe Adherents</param> public void setAdherent(Adherents me) { using (MySqlConnection connection = new MySqlConnection(connectionString)) { connection.Open(); MySqlCommand command = connection.CreateCommand(); command.CommandText = "INSERT INTO adherents(id_clubs, Licence, Sexe, Nom, Prenom, Naissance, Adresse, CodePostal, Ville, Cotisation) VALUES ((SELECT id FROM clubs WHERE Nom = @Club), @Licence, @Sexe, @Nom, @Prenom, @Naissance, @Adresse, @CodePostal, @Ville, @Cotisation)"; command.Parameters.AddWithValue("@Club", me.getClub().getNom()); command.Parameters.AddWithValue("@Licence", me.getLicence()); command.Parameters.AddWithValue("@Sexe", me.getSexe()); command.Parameters.AddWithValue("@Nom", me.getNom()); command.Parameters.AddWithValue("@Prenom", me.getPrenom()); command.Parameters.AddWithValue("@Naissance", me.getNaissance()); command.Parameters.AddWithValue("@Adresse", me.getAdresse()); command.Parameters.AddWithValue("@CodePostal", me.getCPT()); command.Parameters.AddWithValue("@Ville", me.getVille()); command.Parameters.AddWithValue("@Cotisation", me.getCotisation()); command.ExecuteNonQuery(); connection.Close(); } }
/// <summary> /// Methode qui permet de modifié un adhérent dans la base de donnée /// </summary> /// <param name="lAdherent">lAdherent a modifié</param> public void UPDATEAdherent(Adherents lAdherent) { using (MySqlConnection connection = new MySqlConnection(connectionString)) { connection.Open(); MySqlCommand command = connection.CreateCommand(); command.CommandText = "UPDATE adherents SET id_clubs=(SELECT id FROM clubs WHERE Nom=@NomClub), Licence=@Licence, Sexe=@Sexe, Nom=@Nom, Prenom=@Prenom, Naissance=@Naissance, Adresse=@Adresse, CodePostal=@CodePostal, Ville=@Ville, Cotisation=@Cotisation WHERE id=@id"; command.Parameters.AddWithValue("@Id", lAdherent.getId()); command.Parameters.AddWithValue("@NomClub", lAdherent.getClub().getNom()); command.Parameters.AddWithValue("@Licence", lAdherent.getLicence()); command.Parameters.AddWithValue("@Nom", lAdherent.getNom()); command.Parameters.AddWithValue("@Prenom", lAdherent.getPrenom()); command.Parameters.AddWithValue("@Sexe", lAdherent.getSexe()); command.Parameters.AddWithValue("@Naissance", lAdherent.getNaissance()); command.Parameters.AddWithValue("@CodePostal", lAdherent.getCPT()); command.Parameters.AddWithValue("@Adresse", lAdherent.getAdresse()); command.Parameters.AddWithValue("@Ville", lAdherent.getVille()); command.Parameters.AddWithValue("@Cotisation", lAdherent.getCotisation()); command.ExecuteNonQuery(); connection.Close(); } }