Example #1
0
 private void addCenterButton_Click(object sender, EventArgs e)
 {
     if (centerTextBox.Text != "" && agentTextBox.Text != "" && seatComboBox.SelectedItem != null && passwordTextBox.Text != null && confirmPasswordTextBox.Text != null)
     {
         if (passwordTextBox.Text == confirmPasswordTextBox.Text)
         {
             DialogResult dr = MessageBox.Show(string.Format("Are you sure to add center '{0}' with agent '{1}' under seat '{2}' to the database?", centerTextBox.Text, agentTextBox.Text, seatComboBox.SelectedItem.ToString()), "Confirm?", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
             if (dr == DialogResult.Yes)
             {
                 if (CenterHandler.AddCenter(centerTextBox.Text, agentTextBox.Text, passwordTextBox.Text, seatComboBox.SelectedItem.ToString()))
                 {
                     MessageBox.Show("Successfully added center.");
                 }
                 else
                 {
                     MessageBox.Show("Center already present.");
                 }
                 centerGrid.DataSource       = CenterHandler.GetViewAbleCenters(seatComboBox.SelectedItem.ToString());
                 centerTextBox.Text          = "";
                 agentTextBox.Text           = "";
                 passwordTextBox.Text        = "";
                 confirmPasswordTextBox.Text = "";
             }
         }
         else
         {
             MessageBox.Show("Passwords do not match.");
         }
     }
     else
     {
         MessageBox.Show("Please enter values in all the fields.");
     }
 }
Example #2
0
        private void startElectionButton_Click(object sender, EventArgs e)
        {
            DialogResult dr = MessageBox.Show("Are you sure to start the election?", "Confirm?", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

            if (dr == DialogResult.Yes)
            {
                CenterHandler.StartElection();
                MessageBox.Show("Election Started");
            }
        }
Example #3
0
 private void showSelectecButton_Click(object sender, EventArgs e)
 {
     if (seatComboBox.SelectedItem != null)
     {
         blockGrid.DataSource = CenterHandler.GetBlockedCenters(seatComboBox.SelectedItem.ToString());
     }
     else
     {
         MessageBox.Show("Please select a seat.");
     }
 }
Example #4
0
 private void showCenterButton_Click(object sender, EventArgs e)
 {
     if (selectSeatComboBox.SelectedItem != null)
     {
         centerGrid.DataSource = CenterHandler.GetViewAbleCenters(selectSeatComboBox.SelectedItem.ToString());
     }
     else
     {
         MessageBox.Show("Please select seat first.");
     }
 }
Example #5
0
 private void seatComboBox_SelectedIndexChanged(object sender, EventArgs e)
 {
     centerComboBox.Items.Clear();
     if (seatComboBox.SelectedItem != null)
     {
         List <ViewAbleCenters> viewCenter = CenterHandler.GetViewAbleCenters(seatComboBox.SelectedItem.ToString());
         foreach (ViewAbleCenters vCenter in viewCenter)
         {
             centerComboBox.Items.Add(vCenter.CenterName);
         }
     }
 }
Example #6
0
 private void unblockButton_Click(object sender, EventArgs e)
 {
     if (blockGrid.DataSource != null)
     {
         int          rowIndex = blockGrid.CurrentRow.Index;
         int          centerId = int.Parse(blockGrid.Rows[rowIndex].Cells[0].Value.ToString());
         DialogResult dr       = MessageBox.Show(string.Format("Are you sure to unblock center '{0}'?", blockGrid.Rows[rowIndex].Cells[1].Value.ToString()), "Confirm?", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
         if (dr == DialogResult.Yes)
         {
             CenterHandler.UnblockCenter(centerId);
             blockGrid.DataSource = CenterHandler.GetBlockedCenters();
         }
     }
 }
Example #7
0
 private void deleteCenterButton_Click(object sender, EventArgs e)
 {
     if (centerGrid.DataSource != null)
     {
         int          rowIndex   = centerGrid.CurrentRow.Index;
         string       centerName = centerGrid.Rows[rowIndex].Cells[1].Value.ToString();
         int          id         = int.Parse(centerGrid.Rows[rowIndex].Cells[0].Value.ToString());
         DialogResult dr         = MessageBox.Show(string.Format("Are you sure to delete center '{0}' from the database?", centerName), "Confirm?", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
         if (dr == DialogResult.Yes)
         {
             CenterHandler.DeleteCenter(id);
             centerGrid.DataSource = CenterHandler.GetViewAbleCenters(selectSeatComboBox.SelectedItem.ToString());
         }
     }
 }
        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 #9
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.");
            }
        }
Example #10
0
        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.");
            }
        }
Example #11
0
 private void showAllButton_Click(object sender, EventArgs e)
 {
     blockGrid.DataSource = CenterHandler.GetBlockedCenters();
 }
Example #12
0
        private void VotingWindow_Load(object sender, EventArgs e)
        {
            int seatId = CenterHandler.GetSeatId(LoginHandler.CenterId);

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