protected void RowCommand_click(object sender, GridViewCommandEventArgs e) { #region action suppression if (e.CommandName == "supprimer") { int index = Convert.ToInt32(e.CommandArgument); ListeIdeesCadeauxBLL idee = new ListeIdeesCadeauxBLL(); String cle = gridViewMesCadeaux.DataKeys[index].Value.ToString(); IdeeCadeauPourListe ideeCadeau = new IdeeCadeauPourListe(); ideeCadeau.id_ideeCadeau = int.Parse(cle); idee.supprimerCadeauFromListe(ideeCadeau); Refresh(); } #endregion #region action modification else if (e.CommandName == "modifier") { int index = Convert.ToInt32(e.CommandArgument); IdeesCadeaux idee = new IdeesCadeaux(); Liens lien = new Liens(); String cle = gridViewMesCadeaux.DataKeys[index].Value.ToString(); ViewState["cleIdeeCadeauModification"] = cle; viderForm(); updatePanelAjoutCadeaux.Visible = true; updatePanelIdeesCadeaux.Visible = false; btn_AjouterCadeau.Visible = false; btn_ModifierCadeau.Visible = true; DataTable dt = idee.getIdeeCadeauById(cle); TitreCadeau.Text = dt.Rows[0].ItemArray.GetValue(1).ToString(); Description.Text = dt.Rows[0].ItemArray.GetValue(2).ToString(); Prix.Text = dt.Rows[0].ItemArray.GetValue(3).ToString(); Priorite.Text = dt.Rows[0].ItemArray.GetValue(0).ToString(); DataTable dt2 = lien.getInfosLiensByIdeeCadeau(cle); for (int i = 0; i < dt2.Rows.Count; i++) { switch (i) { case 0: tb_lien1.Text = dt2.Rows[i].ItemArray.GetValue(0).ToString(); break; case 1: tb_lien2.Text = dt2.Rows[i].ItemArray.GetValue(0).ToString(); break; case 2: tb_lien3.Text = dt2.Rows[i].ItemArray.GetValue(0).ToString(); break; case 3: tb_lien4.Text = dt2.Rows[i].ItemArray.GetValue(0).ToString(); break; case 4: tb_lien5.Text = dt2.Rows[i].ItemArray.GetValue(0).ToString(); break; } } } #endregion }
protected void RowCommand_click(object sender, GridViewCommandEventArgs e) { int index = Convert.ToInt32(e.CommandArgument); String cle = gridView_cadeaux.DataKeys[index].Value.ToString(); IdeesCadeaux idees = new IdeesCadeaux(); DataTable dt = new DataTable(); Votes votes = new Votes(); DataTable dtVote = new DataTable(); dtVote = votes.getTotalParticipationByIdCadeau(cle); dt = idees.getIdeeCadeauById(cle); DataTable dtLiens = new DataTable(); Liens liens = new Liens(); dtLiens = liens.getInfosLiensByIdeeCadeau(cle); #region vidage/remplissage des liens viderLiens(); if (dtLiens.Rows.Count > 0) { lien1_nom.Text = dtLiens.Rows[0].ItemArray.GetValue(0).ToString(); Lien1.HRef = dtLiens.Rows[0].ItemArray.GetValue(0).ToString(); if (dtLiens.Rows.Count > 1) { Lien2.HRef = dtLiens.Rows[1].ItemArray.GetValue(0).ToString(); lien2_nom.Text = dtLiens.Rows[1].ItemArray.GetValue(0).ToString(); if (dtLiens.Rows.Count > 2) { Lien3.HRef = dtLiens.Rows[2].ItemArray.GetValue(0).ToString(); lien3_nom.Text = dtLiens.Rows[2].ItemArray.GetValue(0).ToString(); if (dtLiens.Rows.Count > 3) { Lien4.HRef = dtLiens.Rows[3].ItemArray.GetValue(0).ToString(); lien4_nom.Text = dtLiens.Rows[3].ItemArray.GetValue(0).ToString(); if (dtLiens.Rows.Count > 4) { Lien5.HRef = dtLiens.Rows[4].ItemArray.GetValue(0).ToString(); lien5_nom.Text = dtLiens.Rows[4].ItemArray.GetValue(0).ToString(); } } } } } #endregion ViewState["cleIdeeCadeauVote"] = cle; updatePanel_participationCadeau.Visible = true; SuccessText.Text = ""; titreIdeeCadeau.Text = dt.Rows[0].ItemArray.GetValue(1).ToString(); descriptionIdeeCadeau.Text = dt.Rows[0].ItemArray.GetValue(2).ToString(); ordreDePrixIdeeCadeau.Text = dt.Rows[0].ItemArray.GetValue(3).ToString(); DataTable dtVoteModif = new DataTable(); if ((dtVoteModif = votes.getInfosParticipationCadeauByPersonne(cle, Session["personneID"].ToString())).Rows.Count >= 1) { radioButtonList_vote.SelectedValue = dtVoteModif.Rows[0].ItemArray.GetValue(1).ToString(); button_sauvegardeParticipation.Visible = false; button_modificationParticipation.Visible = true; button_sauvegardeParticipation.ValidationGroup = ""; button_modificationParticipation.ValidationGroup = "participation"; ViewState["ModificationVote"] = "true"; } else { button_sauvegardeParticipation.Visible = true; button_modificationParticipation.Visible = false; button_sauvegardeParticipation.ValidationGroup = "participation"; button_modificationParticipation.ValidationGroup = ""; ViewState["ModificationVote"] = ""; } }
protected void gridView_cadeauResponsable_OnRowCommand(object sender, GridViewCommandEventArgs e) { updatePanel_detailCadeau.Visible = true; int index = Convert.ToInt32(e.CommandArgument); IdeesCadeaux idee = new IdeesCadeaux(); Liens lien = new Liens(); Votes vote = new Votes(); String cle = gridView_cadeauResponsable.DataKeys[index].Value.ToString(); DataTable dtIdeeCadeau = new DataTable(); dtIdeeCadeau = idee.getIdeeCadeauById(cle); DataTable dtLiens = new DataTable(); dtLiens = lien.getInfosLiensByIdeeCadeau(cle); string nbVotesOui = vote.getNombreOuiByIdCadeau(cle); string nbVotesPourquoiPas = vote.getNombrePourquoiPasByIdCadeau(cle); string nbVotesNon = vote.getNombreNonByIdCadeau(cle); titreIdeeCadeau.Text = dtIdeeCadeau.Rows[0].ItemArray.GetValue(1).ToString(); descriptionIdeeCadeau.Text = dtIdeeCadeau.Rows[0].ItemArray.GetValue(2).ToString(); ordreDePrixIdeeCadeau.Text = dtIdeeCadeau.Rows[0].ItemArray.GetValue(3).ToString(); prioriteCadeau.Text = dtIdeeCadeau.Rows[0].ItemArray.GetValue(0).ToString(); lbl_votesOui.Text = nbVotesOui; lbl_votesPourquoiPas.Text = nbVotesPourquoiPas; lbl_votesNon.Text = nbVotesNon; #region vidage/remplissage des liens viderLiens(); if (dtLiens.Rows.Count > 0) { Lien1.HRef = dtLiens.Rows[0].ItemArray.GetValue(0).ToString(); lien1_nom.Text = dtLiens.Rows[0].ItemArray.GetValue(0).ToString(); if (dtLiens.Rows.Count > 1) { Lien2.HRef = dtLiens.Rows[1].ItemArray.GetValue(0).ToString(); lien2_nom.Text = dtLiens.Rows[1].ItemArray.GetValue(0).ToString(); if (dtLiens.Rows.Count > 2) { Lien3.HRef = dtLiens.Rows[2].ItemArray.GetValue(0).ToString(); lien3_nom.Text = dtLiens.Rows[2].ItemArray.GetValue(0).ToString(); if (dtLiens.Rows.Count > 3) { Lien4.HRef = dtLiens.Rows[3].ItemArray.GetValue(0).ToString(); lien4_nom.Text = dtLiens.Rows[3].ItemArray.GetValue(0).ToString(); if (dtLiens.Rows.Count > 4) { Lien5.HRef = dtLiens.Rows[4].ItemArray.GetValue(0).ToString(); lien5_nom.Text = dtLiens.Rows[4].ItemArray.GetValue(0).ToString(); } } } } } #endregion }