CEL_Payroll/Payroll.BO/HRBasic/NominationPurpose.cs

208 lines
5.5 KiB
C#
Raw Normal View History

2024-09-17 14:30:13 +06:00
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 class NominationPurpose
[Serializable]
public class NominationPurpose : BasicBaseObject
{
#region cache store
private static Cache _cache = new Cache(typeof(NominationPurpose));
#endregion
#region constructor
#region Input validator
public string[] InputValidator()
{
string[] sErrorString = new string[2];
if (this.Code == "")
{
sErrorString[0] = "Code can not be empty";
sErrorString[1] = "Code";
return sErrorString;
}
if (this.Description == "")
{
sErrorString[0] = "Description can not be empty";
sErrorString[1] = "Description";
return sErrorString;
}
sErrorString = null;
return sErrorString;
}
#endregion
public NominationPurpose()
{
_code = string.Empty;
_description = string.Empty;
_status = EnumStatus.Active;
}
#endregion
#region properties
#region code : string
private string _code;
public string Code
{
get { return _code; }
set
{
base.OnPropertyChange<string>("CODE", _code, value);
_code = 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 Service Factory INominationPurposeService : INominationPurposeService
internal static INominationPurposeService Service
{
get { return Services.Factory.CreateService<INominationPurposeService>(typeof(INominationPurposeService)); }
}
#endregion
#endregion
#region Function
public static NominationPurpose Get(ID nID)
{
NominationPurpose oNominationPurpose = null;
#region Cache Header
oNominationPurpose = (NominationPurpose)_cache["Get", nID];
if (oNominationPurpose != null)
return oNominationPurpose;
#endregion
oNominationPurpose = NominationPurpose.Service.Get(nID);
#region Cache Footer
_cache.Add(oNominationPurpose, "Get", nID);
#endregion
return oNominationPurpose;
}
public static NominationPurpose Get(string sCode)
{
NominationPurpose oNominationPurpose = null;
#region Cache Header
oNominationPurpose = (NominationPurpose)_cache["Get", sCode];
if (oNominationPurpose != null)
return oNominationPurpose;
#endregion
oNominationPurpose = NominationPurpose.Service.Get(sCode);
#region Cache Footer
_cache.Add(oNominationPurpose, "Get", sCode);
#endregion
return oNominationPurpose;
}
public static ObjectsTemplate<NominationPurpose> Get()
{
#region cache header
ObjectsTemplate<NominationPurpose> nominationPurposes = _cache["Get"] as ObjectsTemplate<NominationPurpose>;
if (nominationPurposes != null)
return nominationPurposes;
#endregion
try
{
nominationPurposes = Service.Get();
}
catch (ServiceException e)
{
throw new Exception(e.Message, e);
}
#region cache footer
_cache.Add(nominationPurposes, "Get");
#endregion
return nominationPurposes;
}
public static ObjectsTemplate<NominationPurpose> Get(EnumStatus status)
{
#region Cache Header
ObjectsTemplate<NominationPurpose> nominationPurposes = _cache["Get", status] as ObjectsTemplate<NominationPurpose>;
if (nominationPurposes != null)
return nominationPurposes;
#endregion
try
{
nominationPurposes = Service.Get(status);
}
catch (ServiceException e)
{
throw new Exception(e.Message, e);
}
#region Cache Footer
_cache.Add(nominationPurposes, "Get", status);
#endregion
return nominationPurposes;
}
public ID Save()
{
this.SetAuditTrailProperties();
return NominationPurpose.Service.Save(this);
}
public void Delete(ID id)
{
NominationPurpose.Service.Delete(id);
}
#endregion
}
#endregion
#region INationality Service
public interface INominationPurposeService
{
NominationPurpose Get(ID id);
NominationPurpose Get(string sCode);
ObjectsTemplate<NominationPurpose> Get();
ObjectsTemplate<NominationPurpose> Get(EnumStatus status);
ID Save(NominationPurpose item);
void Delete(ID id);
}
#endregion
}