private void recupererListeParticipants(Evenement evt) { ParticipantBLL ptcpBLL = new ParticipantBLL(); List <Participant> listeParticipants = ptcpBLL.getAllParticipantByEvenement(evt); gridViewParticipants.DataSource = listeParticipants; gridViewParticipants.DataBind(); }
/// <summary> /// Action effectuée au moment du clic sur la recherche des personnes /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnRecherchePersonne_Click(object sender, EventArgs e) { string nom = rechercheNomParticipantTb.Text; string prenom = recherchePrenomParticipantTb.Text; int cle = int.Parse(Request.Params["evenementId"].ToString()); PersonnesBLL personnesService = new PersonnesBLL(); EvenementBLL evtBLL = new EvenementBLL(); ParticipantBLL ptcpBLL = new ParticipantBLL(); //Récupération des personnes que l'on a recherché List <Personne> listePersonnesRecherches = personnesService.recherchePersonne(nom, prenom); //Recherche des personnes qui font déjà partie de l'évènement Evenement evt = evtBLL.getEvenementById(cle); List <Participant> listeParticipants = ptcpBLL.getAllParticipantByEvenement(evt); //On retire les personnes participant déjà if (listeParticipants.Count > 0) { for (int i = 0; i < listePersonnesRecherches.Count; i++) { Personne pers = listePersonnesRecherches[i]; for (int j = 0; j < listeParticipants.Count; j++) { Participant part = listeParticipants[j]; if (part.id_personne == pers.id_personne) { listePersonnesRecherches.Remove(pers); i--; } } } } if (listePersonnesRecherches.Count > 0) { btnAjouterParticipant.Visible = true; gridViewPersonnesRecherche.DataSource = listePersonnesRecherches; gridViewPersonnesRecherche.DataBind(); } else { FailureText.Text = "Aucune personne ne correspond aux critères."; } }
/// <summary> /// Action effectuée lorsque l'on clique sur le bouton enregistrer les modifications /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnModifierParticipant_Click(object sender, EventArgs e) { List <Participant> listeParticipantsAModifier = new List <Participant>(); List <Participant> listeParticipants = new List <Participant>(); ParticipantBLL partService = new ParticipantBLL(); Participant partTemp = new Participant(); foreach (GridViewRow row in gridViewParticipants.Rows) { String id = gridViewParticipants.DataKeys[row.RowIndex]["id_participant"].ToString(); Participant part = new Participant(); part.id_participant = int.Parse(id); part.id_evenement = int.Parse(ViewState["evenementId"].ToString()); part.hasListe = ((CheckBox)row.FindControl("cbHasListe")).Checked; //On récupère l'id de la personne partTemp = partService.getAllInfosByParticipant(part); if (partTemp != null) { part.id_personne = partTemp.id_personne; } listeParticipants.Add(part); } //Ne garder que les participants modifiés int cle = int.Parse(ViewState["evenementId"].ToString()); EvenementBLL evtBLL = new EvenementBLL(); ParticipantBLL ptcpBLL = new ParticipantBLL(); Evenement evt = evtBLL.getEvenementById(cle); List <Participant> listeParticipantsBefore = ptcpBLL.getAllParticipantByEvenement(evt); if (listeParticipants.Count == listeParticipantsBefore.Count) { for (int i = 0; i < listeParticipants.Count; i++) { if (listeParticipants[i].id_participant == listeParticipantsBefore[i].id_participant && listeParticipants[i].hasListe != listeParticipantsBefore[i].hasListe) { listeParticipantsAModifier.Add(listeParticipants[i]); } } } //Modifier les participants if (listeParticipantsAModifier.Count > 0) { ParticipantBLL partBLL = new ParticipantBLL(); ListeIdeesCadeauxBLL listeService = new ListeIdeesCadeauxBLL(); Boolean retour = partBLL.modifierHasListesListeParticipants(listeParticipantsAModifier) && listeService.updateActiveListe(listeParticipantsAModifier, evt); if (retour) { SuccessText.Text = "Les modifications ont bien été prises en compte"; } else { FailureText.Text = "Les modifications n'ont pas pu être prises en compte"; } RechargerGridViewParticipants(); } }