Exemple #1
0
        // Ajout d'un adhérent
        public static void AjouterAdherent(Adherent unAdhe)
        {
            string nom       = unAdhe.getNom();
            string prenom    = unAdhe.getPrenom();
            char   sexe      = unAdhe.getSexe();
            string rue       = unAdhe.getRue();
            string cp        = unAdhe.getCp();
            string ville     = unAdhe.getVille();
            string naissance = unAdhe.getNaissance();
            //connection base
            MySqlCommand maCommande = connection.CreateCommand();

            maCommande.CommandText = "INSERT INTO `adherent` (`nom`,`prenom`,`sexe`,`naissance`,`rueAdresse`,`cp`,`ville`,`cotisation`) VALUES ('" + nom + "','" + prenom + "','" + sexe + "','" + naissance + "','" + rue + "','" + cp + "','" + ville + "')";
            connection.Open();
            maCommande.ExecuteReader();
            connection.Close();
        }
        private void Add_Adherent_Click(object sender, EventArgs e)
        {
            List <Adherent> LesAdhe = DBAdherent.getAllAdherent();
            int             i       = -1;
            bool            trouve  = false;

            while (i < LesAdhe.Count && !trouve)
            {
                i++;
                if (LesAdhe.ElementAt(i).getId() == leAdhe.getId())
                {
                    DBAdherent.DeleteAdhe(leAdhe.getId());
                    Adherent nouveauAdhe = new Adherent(leAdhe.getSexe(), tb_nom.Text, leAdhe.getPrenom(), leAdhe.getNaissance(), tb_rue.Text, tb_cp.Text, tb_ville.Text, leAdhe.getId(), int.Parse(tb_coti.Text));
                    DBAdherent.AjouterAdherent(nouveauAdhe);
                    trouve = true;
                    MessageBox.Show("Modification enregistrer");
                    this.Close();
                }
            }
        }
 //int test;
 public EditAdherent(Adherent unAdhe)
 {
     test = unAdhe;
     InitializeComponent();
 }