184 lines
4.3 KiB
C#
184 lines
4.3 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 Function
|
|||
|
|
|||
|
[Serializable]
|
|||
|
public class Function : BasicBaseObject
|
|||
|
{
|
|||
|
#region Cache Store
|
|||
|
|
|||
|
private static Cache _cache = new Cache(typeof(Function));
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
#region Constructor
|
|||
|
|
|||
|
#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.Name == "")
|
|||
|
{
|
|||
|
sErrorString[0] = "Description can not be empty";
|
|||
|
sErrorString[1] = "Description";
|
|||
|
return sErrorString;
|
|||
|
}
|
|||
|
|
|||
|
sErrorString = null;
|
|||
|
return sErrorString;
|
|||
|
}
|
|||
|
#endregion
|
|||
|
|
|||
|
public Function()
|
|||
|
{
|
|||
|
_code = string.Empty;
|
|||
|
_name = string.Empty;
|
|||
|
_status = EnumStatus.Active;
|
|||
|
}
|
|||
|
|
|||
|
#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 name : string
|
|||
|
|
|||
|
private string _name;
|
|||
|
public string Name
|
|||
|
{
|
|||
|
get { return _name; }
|
|||
|
set
|
|||
|
{
|
|||
|
base.OnPropertyChange<string>("name", _name, value);
|
|||
|
_name = value;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
#region Service Factory IFunctionService : IFunctionService
|
|||
|
|
|||
|
internal static IFunctionService Service
|
|||
|
{
|
|||
|
get { return Services.Factory.CreateService<IFunctionService>(typeof(IFunctionService)); }
|
|||
|
}
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
#region Functions
|
|||
|
|
|||
|
public static Function Get(ID nID)
|
|||
|
{
|
|||
|
Function oFunction = null;
|
|||
|
#region Cache Header
|
|||
|
oFunction = (Function)_cache["Get", nID];
|
|||
|
if (oFunction != null)
|
|||
|
return oFunction;
|
|||
|
#endregion
|
|||
|
oFunction = Function.Service.Get(nID);
|
|||
|
#region Cache Footer
|
|||
|
_cache.Add(oFunction, "Get", nID);
|
|||
|
#endregion
|
|||
|
return oFunction;
|
|||
|
}
|
|||
|
public static Function Get(string sCode)
|
|||
|
{
|
|||
|
Function oFunction = null;
|
|||
|
#region Cache Header
|
|||
|
oFunction = (Function)_cache["Get", sCode];
|
|||
|
if (oFunction != null)
|
|||
|
return oFunction;
|
|||
|
#endregion
|
|||
|
oFunction = Function.Service.Get(sCode);
|
|||
|
#region Cache Footer
|
|||
|
_cache.Add(oFunction, "Get", sCode);
|
|||
|
#endregion
|
|||
|
return oFunction;
|
|||
|
}
|
|||
|
public static ObjectsTemplate<Function> Get(EnumStatus status)
|
|||
|
{
|
|||
|
#region Cache Header
|
|||
|
|
|||
|
ObjectsTemplate<Function> Functions = _cache["Get", status] as ObjectsTemplate<Function>;
|
|||
|
if (Functions != null)
|
|||
|
return Functions;
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
try
|
|||
|
{
|
|||
|
Functions = Service.Get(status);
|
|||
|
}
|
|||
|
catch (ServiceException e)
|
|||
|
{
|
|||
|
throw new Exception(e.Message, e);
|
|||
|
}
|
|||
|
|
|||
|
#region Cache Footer
|
|||
|
|
|||
|
_cache.Add(Functions, "Get", status);
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
return Functions;
|
|||
|
}
|
|||
|
|
|||
|
public ID Save()
|
|||
|
{
|
|||
|
base.SetAuditTrailProperties();
|
|||
|
return Function.Service.Save(this);
|
|||
|
}
|
|||
|
public void Delete(ID id)
|
|||
|
{
|
|||
|
Function.Service.Delete(id);
|
|||
|
}
|
|||
|
#endregion
|
|||
|
|
|||
|
}
|
|||
|
#endregion
|
|||
|
|
|||
|
#region IFunction Service
|
|||
|
|
|||
|
public interface IFunctionService
|
|||
|
{
|
|||
|
Function Get(ID id);
|
|||
|
Function Get(string sCode);
|
|||
|
ObjectsTemplate<Function> Get(EnumStatus status);
|
|||
|
ID Save(Function item);
|
|||
|
void Delete(ID id);
|
|||
|
}
|
|||
|
|
|||
|
#endregion
|
|||
|
}
|