CEL_Payroll/Payroll.BO/Tax/TaxInvestment.cs

169 lines
4.0 KiB
C#
Raw Permalink 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 TaxInvestment
[Serializable]
public class TaxInvestment : BasicBaseObject
{
#region Cache Store
private static Cache _cache = new Cache(typeof(TaxInvestment));
#endregion
#region Constructor
public TaxInvestment()
{
_code = string.Empty;
_name = string.Empty;
_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] = "Description can not be empty";
sErrorString[1] = "Description";
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", _name, value);
_name = value;
}
}
#endregion
#region Service Factory ITaxInvestmentService : ITaxInvestmentService
internal static ITaxInvestmentService Service
{
get { return Services.Factory.CreateService<ITaxInvestmentService>(typeof(ITaxInvestmentService)); }
}
#endregion
#endregion
#region Functions
public static TaxInvestment Get(ID nID)
{
TaxInvestment oTaxInvestment = null;
#region Cache Header
oTaxInvestment = (TaxInvestment)_cache["Get", nID];
if (oTaxInvestment != null)
return oTaxInvestment;
#endregion
oTaxInvestment = TaxInvestment.Service.Get(nID);
#region Cache Footer
_cache.Add(oTaxInvestment, "Get", nID);
#endregion
return oTaxInvestment;
}
public static ObjectsTemplate<TaxInvestment> Get(EnumStatus status)
{
#region Cache Header
ObjectsTemplate<TaxInvestment> taxInvestments = _cache["Get",status] as ObjectsTemplate<TaxInvestment>;
if (taxInvestments != null)
return taxInvestments;
#endregion
try
{
taxInvestments = Service.Get(status);
}
catch (ServiceException e)
{
throw new Exception(e.Message, e);
}
#region Cache Footer
_cache.Add(taxInvestments, "Get",status);
#endregion
return taxInvestments;
}
public ID Save()
{
this.SetAuditTrailProperties();
return TaxInvestment.Service.Save(this);
}
public void Delete(ID id)
{
TaxInvestment.Service.Delete(id);
}
#endregion
}
#endregion
#region ITaxInvestment Service
public interface ITaxInvestmentService
{
TaxInvestment Get(ID id);
ObjectsTemplate<TaxInvestment> Get(EnumStatus status);
ID Save(TaxInvestment item);
void Delete(ID id);
}
#endregion
}