Пример #1
0
        private void btn_Mod_Adherent_Click(object sender, EventArgs e)
        {
            if (!DateTime.TryParse(txtAdherentBirthDate.Text, out DateTime birthDate))
            {
                MessageBox.Show("Veuillez renseigner une date valide.", "Date non valide",
                                MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            if (txtAdherentLastName.Text != string.Empty && txtAdherentFirstName.Text != string.Empty &&
                txtAdherentZipCode.Text != string.Empty && txtAdherentCity.Text != string.Empty &&
                txtAdherentAddress.Text != string.Empty)
            {
                AdherentToModify.BirthDate = birthDate;
                AdherentToModify.LastName  = txtAdherentLastName.Text;
                AdherentToModify.FirstName = txtAdherentFirstName.Text;
                AdherentToModify.ZipCode   = txtAdherentZipCode.Text;
                AdherentToModify.City      = txtAdherentCity.Text;
                AdherentToModify.Address   = txtAdherentAddress.Text;
                AdherentToModify.Club      = ManageClub.GetClubByName(cmbAdherentClub.Text);

                DBAdherent.ModifyAdherent(AdherentToModify);

                MessageBox.Show("Les modifications ont bien été effectuées.", "Modifications réussies",
                                MessageBoxButtons.OK, MessageBoxIcon.Information);
                Close();
            }
            else
            {
                MessageBox.Show("Veuillez remplir tous les champs.", "Champ(s) non rempli(s)",
                                MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
Пример #2
0
        private void btn_Add_Adherent_Click(object sender, EventArgs e)
        {
            if (!DateTime.TryParse(txtAdherentBirthDate.Text, out DateTime birthDate))
            {
                MessageBox.Show("Veuillez renseigner une date valide.", "Date non valide",
                                MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }

            if (txtAdherentLastName.Text != string.Empty && txtAdherentFirstName.Text != string.Empty &&
                birthDate.ToString() != string.Empty && txtAdherentZipCode.Text != string.Empty &&
                txtAdherentCity.Text != string.Empty && txtAdherentAddress.Text != string.Empty)
            {
                var lastName     = txtAdherentLastName.Text;
                var firstName    = txtAdherentFirstName.Text;
                var zipCode      = txtAdherentZipCode.Text;
                var city         = txtAdherentCity.Text;
                var address      = txtAdherentAddress.Text;
                var subscription = 150;
                var club         = ManageClub.GetClubByName(cmbAdherentClub.Text);

                var newAdherent = new Adherent(lastName, firstName, zipCode, address, city, birthDate, subscription, club);

                ManageAdherent.AddAdherent(newAdherent);
                DBAdherent.AddAdherent(newAdherent);

                ManageAdherent.UpdateManagementAdherent();
                DBAdherent.UpdateAdherent();

                MessageBox.Show("L'adhérent a bien été ajouté.", "Ajout réussi",
                                MessageBoxButtons.OK, MessageBoxIcon.Information);
                Close();
            }
            else
            {
                MessageBox.Show("Veuillez remplir tous les champs.", "Champ(s) vide(s)",
                                MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }