예제 #1
0
        public static EmployeeHolidaysInfo UpdateSpareHolidaysExc_Austria(EmployeeHolidaysInfo entity, double spare_holidays)
        {
            if (entity == null)
                throw new ArgumentNullException();
            decimal new_spare_exc = Convert.ToDecimal(spare_holidays);
            decimal old_spare_exc = entity.SpareHolidaysExc;

            bool bModified = entity.IsNew || (old_spare_exc != new_spare_exc);

            entity.SpareHolidaysExc = new_spare_exc;
            bModified |= entity.CalculateSpareHolidays_Austria();

            if (bModified)
                Srv.SaveOrUpdate(entity);

            return entity;
        }
예제 #2
0
        public static EmployeeHolidaysInfo CalculateAndUpdate(EmployeeHolidaysInfo entity, bool bAustria)
        {
            Debug.Assert(entity != null);

            if (entity == null) return null;

            Debug.WriteLine("Begin calculate: " + entity.ToString());
            int TodayYear = DateTimeHelper.GetYearByDate(DateTime.Today);

            DateTime begin_year_date = DateTimeHelper.GetBeginYearDate(entity.Year);
            DateTime end_year_date = DateTimeHelper.GetEndYearDate(entity.Year);

            StoreService storeservice = ServerEnvironment.StoreService as StoreService;
            EmlpoyeeHolidaysSumDays sums_by_year =
                storeservice.EmlpoyeeHolidaysSumInfoByEmployeeIDGet(entity.EmployeeID, begin_year_date, end_year_date, DateTime.Today);

            bool bModified = entity.IsNew;

            if (sums_by_year != null)
            {
                //decimal taken = Math.Round(sums_by_year.TimeRecording / 1440, 2);
                //decimal used = Math.Round(sums_by_year.TimePlanning / 1440, 2);

                decimal taken = Math.Round(sums_by_year.TimeRecording, 2);
                decimal used = Math.Round(sums_by_year.TimePlanning, 2);

                bModified |= (taken != entity.TakenHolidays) ||
                    (used != entity.PlannedHolidays);

                entity.TakenHolidays = taken;
                entity.PlannedHolidays = used;
            }
            if (bAustria )
                bModified |= entity.CalculateSpareHolidays_Austria();
            else
                bModified |= entity.CalculateSpareHolidays();

            //Debug.Assert(entity.IsNew == bModified);

            if (bModified)
            {
                Debug.WriteLine("Entity was changed : " + entity.ToString());
                Srv.SaveOrUpdate(entity);
            }

            Debug.WriteLine("End calculate: " + entity.ToString());
            return entity;
        }