private void showCandidateButton_Click(object sender, EventArgs e)
 {
     if (selectSeatComboBox.SelectedItem != null)
     {
         candidateGrid.DataSource = CandidateHandler.GetViewAbleCandidatesAdmin(selectSeatComboBox.SelectedItem.ToString());
     }
     else
     {
         MessageBox.Show("Please select seat.");
     }
 }
 private void deleteCandidateButton_Click(object sender, EventArgs e)
 {
     if (candidateGrid.DataSource != null)
     {
         int          rowIndex      = candidateGrid.CurrentRow.Index;
         string       candidateName = candidateGrid.Rows[rowIndex].Cells[1].Value.ToString();
         string       seatName      = candidateGrid.Rows[rowIndex].Cells[2].Value.ToString();
         string       teamName      = candidateGrid.Rows[rowIndex].Cells[3].Value.ToString();
         DialogResult dr            = MessageBox.Show(string.Format("Are you sure to delete candidate '{0}' from team '{1}'from the database?", candidateName, teamName), "Confirm?", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
         if (dr == DialogResult.Yes)
         {
             CandidateHandler.DeleteCandidate(candidateName, seatName, teamName);
             MessageBox.Show("Deleted");
             candidateGrid.DataSource = CandidateHandler.GetViewAbleCandidatesAdmin(seatName);
         }
     }
 }
Example #3
0
        private void voteButton_Click(object sender, EventArgs e)
        {
            int status = CenterHandler.GetCenterStatus(LoginHandler.CenterId);

            if (status == 1)
            {
                try
                {
                    long         nId           = long.Parse(nIdTextBox.Text);
                    int          rowIndex      = candidateGrid.CurrentRow.Index;
                    int          candidateId   = int.Parse(candidateGrid.Rows[rowIndex].Cells[4].Value.ToString());
                    string       candidateName = candidateGrid.Rows[rowIndex].Cells[0].Value.ToString();
                    string       teamName      = candidateGrid.Rows[rowIndex].Cells[2].Value.ToString();
                    DialogResult dr            = MessageBox.Show(string.Format("Are you sure to vote '{0}' from team '{1}'?", candidateName, teamName), "Confirm?", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                    if (dr == DialogResult.Yes)
                    {
                        if (VoterHandler.Voted(nId))
                        {
                            VoterHandler.Vote(candidateId);
                            MessageBox.Show("Vote counted.");
                            nIdTextBox.Text = "";
                            int seatId = CenterHandler.GetSeatId(LoginHandler.CenterId);
                            candidateGrid.DataSource = CandidateHandler.GetViewAbleCandidates(seatId);
                        }
                        else
                        {
                            MessageBox.Show("Vote not counted. Contact Polling Agent.");
                        }
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Enter NID properly.");
                }
            }
            else if (status == 2)
            {
                MessageBox.Show("Center Blocked.");
            }
            else
            {
                MessageBox.Show("Election is not going on.");
            }
        }
 private void addCandidateButton_Click(object sender, EventArgs e)
 {
     if (candidateNameTextBox.Text != "" && teamComboBox.SelectedItem != null && districtComboBox.SelectedItem != null && seatComboBox.SelectedItem != null)
     {
         DialogResult dr = MessageBox.Show(string.Format("Are you sure to add candidate '{0}' from team '{1}' in seat '{2}'?", candidateNameTextBox.Text, teamComboBox.SelectedItem.ToString(), seatComboBox.SelectedItem.ToString()), "Confirm?", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
         if (dr == DialogResult.Yes)
         {
             if (CandidateHandler.AddCandidate(candidateNameTextBox.Text, seatComboBox.SelectedItem.ToString(), teamComboBox.SelectedItem.ToString()))
             {
                 MessageBox.Show("Successfully added candidate.");
             }
             else
             {
                 MessageBox.Show("Candidate from the team already present.");
             }
             candidateNameTextBox.Text = "";
             candidateGrid.DataSource  = CandidateHandler.GetViewAbleCandidatesAdmin(seatComboBox.SelectedItem.ToString());
         }
     }
     else
     {
         MessageBox.Show("Enter the values properly.");
     }
 }
Example #5
0
        private void VotingWindow_Load(object sender, EventArgs e)
        {
            int seatId = CenterHandler.GetSeatId(LoginHandler.CenterId);

            candidateGrid.DataSource = CandidateHandler.GetViewAbleCandidates(seatId);
        }