コード例 #1
0
 private void button_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         bl.DeleteTrainee(temp_trainee);
         TraineePage t = new TraineePage();
         this.NavigationService.Navigate(t);
         MessageBox.Show("Trainee" + " " + temp_trainee.TraineeId + " " + "deleted");
     }
     catch (Exception message)
     {
         MessageBox.Show(message.Message);
     }
 }
コード例 #2
0
 private void OKbutton_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         if (IdtextBox.Text.Length < 9)
         {
             IdtextBox.BorderBrush = Brushes.Red;
             throw new Exception("id - Not enough digits");
         }
         if (IdtextBox.Text.Length > 9)
         {
             IdtextBox.BorderBrush = Brushes.Red;
             throw new Exception("id - To much digits");
         }
         if (PhoneNumbertextBox.Text.Length < 10)
         {
             PhoneNumbertextBox.BorderBrush = Brushes.Red;
             throw new Exception("Phone Number - Not enough digits");
         }
         if (EmailtextBox.Text.Length == 0)
         {
             EmailtextBox.BorderBrush = Brushes.Red;
             throw new Exception("The email is not currect");
         }
         if (EmailtextBox.Text.IndexOf('@') != EmailtextBox.Text.LastIndexOf('@') || EmailtextBox.Text.IndexOf('@') == -1)
         {
             EmailtextBox.BorderBrush = Brushes.Red;
             throw new Exception("The email is not currect - does not contain the value @");
         }
         if (EmailtextBox.Text.IndexOf(".") == -1)
         {
             EmailtextBox.BorderBrush = Brushes.Red;
             throw new Exception("The email is not currect - does not contain the value .");
         }
         if (comboBox.SelectedItem == null)
         {
             throw new Exception("Please choose driving school");
         }
         if (comboBox1.SelectedItem == null)
         {
             throw new Exception("Please choose teacher name");
         }
         if (((int)LessonstextBox.Value < Configuration.MINNumberOfLessons) && (InternalTestcheckBox.IsChecked == true))
         {
             InternalTestcheckBox.IsChecked = false;
             throw new Exception("Error - Not enough lessons to pass an internal test ");
         }
         temp_trainee.TraineeNumOfDrivingLessons    = (int)LessonstextBox.Value;
         temp_trainee.IfTraineePassedAnInternalTest = InternalTestcheckBox.IsChecked.Value;
         bl.AddTrainee(temp_trainee);
         temp_trainee         = new BE.Trainee();
         this.DataContext     = temp_trainee;
         LessonstextBox.Value = 0;
         throw new Exception("Trainee successfully added");
     }
     catch (Exception message)
     {
         MessageBox.Show(message.Message);
         IdtextBox.BorderBrush          = Brushes.Black;
         PhoneNumbertextBox.BorderBrush = Brushes.Black;
         EmailtextBox.BorderBrush       = Brushes.Black;
         if (message.Message == "Trainee successfully added")
         {
             TraineePage t = new TraineePage();
             this.NavigationService.Navigate(t);
         }
     }
 }