public AllTraineeTests(Trainee source) { InitializeComponent(); trainee = new Trainee(source); obs = new ObservableCollection <Test>(FactoryBL.GetInstance().GetTests(t => t.Trainee_id == trainee.Id)); AllTraineeTest.DataContext = obs; }
private void Add_Click(object sender, RoutedEventArgs e) { int house_number; try { house_number = int.Parse(HouseNumberInput.Text); } catch (Exception) { MessageBox.Show("the house number must contain only digits", "house number error", MessageBoxButton.OK, MessageBoxImage.Error); HouseNumberInput.Text = "number"; return; } Address addrees = new Address(StreetInput.Text, house_number, CityInput.Text); DateTime time = DayInput.SelectedDate.Value; int hour = int.Parse(HourInput.Text.Split(':')[0]); time = new DateTime(time.Year, time.Month, time.Day, hour, 0, 0); try { Test test = new Test(trainee.Id, addrees, time); FactoryBL.GetInstance().AddTest(test); } catch (Exception exc) { MessageBox.Show(exc.Message, "logic error", MessageBoxButton.OK, MessageBoxImage.Error); return; } Visibility = Visibility.Collapsed; }
public AllTesters() { InitializeComponent(); Ibl help = FactoryBL.GetInstance(); data.DataContext = new ObservableCollection <Tester>(help.GetTesters()); }
private void Search_Click(object sender, RoutedEventArgs e) { address.City = CityInput.Text; address.Street = StreetInput.Text; try { address.Building_number = int.Parse(HouseNumberInput.Text); } catch (Exception) { MessageBox.Show("the house number must contain only digits", "house number error", MessageBoxButton.OK, MessageBoxImage.Error); HouseNumberInput.Text = "number"; return; } try { TestersNumber.Text = ""; int help = (int)distance.Value; TestersNumber.Text = FactoryBL.GetInstance().InRadius(address, help).Count.ToString(); } catch (Exception) { TestersNumber.Text = 0.ToString(); } }
private void DoneUpdate_Click(object sender, RoutedEventArgs e) { string id = TraineeUC.person.IdInput.Text; string fname = TraineeUC.person.FirstNameInput.Text; string lname = TraineeUC.person.LastNameInput.Text; Gender gender = (Gender)Enum.Parse(typeof(Gender), TraineeUC.person.GenderInput.Text); DateTime Birthdate = TraineeUC.person.BirthdateInput.SelectedDate.Value; string phone = TraineeUC.person.PhoneNumberInput.Text; int house_number; try { house_number = int.Parse(TraineeUC.person.HouseNumberInput.Text); } catch (Exception) { MessageBox.Show("the house number must contain only digits", "house number error", MessageBoxButton.OK, MessageBoxImage.Error); TraineeUC.person.HouseNumberInput.Text = "number"; return; } Address addrees = new Address(TraineeUC.person.StreetInput.Text, house_number, TraineeUC.person.CityInput.Text); Vehicle speciality = (Vehicle)Enum.Parse(typeof(Vehicle), TraineeUC.SpecialityInput.Text); Gearbox gearbox = (Gearbox)Enum.Parse(typeof(Gearbox), TraineeUC.GearboxInput.Text); string sname = TraineeUC.SchoolNameInput.Text; string tname = TraineeUC.TeacherNameInput.Text; int numlessons; try { numlessons = int.Parse(TraineeUC.LessonsCounterInput.Text); } catch (Exception) { MessageBox.Show("the number lessons must contain only digits", "numer lessons error", MessageBoxButton.OK, MessageBoxImage.Error); TraineeUC.person.HouseNumberInput.Text = "number"; return; } try { Trainee trainee = new Trainee(id, fname, lname, Birthdate, gender, phone, addrees, speciality, gearbox, sname, tname, numlessons); Ibl help = FactoryBL.GetInstance(); help.UpdateTrainee(trainee); bool success = help.UpdateTrainee(trainee); if (success) { MessageBox.Show("the trainee update successfuly"); } else { MessageBox.Show("something went wrong"); } Visibility = Visibility.Collapsed; } catch (Exception exc) { MessageBox.Show(exc.Message, "logic error", MessageBoxButton.OK); } }
private void EnteredId_PreviewKeyDown(object sender, System.Windows.Input.KeyEventArgs e) { try { } catch (Exception) { throw; } if (e.Key != Key.Return) { return; } string id = ent.EnteredId.Text; if (id.Length < 9) { System.Windows.MessageBox.Show("id must have 9 numbers"); } if (id == "000000000") { DirectorHome = new DirectorHome(); ent.EnteredId.Clear(); Program.Children.Clear(); Program.Children.Add(DirectorHome); } else { Ibl help = FactoryBL.GetInstance(); List <Tester> tester = help.GetTesters(t => t.Id == id); List <Trainee> trainee = help.GetTrainees(t => t.Id == id); if (trainee.Count == 0 && tester.Count == 0) { System.Windows.MessageBox.Show("Not Exist!"); } else if (trainee.Count != 0 && tester.Count != 0) { System.Windows.MessageBox.Show("ERORR"); } else if (tester.Count != 0) { testerHome = new TesterHome(tester[0]); testerHome.LogOutRequest += Logout_Request; ent.EnteredId.Clear(); Program.Children.Clear(); Program.Children.Add(testerHome); } else if (trainee.Count != 0) { traineeHome = new TraineeHome(trainee[0]); traineeHome.LogOutRequest += Logout_Request; ent.EnteredId.Clear(); Program.Children.Clear(); Program.Children.Add(traineeHome); } } }
public AllTesterTests(Tester source) { tester = new Tester(source); InitializeComponent(); Ibl help = FactoryBL.GetInstance(); obs = new ObservableCollection <Test>(help.GetTests(t => t.Tester_id == tester.Id)); AllTesterTest.DataContext = obs; }
public UpdateTestByTester(Tester source) { tester = new Tester(source); InitializeComponent(); Ibl help = FactoryBL.GetInstance(); obs = new ObservableCollection <Test>(help.GetTests(t => t.Tester_id == tester.Id)); AllTesterTest.DataContext = obs; Note.TextChanged += IsEnabled_Update_Click; Grade.TextChanged += IsEnabled_Update_Click; }
private void Yes_Click(object sender, RoutedEventArgs e) { Ibl help = FactoryBL.GetInstance(); try { help.RemoveTester(id); } catch (Exception exc) { MessageBox.Show(exc.Message, "logic error", MessageBoxButton.OK, MessageBoxImage.Error); } Visibility = Visibility.Collapsed; the_tester_deleted(this, new EventArgs()); }
private void Update_Click(object sender, RoutedEventArgs e) { Ibl help = FactoryBL.GetInstance(); try { help.UpdateTest(long.Parse(TestId.Text), int.Parse(Grade.Text), Note.Text); } catch (Exception exc) { MessageBox.Show(exc.Message, "LOGIC ERORR", MessageBoxButton.OK, MessageBoxImage.Error); return; } UpdateInfo.Visibility = Visibility.Collapsed; }
public AllTests() { InitializeComponent(); DataContext = new ObservableCollection <Test>(FactoryBL.GetInstance().GetTests()); }
private void Location_Click(object sender, RoutedEventArgs e) { Ibl help = FactoryBL.GetInstance(); data.DataContext = help.GetTestersByLocation(true); }
private void Speciality_Click(object sender, RoutedEventArgs e) { Ibl help = FactoryBL.GetInstance(); data.DataContext = help.GetTestersBySpeciality(true); }
private void Create_Click(object sender, RoutedEventArgs e) { string id = data.PersonAttribute.IdInput.Text; string lname = data.PersonAttribute.LastNameInput.Text; string fname = data.PersonAttribute.FirstNameInput.Text; Gender gender = (Gender)Enum.Parse(typeof(Gender), data.PersonAttribute.GenderInput.Text); DateTime Birthdate = data.PersonAttribute.BirthdateInput.SelectedDate.Value; string phone = data.PersonAttribute.PhoneNumberInput.Text; int house_number; try { house_number = int.Parse(data.PersonAttribute.HouseNumberInput.Text); } catch (Exception) { MessageBox.Show("the house number must contain only digits", "house number error", MessageBoxButton.OK, MessageBoxImage.Error); data.PersonAttribute.HouseNumberInput.Text = "number"; return; } Address addrees = new Address(data.PersonAttribute.StreetInput.Text, house_number, data.PersonAttribute.CityInput.Text); int experience; try { experience = int.Parse(data.ExperienceInput.Text); } catch (Exception) { MessageBox.Show("the Experience must contain only digits", "Experience error", MessageBoxButton.OK, MessageBoxImage.Error); data.ExperienceInput.Text = "0"; return; } int max_tests; try { max_tests = int.Parse(data.MaxTestInput.Text); } catch (Exception) { MessageBox.Show("the Max Tests Per Week must contain only digits", "Max Tests Per Week error", MessageBoxButton.OK, MessageBoxImage.Error); data.MaxTestInput.Text = "0"; return; } float max_range; try { max_range = float.Parse(data.MaxRangeInput.Text); } catch (Exception) { MessageBox.Show("the Max Range must contain only digits", "Max Range( error", MessageBoxButton.OK, MessageBoxImage.Error); data.MaxRangeInput.Text = "0"; return; } Vehicle speciality = (Vehicle)Enum.Parse(typeof(Vehicle), data.SpecialityInput.Text); bool[][] hours = new bool[5][]; for (int i = 0; i < 5; i++) { hours[i] = new bool[6]; } //Initialize hours array foreach (var item in data.ScheduleTable.Children) { if (item is CheckBox) { CheckBox help = (CheckBox)item; if (help.IsChecked == true) { hours[Grid.GetRow(help) - 2][Grid.GetColumn(help) - 1] = true; } } } //update the tester try { Tester tester = new Tester(id, fname, lname, Birthdate, gender, phone, addrees, experience, max_tests, max_range, speciality, hours); Ibl help = FactoryBL.GetInstance(); bool success = help.UpdateTester(tester); if (success) { MessageBox.Show("the tester update successfuly"); } else { MessageBox.Show("something went wrong"); } this.Visibility = Visibility.Collapsed; } catch (Exception exc) { MessageBox.Show(exc.Message, "logic error", MessageBoxButton.OK, MessageBoxImage.Error); } }
public AllTrainees() { InitializeComponent(); data.DataContext = new ObservableCollection <Trainee>(FactoryBL.GetInstance().GetTrainees()); }
private void Done_Click(object sender, RoutedEventArgs e) { string id = data.PersonAttribute.IdInput.Text; string lname = data.PersonAttribute.LastNameInput.Text; string fname = data.PersonAttribute.FirstNameInput.Text; Gender gender = (Gender)Enum.Parse(typeof(Gender), data.PersonAttribute.GenderInput.Text); DateTime Birthdate = data.PersonAttribute.BirthdateInput.SelectedDate.Value; string phone = data.PersonAttribute.PhoneNumberInput.Text; for (int i = 0; i < lname.Length; i++) { if (lname[i] == ' ') { lname = "last name"; data.PersonAttribute.LastNameInput.Text = lname; MessageBox.Show("the last name must not contain space", "Name error", MessageBoxButton.OK, MessageBoxImage.Error); return; } } for (int i = 0; i < fname.Length; i++) { if (fname[i] == ' ') { fname = "first name"; data.PersonAttribute.FirstNameInput.Text = fname; MessageBox.Show("the first name must not contain space", "Name error", MessageBoxButton.OK, MessageBoxImage.Error); return; } } try { int.Parse(id); } catch (Exception) { MessageBox.Show("the ID must contain only digits", "ID error", MessageBoxButton.OK, MessageBoxImage.Error); return; } int house_number; try { house_number = int.Parse(data.PersonAttribute.HouseNumberInput.Text); } catch (Exception) { MessageBox.Show("the house number must contain only digits", "house number error", MessageBoxButton.OK, MessageBoxImage.Error); data.PersonAttribute.HouseNumberInput.Text = "number"; return; } Address addrees = new Address(data.PersonAttribute.StreetInput.Text, house_number, data.PersonAttribute.CityInput.Text); int experience; try { experience = int.Parse(data.ExperienceInput.Text); } catch (Exception) { MessageBox.Show("the Experience must contain only digits", "Experience error", MessageBoxButton.OK, MessageBoxImage.Error); data.ExperienceInput.Text = "0"; return; } int max_tests; try { max_tests = int.Parse(data.MaxTestInput.Text); } catch (Exception) { MessageBox.Show("the Max Tests Per Week must contain only digits", "Max Tests Per Week error", MessageBoxButton.OK, MessageBoxImage.Error); data.MaxTestInput.Text = "0"; return; } int max_range; try { max_range = int.Parse(data.MaxRangeInput.Text); } catch (Exception) { MessageBox.Show("the Max Range must contain only digits", "Max Range( error", MessageBoxButton.OK, MessageBoxImage.Error); data.MaxRangeInput.Text = "0"; return; } Vehicle speciality = (Vehicle)Enum.Parse(typeof(Vehicle), data.SpecialityInput.Text); bool[][] hours = new bool[5][]; for (int i = 0; i < 5; i++) { hours[i] = new bool[6]; } //Initialize hours array foreach (var item in data.ScheduleTable.Children) { if (item is CheckBox) { CheckBox help = (CheckBox)item; if (help.IsChecked == true) { hours[Grid.GetRow(help) - 2][Grid.GetColumn(help) - 1] = true; } } } //create the tester try { Tester tester = new Tester(id, fname, lname, Birthdate, gender, phone, addrees, experience, max_tests, max_range, speciality, hours); Ibl help = FactoryBL.GetInstance(); help.AddTester(tester); } catch (Exception exc) { MessageBox.Show(exc.Message, "logic error", MessageBoxButton.OK, MessageBoxImage.Error); } MessageBox.Show("Tester successfully added", "Tracking message", MessageBoxButton.OK, MessageBoxImage.Information); LogOutRequest(this, new EventArgs()); }