/// <summary> /// Button Method to EDIT Employee /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void BtnEditEmployee(object sender, RoutedEventArgs e) { if (inputDataIsCorrect) { var newEnployeeData = new Employee(tbAddName.Text, tbAddLastName.Text, age, (cbAddEmployeeDepartment.SelectedItem as Department).DepartmentName, employee.DaysWorked); switch (GetPositionIndexFromComboBox()) { case 0: newEnployeeData = new HeadOfOrganization(); break; case 1: newEnployeeData = new HeadOfDepartment(); break; case 2: newEnployeeData = new Worker(); break; case 3: newEnployeeData = new Intern(); break; default: newEnployeeData = new Employee(tbAddName.Text, tbAddLastName.Text, age, (cbAddEmployeeDepartment.SelectedItem as Department).DepartmentName, employee.DaysWorked); break; } DefineEmployeeClass(newEnployeeData); repository[employee.EmployeeName, employee.LastName, employee.Age, employee.Department, GetPositionIndex()] = newEnployeeData; CloseWindow(); } else { MessageBox.Show("The DATA you are entering is wrong!", $"{AddWindow.TitleProperty.Name}", MessageBoxButton.OK, MessageBoxImage.Error); } }
/// <summary> /// Method to ADD new Employee /// </summary> /// <param name="Name">New Employee Name</param> /// <param name="LastName">New Employee Last Name</param> /// <param name="Age">New Employee Age</param> /// <param name="Department">New Employee Department</param> public void AddEmployee(string Name, string LastName, int Age, string Department, int employeeClass) { Employee employee; switch (employeeClass) { case 0: employee = new Intern(Name, LastName, Age, Department, 0); break; case 1: employee = new Worker(Name, LastName, Age, Department, 0); break; case 2: employee = new HeadOfDepartment(Name, LastName, Age, Department, 0); break; case 3: employee = new HeadOfOrganization(Name, LastName, Age, Department, 0); break; default: employee = new Employee(Name, LastName, Age, Department, 0); break; } EmployeesDB.Add(employee); }