Exemple #1
0
        /// <summary>
        /// Modifie l'évènement
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void buttonUpdate_Click(object sender, EventArgs e)
        {
            if (condition())
            {
                if (verifiLicence())
                {
                    Clubs club = new Clubs();
                    club.setNom(comboBox2.Text);
                    Adherents adherent = new Adherents();
                    adherent.setId(Int32.Parse(textID.Text));
                    adherent.setClub(club);
                    adherent.setSexe(comboBox1.Text);
                    adherent.setNom(textNom.Text);
                    adherent.setPrenom(textPrenom.Text);
                    adherent.setLicence(textLicence.Text);
                    adherent.setNaissance(dateTimePicker1.Value);
                    adherent.setAdresse(textAdresse.Text);
                    adherent.setCPT(Int32.Parse(textCodePostal.Text));
                    adherent.setVille(textVille.Text);
                    adherent.setCotisation(Int32.Parse(textCotisation.Text));
                    try
                    {
                        ModeleBDD bd = new ModeleBDD();

                        bd.UPDATEAdherent(adherent);

                        comboBox1.Text   = "";
                        comboBox2.Text   = "";
                        textID.Text      = "";
                        textNom.Text     = "";
                        textPrenom.Text  = "";
                        textLicence.Text = "";
                        //dateTimePicker1.Value = DateTime.Now;
                        textAdresse.Text    = "";
                        textCodePostal.Text = "";
                        textVille.Text      = "";
                        textCotisation.Text = "";
                        label10.Text        = adherent.getNom() + " a été modifié ";
                        dataGridView1.ClearSelection();
                        FillDataGridView();
                    }catch (Exception e2)
                    {
                        MessageBox.Show("Message d'erreur : " + e2.Message + " \nType de l'exception " + e2.GetType() + " \nPile d'appel" + e2.StackTrace);
                    }
                }
                else
                {
                    MessageBox.Show("La licence doit être unique");
                }
            }
            else
            {
                MessageBox.Show("Veuillez remplir tout les champs");
            }
        }
Exemple #2
0
        /// <summary>
        /// Ajoute un évènements
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e">l'évènement à ajouter</param>
        private void buttonInsertion_Click(object sender, EventArgs e)
        {
            if (condition())
            {
                if (verifiLicence())
                {
                    Clubs club = new Clubs();
                    club.setNom(comboBox2.Text);
                    Adherents adherent = new Adherents();
                    adherent.setClub(club);
                    adherent.setSexe(comboBox1.Text);
                    adherent.setNom(textNom.Text);
                    adherent.setPrenom(textPrenom.Text);
                    adherent.setLicence(textLicence.Text);
                    adherent.setNaissance(dateTimePicker1.Value);
                    adherent.setAdresse(textAdresse.Text);
                    adherent.setCPT(Int32.Parse(textCodePostal.Text));
                    adherent.setVille(textVille.Text);
                    adherent.setCotisation(Int32.Parse(textCotisation.Text));

                    ModeleBDD bd = new ModeleBDD();

                    bd.setAdherent(adherent);

                    comboBox1.Text   = "";
                    comboBox2.Text   = "";
                    textNom.Text     = "";
                    textPrenom.Text  = "";
                    textLicence.Text = "";
                    //dateTimePicker1.Value = DateTime.Now;
                    textAdresse.Text    = "";
                    textCodePostal.Text = "";
                    textVille.Text      = "";
                    textCotisation.Text = "";
                    label10.Text        = adherent.getNom() + " a été ajouter avec succès ";
                    dataGridView1.ClearSelection();
                    FillDataGridView();
                }
                else
                {
                    MessageBox.Show("La Licence doit être unique");
                }
            }
            else
            {
                MessageBox.Show("Veuillez rmplir tout les champs");
            }
        }
Exemple #3
0
 /// <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();
     }
 }
Exemple #4
0
 /// <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();
     }
 }