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 button_trainee_Click(object sender, RoutedEventArgs e) { Window trainee; if (GlobalSettings.User is Trainee) { trainee = new ViewTrainee((Trainee)GlobalSettings.User, null); } else { trainee = new TraineeWindow(); } trainee.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(); }