コード例 #1
0
    protected void ComputeVoteColumn()
    {
        if (SessionState.Questionnaire != null)
        {
            if (GridViewContacts.Rows.Count > 0)
            {
                int   indexRow = GridViewContacts.Rows.Count - 1;
                Image vote     = ( Image )GridViewContacts.Rows[indexRow].FindControl("ImageVote");
                vote.EnableViewState = true;
                Label personneID   = ( Label )GridViewContacts.Rows[indexRow].FindControl("LabelPersonneGUID");
                Guid  personneGUID = new Guid(personneID.Text);

                Label labelVote = new Label();
                if (Request.QueryString["print"] != null || Request.QueryString["excel"] != null)
                {
                    vote.Visible = false;
                    labelVote    = ( Label )GridViewContacts.Rows[indexRow].FindControl("LabelVote");
                }

                // Optimiser
                if (CheckBoxDateVotes.Checked)
                {
                    DateTime dateVote = new DateTime();
                    bool     aVote    = Votes.ADejaVote(personneGUID, ref dateVote);
                    vote.ImageUrl = string.Format("~/App_Themes/" + Page.Theme.ToString() + "/Images/vote_{0}.gif", aVote == true ? "oui" : "non");

                    // Date du vote
                    if (aVote)
                    {
                        Label date = ( Label )GridViewContacts.Rows[indexRow].FindControl("LabelDateVotes");
                        date.Text         = dateVote.ToShortDateString();
                        date.ToolTip      = dateVote.ToShortTimeString();
                        labelVote.Visible = true;
                    }
                }
                else
                {
                    bool aVote = Votes.ADejaVote(personneGUID);
                    vote.ImageUrl = string.Format("~/App_Themes/" + Page.Theme.ToString() + "/Images/vote_{0}.gif", aVote == true ? "oui" : "non");

                    if (aVote)
                    {
                        labelVote.Visible = true;
                    }
                }

                // Colonne numero
                Label numero = ( Label )GridViewContacts.Rows[indexRow].FindControl("LabelNumero");
                int   num    = GridViewContacts.Rows.Count + (GridViewContacts.PageIndex * GridViewContacts.PageSize);
                numero.Text = num.ToString();
            }
        }
    }