CEL_Payroll/Payroll.BO/HRBasic/EducationLevel.cs

289 lines
7.5 KiB
C#
Raw 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;
using System.Data;
namespace Payroll.BO
{
#region Class Education Level
[Serializable]
public class EducationLevel : BasicBaseObject
{
#region cache store
private static Cache _cache = new Cache(typeof(EducationLevel));
#endregion
#region constructor
public EducationLevel()
{
_code = string.Empty;
_description = string.Empty;
_educationTypeID = null;
_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 educationTypeID : ID
private ID _educationTypeID;
public ID EducationTypeID
{
get
{
return _educationTypeID;
}
set { _educationTypeID = value; }
}
#endregion
#region Service Factory IEducationLevelService : IEducationLevelService
internal static IEducationLevelService Service
{
get { return Services.Factory.CreateService<IEducationLevelService>(typeof(IEducationLevelService)); }
}
#endregion
#endregion
#region functions
public static EducationLevel Get(ID nID)
{
EducationLevel oEducationLevel = null;
#region Cache Header
oEducationLevel = (EducationLevel)_cache["Get", nID];
if (oEducationLevel != null)
return oEducationLevel;
#endregion
oEducationLevel = EducationLevel.Service.Get(nID);
#region Cache Footer
_cache.Add(oEducationLevel, "Get", nID);
#endregion
return oEducationLevel;
}
public static EducationLevel Get(string sCode)
{
EducationLevel oEducationLevel = null;
#region cache header
oEducationLevel = (EducationLevel)_cache["Get", sCode];
if (oEducationLevel != null)
return oEducationLevel;
#endregion
oEducationLevel = EducationLevel.Service.Get(sCode);
#region cache footer
_cache.Add(oEducationLevel, "Get", sCode);
#endregion
return oEducationLevel;
}
public static ObjectsTemplate<EducationLevel> Get()
{
#region cache header
ObjectsTemplate<EducationLevel> educationLevels = _cache["Get"] as ObjectsTemplate<EducationLevel>;
if (educationLevels != null)
return educationLevels;
#endregion
try
{
educationLevels = Service.Get();
}
catch (ServiceException e)
{
throw new Exception(e.Message, e);
}
#region cache footer
_cache.Add(educationLevels, "Get");
#endregion
return educationLevels;
}
public static ObjectsTemplate<EducationLevel> Get(EnumStatus status)
{
#region Cache Header
ObjectsTemplate<EducationLevel> educationLevels = _cache["Get", status] as ObjectsTemplate<EducationLevel>;
if (educationLevels != null)
return educationLevels;
#endregion
try
{
educationLevels = Service.Get(status);
}
catch (ServiceException e)
{
throw new Exception(e.Message, e);
}
#region Cache Footer
_cache.Add(educationLevels, "Get", status);
#endregion
return educationLevels;
}
public static ObjectsTemplate<EducationLevel> GetByType(ID typeID)
{
#region Cache Header
ObjectsTemplate<EducationLevel> educationLevels = _cache["GetByType", typeID] as ObjectsTemplate<EducationLevel>;
if (educationLevels != null)
return educationLevels;
#endregion
try
{
educationLevels = Service.GetByType(typeID);
}
catch (ServiceException e)
{
throw new Exception(e.Message, e);
}
#region Cache Footer
_cache.Add(educationLevels, "GetByType", typeID);
#endregion
return educationLevels;
}
public static EducationLevel GetByLevelID(ID nLevelID)
{
EducationLevel oEducationLevel = null;
#region Cache Header
oEducationLevel = (EducationLevel)_cache["GetByLevelID", nLevelID];
if (oEducationLevel != null)
return oEducationLevel;
#endregion
oEducationLevel = EducationLevel.Service.GetByLevelID(nLevelID);
#region Cache Footer
_cache.Add(oEducationLevel, "GetByLevelID", nLevelID);
#endregion
return oEducationLevel;
}
public ID Save()
{
this.SetAuditTrailProperties();
return EducationLevel.Service.Save(this);
}
public void Delete(ID id)
{
EducationLevel.Service.Delete(id);
}
#endregion
public static System.Data.DataSet GetManpower(string sparam)
{
DataSet ds = null;
try
{
ds = Service.GetManpower(sparam);
}
catch (Exception e)
{
throw new Exception(e.Message, e);
}
return ds;
}
}
#endregion
#region IEducationLevel Service
public interface IEducationLevelService
{
EducationLevel Get(ID id);
EducationLevel Get(string sCode);
ObjectsTemplate<EducationLevel> Get();
ObjectsTemplate<EducationLevel> GetByType(ID typeID);
ObjectsTemplate<EducationLevel> Get(EnumStatus status);
EducationLevel GetByLevelID(ID LevelID);
ID Save(EducationLevel item);
void Delete(ID id);
DataSet GetManpower(string sparam);
}
#endregion
}