コード例 #1
0
        //La methode est modifié //typeclub
        /// <summary>
        /// Methode qui selection tous Typeclub de la base de données
        /// </summary>
        /// <returns>Return une Liste de Typeclub</returns>
        public List <TypeClub> getTypeClub()
        {
            List <TypeClub> lesTypeClub = new List <TypeClub>();

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

                //Crée Commande
                MySqlCommand command = new MySqlCommand(query, connection);
                //On crée un datareader et on execute la commande
                using (MySqlDataReader dataReader = command.ExecuteReader())
                {
                    //On li la base de données et on ajoute dans la liste les TypeClub de la base
                    while (dataReader.Read())
                    {
                        TypeClub Type = new TypeClub();
                        Type.setId((int)dataReader["Id"]);
                        Type.setLibelle((string)dataReader["Libelle"]);



                        lesTypeClub.Add(Type);
                    }
                }

                connection.Close();

                return(lesTypeClub);
            }
        }
コード例 #2
0
        private void buttonUpdate_Click(object sender, EventArgs e)
        {
            if (condition())
            {
                TypeClub letype = new TypeClub();
                letype.setLibelle(comboBox1.Text);

                Clubs club = new Clubs();

                club.setId(Int32.Parse(textID.Text));
                club.setLienSite(textLienSite.Text);
                club.setNom(textNom.Text);
                club.setMail(textEmail.Text);
                club.setType(letype);
                club.setAdresse(textAdresse.Text);
                club.setCPT(Int32.Parse(textCPT.Text));
                club.setVille(textVille.Text);
                club.setTel(Int32.Parse(textTel.Text));

                ModeleBDD bd = new ModeleBDD();

                bd.UPDATEClub(club);

                labelInfo.Text = club.getNom() + " a été modifié ";
                dataGridView1.ClearSelection();
                FillDataGridView();
            }
            else
            {
                MessageBox.Show("Veuillez remplir tout les champs");
            }
        }
コード例 #3
0
        private void buttonAdd_Click(object sender, EventArgs e)
        {
            if (textSport.Text != "")
            {
                try
                {
                    ModeleBDD con = new ModeleBDD();

                    TypeClub Type = new TypeClub();

                    Type.setLibelle(textSport.Text);

                    con.setTypeSport(Type);
                    textSport.Text = "";
                    listBox1.Items.Clear();
                    FillList();
                }catch (Exception e1)
                {
                    MessageBox.Show("Message d'erreur : " + e1.Message + " \nType de l'exception " + e1.GetType() + " \nPile d'appel" + e1.StackTrace);
                }
            }
            else
            {
                MessageBox.Show("....");
            }
        }
コード例 #4
0
 public void setTypeSport(TypeClub Type)
 {
     using (MySqlConnection connection = new MySqlConnection(connectionString))
     {
         connection.Open();
         MySqlCommand command = connection.CreateCommand();
         command.CommandText = "INSERT INTO type(Libelle) VALUES (@Libelle)";
         command.Parameters.AddWithValue("@Libelle", Type.getLibelle());
         command.ExecuteNonQuery();
         connection.Close();
     }
 }
コード例 #5
0
 public Clubs(int lId, string leNom, string leLien, string lAdresse, string laVille, int CPT, int Tel, string Mail, TypeClub leType)
 {
     this.Id         = lId;
     this.Nom        = leNom;
     this.LienSite   = leLien;
     this.Adresse    = lAdresse;
     this.Ville      = laVille;
     this.CodePostal = CPT;
     this.Telephone  = Tel;
     this.EMail      = Mail;
     this.Type       = leType;
 }
コード例 #6
0
        private void buttonSup_Click(object sender, EventArgs e)
        {
            ModeleBDD con = new ModeleBDD();

            TypeClub Type = new TypeClub();

            Type.setLibelle(textSport.Text);

            con.supTypeSport(Type);
            textSport.Text = "";
            listBox1.Items.Clear();
            FillList();
        }
コード例 #7
0
        public void supTypeSport(TypeClub type)
        {
            using (MySqlConnection connection = new MySqlConnection(connectionString))
            {
                connection.Open();
                string query = "DELETE FROM type WHERE Libelle=@Libelle";

                //on crée la commande
                MySqlCommand command = new MySqlCommand(query, connection);

                command.Parameters.AddWithValue("@Libelle", type.getLibelle());
                command.ExecuteNonQuery();

                connection.Close();
            }
        }
コード例 #8
0
        private void buttonInsert_Click(object sender, EventArgs e)
        {
            if (condition())
            {
                TypeClub letype = new TypeClub();
                letype.setLibelle(comboBox1.Text);

                Clubs club = new Clubs();
                club.setLienSite(textLienSite.Text);
                club.setNom(textNom.Text);
                club.setMail(textEmail.Text);
                club.setType(letype);
                club.setAdresse(textAdresse.Text);
                club.setCPT(Int32.Parse(textCPT.Text));
                club.setVille(textVille.Text);
                club.setTel(Int32.Parse(textTel.Text));

                try
                {
                    ModeleBDD bd = new ModeleBDD();

                    bd.setClub(club);


                    textNom.Text      = "";
                    textLienSite.Text = "";
                    comboBox1.Text    = "";
                    textEmail.Text    = "";
                    textAdresse.Text  = "";
                    textCPT.Text      = "";
                    textVille.Text    = "";
                    textTel.Text      = "";
                    labelInfo.Text    = club.getNom() + " a été ajouter avec succès ";
                    dataGridView1.ClearSelection();
                    FillDataGridView();
                }catch (Exception e1)
                {
                    MessageBox.Show("Message d'erreur : " + e1.Message + " \nType de l'exception " + e1.GetType() + " \nPile d'appel" + e1.StackTrace);
                }
            }
            else
            {
                MessageBox.Show("Veuillez remplir tout les champs");
            }
        }
コード例 #9
0
        //La methode est modifié //club
        /// <summary>
        /// Methode qui selection tous clubs sur la base de données
        /// </summary>
        /// <returns>Return un Listes des clubs</returns>
        public List <Clubs> getClubs()
        {
            List <Clubs> lesClubs = new List <Clubs>();

            using (MySqlConnection connection = new MySqlConnection(connectionString))
            {
                connection.Open();
                string query = "SELECT c.id AS IdClub, c.Nom, c.LienSIte, c.Adresse, c.Ville, c.CodePostal, c.Telephone, c.Email, c.id_type, t.id AS IdType, t.Libelle From clubs AS c INNER JOIN type AS t ON c.id_type = t.id";

                //Crée Commande
                MySqlCommand command = new MySqlCommand(query, connection);
                //On crée un datareader et on execute la commande
                using (MySqlDataReader dataReader = command.ExecuteReader())
                {
                    //On li la base de données et on ajiute dans la liste les ahderents de la base de données
                    while (dataReader.Read())
                    {
                        TypeClub Type = new TypeClub();
                        Type.setId((int)dataReader["IdType"]);
                        Type.setLibelle((string)dataReader["Libelle"]);

                        Clubs lClub = new Clubs();
                        lClub.setId((int)dataReader["IdClub"]);
                        lClub.setLienSite((string)dataReader["LienSite"]);
                        lClub.setMail((string)dataReader["Email"]);
                        lClub.setNom((string)dataReader["Nom"]);
                        lClub.setType(Type);
                        lClub.setTel((int)dataReader["Telephone"]);
                        lClub.setAdresse((string)dataReader["Adresse"]);
                        lClub.setCPT((int)dataReader["CodePostal"]);
                        lClub.setVille((string)dataReader["Ville"]);

                        lesClubs.Add(lClub);
                    }
                }

                connection.Close();

                return(lesClubs);
            }
        }
コード例 #10
0
 public TypeClub setType(TypeClub leType)
 {
     this.Type = leType;
     return(Type);
 }
コード例 #11
0
 public void setType(TypeClub leType)
 {
     this.Type = leType;
 }