示例#1
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));

                    try
                    {
                        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();
                    }catch (Exception e1)
                    {
                        MessageBox.Show("Message d'erreur : " + e1.Message + " \nType de l'exception " + e1.GetType() + " \nPile d'appel" + e1.StackTrace);
                    }
                }
                else
                {
                    MessageBox.Show("La Licence doit être unique");
                }
            }
            else
            {
                MessageBox.Show("Veuillez rmplir tout les champs");
            }
        }