protected void ButtonEffacerTousLesVotes_Click(object sender, EventArgs e)
 {
     QuestionsVotesEnBas.Clear();
     PanelReponsesEnBas.Controls.Clear();
     AfficherTousLesVotes = false;
     Response.Redirect("~/Poll/QuestionnaireStatAll.aspx");
 }
 protected void ButtonAfficherTousLesVotes_Click(object sender, EventArgs e)
 {
     QuestionsVotesEnBas.Clear();
     PanelReponsesEnBas.Controls.Clear();
     AfficherTousLesVotes = true;
     AfficherToutLesVotesEnBas(Guid.Empty);
 }
    void AfficherToutLesVotesEnBas(Guid pollQuestionID)
    {
        PanelReponsesEnBas.Controls.Clear();

        bool afficherDateVote = SessionState.CheckBox["CheckBoxAfficherDateVote"];
        PollQuestionCollection pollQuestionCollection = PollQuestionCollection.GetByQuestionnaire(SessionState.Questionnaire.QuestionnaireID);

        // On cumul les Questions cliquees par l'utilisateur
        if (pollQuestionID != Guid.Empty)
        {
            // La Collection se reduit a une seule Question
            PollQuestion pollQuestion = pollQuestionCollection.FindByPollQuestionID(pollQuestionID);

            // Cumuler les questions cliquees par l'utilisateur
            // Sauf si elle est deja dans QuestionsVotesEnBas
            //   cela permet d'eviter de cumuler encore quand on passe aux formulaires print ou excel
            bool trouve = false;
            foreach (PollQuestion q in QuestionsVotesEnBas)
            {
                if (q.PollQuestionId == pollQuestionID)
                {
                    trouve = true;
                    break;
                }
            }
            if (trouve == false)
            {
                QuestionsVotesEnBas.Add(pollQuestion);
            }
        }
        else
        {
            // On prend toutes les questions du questionnaire
            QuestionsVotesEnBas = pollQuestionCollection;
        }

        // Si une sous-population est a l'etude on affiche que cette sous-population AME13072010
        PersonneCollection personnesAffichees = new PersonneCollection();

        PollVoteCollection[] tableauPollVotespersonnesAffichees;
        if (PersonnesOntReponduATout.Count > 0)
        {
            personnesAffichees = PersonnesOntReponduATout;
            // Il faut reafficher PanelReponse sinon il disparait
            // Attention ici on est appellé par ListBoxQui_SelectedIndexChange donc on doit faire un Clear
            PanelReponses.Controls.Clear();
            AfficherEnHautReponsesDeSousPopulation();
            tableauPollVotespersonnesAffichees = TableauVotesPersonnesOntReponduATout;
        }
        else
        {
            personnesAffichees = Personnes;
            tableauPollVotespersonnesAffichees = TableauVotesPersonnes;
        }

        foreach (PollQuestion question in QuestionsVotesEnBas)
        {
            PollAnswerCollection reponses = PollAnswerCollection.GetByPollQuestionID(question.PollQuestionId);

            Label labelQ = new Label();
            labelQ.CssClass = "LabelQuestionStyle";
            labelQ.Text     = question.Rank.ToString() + " - " + question.Question;

            Table     tableQ = new Table();
            TableCell cellQ  = new TableCell();
            TableRow  rowQ   = new TableRow();

            cellQ.Controls.Add(labelQ);
            rowQ.Controls.Add(cellQ);
            tableQ.Controls.Add(rowQ);
            PanelReponsesEnBas.Controls.Add(tableQ);

            foreach (PollAnswer reponse in reponses)
            {
                Table     tableR = new Table();
                TableCell cellR  = new TableCell();
                TableRow  rowR   = new TableRow();

                Label labelR = new Label();
                labelR.CssClass = "HyperLinkQuestionEnCoursStyle";
                if (FormulaireEnModeExcel)
                {
                    labelR.Text = "r : "; // ajouter un petit " r : " pour que ce con d'excel ne prenne pas ca pour une date
                }
                labelR.Text += reponse.Rank.ToString() + " - " + reponse.Answer;

                cellR.Controls.Add(labelR);
                rowR.Controls.Add(cellR);
                tableR.Controls.Add(rowR);
                PanelReponsesEnBas.Controls.Add(tableR);

                Table tableP = new Table();

                int indexPollVotes = 0;
                foreach (Personne p in personnesAffichees)
                {
                    PollVoteCollection pvc      = tableauPollVotespersonnesAffichees[indexPollVotes].FindByAnswerID(reponse.PollAnswerId);
                    string             personne = FormatPersonne(p);

                    foreach (PollVote pv in pvc)
                    {
                        // Table de Reponses des Interviewes
                        TableCell cellP = new TableCell();
                        TableRow  rowP  = new TableRow();

                        if (afficherDateVote)
                        {
                            TableCell cellD = new TableCell();
                            cellD.Text = pv.CreationDate.ToString();
                            rowP.Cells.Add(cellD);
                        }

                        cellP.Text     = personne; // OPT17072010 Strings.TexteToHTML( personne );
                        cellP.CssClass = "TableReponsePersonneStyle";
                        rowP.Cells.Add(cellP);
                        tableP.Rows.Add(rowP);
                        // Pour les reponses textuelles
                        if (pv.Vote != "")
                        {
                            TableCell cellV = new TableCell();
                            cellV.Text = Strings.TexteToHTML(pv.Vote);
                            rowP.Cells.Add(cellV);
                            tableP.Rows.Add(rowP);
                        }
                    }
                    if (pvc.Count > 0 /* votant */)
                    {
                        PanelReponsesEnBas.Controls.Add(tableP);
                    }
                    indexPollVotes += 1;
                }
            }
        }
    }