public void RecalculateAfterImport(DateTime monday) { long id = BzEmployee.Employee.ID; if (!IsNeedRecalculationAfterImport(id, monday)) { return; } int lastSaldo = 0; if (BzEmployee.AustriaEmployee) { lastSaldo = Convert.ToInt32(BzEmployee.Employee.BalanceHours); } else { DateTime prevMonday = monday.AddDays(-7); IEmployeeWeek week = RecordingWeeks.GetByDate(id, prevMonday); if (week == null) { week = GetByDate(id, prevMonday); if (week == null) { lastSaldo = BzEmployee.GetLastSaldoForPlanning(monday); } else { lastSaldo = week.Saldo; } } else { lastSaldo = week.Saldo; } } List <EmployeeWeekTimePlanning> list = GetEntitiesByEmployeeId(id); if (list != null && list.Count > 0) { int contract = 0; bool allin = false; bool customedit = false; bool bModified = false; foreach (EmployeeWeekTimePlanning entity in list) { contract = 0; allin = false; customedit = false; bModified = false; if (entity.EmployeeID == id && entity.WeekBegin >= monday) { allin = AllInManager.GetAllIn(id, entity.WeekBegin, entity.WeekEnd); if (RecordingWeeks != null) { EmployeeWeekTimeRecording rec = RecordingWeeks.GetByDate(id, entity.WeekBegin); if (rec != null) { customedit = rec.CustomEdit; } } contract = Contracts.GetContractHours(entity.EmployeeID, entity.WeekBegin, entity.WeekEnd); bModified = (entity.CustomEdit != customedit) | (entity.AllIn != allin) | (entity.ContractHours != contract); if (bModified) { entity.CustomEdit = customedit; entity.AllIn = allin; entity.ContractHours = contract; } if (entity.CalculateSaldo(lastSaldo) | bModified) { UpdateEntity(entity); } lastSaldo = entity.Saldo; } } } }