Exemplo n.º 1
0
 /// <summary>
 /// methode setClub ajouter un club dans la base dedonnées
 /// </summary>
 /// <param name="leClub">est un abjet de la classe Clubs</param>
 public void setClub(Clubs leClub)
 {
     using (MySqlConnection connection = new MySqlConnection(connectionString))
     {
         connection.Open();
         MySqlCommand command = connection.CreateCommand();
         command.CommandText = "INSERT INTO clubs(Nom, LienSite, Adresse, Ville, CodePostal, Telephone, Email, id_type) VALUES (@Nom, @LienSite, @Adresse, @Ville, @CodePostal, @Telephone, @Email, (SELECT id FROM Type WHERE Libelle = @Type))";
         command.Parameters.AddWithValue("@Nom", leClub.getNom());
         command.Parameters.AddWithValue("@LienSite", leClub.getLienSite());
         command.Parameters.AddWithValue("@Adresse", leClub.getAdresse());
         command.Parameters.AddWithValue("@Ville", leClub.getVille());
         command.Parameters.AddWithValue("@CodePostal", leClub.getCPT());
         command.Parameters.AddWithValue("@Telephone", leClub.getTel());
         command.Parameters.AddWithValue("@Email", leClub.getEMail());
         command.Parameters.AddWithValue("@Type", leClub.getType().getLibelle());
         command.ExecuteNonQuery();
         connection.Close();
     }
 }
Exemplo n.º 2
0
 /// <summary>
 /// La méthode modifie un club en fonction de l'objet Clubs en parametre.
 /// </summary>
 /// <param name="Clubs">Leclub a modifié </param>
 /// <returns>un club</returns>
 public void UPDATEClub(Clubs leClub)
 {
     using (MySqlConnection connection = new MySqlConnection(connectionString))
     {
         connection.Open();
         MySqlCommand command = connection.CreateCommand();
         command.CommandText = "UPDATE clubs SET Nom=@Nom, LienSite=@LienSite, Adresse=@Adresse, Ville=@Ville, CodePostal=@CodePostal, Telephone=@Telephone, Email=@Email, id_type= ( SELECT id FROM type WHERE Libelle=@Type ) WHERE id=@id";
         command.Parameters.AddWithValue("@Id", leClub.getId());
         command.Parameters.AddWithValue("@Nom", leClub.getNom());
         command.Parameters.AddWithValue("@LienSite", leClub.getLienSite());
         command.Parameters.AddWithValue("@Adresse", leClub.getAdresse());
         command.Parameters.AddWithValue("@Ville", leClub.getVille());
         command.Parameters.AddWithValue("@CodePostal", leClub.getCPT());
         command.Parameters.AddWithValue("@Telephone", leClub.getTel());
         command.Parameters.AddWithValue("@Email", leClub.getEMail());
         command.Parameters.AddWithValue("@Type", leClub.getType().getLibelle());
         command.ExecuteNonQuery();
         connection.Close();
     }
 }