CEL_Payroll/Payroll.BO/Discipline Action Management/Complain.cs

197 lines
4.5 KiB
C#
Raw Permalink 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 Complain
[Serializable]
public class Complain : BasicBaseObject
{
#region Cache Store
private static Cache _cache = new Cache(typeof(Complain));
#endregion
#region Constructor
public Complain()
{
_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 IComplainService Service
{
get { return Services.Factory.CreateService<IComplainService>(typeof(IComplainService)); }
}
#endregion
#endregion
#region Functions
public static Complain Get(ID nID)
{
Complain oComplain = null;
#region Cache Header
oComplain = (Complain)_cache["Get", nID];
if (oComplain != null)
return oComplain;
#endregion
oComplain = Complain.Service.Get(nID);
#region Cache Footer
_cache.Add(oComplain, "Get", nID);
#endregion
return oComplain;
}
public static ObjectsTemplate<Complain> Get()
{
#region Cache Header
ObjectsTemplate<Complain> complains = _cache["Get"] as ObjectsTemplate<Complain>;
if (complains != null)
return complains;
#endregion
try
{
complains = Service.Get();
}
catch (ServiceException e)
{
throw new Exception(e.Message, e);
}
#region Cache Footer
_cache.Add(complains, "Get");
#endregion
return complains;
}
public static ObjectsTemplate<Complain> Get(EnumStatus status)
{
#region Cache Header
ObjectsTemplate<Complain> complains = _cache["Get", status] as ObjectsTemplate<Complain>;
if (complains != null)
return complains;
#endregion
try
{
complains = Service.Get(status);
}
catch (ServiceException e)
{
throw new Exception(e.Message, e);
}
#region Cache Footer
_cache.Add(complains, "Get", status);
#endregion
return complains;
}
public ID Save()
{
this.SetAuditTrailProperties();
return Complain.Service.Save(this);
}
public void Delete(ID id)
{
Complain.Service.Delete(id);
}
#endregion
}
#endregion
#region IBank Service
public interface IComplainService
{
Complain Get(ID id);
ObjectsTemplate<Complain> Get();
ObjectsTemplate<Complain> Get(EnumStatus status);
ID Save(Complain item);
void Delete(ID id);
}
#endregion
}