CEL_Payroll/Payroll.BO/Survey/SurveyCategory.cs
2024-09-17 14:30:13 +06:00

204 lines
5.1 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
{
[Serializable]
public class SurveyCategory:BasicBaseObject
{
#region Cache Store
private static Cache _cache = new Cache(typeof(SurveyCategory));
#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.Description == "")
{
sErrorString[0] = "Description can not be empty";
sErrorString[1] = "Description";
return sErrorString;
}
sErrorString = null;
return sErrorString;
}
#endregion
public SurveyCategory()
{
_categoryID = null;
_code = string.Empty;
_description = string.Empty;
_status = EnumStatus.Active;
}
#endregion
#region Properties
#region CategoryID : ID
private ID _categoryID;
public ID CategoryID
{
get { return _categoryID; }
set
{
base.OnPropertyChange<ID>("CategoryID", _categoryID, value);
_categoryID = value;
}
}
#endregion
#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 ISurveyCategoryService : ISurveyCategoryService
internal static ISurveyCategoryService Service
{
get { return Services.Factory.CreateService<ISurveyCategoryService>(typeof(ISurveyCategoryService)); }
}
#endregion
#endregion
#region Functions
public string GetNextCode()
{
return SurveyCategory.Service.GetNextCode();
}
public static SurveyCategory Get(ID nID)
{
SurveyCategory oSurveyCategory = null;
#region Cache Header
oSurveyCategory = (SurveyCategory)_cache["Get", nID];
if (oSurveyCategory != null)
return oSurveyCategory;
#endregion
oSurveyCategory = SurveyCategory.Service.Get(nID);
#region Cache Footer
_cache.Add(oSurveyCategory, "Get", nID);
#endregion
return oSurveyCategory;
}
public static SurveyCategory Get(string sCode)
{
SurveyCategory oSurveyCategory = null;
#region Cache Header
oSurveyCategory = (SurveyCategory)_cache["Get", sCode];
if (oSurveyCategory != null)
return oSurveyCategory;
#endregion
oSurveyCategory = SurveyCategory.Service.Get(sCode);
#region Cache Footer
_cache.Add(oSurveyCategory, "Get", sCode);
#endregion
return oSurveyCategory;
}
public static ObjectsTemplate<SurveyCategory> Get(EnumStatus status)
{
#region Cache Header
ObjectsTemplate<SurveyCategory> SurveyCategorys = _cache["Get",status] as ObjectsTemplate<SurveyCategory>;
if (SurveyCategorys != null)
return SurveyCategorys;
#endregion
try
{
SurveyCategorys = Service.Get(status);
}
catch (ServiceException e)
{
throw new Exception(e.Message, e);
}
#region Cache Footer
_cache.Add(SurveyCategorys, "Get",status);
#endregion
return SurveyCategorys;
}
public ID Save()
{
this.SetAuditTrailProperties();
return SurveyCategory.Service.Save(this);
}
public void Delete(ID id)
{
SurveyCategory.Service.Delete(id);
}
#endregion
}
#region ISurveyCategory Service
public interface ISurveyCategoryService
{
SurveyCategory Get(ID id);
ObjectsTemplate<SurveyCategory> Get(EnumStatus status);
ID Save(SurveyCategory item);
void Delete(ID id);
SurveyCategory Get(string sCode);
string GetNextCode();
}
#endregion
}