/// <summary> /// Action effectuée lorsque l'on clique sur le bouton ajout des participants /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnAjouterParticipant_Click(object sender, EventArgs e) { //L'utilisateur a confirmé l'ajout des participants sélectionnés if ("Y".Equals(hiddenFieldAjouterParticipant.Value)) { List <Participant> listeParticipantsAAjouter = new List <Participant>(); ProjetCadeaux_Entites.Evenement evt = new ProjetCadeaux_Entites.Evenement(); evt.id_evenement = int.Parse(ViewState["evenementId"].ToString()); foreach (GridViewRow row in gridViewPersonnesRecherche.Rows) { CheckBox cbChoixPersonne = ((CheckBox)row.FindControl("cbChoixPersonne")); if (cbChoixPersonne.Checked) { CheckBox cbHasListe = ((CheckBox)row.FindControl("cbChoixListe")); String id = gridViewPersonnesRecherche.DataKeys[row.RowIndex]["id_personne"].ToString(); String nomSelect = row.Cells[3].Text; String prenomSelect = row.Cells[4].Text; Participant part = new Participant(); part.hasListe = cbHasListe.Checked; part.nom_participant = nomSelect + " " + prenomSelect; part.id_personne = int.Parse(id); part.id_evenement = int.Parse(ViewState["evenementId"].ToString()); listeParticipantsAAjouter.Add(part); } } gridViewPersonnesRecherche.DataSource = null; gridViewPersonnesRecherche.DataBind(); ParticipantBLL partBLL = new ParticipantBLL(); ListeIdeesCadeauxBLL listeService = new ListeIdeesCadeauxBLL(); Boolean retour = partBLL.ajouterListeParticipant(listeParticipantsAAjouter) && listeService.creerListeIdeesCadeaux(listeParticipantsAAjouter, evt); if (!retour) { FailureText.Text = "Tous les participants n'ont pas pû être ajoutés"; } else { SuccessText.Text = "Les participants ont été ajoutés"; } btnAjouterParticipant.Visible = false; RechargerGridViewParticipants(); } }
protected void btnAjouterEvt_Click(object sender, EventArgs e) { int idPersonne = int.Parse(Session["personneID"].ToString()); ProjetCadeaux_Entites.Evenement evt = new ProjetCadeaux_Entites.Evenement(); evt.libelle = TitreEvenementTb.Text; evt.dateEvenement = DateTime.Parse(dateEvenementTb.Text); evt.dateButoir = DateTime.Parse(dateButoirTb.Text); evt.id_admin = idPersonne; Participant participant = new Participant(); participant.dateAjout = DateTime.Now; participant.id_personne = idPersonne; participant.hasListe = hasListeCb.Checked; EvenementBLL evtBLL = new EvenementBLL(); ProjetCadeaux_Entites.Evenement evtRetour = evtBLL.creerEvenement(evt, participant); ListeIdeesCadeauxBLL listeIdeesService = new ListeIdeesCadeauxBLL(); if (evtRetour != null) { ListeIdeesCadeaux listeRetour = listeIdeesService.creerListeIdeesCadeaux(participant, evtRetour, hasListeCb.Checked); if (listeRetour != null) { SuccessText.Text = "L'évènement a bien été créé."; FailureText.Text = null; TitreEvenementTb.Text = ""; dateEvenementTb.Text = ""; dateButoirTb.Text = ""; hasListeCb.Checked = false; Page_Load(sender, e); } else { TitreEvenementTb.Text = ""; dateEvenementTb.Text = ""; dateButoirTb.Text = ""; hasListeCb.Checked = false; SuccessText.Text = null; FailureText.Text = "L'évènement a été créé, mais la liste n'a pas été créée."; Page_Load(sender, e); } } else { TitreEvenementTb.Text = ""; dateEvenementTb.Text = ""; dateButoirTb.Text = ""; hasListeCb.Checked = false; SuccessText.Text = null; FailureText.Text = "L'évènement n'a pas pu être créé."; Page_Load(sender, e); } }