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.");
            }
        }