public void UpdateInformation(SpecialistLicenseRating licenseRating, EmployeeLicenceType licenseEmployeeLicenceType) { _licenseRating = licenseRating; UpdateComboboxs(licenseEmployeeLicenceType); dateTimePickerIssue.Value = _licenseRating.IssueDate; }
public void UpdateComboboxs(EmployeeLicenceType selectedCategory) { comboBoxFunction.Items.Clear(); comboBoxRights.Items.Clear(); IEnumerable <LicenseFunction> listFunction = null; IEnumerable <LicenseRights> listRights = null; if (selectedCategory.Category == PersonnelCategory.FlightCrewMembersPilots) { listFunction = LicenseFunction.Items.Where(l => l.Category == selectedCategory.Category); foreach (var o in listFunction) { comboBoxFunction.Items.Add(o); } listRights = LicenseRights.Items.Where(l => l.Category == selectedCategory.Category); foreach (var o in listRights) { comboBoxRights.Items.Add(o); } comboBoxRights.Items.Add(LicenseRights.UNK); } else if (selectedCategory == EmployeeLicenceType.AircraftMaintenanceEngineer || selectedCategory == EmployeeLicenceType.AircraftMaintenanceMechanic || selectedCategory == EmployeeLicenceType.AircraftMaintenanceTechnician) { listFunction = LicenseFunction.Items.Where(l => l.Category != PersonnelCategory.FlightCrewMembersPilots); foreach (var o in listFunction) { comboBoxFunction.Items.Add(o); } listRights = LicenseRights.Items.Where(l => l.Category != PersonnelCategory.FlightCrewMembersPilots); foreach (var o in listRights) { comboBoxRights.Items.Add(o); } } else { comboBoxFunction.Items.Add(LicenseFunction.UNK); comboBoxRights.Items.Add(LicenseRights.UNK); } if (listFunction != null) { comboBoxFunction.SelectedItem = listFunction.FirstOrDefault(e => e == _licenseRating.LicenseFunction) ?? LicenseFunction.UNK; } else { comboBoxFunction.SelectedItem = LicenseFunction.UNK; } if (listRights != null) { comboBoxRights.SelectedItem = listRights.FirstOrDefault(e => e == _licenseRating.Rights) ?? LicenseRights.UNK; } else { comboBoxRights.SelectedItem = LicenseRights.UNK; } }