コード例 #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.");
            }
        }
コード例 #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.");
     }
 }
コード例 #3
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.");
     }
 }