protected void Page_Load(object sender, EventArgs e)
    {
        try
        {
            pollOperator = new PollDAL();

            if (!IsPostBack)
            {
                if (!string.IsNullOrEmpty(Request.QueryString[CommonStrings.ID]))
                {
                    Poll pollInfo = pollOperator.SelectPollByID(Convert.ToInt32(Request.QueryString[CommonStrings.ID]), (bool?)IsArabic);

                    if (pollInfo != null)
                    {
                        if (IsArabic)
                        {
                            lblQuestion.Text = pollInfo.TitleAr;
                        }
                        else
                        {
                            lblQuestion.Text = pollInfo.TitleEn;
                        }

                        lblTotalVotes.Text = string.Concat(Literals.TotalVotes, " = ", pollInfo.TotalVotes.ToString(), ' ', Literals.Votes);

                        dlResults.DataSource = pollInfo.Options;
                        dlResults.DataBind();
                    }
                }
            }
        }
        catch
        {
            Response.Redirect(Utility.AppendQueryString(PagesPathes.ErrorPage, new KeyValue(CommonStrings.BackUrl, CommonStrings.PollList)));
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        try
        {
            pollOperator = new PollDAL();

            if (!IsPostBack)
            {
                Poll currentPoll = pollOperator.SelectCurrentPoll((bool?)IsArabic);

                if (currentPoll != null)
                {
                    if (IsArabic)
                    {
                        lblQuestion.Text = currentPoll.TitleAr;
                    }
                    else
                    {
                        lblQuestion.Text = currentPoll.TitleEn;
                    }

                    if (!HasUserVoted(currentPoll.ID))
                    {
                        rdOptions.DataSource = currentPoll.Options;
                        rdOptions.DataValueField = PollOption.CommonColumns.ID;
                        if (IsArabic)
                        {
                            rdOptions.DataTextField = PollOption.TableColumns.TextAr;
                        }
                        else
                        {
                            rdOptions.DataTextField = PollOption.TableColumns.TextEn;
                        }
                        rdOptions.DataBind();

                        btnSubmit.CommandArgument = currentPoll.ID.ToString();

                        btnSubmit.Visible = true;
                        divOptions.Visible = true;
                        divResults.Visible = false;
                    }
                    else
                    {
                        dlResults.DataSource = currentPoll.Options;
                        dlResults.DataBind();
                        lblTotalVotes.Text = string.Concat(Literals.TotalVotes, " = ", currentPoll.TotalVotes.ToString(), ' ', Literals.Votes);

                        btnSubmit.Visible = false;
                        divOptions.Visible = false;
                        divResults.Visible = true;
                    }
                    lblEmptyDataMessage.Visible = false;
                }
                else
                {
                    lblEmptyDataMessage.Visible = true;
                }
            }
        }
        catch
        {
            Response.Redirect(Utility.AppendQueryString(PagesPathes.ErrorPage, new KeyValue(CommonStrings.BackUrl, CommonStrings.ViewDefault)));
        }
    }
Exemple #3
0
    protected void Page_Load(object sender, EventArgs e)
    {
        try
        {
            pollOperator = new PollDAL();

            if (!IsPostBack)
            {
                ViewState.Add("updatePollOption", false);

                if (!string.IsNullOrEmpty(Request.QueryString["ID"]))
                {
                    Poll pollInfo = pollOperator.SelectPollByID(Convert.ToInt32(Request.QueryString["ID"]), null);

                    if (pollInfo != null)
                    {
                        txtQuestionAr.Text = pollInfo.TitleAr;
                        txtQuestionEn.Text = pollInfo.TitleEn;

                        optionsList = pollInfo.Options;
                        BindGrid();
                    }
                }
                else
                {
                    optionsList = new List<PollOption>();
                }

                Session["PollOptionsList"] = optionsList;
            }
            else
            {
                optionsList = (List<PollOption>)Session["PollOptionsList"];
                updateOption = (bool)ViewState["updatePollOption"];
            }
        }
        catch
        {
            Response.Redirect(Utility.AppendQueryString(PagesPathes.ErrorPage, new KeyValue(CommonStrings.BackUrl, CommonStrings.AdminDefault)));
        }
    }
Exemple #4
0
 protected void Page_Load(object sender, EventArgs e)
 {
     try
     {
         pollOperator = new PollDAL();
         if (!IsPostBack)
         {
             BindGrid();
         }
     }
     catch
     {
         Response.Redirect(Utility.AppendQueryString(PagesPathes.ErrorPage, new KeyValue(CommonStrings.BackUrl, CommonStrings.AdminDefault)));
     }
 }