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

202 lines
5.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 class occupation
[Serializable]
public class Occupation : BasicBaseObject
{
#region Cache Store
private static Cache _cache = new Cache(typeof(Occupation));
#endregion
#region Constructor
public Occupation()
{
_code = string.Empty;
_description = string.Empty;
_status = EnumStatus.Active;
}
#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
#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 IOccupationService : IOccupationService
internal static IOccupationService Service
{
get { return Services.Factory.CreateService<IOccupationService>(typeof(IOccupationService)); }
}
#endregion
#endregion
#region Function
public static Occupation Get(ID nID)
{
Occupation oOccupation = null;
#region Cache Header
oOccupation = (Occupation)_cache["Get", nID];
if (oOccupation != null)
return oOccupation;
#endregion
oOccupation = Occupation.Service.Get(nID);
#region Cache Footer
_cache.Add(oOccupation, "Get", nID);
#endregion
return oOccupation;
}
public static Occupation Get(string sCode)
{
Occupation oOccupation = null;
#region Cache Header
oOccupation = (Occupation)_cache["Get", sCode];
if (oOccupation != null)
return oOccupation;
#endregion
oOccupation = Occupation.Service.Get(sCode);
#region Cache Footer
_cache.Add(oOccupation, "Get", sCode);
#endregion
return oOccupation;
}
public static ObjectsTemplate<Occupation> Get()
{
#region cache header
ObjectsTemplate<Occupation> occupations = _cache["Get"] as ObjectsTemplate<Occupation>;
if (occupations != null)
return occupations;
#endregion
try
{
occupations = Service.Get();
}
catch (ServiceException e)
{
throw new Exception(e.Message, e);
}
#region cache footer
_cache.Add(occupations, "Get");
#endregion
return occupations;
}
public static ObjectsTemplate<Occupation> Get(EnumStatus status)
{
#region Cache Header
ObjectsTemplate<Occupation> occupations = _cache["Get", status] as ObjectsTemplate<Occupation>;
if (occupations != null)
return occupations;
#endregion
try
{
occupations = Service.Get(status);
}
catch (ServiceException e)
{
throw new Exception(e.Message, e);
}
#region Cache Footer
_cache.Add(occupations, "Get", status);
#endregion
return occupations;
}
public ID Save()
{
this.SetAuditTrailProperties();
return Occupation.Service.Save(this);
}
public void Delete(ID id)
{
Occupation.Service.Delete(id);
}
#endregion
}
#endregion
#region IOccupation Service
public interface IOccupationService
{
Occupation Get(ID id);
Occupation Get(string sCode);
ObjectsTemplate<Occupation> Get();
ObjectsTemplate<Occupation> Get(EnumStatus status);
ID Save(Occupation item);
void Delete(ID id);
}
#endregion
}