/// <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(); } }