Пример #1
0
        private void Add_Adherent_Click_1(object sender, EventArgs e)
        {
            List <Adherent> LesAdherents = new List <Adherent>();

            char sexe;

            if (rb_female.Checked)
            {
                sexe = char.Parse("F");
            }
            else
            {
                sexe = char.Parse("M");
            }
            if (!LesAdherents.Exists(x => (x.getNom() == tb_nom.Text)))
            {
                Adherent unAdhe = new Adherent(sexe, tb_nom.Text, tb_prenom.Text, mc_naissance.SelectionStart.ToShortDateString(), tb_rue.Text, tb_cp.Text, tb_ville.Text, int.Parse(tb_coti.Text));
                DBAdherent.AjouterAdherent(unAdhe);
                MessageBox.Show("L'adherent " + tb_nom.Text + " " + tb_prenom.Text + " a bien été ajouter");
            }
            else
            {
                MessageBox.Show("L'adherent " + tb_nom.Text + " " + tb_prenom.Text + " existe deja");
            }
        }
        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();
                }
            }
        }