/// <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(); } }
/// <summary> /// Action de suppression des participants sélectionnés /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnSupprimerParticipant_Click(object sender, EventArgs e) { //L'utilisateur a confirmé la suppression des participants if ("Y".Equals(supprimerParticipants.Value)) { Boolean connecteEstParticipantASupprimer = false; List <Participant> listeParticipantsASupprimer = new List <Participant>(); ParticipantBLL partService = new ParticipantBLL(); Participant partTemp = new Participant(); foreach (GridViewRow row in gridViewParticipants.Rows) { CheckBox cbChoixParticipant = ((CheckBox)row.FindControl("cbChoix")); if (cbChoixParticipant.Checked) { String id = gridViewParticipants.DataKeys[row.RowIndex]["id_participant"].ToString(); if (id.Equals(Session["personneID"].ToString())) { connecteEstParticipantASupprimer = true; } Participant part = new Participant(); part.id_participant = int.Parse(id); part.id_evenement = int.Parse(ViewState["evenementId"].ToString()); partTemp = partService.getAllInfosByParticipant(part); if (partTemp != null) { part.id_personne = partTemp.id_personne; } listeParticipantsASupprimer.Add(part); } } if (!connecteEstParticipantASupprimer) { ListeIdeesCadeauxBLL listeService = new ListeIdeesCadeauxBLL(); ProjetCadeaux_Entites.Evenement evt = new ProjetCadeaux_Entites.Evenement(); evt.id_evenement = int.Parse(ViewState["evenementId"].ToString()); Boolean retour = partService.supprimerListeParticipants(listeParticipantsASupprimer) && listeService.desactiverListe(listeParticipantsASupprimer, evt); if (retour) { SuccessText.Text = "Tous les participants sélectionnés ont pu être supprimés"; } else { FailureText.Text = "Les participants n'ont pas pu être supprimés"; } RechargerGridViewParticipants(); } else { FailureText.Text = "Vous ne pouvez supprimer l'administrateur de l'évènement"; } } }