protected void Page_Load(object sender, EventArgs e)
        {
            DataSet   candidateDataSet = vbl.GetCandidiateList();
            DataTable dtVotingResult   = vbl.GetVotingResult();
            DataTable dt;

            if (!IsPostBack)
            {
                dt = candidateDataSet.Tables[0];

                foreach (DataRow row in dt.Rows)
                {
                    if (row["Position"].ToString() == "President")
                    {
                        RadioButtonListPresident.Items.Add(new ListItem(row["Name"].ToString(), row["Id"].ToString()));
                    }
                    else if (row["Position"].ToString() == "Vice-President")
                    {
                        RadioButtonListVicePresident.Items.Add(new ListItem(row["Name"].ToString(), row["Id"].ToString()));
                    }
                    else if (row["Position"].ToString() == "Secretary")
                    {
                        RadioButtonListSecretary.Items.Add(new ListItem(row["Name"].ToString(), row["Id"].ToString()));
                    }
                    else if (row["Position"].ToString() == "Treasurer")
                    {
                        RadioButtonListTreasurer.Items.Add(new ListItem(row["Name"].ToString(), row["Id"].ToString()));
                    }
                }
            }
            this.BindDummyRow();
            GridViewResult.DataSource = dtVotingResult;
            GridViewResult.DataBind();
            int id = Convert.ToInt32(Session["VoterId"]);

            if (id == 0)
            {
                Response.Redirect("Login");
            }
            vp = vbl.GetVoterDetails(id);

            lblName.Text    = vp.FullName;
            lblVoterId.Text = vp.VoterId.ToString();

            Chart1.Series["series1"].XValueMember  = "Candidate Name";
            Chart1.Series["series1"].YValueMembers = "Votes";
            Chart1.Series["series1"].ChartType     = System.Web.UI.DataVisualization.Charting.SeriesChartType.Column;
            Chart1.DataSource = dtVotingResult;
            Chart1.DataBind();

            Master.AfterLogInPanelControl.Visible  = true;
            Master.BeforeLogInPanelControl.Visible = false;
        }
Esempio n. 2
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         voterDataset = vbl.GetVoterList();
         GridViewVoterList.DataSource = voterDataset;
         GridViewVoterList.DataBind();
         candidateDataset = vbl.GetCandidiateList();
         GridViewCandidateList.DataSource = candidateDataset;
         GridViewCandidateList.DataBind();
     }
     GridViewVotingResult.DataSource = vbl.GetVotingResult();
     GridViewVotingResult.DataBind();
 }