示例#1
0
        private void OrderTestClick(object sender, RoutedEventArgs e)
        {
            try
            {
                if (Date.Text == "" ||
                    Time.Text == "" ||
                    Street.Text == "" ||
                    HouseNumber.Text == "" ||
                    City.Text == "")
                {
                    MessageBox.Show("Please fill all the fields before requesting a test.");
                    return;
                }

                bl.addTest(
                    AddTestWorker,
                    Trainee,
                    Date.SelectedDate.Value,
                    int.Parse(Time.Text),
                    new Address(Street.Text, int.Parse(HouseNumber.Text), City.Text));
                systemIsWorkingWindow.Show();
                AddTestWorker.RunWorkerCompleted += AddTestWorker_RunWorkerCompleted;
            }
            catch (Exception exception)
            {
                HandleExceptions.Handle(exception, this);
            }
        }
示例#2
0
 private void AddTestWorker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
 {
     systemIsWorkingWindow.Close();
     if (e.Cancelled)
     {
         MessageBox.Show(
             "The test request has been cacelled.",
             "Cancelled",
             MessageBoxButton.OK,
             MessageBoxImage.Information);
         Close();
         return;
     }
     if (e.Result is int)
     {
         MessageBox.Show(
             "A test has been fixed.\nTest number is: " + ((int)e.Result).ToString(),
             "Success!",
             MessageBoxButton.OK,
             MessageBoxImage.Information);
         Close();
         return;
     }
     if (e.Result is Exception)
     {
         Exception exception = e.Result as Exception;
         HandleExceptions.Handle(exception, this);
     }
 }
 private void TraineeFiltersChanged(object sender, SelectionChangedEventArgs e)
 {
     try
     {
         List <Trainee> traineesList = bl.getTrainees();
         if (traineeCityFilterCheck.IsChecked == true && traineeCityFilterCombo.SelectedItem != null)
         {
             traineesList = (from Trainee trainee in traineesList
                             where trainee.Address.City == (string)traineeCityFilterCombo.SelectedItem
                             select trainee).ToList();
         }
         if (traineeGenderFilterCheck.IsChecked == true && traineeGenderFilterCombo.SelectedItem != null)
         {
             traineesList = (from Trainee trainee in traineesList
                             where trainee.Gender == (Gender)traineeGenderFilterCombo.SelectedItem
                             select trainee).ToList();
         }
         if (traineeVehicleFilterCheck.IsChecked == true && traineeVehicleFilterCombo.SelectedItem != null)
         {
             traineesList = (from Trainee trainee in traineesList
                             where trainee.CarType == (VehicleType)traineeVehicleFilterCombo.SelectedItem
                             select trainee).ToList();
         }
         traineesListView.ItemsSource = traineesList;
     }
     catch (Exception exception)
     {
         HandleExceptions.Handle(exception);
     }
 }
示例#4
0
        private void Button_login(object sender, RoutedEventArgs e)
        {
            try
            {
                string TypeOfUser = bl.getTypeOfUser(int.Parse(idInput.Text));
                switch (TypeOfUser)
                {
                case "Trainee":
                    TraineeWindow traineeWindow = new TraineeWindow(bl.getTrainee(int.Parse(idInput.Text)));
                    traineeWindow.Show();
                    Close();
                    break;

                case "Tester":
                    TesterWindow testerWindow = new TesterWindow(bl.getTester(int.Parse(idInput.Text)));
                    testerWindow.Show();
                    Close();
                    break;
                }
            }
            catch (Exception exception)
            {
                HandleExceptions.Handle(exception, this);
            }
        }
 private void TesterFiltersChanged(object sender, SelectionChangedEventArgs e)
 {
     try
     {
         List <Tester> testersList = bl.getTesters();
         if (testerCityFilterCheck.IsChecked == true && testerCityFilterCombo.SelectedItem != null)
         {
             testersList = (from Tester tester in testersList
                            where tester.Address.City == (string)testerCityFilterCombo.SelectedItem
                            select tester).ToList();
         }
         if (testerGenderFilterCheck.IsChecked == true && testerGenderFilterCombo.SelectedItem != null)
         {
             testersList = (from Tester tester in testersList
                            where tester.Gender == (Gender)testerGenderFilterCombo.SelectedItem
                            select tester).ToList();
         }
         if (testerVehicleFilterCheck.IsChecked == true && testerVehicleFilterCombo.SelectedItem != null)
         {
             testersList = (from Tester tester in testersList
                            where tester.CarType == (VehicleType)testerVehicleFilterCombo.SelectedItem
                            select tester).ToList();
         }
         testersListView.ItemsSource = testersList;
     }
     catch (Exception exception)
     {
         HandleExceptions.Handle(exception);
     }
 }
示例#6
0
 private void SystemTimeSet_SelectedDateChanged(object sender, SelectionChangedEventArgs e)
 {
     try
     {
         bl.setSystemTime(systemTimeSet.SelectedDate.Value);
     }
     catch (Exception exception)
     {
         HandleExceptions.Handle(exception, this);
     }
 }
示例#7
0
 private void DetailsUpdated(object sender, EventArgs e)
 {
     try
     {
         Trainee     = bl.getTrainee(Trainee.ID);
         DataContext = Trainee;
     }
     catch (Exception exception)
     {
         HandleExceptions.Handle(exception, this);
     }
 }
 private void updateTestButtonClicked(object sender, RoutedEventArgs e)
 {
     try
     {
         bl.updateTestAsAdmin(UpdatedTest.TestNumber, UpdatedTest);
         MessageBox.Show("Test Feedback was updated in the system", "Feedback Saved", MessageBoxButton.OK, MessageBoxImage.Asterisk);
         Close();
     }
     catch (Exception exception)
     {
         HandleExceptions.Handle(exception, this);
     }
 }
示例#9
0
 private void DetailsUpdated(object sender, EventArgs e)
 {
     try
     {
         Tester               = bl.getTester(Tester.ID);
         ListSchedule         = bl.getTesterSchedule(Tester);
         DataContext          = Tester;
         schedule.ItemsSource = ListSchedule.ScheduleAsList;
     }
     catch (Exception exception)
     {
         HandleExceptions.Handle(exception, this);
     }
 }
 private void AddTraineeButtonClicked(object sender, RoutedEventArgs e)
 {
     try
     {
         if (id.Text != "" &&
             firstName.Text != "" &&
             lastName.Text != "" &&
             dateOfbirth.Text != "" &&
             genderComboBox.Text != "" &&
             phone.Text != "" &&
             street.Text != "" &&
             houseNumber.Text != "" &&
             city.Text != "" &&
             carTypeComboBox.Text != "" &&
             gearBoxComboBox.Text != "" &&
             schoolName.Text != "" &&
             teacherName.Text != "" &&
             numOfLessons.Text != ""
             )
         {
             Trainee inputTrainee = new Trainee(
                 Int32.Parse(id.Text),
                 lastName.Text,
                 firstName.Text,
                 (DateTime)dateOfbirth.SelectedDate,
                 (Gender)genderComboBox.SelectedItem,
                 phone.Text,
                 new Address(street.Text, int.Parse(houseNumber.Text), city.Text),
                 (VehicleType)carTypeComboBox.SelectedItem,
                 (GearBox)gearBoxComboBox.SelectedItem,
                 schoolName.Text,
                 teacherName.Text,
                 int.Parse(numOfLessons.Text),
                 new List <TraineeTest>());
             bl.addTrainee(inputTrainee);
             MessageBox.Show("Your details have successfully recorded in the system.\nUse your ID number to log in any time you wish.", "Success!", MessageBoxButton.OK, MessageBoxImage.Information);
             Close();
         }
         else
         {
             MessageBox.Show("Please fill all the fields before registerring", "Missing Input Data", MessageBoxButton.OK, MessageBoxImage.Hand);
             return;
         }
     }
     catch (Exception exception)
     {
         HandleExceptions.Handle(exception, this);
     }
 }
 private void updateTestButtonClicked(object sender, RoutedEventArgs e)
 {
     try
     {
         Button button = sender as Button;
         UpdatedTest = button.Tag as TesterTest;
         bl.updateTest(UpdatedTest.TestNumber, UpdatedTest, TesterID);
         button.IsEnabled = false;
         MessageBox.Show("Test Feedback was updated in the system", "Feedback Saved", MessageBoxButton.OK, MessageBoxImage.Asterisk);
     }
     catch (Exception exception)
     {
         HandleExceptions.Handle(exception, this);
     }
 }
示例#12
0
 private void GiveFeedbackButtonClicked(object sender, RoutedEventArgs e)
 {
     try
     {
         TestFeedbackWindow testFeedBackWindow = new TestFeedbackWindow(
             bl.getTestswaitingForfeedback(Tester.ID),
             Tester.FirstName + " " + Tester.LastName,
             Tester.ID);
         testFeedBackWindow.Show();
     }
     catch (Exception exception)
     {
         HandleExceptions.Handle(exception, this);
     }
 }
 private void AddTest_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         List <Trainee>     allowedForTest     = bl.getAllTraineesAllowedForTest();
         ChoseTraineeWindow choseTraineeWindow = new ChoseTraineeWindow(allowedForTest);
         choseTraineeWindow.Show();
         IsEnabled = false;
         choseTraineeWindow.Closed += ChildWindowClosed;
     }
     catch (Exception exception)
     {
         HandleExceptions.Handle(exception, this);
     }
 }
示例#14
0
 private void DeleteTester(object sender, RoutedEventArgs e)
 {
     try
     {
         MessageBoxResult result = MessageBox.Show("Are you sure you want to remove all details from the system?", "Delete Tester",
                                                   MessageBoxButton.YesNo, MessageBoxImage.Question);
         if (result == MessageBoxResult.Yes)
         {
             bl.removeTester(Tester.ID);
             Close();
         }
     }
     catch (Exception exception)
     {
         HandleExceptions.Handle(exception, this);
     }
 }
示例#15
0
 private void DeleteTrainee(object sender, RoutedEventArgs e)
 {
     try
     {
         var result = MessageBox.Show("Are you sure you want to delete?", "Delete trainee",
                                      MessageBoxButton.YesNo, MessageBoxImage.Question);
         if (result == MessageBoxResult.Yes)
         {
             bl.removeTrainee(Trainee.ID);
             Close();
         }
     }
     catch (Exception exception)
     {
         HandleExceptions.Handle(exception, this);
     }
 }
示例#16
0
        private void Button_Subscribe(object sender, RoutedEventArgs e)
        {
            try
            {
                if (id.Text == "" ||
                    lastName.Text == "" ||
                    firstName.Text == "" ||
                    dateOfBrith.Text == "" ||
                    genderComboBox.Text == "" ||
                    phone.Text == "" ||
                    street.Text == "" ||
                    houseNumber.Text == "" ||
                    city.Text == "" ||
                    seniority.Text == "" ||
                    maxTestsPerWeek.Text == "" ||
                    carTypeComboBox.Text == "" ||
                    maxDistanceFromAddress.Text == "")
                {
                    MessageBox.Show("Please fill all the fields before registerring", "Missing Input Data", MessageBoxButton.OK, MessageBoxImage.Hand);
                    return;
                }


                Tester tester = new Tester(
                    int.Parse(id.Text),
                    lastName.Text,
                    firstName.Text,
                    dateOfBrith.SelectedDate.Value,
                    (Gender)genderComboBox.SelectedIndex,
                    phone.Text,
                    new Address(street.Text, int.Parse(houseNumber.Text), city.Text),
                    int.Parse(seniority.Text),
                    int.Parse(maxTestsPerWeek.Text),
                    (VehicleType)carTypeComboBox.SelectedIndex,
                    double.Parse(maxDistanceFromAddress.Text),
                    new List <TesterTest>());
                bl.setTesterSchedule(tester, ListSchedule);
                bl.addTester(tester);
                MessageBox.Show("Your details have successfully recorded in the system.\nUse the ID number to log in.", "Success!", MessageBoxButton.OK, MessageBoxImage.Information);
                Close();
            }
            catch (Exception exception)
            {
                HandleExceptions.Handle(exception, this);
            }
        }
示例#17
0
 private void confirmScheduleChanges_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         schedulePageTitle.Text = "Tester's Weekly Work Schedule";
         bl.setTesterSchedule(Tester, ListSchedule);
         bl.updateTester(Tester.ID, Tester);
         DetailsUpdated(null, null);
         confirmScheduleChanges.Visibility = Visibility.Hidden;
         backToOriginalSchedule.Visibility = Visibility.Hidden;
         updateSchedule.Visibility         = Visibility.Visible;
         schedule.IsReadOnly = true;
     }
     catch (Exception exception)
     {
         HandleExceptions.Handle(exception, this);
     }
 }
 private void UpdateTest_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         if (testsListView.SelectedItem == null)
         {
             MessageBox.Show("Please select a test to update from the list");
             return;
         }
         Test             test             = testsListView.SelectedItem as Test;
         UpdateTestWindow updateTestWindow = new UpdateTestWindow(test);
         IsEnabled = false;
         updateTestWindow.Show();
         updateTestWindow.Closed += ChildWindowClosed;
     }
     catch (Exception ex)
     {
         HandleExceptions.Handle(ex, this);
     }
 }
示例#19
0
 private void DeleteTestClicked(object sender, RoutedEventArgs e)
 {
     try
     {
         MessageBoxResult result = MessageBox.Show("Are you sure you want abort this test?", "Delete Test",
                                                   MessageBoxButton.YesNo, MessageBoxImage.Question);
         if (result == MessageBoxResult.Yes)
         {
             Button button     = sender as Button;
             int    testNumber = (int)button.Tag;
             bl.removeTest(testNumber);
             MessageBox.Show("The test is aborted.\n", "Test Deleted", MessageBoxButton.OK, MessageBoxImage.Information);
             Tester      = bl.getTester(Tester.ID);
             DataContext = Tester;
         }
     }
     catch (Exception exception)
     {
         HandleExceptions.Handle(exception, this);
     }
 }
 public AdminWindow()
 {
     try
     {
         bl = BL.Factory.GetBL();
         InitializeComponent();
         testersListView.ItemsSource           = bl.getTestersByVehicleType();
         traineesListView.ItemsSource          = bl.getTraineesBySchool();
         testsListView.ItemsSource             = bl.getTests();
         testerCityFilterCombo.ItemsSource     = bl.getCitiesOfTesters();
         testerGenderFilterCombo.ItemsSource   = Enum.GetValues(typeof(Gender));
         testerVehicleFilterCombo.ItemsSource  = Enum.GetValues(typeof(VehicleType));
         traineeCityFilterCombo.ItemsSource    = bl.getCitiesOfTrainees();
         traineeGenderFilterCombo.ItemsSource  = Enum.GetValues(typeof(Gender));
         traineeVehicleFilterCombo.ItemsSource = Enum.GetValues(typeof(VehicleType));
     }
     catch (Exception ex)
     {
         HandleExceptions.Handle(ex, this);
     }
 }
示例#21
0
 private void UpdateTesterClicked(object sender, RoutedEventArgs e)
 {
     try
     {
         if (id.Text != "" &&
             firstName.Text != "" &&
             lastName.Text != "" &&
             dateOfbirth.Text != "" &&
             genderComboBox.Text != "" &&
             phone.Text != "" &&
             street.Text != "" &&
             houseNumber.Text != "" &&
             city.Text != "" &&
             carTypeComboBox.Text != "" &&
             seniority.Text != "" &&
             maxDistance.Text != "" &&
             maxTests.Text != ""
             )
         {
             UpdatedTester.Address = new Address(street.Text, int.Parse(houseNumber.Text), city.Text);
             bl.setTesterSchedule(UpdatedTester, ListSchedule);
             bl.updateTester(UpdatedTester.ID, UpdatedTester);
             MessageBox.Show("Data updated on system", "", MessageBoxButton.OK, MessageBoxImage.Information);
             Close();
         }
         else
         {
             MessageBox.Show(
                 "Please fill all the fields before updating.",
                 "Missing Data",
                 MessageBoxButton.OK,
                 MessageBoxImage.Asterisk);
         }
     }
     catch (Exception exception)
     {
         HandleExceptions.Handle(exception, this);
     }
 }
 private void UpdateTraineeClicked(object sender, RoutedEventArgs e)
 {
     try
     {
         if (id.Text != "" &&
             firstName.Text != "" &&
             lastName.Text != "" &&
             dateOfbirth.Text != "" &&
             genderComboBox.Text != "" &&
             phone.Text != "" &&
             street.Text != "" &&
             houseNumber.Text != "" &&
             city.Text != "" &&
             carTypeComboBox.Text != "" &&
             gearBoxComboBox.Text != "" &&
             schoolName.Text != "" &&
             teacherName.Text != "" &&
             numOfLessons.Text != ""
             )
         {
             UpdatedTrainee.Address = new Address(street.Text, int.Parse(houseNumber.Text), city.Text);
             bl.updateTrainee(UpdatedTrainee.ID, UpdatedTrainee);
             MessageBox.Show("Data updated on system", "", MessageBoxButton.OK, MessageBoxImage.Information);
             Close();
         }
         else
         {
             MessageBox.Show(
                 "Please fill all the fields before updating.",
                 "Missing Data",
                 MessageBoxButton.OK,
                 MessageBoxImage.Asterisk);
         }
     }
     catch (Exception exception)
     {
         HandleExceptions.Handle(exception, this);
     }
 }
示例#23
0
 private void IncreaseLessonsCounterClicked(object sender, RoutedEventArgs e)
 {
     try
     {
         MessageBoxResult result = MessageBox.Show(
             "You added one more driving lesson to the counter.\nThe updated sum of lessons is: "
             + (Trainee.NumberOfLessons + 1).ToString(),
             "Adding a Lesson",
             MessageBoxButton.OKCancel,
             MessageBoxImage.Information);
         if (result == MessageBoxResult.OK)
         {
             Trainee.NumberOfLessons++;
             bl.updateTrainee(Trainee.ID, Trainee);
             Trainee     = bl.getTrainee(Trainee.ID);
             DataContext = Trainee;
         }
     }
     catch (Exception exception)
     {
         HandleExceptions.Handle(exception, this);
     }
 }
        private void DeleteTester_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                if (testersListView.SelectedItem == null)
                {
                    MessageBox.Show("Please select a tester to update from the list");
                    return;
                }
                Tester tester = testersListView.SelectedItem as Tester;

                MessageBoxResult result = MessageBox.Show("Are you sure you want abort this tester?", "Delete Test",
                                                          MessageBoxButton.YesNo, MessageBoxImage.Question);
                if (result == MessageBoxResult.Yes)
                {
                    bl.removeTester(tester.ID);
                    MessageBox.Show("The tester is deleted.\n", "Tester Deleted", MessageBoxButton.OK, MessageBoxImage.Information);
                }
            }
            catch (Exception ex)
            {
                HandleExceptions.Handle(ex, this);
            }
        }
        private void DeleteTrainee_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                if (traineesListView.SelectedItem == null)
                {
                    MessageBox.Show("Please select a trainee to delete from the list");
                    return;
                }
                Trainee trainee = traineesListView.SelectedItem as Trainee;

                MessageBoxResult result = MessageBox.Show("Are you sure you want dealete this trainee?", "Delete Ttainee",
                                                          MessageBoxButton.YesNo, MessageBoxImage.Question);
                if (result == MessageBoxResult.Yes)
                {
                    bl.removeTrainee(trainee.ID);
                    MessageBox.Show("The trainee is deleted.\n", "Trainee Deleted", MessageBoxButton.OK, MessageBoxImage.Information);
                }
            }
            catch (Exception ex)
            {
                HandleExceptions.Handle(ex, this);
            }
        }