Beispiel #1
0
        /// <summary>
        /// Созадает младший состав работников отдела (Вспомогательный метод)
        /// </summary>
        /// <param name="count">Количество работников</param>
        /// <param name="dep">Экземпляр отдела</param>
        /// <returns>Коллекцию работников</returns>
        ObservableCollection <Person> First_Level_Employees(int count, AbsDepartment dep)
        {
            Random random = new Random(Guid.NewGuid().GetHashCode());

            ObservableCollection <Person> employees = new ObservableCollection <Person>();
            int interns = random.Next(0, count / 3);
            int empl    = count - interns;
            int hw      = (count / random.Next(4, 9)) + 1;

            for (int i = 0; i < interns; i++)
            {
                Intern inter = new Intern($"Интерн_{i}", $"Отдела_{dep.Id}", "Интерн", dep);
                inter.Salary = 25000;
                employees.Add(inter);
            }
            for (int i = 0; i < empl; i++)
            {
                Employee emp = new Employee($"Рабочий{i}", $"Отдела_{dep.Id}", "Сотрудник", dep);
                emp.Salary = 150;
                emp.Hours  = random.Next(0, 200);
                employees.Add(emp);
            }
            for (int i = 0; i < hw; i++)
            {
                LocalManager wkr = new LocalManager($"Главарь{i}", $"Отдела_{dep.Id}", "Руководитель отдела", dep);
                wkr.CoefSalary = 0.15;
                wkr.LowSalary  = 1000;
                employees.Add(wkr);
            }
            return(employees);
        }
Beispiel #2
0
 public override void Edit(AbsDepartment editedDepartment)
 {
     if (editedDepartment.GetType() == this.GetType())
     {
         Title = editedDepartment.Title;
     }
 }
Beispiel #3
0
        static public ObservableCollection <Person> HeadsOfDepartament(AbsDepartment department)
        {
            ObservableCollection <Person> employees = new ObservableCollection <Person>();

            foreach (Person w in EmployeesList)
            {
                if (w.DepartmentId == department.Id && w is LocalManager)
                {
                    employees.Add(w);
                }
            }
            foreach (var d in department.Departments)
            {
                employees.Concat(HeadsOfDepartament(d));
            }
            return(employees);
        }
Beispiel #4
0
        /// <summary>
        /// Получить всех сотрудников департамента и вложенных департаментов)
        /// </summary>
        /// <param name="departament">Экземпляр департамента</param>
        /// <returns></returns>
        static public ObservableCollection <Person> PersonalsOfDepartament(AbsDepartment department)
        {
            ObservableCollection <Person> workers = new ObservableCollection <Person>();

            foreach (Person w in EmployeesList)
            {
                if (w.DepartmentId == department.Id)
                {
                    workers.Add(w);
                }
            }
            foreach (var d in department.Departments)
            {
                workers.Concat(PersonalsOfDepartament(d));
            }
            return(workers);
        }
Beispiel #5
0
        static public ObservableCollection <Person> WorkersOfDepartament(AbsDepartment department)
        {
            ObservableCollection <Person> employees = new ObservableCollection <Person>();

            foreach (Person w in EmployeesList)
            {
                if (w.DepartmentId == department.Id && w is Intern)
                {
                    employees.Add(w);
                }
                if (w.DepartmentId == department.Id && w is Employee)
                {
                    employees.Add(w);
                }
            }
            foreach (var d in department.Departments)
            {
                employees.Concat(WorkersOfDepartament(d));
            }
            return(employees);
        }
Beispiel #6
0
 public AbsManager(string name, string surname, string position, AbsDepartment departament)
     : base(name, surname, position, departament)
 {
 }
Beispiel #7
0
 /// <summary>
 /// Конструктор
 /// </summary>
 /// <param name="name"></param>
 /// <param name="lastName"></param>
 /// <param name="position"></param>
 /// <param name="departament"></param>
 public Employee(string name, string lastName, string position, AbsDepartment departament)
     : base(name, lastName, position, departament)
 {
 }
Beispiel #8
0
        /// <summary>
        /// Создает работников отдела
        /// </summary>
        /// <param name="count">Количество работников</param>
        /// <param name="dep">Экземпляр департамента</param>
        /// <returns>Коллекцию работников</returns>
        ObservableCollection <Person> Second_Level_Employees(int count, AbsDepartment dep)
        {
            Random random = new Random(Guid.NewGuid().GetHashCode());

            ObservableCollection <Person> employees = new ObservableCollection <Person>();

            if (dep.Departments.Count == 0)
            {
                employees = First_Level_Employees(count, dep);
            }
            else
            {
                int ld = 0;
                foreach (var d in dep.Departments)
                {
                    if (d.Employees.Count == 0)
                    {
                        d.Employees = Second_Level_Employees(count, d);
                    }
                    foreach (var e in d.Employees)
                    {
                        if (e.GetType() == typeof(DepBranchManager))
                        {
                            ld++;
                        }
                        if (e.GetType() == typeof(BranchOfficeManager))
                        {
                            ld++;
                        }
                    }
                }

                if (ld > 0)
                {
                    employees = First_Level_Employees(count, dep);
                    BranchOfficeManager emp = new BranchOfficeManager($"Еще больший Начальник", $"Отдела_{dep.Id}", "Директор филиала", dep);
                    emp.CoefSalary = 0.4;
                    emp.LowSalary  = 6000;
                    employees.Add(emp);
                }
                else
                {
                    employees = First_Level_Employees(count, dep);
                    DepBranchManager emp = new DepBranchManager($"Большой начальник", $"Отдела_{dep.Id}", "Директор ветки департаментов", dep);

                    emp.CoefSalary = 0.25;
                    emp.LowSalary  = 2000;
                    employees.Add(emp);
                }
                //Заполняем верхний уровень департаментов
                if (dep.inheritedID == 1)
                {
                    //Обычный персонал. Секретарши и т.п.
                    employees = First_Level_Employees(random.Next(3, 6), dep);
                    for (int i = 0; i < dep.Departments.Count; i++)
                    {
                        TopManager wkr = new TopManager($"ТОП", $"Департамента_{dep.Id}", "Гендир", dep);

                        wkr.CoefSalary = 0.4;
                        wkr.LowSalary  = 12000;
                        employees.Add(wkr);
                    }
                }
            }
            return(employees);
        }