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

272 lines
6.2 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
{
#region Bank
[Serializable]
public class Bank : BasicBaseObject
{
#region Cache Store
private static Cache _cache = new Cache(typeof(Bank));
#endregion
#region Constructor
public Bank()
{
_code = string.Empty;
_name = string.Empty;
_accountingformat = string.Empty;
_branchs = null;
_status = EnumStatus.Active;
_accountNo = 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 AccountNo
private string _accountNo;
public string AccountNo
{
get { return _accountNo; }
set { _accountNo = value; }
}
#endregion
#region accountingformat : string
private string _accountingformat;
public string Accountingformat
{
get { return _accountingformat; }
set
{
base.OnPropertyChange<string>("accountingformat", _accountingformat, value);
_accountingformat = value;
}
}
#endregion
#region Branch : Branch
private ObjectsTemplate<Branch> _branchs;
public ObjectsTemplate<Branch> Branchs
{
get
{
if (_id.Integer > 0 && _branchs == null)
{
_branchs = new ObjectsTemplate<Branch>();
_branchs = Branch.GetChild(this.ID); //GradeSegment.Get(_gradeSegmentID);
}
return this._branchs;
}
set
{
_branchs = value;
}
}
#endregion
#region Service Factory IBankService : IBankService
internal static IBankService Service
{
get { return Services.Factory.CreateService<IBankService>(typeof(IBankService)); }
}
#endregion
#endregion
#region Functions
public string GetNextCode()
{
return Bank.Service.GetNextCode();
}
public static Bank Get(ID nID)
{
Bank oBank = null;
#region Cache Header
oBank = (Bank)_cache["Get", nID];
if (oBank != null)
return oBank;
#endregion
oBank = Bank.Service.Get(nID);
#region Cache Footer
_cache.Add(oBank, "Get", nID);
#endregion
return oBank;
}
public static Bank GetByBrancID(ID nID)
{
Bank oBank = null;
#region Cache Header
oBank = (Bank)_cache["GetByBrancID", nID];
if (oBank != null)
return oBank;
#endregion
oBank = Bank.Service.GetByBrancID(nID);
#region Cache Footer
_cache.Add(oBank, "GetByBrancID", nID);
#endregion
return oBank;
}
public static ObjectsTemplate<Bank> Get()
{
#region Cache Header
ObjectsTemplate<Bank> banks = _cache["Get"] as ObjectsTemplate<Bank>;
if (banks != null)
return banks;
#endregion
try
{
banks = Service.Get();
}
catch (ServiceException e)
{
throw new Exception(e.Message, e);
}
#region Cache Footer
_cache.Add(banks, "Get");
#endregion
return banks;
}
public static ObjectsTemplate<Bank> Get(EnumStatus status)
{
#region Cache Header
ObjectsTemplate<Bank> banks = _cache["Get", status] as ObjectsTemplate<Bank>;
if (banks != null)
return banks;
#endregion
try
{
banks = Service.Get(status);
}
catch (ServiceException e)
{
throw new Exception(e.Message, e);
}
#region Cache Footer
_cache.Add(banks, "Get",status);
#endregion
return banks;
}
public ID Save()
{
this.SetAuditTrailProperties();
return Bank.Service.Save(this);
}
public void Delete(ID id)
{
Bank.Service.Delete(id);
}
#endregion
}
#endregion
#region IBank Service
public interface IBankService
{
Bank Get(ID id);
ObjectsTemplate<Bank> Get();
ObjectsTemplate<Bank> Get(EnumStatus status);
Bank GetByBrancID(ID id);
ID Save(Bank item);
void Delete(ID id);
string GetNextCode();
}
#endregion
}