Example #1
0
        /// <summary>
        /// methode qui permet de modifier les attributs d'un club
        /// </summary>
        /// <param name="Nom"></param>
        /// <param name="Email"></param>
        /// <param name="Ville"></param>
        /// <param name="Adresse"></param>
        /// <param name="Lieu"></param>
        /// <param name="Siteweb"></param>
        /// <param name="CP"></param>
        /// <param name="Telephone"></param>
        /// <param name="ID"></param>
        /// <returns></returns>
        public club UpdateCB(string Nom, string Email, string Ville, string Adresse, string Lieu, string Siteweb, int CP, int Telephone, int ID)
        {
            club leclub = null;

            using (MySqlConnection conection = new MySqlConnection(connectionString))
            {
                conection.Open();
                string query = "Update club Set Nom = @Nom, Email = @Email , Ville = @Ville , Adresse = @Adresse , Lieu = Lieu, Siteweb = @SiteWeb, CP = @CP, Telephone = @Telephone Where id = @id";

                //Create Command
                MySqlCommand cmd = new MySqlCommand(query, conection);


                cmd.Parameters.AddWithValue("@id", ID);
                cmd.Parameters.AddWithValue("@Nom", Nom);
                cmd.Parameters.AddWithValue("@Email", Email);
                cmd.Parameters.AddWithValue("@adresse", Adresse);
                cmd.Parameters.AddWithValue("@Lieu", Lieu);
                cmd.Parameters.AddWithValue("@Ville", Ville);
                cmd.Parameters.AddWithValue("@SiteWeb", Siteweb);
                cmd.Parameters.AddWithValue("@CP", Convert.ToString(CP));
                cmd.Parameters.AddWithValue("@Telephone", Convert.ToString(Telephone));

                cmd.ExecuteNonQuery();
                leclub = new club();
                conection.Close();
            }

            return(leclub);
        }
Example #2
0
        /// <summary>
        /// methode qui permet d'ajouter un club
        /// </summary>
        /// <param name="Nom"></param>
        /// <param name="Email"></param>
        /// <param name="Ville"></param>
        /// <param name="Adresse"></param>
        /// <param name="Lieu"></param>
        /// <param name="Siteweb"></param>
        /// <param name="CP"></param>
        /// <param name="Telephone"></param>
        /// <returns></returns>
        public club InsertCB(string Nom, string Email, string Ville, string Adresse, string Lieu, string Siteweb, int CP, int Telephone)
        {
            club leClub = null;

            using (MySqlConnection conection = new MySqlConnection(connectionString))
            {
                conection.Open();
                string query = "INSERT INTO club (Nom, Email, Ville , Adresse, Lieu, Siteweb, CP, Telephone) VALUES (@Nom, @Email, @Ville, @Adresse, @Lieu, @SiteWeb ,@CP ,@Telephone)";

                //Create Command
                MySqlCommand cmd = new MySqlCommand(query, conection);

                cmd.Parameters.AddWithValue("@Nom", Nom);
                cmd.Parameters.AddWithValue("@Email", Email);
                cmd.Parameters.AddWithValue("@adresse", Adresse);
                cmd.Parameters.AddWithValue("@Lieu", Lieu);
                cmd.Parameters.AddWithValue("@Ville", Ville);
                cmd.Parameters.AddWithValue("@SiteWeb", Siteweb);
                cmd.Parameters.AddWithValue("@CP", Convert.ToString(CP));
                cmd.Parameters.AddWithValue("@Telephone", Convert.ToString(Telephone));

                cmd.ExecuteNonQuery();
                leClub = new club();
                conection.Close();
            }

            return(leClub);
        }
Example #3
0
        /// <summary>
        /// methode qui permet de supprimée un club
        /// </summary>
        /// <param name="ID"></param>
        /// <returns></returns>
        public club DeleteCB(int ID)
        {
            club leclub = null;

            using (MySqlConnection conection = new MySqlConnection(connectionString))
            {
                conection.Open();
                string query = "DELETE from club Where id = @ID";

                //Create Command
                MySqlCommand cmd = new MySqlCommand(query, conection);

                cmd.Parameters.AddWithValue("@id", ID);

                cmd.ExecuteNonQuery();
                leclub = new club();
                conection.Close();
            }

            return(leclub);
        }
Example #4
0
        /// <summary>
        /// methode retourne une liste de club en fonction du nom
        /// </summary>
        /// <returns></returns>
        public List <club> ReadClub()
        {
            club        leclub = null;
            List <club> ListCB = new List <club>();

            using (MySqlConnection connection = new MySqlConnection(connectionString))
            {
                connection.Open();
                string query = "SELECT * FROM club";

                //Create Command
                MySqlCommand cmd = new MySqlCommand(query, connection);



                //Create a data reader and Execute the command
                using (MySqlDataReader dataReader = cmd.ExecuteReader())
                {
                    //Read the data and store them in the list
                    while (dataReader.Read())
                    {
                        leclub = new club();
                        leclub.SetID((int)dataReader["id"]);
                        leclub.SetNom((string)dataReader["Nom"]);
                        leclub.SetVille((string)dataReader["Ville"]);
                        leclub.SetAdresse((string)dataReader["Adresse"]);
                        leclub.SetEmail((string)dataReader["Email"]);
                        leclub.SetSiteWeb((string)dataReader["SiteWeb"]);
                        leclub.SetLieu((string)dataReader["Lieu"]);
                        leclub.SetCP((int)dataReader["CP"]);
                        leclub.SetTelephone((int)dataReader["Telephone"]);
                        ListCB.Add(leclub);
                    }
                }
            }

            return(ListCB);
        }