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

259 lines
6.6 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 WorkPlanGroup
[Serializable]
public class WorkPlanGroup : BasicBaseObject
{
#region Cache Store
private static Cache _cache = new Cache(typeof(WorkPlanGroup));
#endregion
#region Constructor
#region Input validator
public string[] InputValidator()
{
string[] sErrorString = new string[2];
if (this.Name == "")
{
sErrorString[0] = "Name can not be empty";
sErrorString[1] = "Name";
return sErrorString;
}
sErrorString = null;
return sErrorString;
}
#endregion
public WorkPlanGroup()
{
_name = string.Empty;
_status = EnumStatus.Active;
}
#endregion
#region Properties
#region Name : String
private string _name;
public string Name
{
get { return _name; }
set
{
base.OnPropertyChange<string
>("Name", _name, value);
_name = value;
}
}
#endregion
#region Type : EnumWorkPlanDayType
private EnumWorkPlanGroup _type;
public EnumWorkPlanGroup Type
{
get { return _type; }
set
{
base.OnPropertyChange<short>("Type", (short)_type, (short)value);
_type = value;
}
}
#endregion
#region Type : FromTime
private DateTime _fromTime;
public DateTime FromTime
{
get { return _fromTime; }
set
{
base.OnPropertyChange<DateTime>("FromTime", _fromTime, value);
_fromTime = value;
}
}
#endregion
#region Type : ToTime
private DateTime _toTime;
public DateTime ToTime
{
get { return _toTime; }
set
{
base.OnPropertyChange<DateTime>("ToTime", _toTime, value);
_toTime = value;
}
}
#endregion
#region payrollTypeID : ID
private ID _payrollTypeID;
public ID PayrollTypeID
{
get { return _payrollTypeID; }
set
{
base.OnPropertyChange<ID>("payrollTypeID", _payrollTypeID, value);
_payrollTypeID = value;
}
}
#endregion
#region Service Factory IWorkPlanGroupService : IWorkPlanGroupService
internal static IWorkPlanGroupService Service
{
get { return Services.Factory.CreateService<IWorkPlanGroupService>(typeof(IWorkPlanGroupService)); }
}
#endregion
#endregion
#region Functions
public static WorkPlanGroup Get(ID nID)
{
WorkPlanGroup oWorkPlanGroup = null;
#region Cache Header
oWorkPlanGroup = (WorkPlanGroup)_cache["Get", nID];
if (oWorkPlanGroup != null)
return oWorkPlanGroup;
#endregion
oWorkPlanGroup = WorkPlanGroup.Service.GetByID(nID,SystemInformation.CurrentSysInfo.PayrollTypeID);
#region Cache Footer
_cache.Add(oWorkPlanGroup, "Get", nID);
#endregion
return oWorkPlanGroup;
}
public static ObjectsTemplate<WorkPlanGroup> Get()
{
#region Cache Header
ObjectsTemplate<WorkPlanGroup> workPlanGroups = _cache["Get"] as ObjectsTemplate<WorkPlanGroup>;
if (workPlanGroups != null)
return workPlanGroups;
#endregion
try
{
workPlanGroups = Service.Get(SystemInformation.CurrentSysInfo.PayrollTypeID);
}
catch (ServiceException e)
{
throw new Exception(e.Message, e);
}
#region Cache Footer
_cache.Add(workPlanGroups, "Get");
#endregion
return workPlanGroups;
}
public static ObjectsTemplate<WorkPlanGroup> Get(EnumStatus status)
{
#region Cache Header
ObjectsTemplate<WorkPlanGroup> workPlanGroups = _cache["Get", status] as ObjectsTemplate<WorkPlanGroup>;
if (workPlanGroups != null)
return workPlanGroups;
#endregion
try
{
workPlanGroups = Service.Get(status, SystemInformation.CurrentSysInfo.PayrollTypeID);
}
catch (ServiceException e)
{
throw new Exception(e.Message, e);
}
#region Cache Footer
_cache.Add(workPlanGroups, "Get", status);
#endregion
return workPlanGroups;
}
public static ObjectsTemplate<WorkPlanGroup> Get(EnumWorkPlanGroup WPG)
{
#region Cache Header
ObjectsTemplate<WorkPlanGroup> workPlanGroups = _cache["Get", WPG] as ObjectsTemplate<WorkPlanGroup>;
if (workPlanGroups != null)
return workPlanGroups;
#endregion
try
{
workPlanGroups = Service.Get(WPG, SystemInformation.CurrentSysInfo.PayrollTypeID);
}
catch (ServiceException e)
{
throw new Exception(e.Message, e);
}
#region Cache Footer
_cache.Add(workPlanGroups, "Get", WPG);
#endregion
return workPlanGroups;
}
public ID Save()
{
if (this.IsNew)
{
this.Status = EnumStatus.Active;
}
this.SetAuditTrailProperties();
return WorkPlanGroup.Service.Save(this, SystemInformation.CurrentSysInfo.PayrollTypeID);
}
public void Delete(ID id)
{
WorkPlanGroup.Service.Delete(id);
}
#endregion
}
#endregion
#region IAccesscardType Service
public interface IWorkPlanGroupService
{
WorkPlanGroup GetByID(ID id,ID PayrollTypeID);
ObjectsTemplate<WorkPlanGroup> Get(ID PayrolltypeID);
ObjectsTemplate<WorkPlanGroup> Get(EnumStatus status,ID PayrolltypeID);
ObjectsTemplate<WorkPlanGroup> Get(EnumWorkPlanGroup wPlanGroup,ID PayrolltypeID);
ID Save(WorkPlanGroup item,ID PayrolltypeID);
void Delete(ID id);
}
#endregion
}