public EmployeeHolidaysInfo CalculateAndUpdate() { EmployeeHolidaysInfo entity = GetEntity(EmployeeId, Year); if (entity == null) { entity = new EmployeeHolidaysInfo(); entity.Year = (short)Year; entity.EmployeeID = EmployeeId; entity.NewHolidays = entity.OldHolidays = 0; entity.PlannedHolidays = entity.TakenHolidays = 0; entity.SpareHolidaysExc = entity.SpareHolidaysInc = 0; entity.UsedHolidays = 0; } ExEmployeeHolidays.CalculateAndUpdate(entity); Debug.Assert(!entity.IsNew); return(entity); //int TodayYear = DateTimeHelper.GetYearByDate(DateTime.Today); //DateTime begin_year_date = DateTimeHelper.GetBeginYearDate(Year); //DateTime end_year_date = DateTimeHelper.GetEndYearDate(Year); //StoreService storeservice = ServerEnvironment.StoreService as StoreService; //EmlpoyeeHolidaysSumDays sums_by_year = // storeservice.EmlpoyeeHolidaysSumInfoByEmployeeIDGet(EmployeeId, begin_year_date, end_year_date, DateTime.Today); //EmployeeHolidaysInfo entity = Service.GetEntity(EmployeeId, Year); //if (entity == null) //{ // entity = new EmployeeHolidaysInfo(); // entity.Year = (short)Year; // entity.EmployeeID = EmployeeId; // entity.NewHolidays = entity.OldHolidays = 0; // entity.PlannedHolidays = entity.TakenHolidays = 0; // entity.SpareHolidaysExc = entity.SpareHolidaysInc = 0; //} //if (sums_by_year != null) //{ // entity.TakenHolidays = Math.Round(sums_by_year.TimeRecording / 1440, 2); // entity.PlannedHolidays = Math.Round(sums_by_year.TimePlanning / 1440, 2); //} //Service.SaveOrUpdate(entity); //return entity; }
public static void CalculateAndUpdate(long[] emplids, int Year) { if (emplids != null) { ExEmployeeHolidays ex_holidays = null; foreach (long id in emplids) { if (ex_holidays == null) { ex_holidays = new ExEmployeeHolidays(id, Year); ex_holidays.CalculateAndUpdate(); } else { ex_holidays.EmployeeId = id; ex_holidays.Year = Year; ex_holidays.CalculateAndUpdate(); } } } }