public UpdateTraineeWindow(Trainee selectedPerson) { InitializeComponent(); this.DataContext = selectedPerson; genderComboBox.ItemsSource = Enum.GetValues(typeof(Gender)); gearBoxComboBox.ItemsSource = Enum.GetValues(typeof(GearBox)); carTypeComboBox.ItemsSource = Enum.GetValues(typeof(CarType)); birthdayDatePicker.DisplayDateStart = DateTime.Now.AddYears(-bl.getMaximumAge()); houseNumberTextBox.Text = selectedPerson.Address.houseNumber.ToString(); city.ItemsSource = Configuration.city; city.SelectedItem = Configuration.city.Find(i => i == selectedPerson.Address.city); streetComboBox.ItemsSource = Configuration.street[selectedPerson.Address.city]; streetComboBox.SelectedItem = Configuration.street[selectedPerson.Address.city].Find(I => I == selectedPerson.Address.street); if (bl.getAllTests().Find(i => i.TraineeId == selectedPerson.Id) != null) //if the trainee do a test or at least regist to a test - cat change his id { labelID.Visibility = Visibility.Collapsed; ID.Visibility = Visibility.Collapsed; } orginalTrainee = (Trainee)selectedPerson.Clone(); }
public ViewTraineePage(Trainee trainee) { InitializeComponent(); BL = FactoryBL.getInstance(); Trainee = trainee.Clone(); DOBTextBlock.Text = Trainee.BirthDay.ToString("mm/dd/yyy"); this.DataContext = this.Trainee; }
public bool UpdateTrainee(Trainee trainee) { var x = (from d in DAL.DataSource.getTrainees where (d.ID == trainee.ID) select d).FirstOrDefault(); DAL.DataSource.getTrainees.Remove(x); DAL.DataSource.getTrainees.Add((Trainee)trainee.Clone()); return(true); }
public bool AddTrainee(Trainee trainee) { foreach (Trainee item in DS.DataSource.TraineesList) { if (item.ID == trainee.ID) { throw new Exception("trainee already exist"); } } DS.DataSource.TraineesList.Add(trainee.Clone()); return(true); }
public bool removeTrainee(Trainee tr) { foreach (var item in DataSource.Trainees) { if (item.ID == tr.ID) { DataSource.Trainees.Remove(tr.Clone()); return(true); } } return(false); }
public bool addTrainee(Trainee tr) { foreach (var item in DataSource.Trainees) { if (item.ID == tr.ID) { return(false); } } DataSource.Trainees.Add(tr.Clone()); return(true); }
/// <summary> /// A function added by a trainee /// </summary> /// <param name="trainee"></param> void IDL.addTrainee(Trainee trainee) { // Exception in case ID already exists in the system foreach (Trainee _trainee in DataSource.TraineeList) { if (_trainee.ID == trainee.ID) { throw new TraineesIdAlreadyExistsException(trainee.ID, _trainee.FirstName + " " + _trainee.LastName); } } DataSource.TraineeList.Add(trainee.Clone()); }
public bool UpdateTrainee(Trainee trainee) { foreach (Trainee item in DS.DataSource.TraineesList) { if (trainee.ID == item.ID) { DS.DataSource.TraineesList.Remove(item); DS.DataSource.TraineesList.Add(trainee.Clone()); return(true); } } throw new Exception("The current trainee is not in the database"); }
public bool AddTrainee(Trainee trainee) { foreach (var item in DAL.DataSource.getTrainees) { //check if the trainee is already found in the system if (item.ID == trainee.ID) { throw new Exception("Trainee already exists."); } } //add the trainee and return true as the operation has completed DAL.DataSource.getTrainees.Add((Trainee)trainee.Clone()); return(true); }
/// <summary> /// A function that updates the trainee information, the function receives the trainee ID and the updated trainee /// </summary> /// <param name="id"></param> /// <param name="updatedTrainee"></param> void IDL.updateTrainee(int id, Trainee updatedTrainee) { bool noSuchTrainee = true; foreach (Trainee trainee in DataSource.TraineeList) { if (trainee.ID == id) { noSuchTrainee = false; //Remove the old trainee and add the updated trainee DataSource.TraineeList.Remove(trainee); DataSource.TraineeList.Add(updatedTrainee.Clone()); break; } } if (noSuchTrainee) { throw new TraineesIdNotFoundException(id); } }
private void updateTrainee_Click(object sender, RoutedEventArgs e) { update_trainee update_Trainee = new update_trainee(trainee1.Clone(), this); update_Trainee.ShowDialog(); }