//DGV public void refreshDgvParticipant() { dgvParticipant.Rows.Clear(); List <Participant> LesParticipants = DAOParticipant.getAllParticipants(); foreach (var p in LesParticipants) { dgvParticipant.Rows.Add(p.Id, p.Nom, p.Prenom, GetLibForType(p.IdType), p.Adresse, p.Mail, p.NumPortable, GetLibForAtelier(p.IdAtelier), GetLibForHorraireBenevoles(p.IdHorraireBenevoles)); } }
private void buttonCreateParticipant_Click(object sender, EventArgs e) { string addnom = textBoxNom.Text; string addprenom = textBoxPrenom.Text; int addtype = GetIdForType(comboBoxType.SelectedItem.ToString()); string addadresse = textBoxAdresse.Text; string addmail = textBoxMail.Text; string addnumTel = textBoxTel.Text; int addatelier = GetIdForAtelier(comboBoxAtelier.SelectedItem.ToString()); int addhorraire = GetIdForHorraireBenevoles(comboBoxBenevole.SelectedItem.ToString()); if (textBoxNom.Text.Length != 0 && textBoxPrenom.Text.Length != 0 && textBoxAdresse.Text.Length != 0 && textBoxMail.Text.Length != 0 && textBoxTel.Text.Length != 0) { if (textBoxTel.Text.Length == 10) { if (addhorraire == 1 && addtype == 3 || addhorraire == 2 && addtype == 3 || addhorraire == 3 && addtype == 1 || addhorraire == 3 && addtype == 2) { DAOParticipant.AjouterParticipant(addnom, addprenom, addtype, addadresse, addmail, addnumTel, addatelier, addhorraire); //Message Box de validation MessageBox.Show("Le participant a correctement été ajouté"); //Clear des champs de saisis textBoxAdresse.Clear(); textBoxMail.Clear(); textBoxNom.Clear(); textBoxPrenom.Clear(); textBoxTel.Clear(); } else { MessageBox.Show("Erreur d'attribution des rôles", "erreur", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } else { MessageBox.Show("Le numéro de téléphone doit être composé de 10 caractères numériques", "erreur", MessageBoxButtons.OK, MessageBoxIcon.Warning); textBoxTel.Clear(); } } else { MessageBox.Show("Tout les champs doivent être remplies", "erreur", MessageBoxButtons.OK, MessageBoxIcon.Warning); } //refresh bdd refreshDgvParticipant(); }