Example #1
0
        private void addVoterButton_Click(object sender, EventArgs e)
        {
            try
            {
                if (nIdTextBox.Text != "" && centerComboBox.SelectedItem != null && seatComboBox.SelectedItem != null)
                {
                    DialogResult dr = MessageBox.Show(string.Format("Are you sure to add voter with NID '{0}' under center '{1}'?", nIdTextBox.Text, centerComboBox.SelectedItem.ToString()), "Confirm?", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                    if (dr == DialogResult.Yes)
                    {
                        long nId = long.Parse(nIdTextBox.Text);
                        if (VoterHandler.AddVoter(nId, seatComboBox.SelectedItem.ToString(), centerComboBox.SelectedItem.ToString()))
                        {
                            MessageBox.Show("Successfully added voter.");
                            voterGrid.DataSource = VoterHandler.GetVoters(seatComboBox.SelectedItem.ToString(), centerComboBox.SelectedItem.ToString());
                        }
                        else
                        {
                            MessageBox.Show("Voter already present.");
                        }

                        nIdTextBox.Text = "";
                    }
                }
                else
                {
                    MessageBox.Show("Enter Information Properly.");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Enter NID properly.");
            }
        }
Example #2
0
 private void showVoterButton_Click(object sender, EventArgs e)
 {
     if (selectSeatComboBox.SelectedItem != null && selectCenterComboBox.SelectedItem != null)
     {
         voterGrid.DataSource = VoterHandler.GetVoters(selectSeatComboBox.SelectedItem.ToString(), selectCenterComboBox.SelectedItem.ToString());
     }
     else
     {
         MessageBox.Show("Select Center.");
     }
 }
        private void checkButton_Click(object sender, EventArgs e)
        {
            int status = CenterHandler.GetCenterStatus(LoginHandler.CenterId);

            if (status == 1)
            {
                if (nidTextBox.Text != "")
                {
                    try
                    {
                        long nid         = long.Parse(nidTextBox.Text);
                        int  voterStatus = VoterHandler.CheckStatus(nid);
                        if (voterStatus == 0)
                        {
                            MessageBox.Show("Cannot find the NID.");
                        }
                        else if (voterStatus == 1)
                        {
                            MessageBox.Show("Valid NID.");
                        }
                        else if (voterStatus == 2)
                        {
                            MessageBox.Show("Valid NID and Processed, but did not vote");
                        }
                        else if (voterStatus == 3)
                        {
                            MessageBox.Show("Vote Completed");
                        }
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show("Enter proper NID.");
                    }
                }
                else
                {
                    MessageBox.Show("Enter proper NID.");
                }
            }
            else if (status == 2)
            {
                MessageBox.Show("Center is blocked.");
            }
            else
            {
                MessageBox.Show("Election is not going on currently.");
            }
        }
Example #4
0
 private void deleteVoterButton_Click(object sender, EventArgs e)
 {
     if (voterGrid.DataSource != null)
     {
         int          rowIndex = voterGrid.CurrentRow.Index;
         DialogResult dr       = MessageBox.Show(string.Format("Are you sure to delete voter '{0}' from the database?", voterGrid.Rows[rowIndex].Cells[0].Value.ToString()), "Confirm?", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
         if (dr == DialogResult.Yes)
         {
             long nid = long.Parse(voterGrid.Rows[rowIndex].Cells[0].Value.ToString());
             VoterHandler.DeleteVoter(nid);
             voterGrid.DataSource = VoterHandler.GetVoters(selectSeatComboBox.SelectedItem.ToString(), selectCenterComboBox.SelectedItem.ToString());
         }
     }
     else
     {
         MessageBox.Show("Select item to delete.");
     }
 }
Example #5
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 permitButton_Click(object sender, EventArgs e)
        {
            int status = CenterHandler.GetCenterStatus(LoginHandler.CenterId);

            if (status == 1)
            {
                if (nidTextBox.Text != "")
                {
                    try
                    {
                        long         nid = long.Parse(nidTextBox.Text);
                        DialogResult dr  = MessageBox.Show(string.Format("Are you sure to permit voter with NID {0} to vote?", nid), "Confirm?", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                        if (dr == DialogResult.Yes)
                        {
                            if (VoterHandler.Permit(nid))
                            {
                                MessageBox.Show("Voter Permitted.");
                            }
                            else
                            {
                                MessageBox.Show("Voter Not Permitted. Please check status.");
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show("Enter proper NID.");
                    }
                }
                else
                {
                    MessageBox.Show("Enter proper NID.");
                }
            }
            else if (status == 2)
            {
                MessageBox.Show("Center Blocked.");
            }
            else
            {
                MessageBox.Show("Election is not going on currently.");
            }
        }