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

243 lines
6.1 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Ease.CoreV35;
using Ease.CoreV35.Model;
using Ease.CoreV35.Caching;
using System.Data.Linq.Mapping;
namespace Payroll.BO
{
#region WeeklyHoliday
[Serializable]
public class WeeklyHoliday : BasicBaseObject
{
ObjectsTemplate<Location> _oLocs = null;
HolidayCalendar _oHolidayCalendar = null;
ObjectsTemplate<WeeklyHoliday> _oHolidays = null;
ObjectsTemplate<AttnNationalHoliday> _oNationalHolidays = null;
ObjectsTemplate<HolidayCalendar> _oHolidayCalendars = null;
#region Cache Store
private static Cache _cache = new Cache(typeof(WeeklyHoliday));
#endregion
#region Constructor
public WeeklyHoliday()
{
_dateType = 0;
_locID = null;
}
#endregion
#region Properties
#region DateType : int
private int _dateType;
public int DateType
{
get { return _dateType; }
set
{
base.OnPropertyChange<int>("DateType", _dateType, value);
_dateType = value;
}
}
#endregion
#region LocationID : ID
private ID _locID;
public ID LocationID
{
get { return _locID; }
set
{
base.OnPropertyChange<ID>("LocationID", _locID, value);
_locID = value;
}
}
#endregion
#region Service Factory IWeeklyHolidayService : IWeeklyHolidayService
internal static IWeeklyHolidayService Service
{
get { return Services.Factory.CreateService<IWeeklyHolidayService>(typeof(IWeeklyHolidayService)); }
}
#endregion
#endregion
#region Functions
public static WeeklyHoliday Get(ID nID)
{
WeeklyHoliday oWeeklyHoliday = null;
#region Cache Header
oWeeklyHoliday = (WeeklyHoliday)_cache["Get", nID];
if (oWeeklyHoliday != null)
return oWeeklyHoliday;
#endregion
oWeeklyHoliday = WeeklyHoliday.Service.Get(nID);
#region Cache Footer
_cache.Add(oWeeklyHoliday, "Get", nID);
#endregion
return oWeeklyHoliday;
}
public static ObjectsTemplate<WeeklyHoliday> Get(EnumStatus status)
{
#region Cache Header
ObjectsTemplate<WeeklyHoliday> WeeklyHolidays = _cache["Get", status] as ObjectsTemplate<WeeklyHoliday>;
if (WeeklyHolidays != null)
return WeeklyHolidays;
#endregion
try
{
WeeklyHolidays = Service.Get(status);
}
catch (ServiceException e)
{
throw new Exception(e.Message, e);
}
#region Cache Footer
_cache.Add(WeeklyHolidays, "Get", status);
#endregion
return WeeklyHolidays;
}
public static ObjectsTemplate<WeeklyHoliday> GetCompanyEntireHolidays()
{
#region Cache Header
ObjectsTemplate<WeeklyHoliday> WeeklyHolidays = _cache["GetCompanyEntireHolidays"] as ObjectsTemplate<WeeklyHoliday>;
if (WeeklyHolidays != null)
return WeeklyHolidays;
#endregion
try
{
WeeklyHolidays = Service.GetCompanyEntireHolidays();
}
catch (ServiceException e)
{
throw new Exception(e.Message, e);
}
#region Cache Footer
_cache.Add(WeeklyHolidays, "GetCompanyEntireHolidays");
#endregion
return WeeklyHolidays;
}
public static ObjectsTemplate<WeeklyHoliday> GetByLocation(ID nLocID)
{
#region Cache Header
ObjectsTemplate<WeeklyHoliday> WeeklyHolidays = _cache["GetByLocation",nLocID] as ObjectsTemplate<WeeklyHoliday>;
if (WeeklyHolidays != null)
return WeeklyHolidays;
#endregion
try
{
WeeklyHolidays = Service.GetByLocation(nLocID);
}
catch (ServiceException e)
{
throw new Exception(e.Message, e);
}
#region Cache Footer
_cache.Add(WeeklyHolidays, "GetByLocation",nLocID);
#endregion
return WeeklyHolidays;
}
public static ObjectsTemplate<WeeklyHoliday> GetByEmployee(ID nEmpID)
{
#region Cache Header
ObjectsTemplate<WeeklyHoliday> WeeklyHolidays = _cache["GetByEmployee", nEmpID] as ObjectsTemplate<WeeklyHoliday>;
if (WeeklyHolidays != null)
return WeeklyHolidays;
#endregion
try
{
WeeklyHolidays = Service.GetByLocation(nEmpID);
}
catch (ServiceException e)
{
throw new Exception(e.Message, e);
}
#region Cache Footer
_cache.Add(WeeklyHolidays, "GetByEmployee", nEmpID);
#endregion
return WeeklyHolidays;
}
public ID Save()
{
base.SetAuditTrailProperties();
ID id= WeeklyHoliday.Service.Save(this);
return id;
}
public void Delete(ID id)
{
WeeklyHoliday.Service.Delete(id);
}
#endregion
}
#endregion
#region IWeeklyHoliday Service
public interface IWeeklyHolidayService
{
WeeklyHoliday Get(ID id);
ObjectsTemplate<WeeklyHoliday> Get(EnumStatus status);
ObjectsTemplate<WeeklyHoliday> GetCompanyEntireHolidays();
ObjectsTemplate<WeeklyHoliday> GetByLocation(ID nLocID);
ObjectsTemplate<WeeklyHoliday> GetByEmployee(ID nEmpID);
ID Save(WeeklyHoliday item);
void Delete(ID id);
}
#endregion
}