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