private void Back_Click(object sender, RoutedEventArgs e) { Window MenuWindow = new TraineeMenu(); MenuWindow.Show(); this.Close(); }
private void BtnTrainees_Click(object sender, RoutedEventArgs e) { TraineeMenu MytraineeMenu = new TraineeMenu(); this.Close(); MytraineeMenu.Show(); }
private void btnBack_Click(object sender, RoutedEventArgs e) { TraineeMenu menuTrainee = new TraineeMenu(); this.Close(); menuTrainee.Show(); }
private void button_Click(object sender, RoutedEventArgs e) { TraineeMenu mytraineeMenu = new TraineeMenu(); try { if ((string)btnOk.Content == "Add") { int numId = Convert.ToInt32(txtid.Text); if (numId < 100000000 || numId > 999999999) { //check if id is legal throw new Exception("Non-valid Id. Please enter a valid Id."); } if ((txtfirstName.Text == "") || (txtCity.Text == "") || (txtBuilding.Text == "") || (txtLessons.Text == "") || (txtNumOfTest.Text == "") || (txtTeacher.Text == "") || (txtlastName.Text == "") || (txtStreet.Text == "") || (txtphone.Text == "") || (cmbSchool.Text == "") || (cmbGearbox.Text == "") || (cmbKindV.Text == "") || (cmbTraineeGender.Text == "")) //chech the texts box are not empty { throw new Exception("Not all fields are filled in."); } DateTime temp = (MyTrainee.TraineeBirth.AddYears(Configuration.MinAgeForTrainee)); if (temp > DateTime.Today) { throw new Exception("too young to be a trainee"); } if (datePickerTraineeBirth.SelectedDate > DateTime.Today) { throw new Exception("Please, enter a passed date"); } if (DateOfTheLastTest.SelectedDate > DateTime.Today) { throw new Exception("Please, enter a passed date"); } bl.addTrainee(MyTrainee); //ask him if he sure he wants to add? MyTrainee = new Trainee(); //clean the datacontext this.DataContext = MyTrainee; this.Close(); mytraineeMenu.Show(); } else if ((string)btnOk.Content == "Remove") { var mbResult = MessageBox.Show("Are you sure you want to remove this trainee?", "", MessageBoxButton.OKCancel, MessageBoxImage.Question, MessageBoxResult.Yes); if (mbResult == MessageBoxResult.OK) { bl.deleteTrainee(MyTrainee); MyTrainee = new Trainee();//clean the datacontext this.DataContext = MyTrainee; this.Close(); MessageBox.Show("Trainee removed"); mytraineeMenu.Show(); } } else if ((string)btnOk.Content == "Update") { var mbResult = MessageBox.Show("Are you sure you want to update this trainee?", "", MessageBoxButton.OKCancel, MessageBoxImage.Question, MessageBoxResult.Yes); if (mbResult == MessageBoxResult.OK) { bl.updateTrainee(MyTrainee); MyTrainee = new Trainee(); this.DataContext = MyTrainee; this.Close(); MessageBox.Show("Trainee updated"); mytraineeMenu.Show(); } else { this.Close(); mytraineeMenu.Show(); } } else { MyTrainee = new Trainee(); this.DataContext = MyTrainee; this.Close(); mytraineeMenu.Show(); } } catch (Exception ex) { MessageBox.Show(ex.Message); } }