CEL_Payroll/Payroll.BO/Attendence/HolidayCalendar.cs
2024-09-17 14:30:13 +06:00

276 lines
8.3 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Ease.CoreV35.Caching;
using Ease.CoreV35.Model;
namespace Payroll.BO
{
#region HolidayCalendar
[Serializable]
public class HolidayCalendar : AuditTrailBase
{
#region Cache Store
private static Cache _cache = new Cache(typeof(HolidayCalendar));
#endregion
#region Constructor
public HolidayCalendar()
{
_type = 0;
_description = string.Empty;
_holidayDate = DateTime.MinValue;
_locationID = null;
}
#endregion
#region Properties
#region type : EnumHolidayType
private EnumHolidayType _type;
public EnumHolidayType Type
{
get { return _type; }
set
{
base.OnPropertyChange<short>("type", (short)_type, (short)value);
_type = value;
}
}
#endregion
#region description : string
private string _description;
public string Description
{
get { return _description; }
set
{
base.OnPropertyChange<string>("description", _description, value);
_description = value;
}
}
#endregion
#region holidayDate : DateTime
private DateTime _holidayDate;
public DateTime HolidayDate
{
get { return _holidayDate; }
set
{
base.OnPropertyChange<DateTime>("holidayDate", _holidayDate, value);
_holidayDate = value;
}
}
#endregion
#region LocationID : ID
private ID _locationID;
public ID LocationID
{
get { return _locationID; }
set
{
base.OnPropertyChange<ID>("locationID", _locationID, value);
_locationID = value;
}
}
#endregion
#region Service Factory IHolidayCalendarService : IHolidayCalendarService
internal static IHolidayCalendarService Service
{
get { return Services.Factory.CreateService<IHolidayCalendarService>(typeof(IHolidayCalendarService)); }
}
#endregion
#endregion
#region Functions
public static HolidayCalendar Get(ID nID)
{
HolidayCalendar oHolidayCalendar = null;
#region Cache Header
oHolidayCalendar = (HolidayCalendar)_cache["Get", nID];
if (oHolidayCalendar != null)
return oHolidayCalendar;
#endregion
oHolidayCalendar = HolidayCalendar.Service.Get(nID);
#region Cache Footer
_cache.Add(oHolidayCalendar, "Get", nID);
#endregion
return oHolidayCalendar;
}
public static int GetTotalMonthlyHolidays(int loactionNumber, DateTime firstDateOfMonth, DateTime lastDateOfMonth)
{
int totalMonthlyHoliDays = 0;
try
{
totalMonthlyHoliDays = Service.GetTotalMonthlyHolidays(loactionNumber, firstDateOfMonth, lastDateOfMonth);
}
catch (ServiceException e)
{
throw new Exception(e.Message, e);
}
return totalMonthlyHoliDays;
}
public static ObjectsTemplate<HolidayCalendar> Get()
{
#region Cache Header
ObjectsTemplate<HolidayCalendar> holidayCalendars = _cache["Get"] as ObjectsTemplate<HolidayCalendar>;
if (holidayCalendars != null)
return holidayCalendars;
#endregion
try
{
holidayCalendars = Service.Get();
}
catch (ServiceException e)
{
throw new Exception(e.Message, e);
}
#region Cache Footer
_cache.Add(holidayCalendars, "Get");
#endregion
return holidayCalendars;
}
public static ObjectsTemplate<HolidayCalendar> GetWeeklyHoliDay()
{
#region Cache Header
ObjectsTemplate<HolidayCalendar> holidayCalendars = _cache["GetWeeklyHoliDay"] as ObjectsTemplate<HolidayCalendar>;
if (holidayCalendars != null)
return holidayCalendars;
#endregion
try
{
holidayCalendars = Service.GetWeeklyHoliDay();
}
catch (ServiceException e)
{
throw new Exception(e.Message, e);
}
#region Cache Footer
_cache.Add(holidayCalendars, "GetWeeklyHoliDay");
#endregion
return holidayCalendars;
}
public static ObjectsTemplate<HolidayCalendar> GetHoliDayByLocation(ID nLocID)
{
#region Cache Header
ObjectsTemplate<HolidayCalendar> holidayCalendars = _cache["GetHoliDayByLocation", nLocID] as ObjectsTemplate<HolidayCalendar>;
if (holidayCalendars != null)
return holidayCalendars;
#endregion
try
{
holidayCalendars = Service.GetHoliDayByLocation(nLocID);
}
catch (ServiceException e)
{
throw new Exception(e.Message, e);
}
#region Cache Footer
_cache.Add(holidayCalendars, "GetHoliDayByLocation", nLocID);
#endregion
return holidayCalendars;
}
public static ObjectsTemplate<HolidayCalendar> GetWeeklyAndLocHoliday(ID nLocID)
{
#region Cache Header
ObjectsTemplate<HolidayCalendar> holidayCalendars = _cache["GetWeeklyAndLocHoliday", nLocID] as ObjectsTemplate<HolidayCalendar>;
if (holidayCalendars != null)
return holidayCalendars;
#endregion
try
{
holidayCalendars = Service.GetWeeklyAndLocHoliday(nLocID);
}
catch (ServiceException e)
{
throw new Exception(e.Message, e);
}
#region Cache Footer
_cache.Add(holidayCalendars, "GetWeeklyAndLocHoliday", nLocID);
#endregion
return holidayCalendars;
}
public static ObjectsTemplate<HolidayCalendar> GetbyMonthRange(int nLocationID , DateTime dStartDate , DateTime dEndDate)
{
return HolidayCalendar.Service.GetbyMonthRange(nLocationID , dStartDate , dEndDate);
}
public static ObjectsTemplate<HolidayCalendar> GetbyDateRange(DateTime dStartDate , DateTime dEndDate)
{
return HolidayCalendar.Service.GetbyDateRange(dStartDate , dEndDate);
}
public static double GetNoofHoliday()
{
return HolidayCalendar.Service.GetNoofHoliday();
}
public ID Save()
{
this.SetAuditTrailProperties();
return HolidayCalendar.Service.Save(this);
}
public void Delete()
{
HolidayCalendar.Service.Delete(ID);
}
public void DeleteAll()
{
HolidayCalendar.Service.DeleteAll();
}
public void DeleteAll(int nYear)
{
HolidayCalendar.Service.DeleteAll(nYear);
}
#endregion
}
#endregion
#region IHolidayCalendar Service
public interface IHolidayCalendarService
{
HolidayCalendar Get(ID id);
int GetTotalMonthlyHolidays(int loactionNumber, DateTime firstDateOfMonth, DateTime lastDateOfMonth);
ObjectsTemplate<HolidayCalendar> Get();
ObjectsTemplate<HolidayCalendar> GetWeeklyHoliDay();
ObjectsTemplate<HolidayCalendar> GetHoliDayByLocation(ID nLocID);
ObjectsTemplate<HolidayCalendar> GetWeeklyAndLocHoliday(ID nLocID);
double GetNoofHoliday();
ID Save(HolidayCalendar item);
void Delete(ID id);
void DeleteAll();
void DeleteAll(int nYear);
ObjectsTemplate<HolidayCalendar> GetbyMonthRange(int nLocationID , DateTime dStartDate , DateTime dEndDate);
ObjectsTemplate<HolidayCalendar> GetbyDateRange(DateTime dStartDate , DateTime dEndDate);
}
#endregion
}