public AddEmployee(List <Project> projects, Employee employee, MainWindow.AddEmployeeDelegate AddEmployee) { InitializeComponent(); AddEmployeeHandler = AddEmployee; _projects = projects; Type tEmployee = typeof(Employee); _jobs = Assembly.GetAssembly(tEmployee).GetTypes() .Where(type => (type.IsSubclassOf(tEmployee) && !type.IsAbstract)).ToArray(); foreach (Type job in _jobs) { cbJob.Items.Add(job.Name); } foreach (var qualification in Enum.GetNames(typeof(Qualification))) { cbQualification.Items.Add(qualification); } cbProject.Items.Add("<-- None -->"); foreach (Project project in _projects) { cbProject.Items.Add(project.ID); } if (employee == null) { tbFirstName.Text = ""; tbSecondName.Text = ""; cbJob.SelectedIndex = 0; cbQualification.SelectedIndex = 0; cbProject.SelectedIndex = 0; } else { tbFirstName.Text = employee.FirstName; tbSecondName.Text = employee.SecondName; cbJob.SelectedItem = employee.Job; cbQualification.SelectedIndex = (int)employee.Qualification; cbProject.SelectedItem = employee.ProjectID; if (employee.ProjectID == null) { cbProject.SelectedIndex = 0; } } }
public EmployeeManager(MainWindow sender) { _AddEmployeeDelegate = sender.AddEmployeeHandler; }