CEL_Payroll/Payroll.BO/HRBasic/Relation.cs

203 lines
5.0 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 Relation
[Serializable]
public class Relation : BasicBaseObject
{
#region Cache Store
private static Cache _cache = new Cache(typeof(Relation));
#endregion
#region constructor
public Relation()
{
_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 IRelationService : IRelationService
internal static IRelationService Service
{
get { return Services.Factory.CreateService<IRelationService>(typeof(IRelationService)); }
}
#endregion
#endregion
#region Function
public static Relation Get(ID nID)
{
Relation oRelation = null;
#region Cache Header
oRelation = (Relation)_cache["Get", nID];
if (oRelation != null)
return oRelation;
#endregion
oRelation = Relation.Service.Get(nID);
#region Cache Footer
_cache.Add(oRelation, "Get", nID);
#endregion
return oRelation;
}
public static Relation Get(string sCode)
{
Relation oRelation = null;
#region Cache Header
oRelation = (Relation)_cache["Get", sCode];
if (oRelation != null)
return oRelation;
#endregion
oRelation = Relation.Service.Get(sCode);
#region Cache Footer
_cache.Add(oRelation, "Get", sCode);
#endregion
return oRelation;
}
public static ObjectsTemplate<Relation> Get()
{
#region cache header
ObjectsTemplate<Relation> relations = _cache["Get"] as ObjectsTemplate<Relation>;
if (relations != null)
return relations;
#endregion
try
{
relations = Service.Get();
}
catch (ServiceException e)
{
throw new Exception(e.Message, e);
}
#region cache footer
_cache.Add(relations, "Get");
#endregion
return relations;
}
public static ObjectsTemplate<Relation> Get(EnumStatus status)
{
#region Cache Header
ObjectsTemplate<Relation> relations = _cache["Get", status] as ObjectsTemplate<Relation>;
if (relations != null)
return relations;
#endregion
try
{
relations = Service.Get(status);
}
catch (ServiceException e)
{
throw new Exception(e.Message, e);
}
#region Cache Footer
_cache.Add(relations, "Get", status);
#endregion
return relations;
}
public ID Save()
{
this.SetAuditTrailProperties();
return Relation.Service.Save(this);
}
public void Delete(ID id)
{
Relation.Service.Delete(id);
}
#endregion
}
#endregion
#region IRelation Service
public interface IRelationService
{
Relation Get(ID id);
Relation Get(string sCode);
ObjectsTemplate<Relation> Get();
ObjectsTemplate<Relation> Get(EnumStatus status);
ID Save(Relation item);
void Delete(ID id);
}
#endregion
}