private void SaveButton_Click(object sender, RoutedEventArgs e) { trainee.Address = new Address(city: cityTextBox.Text, street: streetTextBox.Text, buildingNumber: buildingNumberTextBox.Text); trainee.Name = new Name(firstNameTextBox.Text, lastNameTextBox.Text); if (numOfLessonsTextBox.Text != "") { trainee.carTypeStats[(VehicleType)currentCarTypeComboBox.SelectedIndex].numOfLessons = Convert.ToInt32(numOfLessonsTextBox.Text); } trainee.carTypeStats[(VehicleType)currentCarTypeComboBox.SelectedIndex].schoolName = schoolNameTextBox.Text; trainee.carTypeStats[(VehicleType)currentCarTypeComboBox.SelectedIndex].gearType = (GearType)gearTypeComboBox.SelectedIndex; trainee.carTypeStats[(VehicleType)currentCarTypeComboBox.SelectedIndex].teacherName.first = teacherFirst.Text; trainee.carTypeStats[(VehicleType)currentCarTypeComboBox.SelectedIndex].teacherName.first = teacherLast.Text; try { Functions.ValidatePerson(trainee); bl.AddTrainee(trainee); MessageBox.Show("Adding Successful!", "Alert", MessageBoxButton.OK, MessageBoxImage.Information); TraineeWindow traineeWindow = new TraineeWindow(); traineeWindow.Show(); Close(); } catch (InvalidOperationException exc) { MessageBox.Show(exc.Message, "Alert", MessageBoxButton.OK, MessageBoxImage.Exclamation); } }
private void BackButton_Click(object sender, RoutedEventArgs e) { Window traineeWindow = new TraineeWindow(); traineeWindow.Show(); Close(); }
private void DeleteButton_Click(object sender, RoutedEventArgs e) { var resetResult = MessageBox.Show(" Are you sure you want to delete this trainee?", "Delete Trainee", MessageBoxButton.YesNo, MessageBoxImage.Information); if (resetResult == MessageBoxResult.Yes) { try { bl.RemoveTrainee(trainee.ID); bl.RemovePassword(trainee.ID); if (!(GlobalSettings.User is Admin)) { LoginWindow loginWindow = new LoginWindow(); loginWindow.Show(); Close(); } else { if (bl.GetTrainees().Count() == 0) { TraineeWindow Window = new TraineeWindow(); Window.Show(); Close(); } else { traineelist = (List <Trainee>)bl.GetTrainees(); RightButton_Click(sender, e); } } } catch (InvalidOperationException exc) { MessageBox.Show(exc.Message, "Alert", MessageBoxButton.OK, MessageBoxImage.Exclamation); } } //Window confirmDelete = new ConfirmDelete(sender, this, trainee.ID); //confirmDelete.ShowDialog(); }