Exemplo n.º 1
0
        // recupere la lise des adherent  + DEfINIr ADHERENT
        public static List <adherent> recupAdherent()
        {
            List <adherent> TableAdherent = new List <adherent>();

            MySqlCommand maCommande = connection.CreateCommand();
            //
            MySqlDataReader maLigne;

            maCommande.CommandText = "select * from adherent";
            connection.Open();
            maLigne = maCommande.ExecuteReader();
            while (maLigne.Read())
            {
                string[] valeurColonnes = new string[9];
                for (int i = 0; i < maLigne.FieldCount; i++)
                {
                    valeurColonnes[i] = maLigne.GetValue(i).ToString();
                }
                int    id         = int.Parse(valeurColonnes[0]);
                string nom        = valeurColonnes[1];
                string prenom     = valeurColonnes[2];
                char   sexe       = char.Parse(valeurColonnes[3]);
                string date       = valeurColonnes[4];
                string adress     = valeurColonnes[5];
                string cp         = valeurColonnes[6];
                string ville      = valeurColonnes[7];
                int    cotisation = int.Parse(valeurColonnes[8]);

                // remplacer dès que l'objet adérent est fait
                adherent adhe = new adherent(id, nom, prenom, sexe, date, adress, cp, ville, cotisation);
                TableAdherent.Add(adhe);
            }//
            connection.Close();
            return(TableAdherent);
        }
Exemplo n.º 2
0
        public static void ajoutAdherent(adherent unAdherent)
        {
            MySqlCommand maCommande = connection.CreateCommand();

            maCommande.CommandText = "insert into `adherent` (`nom`, `prenom`, `sexe`, `naissance`, `rueAdresse`, `cp`, `ville`, `cotisation`) values ( '" + unAdherent.getNom() + "','" + unAdherent.getPrenom() + "','" + unAdherent.getSexe() + "','" + unAdherent.getDateNaissance() + "','" + unAdherent.getRueAdresse() + "','" + unAdherent.getCp() + "','" + unAdherent.getVille() + "','" + unAdherent.getCotisation() + "')";
            connection.Open();
            maCommande.ExecuteReader();
            connection.Close();
        }
Exemplo n.º 3
0
        private void bt_Ajouter_Click(object sender, EventArgs e)
        {
            string nom    = tb_nom.Text;
            string prenom = tb_prenom.Text;
            char   sexe;

            if (rb_femme.Checked)
            {
                sexe = char.Parse("F");
            }
            else
            {
                sexe = char.Parse("M");
            }
            string   naissance  = dtp_naissance.Text;
            string   rueAdresse = tb_adresse.Text;
            string   cp         = tb_CP.Text;
            string   ville      = tb_ville.Text;
            int      cotisation = int.Parse(tb_cotisation.Text);
            adherent unAdherent = new adherent(nom, prenom, sexe, naissance, rueAdresse, cp, ville, cotisation);

            DataBase.ajoutAdherent(unAdherent);
        }