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

204 lines
5.0 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 allergy
[Serializable]
public class Allergy : BasicBaseObject
{
#region Cache Store
private static Cache _cache = new Cache(typeof(Allergy));
#endregion
#region constructor
public Allergy()
{
_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 IAllergyService : IAllergyService
internal static IAllergyService Service
{
get { return Services.Factory.CreateService<IAllergyService>(typeof(IAllergyService)); }
}
#endregion
#endregion
#region Function
public static Allergy Get(ID nID)
{
Allergy oAllergy = null;
#region Cache Header
oAllergy = (Allergy)_cache["Get", nID];
if (oAllergy != null)
return oAllergy;
#endregion
oAllergy = Allergy.Service.Get(nID);
#region Cache Footer
_cache.Add(oAllergy, "Get", nID);
#endregion
return oAllergy;
}
public static Allergy Get(string sCode)
{
Allergy oAllergy = null;
#region Cache Header
oAllergy = (Allergy)_cache["Get", sCode];
if (oAllergy != null)
return oAllergy;
#endregion
oAllergy = Allergy.Service.Get(sCode);
#region Cache Footer
_cache.Add(oAllergy, "Get", sCode);
#endregion
return oAllergy;
}
public static ObjectsTemplate<Allergy> Get()
{
#region cache header
ObjectsTemplate<Allergy> relations = _cache["Get"] as ObjectsTemplate<Allergy>;
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<Allergy> Get(EnumStatus status)
{
#region Cache Header
ObjectsTemplate<Allergy> relations = _cache["Get", status] as ObjectsTemplate<Allergy>;
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 Allergy.Service.Save(this);
}
public void Delete(ID id)
{
Allergy.Service.Delete(id);
}
#endregion
}
#endregion
#region IAllergy Service
public interface IAllergyService
{
Allergy Get(ID id);
Allergy Get(string sCode);
ObjectsTemplate<Allergy> Get();
ObjectsTemplate<Allergy> Get(EnumStatus status);
ID Save(Allergy item);
void Delete(ID id);
}
#endregion
}