CEL_Payroll/Payroll.BO/Discipline Action Management/Punishment.cs
2024-09-17 14:30:13 +06:00

197 lines
4.6 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 Punishment
[Serializable]
public class Punishment : BasicBaseObject
{
#region Cache Store
private static Cache _cache = new Cache(typeof(Punishment));
#endregion
#region Constructor
public Punishment()
{
_code = string.Empty;
_description = string.Empty;
}
#endregion
#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
#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 IBankService : IBankService
internal static IPunishmentService Service
{
get { return Services.Factory.CreateService<IPunishmentService>(typeof(IPunishmentService)); }
}
#endregion
#endregion
#region Functions
public static Punishment Get(ID nID)
{
Punishment oPunishment = null;
#region Cache Header
oPunishment = (Punishment)_cache["Get", nID];
if (oPunishment != null)
return oPunishment;
#endregion
oPunishment = Punishment.Service.Get(nID);
#region Cache Footer
_cache.Add(oPunishment, "Get", nID);
#endregion
return oPunishment;
}
public static ObjectsTemplate<Punishment> Get()
{
#region Cache Header
ObjectsTemplate<Punishment> oPunishments = _cache["Get"] as ObjectsTemplate<Punishment>;
if (oPunishments != null)
return oPunishments;
#endregion
try
{
oPunishments = Service.Get();
}
catch (ServiceException e)
{
throw new Exception(e.Message, e);
}
#region Cache Footer
_cache.Add(oPunishments, "Get");
#endregion
return oPunishments;
}
public static ObjectsTemplate<Punishment> Get(EnumStatus status)
{
#region Cache Header
ObjectsTemplate<Punishment> oPunishments = _cache["Get", status] as ObjectsTemplate<Punishment>;
if (oPunishments != null)
return oPunishments;
#endregion
try
{
oPunishments = Service.Get(status);
}
catch (ServiceException e)
{
throw new Exception(e.Message, e);
}
#region Cache Footer
_cache.Add(oPunishments, "Get", status);
#endregion
return oPunishments;
}
public ID Save()
{
this.SetAuditTrailProperties();
return Punishment.Service.Save(this);
}
public void Delete(ID id)
{
Punishment.Service.Delete(id);
}
#endregion
}
#endregion
#region IBank Service
public interface IPunishmentService
{
Punishment Get(ID id);
ObjectsTemplate<Punishment> Get();
ObjectsTemplate<Punishment> Get(EnumStatus status);
ID Save(Punishment item);
void Delete(ID id);
}
#endregion
}