private void btnAjoutEleve_Click(object sender, EventArgs e) { bool errorActive = false; char sexeSelect = ' '; DateTime dateMaj = new DateTime(); dateMaj = DateTime.Now; // verification des champs du formulaire ajour d'un adhérent if (!GestionAdherent.GetRegexString(txtNom.Text, Adherent.REGEX_STRING1)) { errorNom.SetError(txtNom, "Nom saisi incorrect, aucun caratères spéciaux et aucun espace, 3 à 20 caractères"); errorActive = true; } else { errorNom.SetError(txtNom, ""); } if (!GestionAdherent.GetRegexString(txtPrenom.Text, Adherent.REGEX_STRING1)) { errorPrenom.SetError(txtPrenom, "Prénom saisi incorrect, aucun caratères spéciaux et aucun espace, 3 à 20 caractères"); errorActive = true; } else { errorPrenom.SetError(txtPrenom, ""); } if (Convert.ToString(comboBoxSexe.SelectedValue) == GenreFemme) { sexeSelect = 'F'; } else { sexeSelect = 'H'; } if (!GestionAdherent.GetRegexString(txtTel.Text, Adherent.REGEX_DIGIT1)) { errorTel.SetError(txtTel, "Numéro de téléphone incorrect << exemple : 0102030102 >>"); errorActive = true; } else { errorTel.SetError(txtTel, ""); } if (!GestionAdherent.GetRegexString(txtTelParent.Text, Adherent.REGEX_DIGIT1)) { errorTelParent.SetError(txtTelParent, "Numéro de téléphone incorrect << exemple : 0102030102 >>"); errorActive = true; } else { errorTelParent.SetError(txtTelParent, ""); } if (string.IsNullOrEmpty(txtMail.Text)) { errorMail.SetError(txtMail, "Veuillez saisir un mail"); errorActive = true; } else { try { string addressMail = new MailAddress(txtMail.Text).Address; errorMail.SetError(txtMail, ""); } catch (Exception ex) { errorMail.SetError(txtMail, ex.Message); errorActive = true; } } if (!GestionAdherent.GetRegexString(txtId.Text, Adherent.REGEX_STRING_LOGIN1)) { errorId.SetError(txtId, "Identifiant saisi incorrect << exemple : nom.prenom >>"); errorActive = true; } else { if (GestionAdherent.VerifAdherent(txtId.Text)) { errorId.SetError(txtId, "Identifiant déjà utilisé"); errorActive = true; } else { errorId.SetError(txtId, ""); } } if (!GestionAdherent.GetRegexString(txtMdp.Text, Adherent.REGEX_PASSWORD1)) { errorMdp.SetError(txtMdp, "Votre mot de passe doit comporter au minimum '1 miniscule, 1 majuscule, 1 chiffre, 1 charactère spécial"); errorActive = true; } else { errorMdp.SetError(txtMdp, ""); } if (txtMdp.Text != txtConfirmMdp.Text) { errorConfirmMdp.SetError(txtConfirmMdp, "Veuillez saisir le même mot de passe"); errorActive = true; } if (errorActive) { MessageBox.Show("Error : eleve non ajouté", "Erreur", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { Adherent unAdherent = new Adherent(0, txtNom.Text, txtPrenom.Text, dtpNaissance.Value, txtTel.Text, txtMail.Text, txtTelParent.Text, checkPrelevement.Checked, sexeSelect, txtId.Text, txtMdp.Text, dateMaj, false, Utilisateur.UtilisateurLog, (Classe)comboBoxClasse.SelectedItem); if (GestionAdherent.CreerAdherent(unAdherent)) { MessageBox.Show("Valide : eleve ajouté", "Valide", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); this.Hide(); // fermeture du formulaire actuel FrmAjoutEleve frmAjoutEleve = new FrmAjoutEleve(); frmAjoutEleve.Show(); // ouverture du formulaire } else { MessageBox.Show("Error : error lors de l'insertion", "Erreur", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }
private void btnModifEleve_Click(object sender, EventArgs e) { bool errorActive = false; char sexeSelect = Adherent.AdherentSauvegarder.Sexe; int id = Adherent.AdherentSauvegarder.Id; DateTime dateMaj = new DateTime(); dateMaj = DateTime.Now; // verification des champs du formulaire ajour d'un adhérent // verification du champs nom if (!GestionAdherent.GetRegexString(txtNom.Text, Adherent.REGEX_STRING1)) { errorNom.SetError(txtNom, "Nom saisi incorrect"); errorActive = true; } else { errorNom.SetError(txtNom, ""); } // verification du champs prenom if (!GestionAdherent.GetRegexString(txtPrenom.Text, Adherent.REGEX_STRING1)) { errorPrenom.SetError(txtPrenom, "Prenom saisi incorrect"); errorActive = true; } else { errorPrenom.SetError(txtPrenom, ""); } if (Convert.ToString(comboBoxSexe.SelectedValue) == "Femme") { sexeSelect = 'F'; } else { sexeSelect = 'H'; } // verification du champs telephone if (!GestionAdherent.GetRegexString(txtTel.Text, Adherent.REGEX_DIGIT1)) { errorTel.SetError(txtTel, "Numéro de téléphone incorrect << exemple : 0102030102 >>"); errorActive = true; } else { errorTel.SetError(txtTel, ""); } // verification du champs tel parent if (!GestionAdherent.GetRegexString(txtTelParent.Text, Adherent.REGEX_DIGIT1)) { errorTelParent.SetError(txtTelParent, "Numéro de téléphone incorrect << exemple : 0102030102 >>"); errorActive = true; } else { errorTelParent.SetError(txtTelParent, ""); } // verification du champs mail if (string.IsNullOrEmpty(txtMail.Text)) { errorMail.SetError(txtMail, "Veuillez saisir un mail"); errorActive = true; } else { try { string addressMail = new MailAddress(txtMail.Text).Address; errorMail.SetError(txtMail, ""); } catch (Exception ex) { errorMail.SetError(txtMail, ex.Message); errorActive = true; } } // verification du champs identifiant if (!GestionAdherent.GetRegexString(txtId.Text, Adherent.REGEX_STRING_LOGIN1)) { errorId.SetError(txtId, "Identifiant saisi incorrect << exemple : nom.prenom >>"); errorActive = true; } else { if (GestionAdherent.VerifAdherentByLoginAndId(txtId.Text, Adherent.AdherentSauvegarder.Id)) { errorId.SetError(txtId, "Identifiant déjà utilisé"); errorActive = true; } else { errorId.SetError(txtId, ""); } } // verification du champs mot de passe if (!GestionAdherent.GetRegexString(txtMdp.Text, Adherent.REGEX_PASSWORD1)) { errorMdp.SetError(txtMdp, "Votre mot de passe doit comporter au minimum '1 miniscule, 1 majuscule, 1 chiffre, 1 charactère spécial"); errorActive = true; } else { errorMdp.SetError(txtMdp, ""); } // verification du champs confirmation mot de passe si il egale au champs mot de passe if (txtMdp.Text != txtConfirmMdp.Text) { errorConfirmMdp.SetError(txtConfirmMdp, "Veuillez saisir le même mot de passe"); errorActive = true; } // verification si aucune erreur n'a été déclencher if (errorActive) { MessageBox.Show("Error : eleve non modifié", "Erreur", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { Adherent unAdherent = new Adherent(id, txtNom.Text, txtPrenom.Text, dtpNaissance.Value, txtTel.Text, txtMail.Text, txtTelParent.Text, checkPrelevement.Checked, sexeSelect, txtId.Text, txtMdp.Text, dateMaj, checkArchivage.Checked, Utilisateur.UtilisateurLog, (Classe)comboBoxClasse.SelectedItem); // modification de l'adherent if (GestionAdherent.ModifierAdherent(unAdherent)) { MessageBox.Show("Valide : eleve modifié", "Valide", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); this.Hide(); // fermeture du formulaire actuel FrmDetailsEleve frmDetailsEleve = new FrmDetailsEleve(); frmDetailsEleve.Show(); // ouverture du formulaire } else { MessageBox.Show("Error : error lors de l'update", "Erreur", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }