/// <summary> /// Весь персонал по StructureObjectID недороблено /// </summary> public List <StaffEmployeeView> GetAllHierarhyView(int StructureObjectID) { List <StaffEmployeeView> result; //using (var cdc = new CompasDataContext()) //{ StaffStructureObjectsLogic structureObjectsLogic = new StaffStructureObjectsLogic(manager); //List<Helpers.ItemIntValue> allObjects = structureObjectsLogic.GetStructureObjectsHierarchy(StructureObjectID); result = this.ConvertListToListView((from a in context.StaffEmployees where a.StructureObjectID == StructureObjectID select a).ToList()); //} return(result); }
/// <summary> /// Загальний працівників по відділу /// </summary> /// <returns></returns> public List <StaffEmployee> GetAllWithSubDepartments(int StructureObjectID) { List <StaffEmployee> result = new List <StaffEmployee>(); //using (var cdc = new CompasDataContext()) //{ StaffStructureObjectsLogic structureObjectsLogic = new StaffStructureObjectsLogic(manager); List <Helpers.ItemIntValue> structureObjects = structureObjectsLogic.GetStructureObjectsHierarchy(false, StructureObjectID).ToList(); Compas.Helpers.ItemIntValue rootItemInt = new Helpers.ItemIntValue(); rootItemInt.ID = Convert.ToInt32(StructureObjectID); rootItemInt.Name = "root"; structureObjects.Add(rootItemInt); foreach (Helpers.ItemIntValue so in structureObjects) { foreach (StaffEmployee employee in this.GetAll(so.ID)) { result.Add(employee); } } return(result); }
public int Recalculate(DateTime Month, int StructureObjectID) { int result = 1; StaffEmployeeLogic employeesLogic = new StaffEmployeeLogic(manager); StaffStructureObjectsLogic structureObjectsLogic = new StaffStructureObjectsLogic(manager); //List<Helpers.ItemIntValue> structureObjects = structureObjectsLogic.GetStructureObjectsHierarchy(false, StructureObjectID).ToList(); //спочатку вибираємо працівників, що працюють в цьому відділі і всіх дочірніх відділах StaffEmployeePositionsLogic positionsLogic = new StaffEmployeePositionsLogic(manager); List <StaffEmployee> employees = positionsLogic.GetAllWithSubDepartments(StructureObjectID);; //проходимо покожному окремому працівнику foreach (StaffEmployee employee in employees) { //здійснюємо перерахунок по цьому працівнику decimal prevMonthSalary = 0; decimal prevMonthExtraPercent = 0; decimal currentMonthSalary = 0; decimal currentMonthExtraPercent = 0; decimal documentsSum = 0; //шукаємо документи до яких прикріплений даний працівник DocumentsLogic documentsLogic = new DocumentsLogic(manager); DocumentDetailsLogic documentDetailsLogic = new DocumentDetailsLogic(manager); DocumentStaffDetailsLogic documentStaffDetailsLogic = new DocumentStaffDetailsLogic(manager); List <WareDocument> documents = documentsLogic.GetDocumentsByEmployeeID(employee.ID, Month, Month.AddMonths(1)); //визначаємо суму документів foreach (WareDocument document in documents) { documentsSum = documentsSum + document.DocumentSum; } //для цього спочатку шукаємо оклад працівника за ПОТОЧНИЙ місяць, якщо такий відсутній, то прирівнюємо до 0 StaffEmployeeSalary currentSalary = this.GetByEmployeeID(employee.ID, Month); if (currentSalary != null) { currentMonthSalary = currentSalary.Salary; currentMonthExtraPercent = currentSalary.ExtraPercent; currentSalary.SumSale = documentsSum; currentSalary.SumSalary = currentSalary.SumSale * (currentMonthExtraPercent / 100) + currentMonthSalary; } else { //для цього спочатку шукаємо оклад працівника за попередній місяць, якщо такий відсутній, то прирівнюємо до 0 StaffEmployeeSalary prevSalary = this.GetByEmployeeID(employee.ID, Month.AddMonths(-1)); if (prevSalary != null) { prevMonthSalary = prevSalary.Salary; prevMonthExtraPercent = prevSalary.ExtraPercent; } currentMonthSalary = prevMonthSalary; currentMonthExtraPercent = prevMonthExtraPercent; this.Create(Month, StructureObjectID, employee.ID, documentsSum, currentMonthExtraPercent, currentMonthSalary); } } return(result); }