コード例 #1
0
 private void txtNumOfDancers_KeyDown(object sender, KeyEventArgs e)
 {
     if (e.KeyCode == Keys.Enter)
     {
         try
         {
             numOfDancers = int.Parse(txtNumOfDancers.Text);
             if (numOfDancers <= 0)
             {
                 throw new Exception("Invalid number-number is too small\n Please try again");
             }
             ds = new DancerStudio(numOfDancers);
             txtNumOfDancers.Hide();
             lblNumOfDancers.Hide();
             txtNumOfDancers.Enabled = false;
             lblNumOfDancers.Enabled = true;
             checkEnable(true);
             VisibleControl(true);
             txtShow.Text = "Dancers' Details Overview\r\n";
         }
         catch (FormatException)
         {
             MessageBox.Show("Please enter an integer number");
         }
         catch (OverflowException)
         {
             MessageBox.Show("Invalid number-number is too big");
         }
         catch (Exception ex)
         {
             MessageBox.Show(ex.Message);
         }
     }
 }
コード例 #2
0
 public void checkNumOfDancers()
 {
     try
     {
         numOfDancers = int.Parse(txtNumOfDancers.Text);
         if (numOfDancers <= 0)
         {
             throw new Exception("Invalid number-number is too small\n Please try again");
         }
         ds = new DancerStudio(numOfDancers);
         txtNumOfDancers.Hide();
         lblNumOfDancers.Hide();
         btnNumOfDancers.Hide();
         checkEnable(true);
     }
     catch (FormatException)
     {
         MessageBox.Show("Please enter an integer number");
     }
     catch (OverflowException)
     {
         MessageBox.Show("Invalid number-number is too big");
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }