예제 #1
0
    // получаем список сотрудников в конкретном отделе
    public List<Employee> getEmployeesOfDepartment(List<EmployeeAttrib> emp_attribs, string depID, string period)
    {
        SQLDB db = new SQLDB();
        List<Employee> all_employees = db.getEmployeesOfDepartment(depID, period);
        List<Employee> new_employees = new List<Employee>();

        foreach (EmployeeAttrib emp_attr in emp_attribs)
        {
            if (new_employees.Count > 0)
            {
                Employee employee = new_employees.Find(delegate(Employee emp) { return emp.EmployeeID.Equals(emp_attr.EmployeeID); });
                if (employee == null)
                {
                    List<Employee> employees = all_employees.FindAll(delegate(Employee emp) { return emp.EmployeeID.Equals(emp_attr.EmployeeID); });

                    foreach (Employee em in employees)
                        new_employees.Add(em);

                }
            }
            else
            {
                List<Employee> employees = all_employees.FindAll(delegate(Employee emp) { return emp.EmployeeID.Equals(emp_attr.EmployeeID); });

                foreach (Employee em in employees)
                    new_employees.Add(em);
            }

        }

        EmployeeComparerByFullnameASC cp = new EmployeeComparerByFullnameASC();
        new_employees.Sort(cp);

        return new_employees;
    }