286 lines
6.7 KiB
C#
286 lines
6.7 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;
|
|||
|
using System.Data;
|
|||
|
|
|||
|
|
|||
|
namespace Payroll.BO
|
|||
|
{
|
|||
|
#region SkillLevel
|
|||
|
[Serializable]
|
|||
|
public class SkillLevel : BasicBaseObject
|
|||
|
{
|
|||
|
#region Cache Store
|
|||
|
|
|||
|
private static Cache _cache = new Cache(typeof(SkillLevel));
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
#region Constructor
|
|||
|
|
|||
|
public SkillLevel()
|
|||
|
{
|
|||
|
_value = string.Empty;
|
|||
|
_code = string.Empty;
|
|||
|
_name = string.Empty;
|
|||
|
//_skillPoint = 0;
|
|||
|
}
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
#region Properties
|
|||
|
|
|||
|
#region Property value : string
|
|||
|
|
|||
|
protected string _value;
|
|||
|
public string Value
|
|||
|
{
|
|||
|
get { return _value; }
|
|||
|
set { _value = value; }
|
|||
|
}
|
|||
|
|
|||
|
#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.Name == "")
|
|||
|
{
|
|||
|
sErrorString[0] = "Name can not be empty";
|
|||
|
sErrorString[1] = "Name";
|
|||
|
return sErrorString;
|
|||
|
}
|
|||
|
|
|||
|
sErrorString = null;
|
|||
|
return sErrorString;
|
|||
|
}
|
|||
|
#endregion
|
|||
|
|
|||
|
#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 skillPoint : int
|
|||
|
|
|||
|
//private int _skillPoint;
|
|||
|
//public int SkillPoint
|
|||
|
//{
|
|||
|
// get { return _skillPoint; }
|
|||
|
// set
|
|||
|
// {
|
|||
|
// base.OnPropertyChange<int>("skillPoint", _skillPoint, value);
|
|||
|
// _skillPoint = value;
|
|||
|
// }
|
|||
|
//}
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
#region Service Factory ISkillLevelService : ISkillLevelService
|
|||
|
|
|||
|
internal static ISkillLevelService Service
|
|||
|
{
|
|||
|
get { return Services.Factory.CreateService<ISkillLevelService>(typeof(ISkillLevelService)); }
|
|||
|
}
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
#region Functions
|
|||
|
|
|||
|
public ID Save()
|
|||
|
{
|
|||
|
try
|
|||
|
{
|
|||
|
if(this.IsNew)
|
|||
|
{
|
|||
|
if (IsExists(this.Code))
|
|||
|
{
|
|||
|
throw new ServiceException("Code already exists");
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
base.SetAuditTrailProperties();
|
|||
|
return SkillLevel.Service.Save(this);
|
|||
|
}
|
|||
|
|
|||
|
catch (ServiceException e)
|
|||
|
{
|
|||
|
throw new ServiceException(e.Message, e);
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
public void Delete(ID id)
|
|||
|
{
|
|||
|
SkillLevel.Service.Delete(id);
|
|||
|
}
|
|||
|
|
|||
|
public static SkillLevel Get(ID nID)
|
|||
|
{
|
|||
|
SkillLevel oSkilLevel = null;
|
|||
|
#region Cache Header
|
|||
|
oSkilLevel = (SkillLevel)_cache["Get", nID];
|
|||
|
if (oSkilLevel != null)
|
|||
|
return oSkilLevel;
|
|||
|
#endregion
|
|||
|
oSkilLevel = SkillLevel.Service.Get(nID);
|
|||
|
#region Cache Footer
|
|||
|
_cache.Add(oSkilLevel, "Get", nID);
|
|||
|
#endregion
|
|||
|
return oSkilLevel;
|
|||
|
}
|
|||
|
|
|||
|
public static ObjectsTemplate<SkillLevel> Get()
|
|||
|
{
|
|||
|
#region Cache Header
|
|||
|
ObjectsTemplate<SkillLevel> oSkilLevel = _cache["Get"] as ObjectsTemplate<SkillLevel>;
|
|||
|
if (oSkilLevel != null)
|
|||
|
return oSkilLevel;
|
|||
|
#endregion
|
|||
|
try
|
|||
|
{
|
|||
|
oSkilLevel = Service.Get();
|
|||
|
}
|
|||
|
catch (ServiceException e)
|
|||
|
{
|
|||
|
throw new Exception(e.Message, e);
|
|||
|
}
|
|||
|
#region Cache Footer
|
|||
|
_cache.Add(oSkilLevel, "Get");
|
|||
|
#endregion
|
|||
|
return oSkilLevel;
|
|||
|
}
|
|||
|
|
|||
|
public static ObjectsTemplate<SkillLevel> Get(EnumStatus status)
|
|||
|
{
|
|||
|
#region Cache Header
|
|||
|
|
|||
|
ObjectsTemplate<SkillLevel> skills = _cache["Get", status] as ObjectsTemplate<SkillLevel>;
|
|||
|
if (skills != null)
|
|||
|
return skills;
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
try
|
|||
|
{
|
|||
|
skills = Service.Get(status);
|
|||
|
}
|
|||
|
catch (ServiceException e)
|
|||
|
{
|
|||
|
throw new Exception(e.Message, e);
|
|||
|
}
|
|||
|
|
|||
|
#region Cache Footer
|
|||
|
|
|||
|
_cache.Add(skills, "Get", status);
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
return skills;
|
|||
|
}
|
|||
|
|
|||
|
private bool IsExists(string Code)
|
|||
|
{
|
|||
|
try
|
|||
|
{
|
|||
|
bool isExists = false;
|
|||
|
if (this.Code != null && this.Value.ToUpper() != Code.ToUpper())
|
|||
|
{
|
|||
|
isExists = SkillLevel.Service.IsExists(Code);
|
|||
|
}
|
|||
|
return isExists;
|
|||
|
}
|
|||
|
catch (ServiceException e)
|
|||
|
{
|
|||
|
throw new ServiceException(e.Message, e);
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
//public static ObjectsTemplate<SkillLevel> GetChilds(ID parentID)
|
|||
|
//{
|
|||
|
// #region Cache Header
|
|||
|
|
|||
|
// ObjectsTemplate<SkillLevel> skills = _cache["GetChilds"] as ObjectsTemplate<SkillLevel>;
|
|||
|
// if (skills != null)
|
|||
|
// return skills;
|
|||
|
|
|||
|
// #endregion
|
|||
|
|
|||
|
// try
|
|||
|
// {
|
|||
|
// skills = Service.GetChilds(parentID);
|
|||
|
// }
|
|||
|
// catch (ServiceException e)
|
|||
|
// {
|
|||
|
// throw new Exception(e.Message, e);
|
|||
|
// }
|
|||
|
|
|||
|
// #region Cache Footer
|
|||
|
|
|||
|
// _cache.Add(skills, "GetChilds");
|
|||
|
|
|||
|
// #endregion
|
|||
|
|
|||
|
// return skills;
|
|||
|
//}
|
|||
|
#endregion
|
|||
|
}
|
|||
|
#endregion
|
|||
|
|
|||
|
#region ISkilLevel Service
|
|||
|
|
|||
|
public interface ISkillLevelService
|
|||
|
{
|
|||
|
ID Save(SkillLevel item);
|
|||
|
void Delete(ID id);
|
|||
|
SkillLevel Get(ID id);
|
|||
|
ObjectsTemplate<SkillLevel> Get();
|
|||
|
ObjectsTemplate<SkillLevel> Get(EnumStatus status);
|
|||
|
//ObjectsTemplate<SkillLevel> GetChilds(ID parentID);
|
|||
|
bool IsExists(string Code);
|
|||
|
}
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
}
|