CEL_Payroll/Payroll.BO/HRBasic/District.cs

213 lines
5.2 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;
namespace Payroll.BO
{
#region class District
[Serializable]
public class District : BasicBaseObject
{
#region Cache Store
private static Cache _cache = new Cache(typeof(District));
#endregion
#region constructor
public District()
{
_code = string.Empty;
_name = string.Empty;
_divisionID = null;
_status = EnumStatus.Active;
}
#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 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", _code, value);
_name = value;
}
}
#endregion
#region divisionID : ID
private ID _divisionID;
public ID DivisionID
{
get { return _divisionID; }
set { _divisionID = value; }
}
#endregion
#region Service Factory IDistrictService : IDistrictService
internal static IDistrictService Service
{
get { return Services.Factory.CreateService<IDistrictService>(typeof(IDistrictService)); }
}
#endregion
#endregion
#region Function
public static District Get(ID nID)
{
District oDistrict = null;
#region Cache Header
oDistrict = (District)_cache["Get", nID];
if (oDistrict != null)
return oDistrict;
#endregion
oDistrict = District.Service.Get(nID);
#region Cache Footer
_cache.Add(oDistrict, "Get", nID);
#endregion
return oDistrict;
}
public static District Get(string sCode)
{
District oDistrict = null;
#region Cache Header
oDistrict = (District)_cache["Get", sCode];
if (oDistrict != null)
return oDistrict;
#endregion
oDistrict = District.Service.Get(sCode);
#region Cache Footer
_cache.Add(oDistrict, "Get", sCode);
#endregion
return oDistrict;
}
public static ObjectsTemplate<District> Get()
{
#region cache header
ObjectsTemplate<District> districts = _cache["Get"] as ObjectsTemplate<District>;
if (districts != null)
return districts;
#endregion
try
{
districts = Service.Get();
}
catch (ServiceException e)
{
throw new Exception(e.Message, e);
}
#region cache footer
_cache.Add(districts, "Get");
#endregion
return districts;
}
public static ObjectsTemplate<District> Get(EnumStatus status)
{
#region Cache Header
ObjectsTemplate<District> districts = _cache["Get", status] as ObjectsTemplate<District>;
if (districts != null)
return districts;
#endregion
try
{
districts = Service.Get(status);
}
catch (ServiceException e)
{
throw new Exception(e.Message, e);
}
#region Cache Footer
_cache.Add(districts, "Get", status);
#endregion
return districts;
}
public ID Save()
{
this.SetAuditTrailProperties();
return District.Service.Save(this);
}
public void Delete(ID id)
{
District.Service.Delete(id);
}
#endregion
}
#endregion
#region IDistrict Service
public interface IDistrictService
{
District Get(ID id);
District Get(string sCode);
ObjectsTemplate<District> Get();
ObjectsTemplate<District> Get(EnumStatus status);
ID Save(District item);
void Delete(ID id);
}
#endregion
}