Esempio n. 1
0
        /// <summary>
        /// readType retourne la liste des types de clubs
        /// </summary>
        /// <returns></returns>
        public List <TypeClub> ReadType()
        {
            List <TypeClub> liste = new List <TypeClub>();

            TypeClub type;

            using ( connexion )
            {
                connexion.Open();
                string requete = "SELECT * FROM type_club";


                MySqlCommand cmd = new MySqlCommand(requete, connexion);
                using (MySqlDataReader datareader = cmd.ExecuteReader())
                {
                    while (datareader.Read())
                    {
                        type = new TypeClub(
                            (string)datareader["libelle"]);

                        type.id = (int)datareader["id_type_club"];
                        liste.Add(type);
                    }
                }
            }
            return(liste);
        }
Esempio n. 2
0
        /// <summary>
        /// La méthode ReadClub retourne une liste de tout les clubs  dans la table.
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public List <Club> ReadClub()
        {
            List <Club> liste = new List <Club>();
            TypeClub    type;
            Club        clubs;

            using ( connexion )
            {
                connexion.Open();
                string requete = "SELECT * FROM club join type_club on club.id_type_club = type_club.id_type_club ";


                MySqlCommand cmd = new MySqlCommand(requete, connexion);
                using (MySqlDataReader datareader = cmd.ExecuteReader())
                {
                    while (datareader.Read())
                    {
                        clubs = new Club(
                            (string)datareader["Titre_club"], (string)datareader["url_club"],
                            (string)datareader["Ville_club"], (string)datareader["telephone_club"], (string)datareader["Code_Postal_club"],
                            (string)datareader["mail_club"], (int)datareader["id_type_club"], (string)datareader["Adresse_club"]);

                        type = new TypeClub(
                            (string)datareader["libelle"]);

                        type.id = (int)datareader["id_type_club"];


                        clubs.id   = (int)datareader["id_club"];
                        clubs.Type = type;
                        liste.Add(clubs);
                    }
                }
            }
            return(liste);
        }