private void ChargerListeEvenement()
        {
            if (Session["connecte"] != null)
            {
                int      personneId = int.Parse(Session["personneID"].ToString());
                Personne pers       = new Personne();
                pers.id_personne = personneId;

                EvenementBLL evtService = new EvenementBLL();

                ddl_choixEvenement.DataSource     = evtService.getAllEvenementAvecListeByIdPersonne(pers);
                ddl_choixEvenement.DataTextField  = "libelle";
                ddl_choixEvenement.DataValueField = "id_evenement";

                ddl_choixEvenement.DataBind();

                if (ddl_choixEvenement.SelectedValue != null)
                {
                    ViewState["evenementIdSelection"] = ddl_choixEvenement.SelectedValue;
                }

                FailureText.Text = "";
            }
            else
            {
                Response.Redirect("~/");
            }
        }
Пример #2
0
        private void RechargerGridViewParticipants()
        {
            int cle = int.Parse(ViewState["evenementId"].ToString());

            EvenementBLL evtBLL = new EvenementBLL();

            ProjetCadeaux_Entites.Evenement evt = evtBLL.getEvenementById(cle);

            if (evt != null)
            {
                TitreEvenementLabel.Text   = evt.libelle;
                TitreEvenementLabelh3.Text = evt.libelle;
                dateEvenement.Text         = evt.dateEvenement.ToShortDateString();
                dateButoir.Text            = evt.dateButoir.ToShortDateString();

                recupererListeParticipants(evt);
            }
            else
            {
                TitreEvenementLabel.Text   = "";
                TitreEvenementLabelh3.Text = "";
                dateEvenement.Text         = "";
                dateButoir.Text            = "";


                FailureText.Text = "Cet évènement n'existe pas.";
            }
        }
        /// <summary>
        /// Rechargement de la grille des participants selon l'évènement
        /// </summary>
        private void RechargerGridViewParticipants()
        {
            int cle = int.Parse(ViewState["evenementId"].ToString());

            EvenementBLL evtBLL = new EvenementBLL();

            ProjetCadeaux_Entites.Evenement evt = evtBLL.getEvenementById(cle);

            if (evt != null)
            {
                TitreEvenementLabel.Text   = evt.libelle;
                TitreEvenementLabelh3.Text = evt.libelle;

                if (evt.id_admin == int.Parse(Session["personneID"].ToString()))
                {
                    recupererListeParticipants(evt);
                }
                else
                {
                    FailureText.Text = "Vous n'avez pas les droits pour consulter les informations de cet évènement.";
                }
            }
            else
            {
                TitreEvenementLabel.Text   = "";
                TitreEvenementLabelh3.Text = "";

                FailureText.Text = "Cet évènement n'existe pas.";
            }
        }
        /// <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.";
            }
        }
Пример #5
0
        private void Refresh()
        {
            if (Session["connecte"] != null)
            {
                EvenementBLL evtBLL = new EvenementBLL();

                string id_personne = Session["personneID"].ToString();

                List <Evenement> listeRetour = evtBLL.getAllEvenementByIdPersonne(id_personne);

                gridViewMesEvenements.DataSource = listeRetour;

                gridViewMesEvenements.DataBind();
            }
            else
            {
                Response.Redirect("~/");
            }
        }
        private void chargerListeEvenement()
        {
            if (Session["personneId"] != null)
            {
                EvenementBLL evtBLL = new EvenementBLL();

                List <Evenement> listeEvt = evtBLL.getAllEvenementByIdPersonne(Session["personneId"].ToString());

                DataTable retour = new DataTable();

                retour.Columns.Add("ID");
                retour.Columns.Add("nom");

                DataRow dr2 = retour.NewRow();
                dr2["ID"]  = "0";
                dr2["nom"] = "--";
                retour.Rows.Add(dr2);

                foreach (Evenement evt in listeEvt)
                {
                    String id      = evt.id_evenement.ToString();
                    String libelle = evt.libelle;

                    DataRow dr = retour.NewRow();
                    dr["ID"]  = id;
                    dr["nom"] = libelle;

                    retour.Rows.Add(dr);
                }

                ddl_listeEvenements.DataValueField = "ID";
                ddl_listeEvenements.DataTextField  = "nom";

                ddl_listeEvenements.DataSource = retour;

                ddl_listeEvenements.DataBind();
            }
        }
Пример #7
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["connecte"] != null && Request.Params["evenementId"] != null)
            {
                if (!IsPostBack)
                {
                    ViewState["evenementId"] = Request.Params["evenementId"].ToString();

                    RechargerGridViewParticipants();
                }

                if (ViewState["listePersonnesChargee"] == null || ViewState["listePersonnesChargee"].ToString() != "true")
                {
                    ParticipantBLL participantBLL = new ParticipantBLL();

                    List <Participant> listeParticipantAyantListeCadeau = new List <Participant>();
                    ProjetCadeaux_Entites.Evenement evt = new ProjetCadeaux_Entites.Evenement();
                    Participant connecte     = new Participant();
                    Personne    persConnecte = new Personne();

                    evt.id_evenement         = int.Parse(ViewState["evenementId"].ToString());
                    connecte.id_personne     = int.Parse(Session["personneID"].ToString());
                    persConnecte.id_personne = connecte.id_personne;

                    //Afficher le lien administration si admin
                    EvenementBLL evtService = new EvenementBLL();
                    evt = evtService.getEvenementById(evt.id_evenement);

                    if (estAdmin(persConnecte, evt))
                    {
                        linkAdministrerEvenement.Visible      = true;
                        linkAdministrerEvenement.NavigateUrl += evt.id_evenement;
                    }
                    else
                    {
                        linkAdministrerEvenement.Visible = false;
                    }

                    listeParticipantAyantListeCadeau = participantBLL.getAllParticipantSaufConnecteAyantListeByEvenement(evt, connecte);

                    DataTable retour = new DataTable();

                    retour.Columns.Add("ID");
                    retour.Columns.Add("nom");

                    DataRow dr2 = retour.NewRow();
                    dr2["ID"]  = "";
                    dr2["nom"] = "--";
                    retour.Rows.Add(dr2);

                    foreach (Participant part in listeParticipantAyantListeCadeau)
                    {
                        String id  = part.id_personne.ToString();
                        String nom = part.nom_participant;

                        DataRow dr = retour.NewRow();
                        dr["ID"]  = id;
                        dr["nom"] = nom;

                        retour.Rows.Add(dr);
                    }

                    listeParticipantAyantListe.DataValueField = "ID";
                    listeParticipantAyantListe.DataTextField  = "nom";

                    listeParticipantAyantListe.DataSource = retour;
                    listeParticipantAyantListe.DataBind();
                    ViewState["listePersonnesChargee"] = "true";
                }
            }
            else
            {
                Response.Redirect("~/");
            }
        }
        /// <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();
            }
        }
        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);
            }
        }