301 lines
6.8 KiB
C#
301 lines
6.8 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;
|
|||
|
using System.Data;
|
|||
|
|
|||
|
namespace Payroll.BO
|
|||
|
{
|
|||
|
#region Branch
|
|||
|
|
|||
|
[Serializable]
|
|||
|
public class Branch : BasicBaseObject
|
|||
|
{
|
|||
|
#region Cache Store
|
|||
|
|
|||
|
private static Cache _cache = new Cache(typeof(Branch));
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
#region Constructor
|
|||
|
|
|||
|
public Branch()
|
|||
|
{
|
|||
|
_code = string.Empty;
|
|||
|
_name = string.Empty;
|
|||
|
_address = string.Empty;
|
|||
|
_telephone = string.Empty;
|
|||
|
_bankID = ID.FromInteger(0);
|
|||
|
_bank = 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] = "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 address : string
|
|||
|
|
|||
|
private string _address;
|
|||
|
public string Address
|
|||
|
{
|
|||
|
get { return _address; }
|
|||
|
set
|
|||
|
{
|
|||
|
base.OnPropertyChange<string>("address", _address, value);
|
|||
|
_address = value;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
#region telephone : string
|
|||
|
|
|||
|
private string _telephone;
|
|||
|
public string Telephone
|
|||
|
{
|
|||
|
get { return _telephone; }
|
|||
|
set
|
|||
|
{
|
|||
|
base.OnPropertyChange<string>("telephone", _telephone, value);
|
|||
|
_telephone = value;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
#region bankID : ID
|
|||
|
|
|||
|
private ID _bankID;
|
|||
|
public ID BankID
|
|||
|
{
|
|||
|
get { return _bankID; }
|
|||
|
set
|
|||
|
{
|
|||
|
base.OnPropertyChange<ID>("bankID", _bankID, value);
|
|||
|
_bankID = value;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
#region bank : Bank
|
|||
|
|
|||
|
private Bank _bank;
|
|||
|
public Bank Bank
|
|||
|
{
|
|||
|
get
|
|||
|
{
|
|||
|
if (_bank == null && _bankID!=null && _bankID.IsUnassigned==false && _bankID.Integer>0)
|
|||
|
{
|
|||
|
_bank = new Bank();
|
|||
|
_bank = Bank.Get(_bankID);
|
|||
|
}
|
|||
|
return this._bank;
|
|||
|
}
|
|||
|
set
|
|||
|
{
|
|||
|
_bank = value;
|
|||
|
}
|
|||
|
}
|
|||
|
#endregion
|
|||
|
|
|||
|
#region Service Factory IBranchService : IBranchService
|
|||
|
|
|||
|
internal static IBranchService Service
|
|||
|
{
|
|||
|
get { return Services.Factory.CreateService<IBranchService>(typeof(IBranchService)); }
|
|||
|
}
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
#region Functions
|
|||
|
|
|||
|
|
|||
|
public string GetNextCode()
|
|||
|
{
|
|||
|
return Branch.Service.GetNextCode();
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
public static Branch Get(ID nID)
|
|||
|
{
|
|||
|
Branch oBranch = null;
|
|||
|
#region Cache Header
|
|||
|
oBranch = (Branch)_cache["Get", nID];
|
|||
|
if (oBranch != null)
|
|||
|
return oBranch;
|
|||
|
#endregion
|
|||
|
oBranch = Branch.Service.Get(nID);
|
|||
|
#region Cache Footer
|
|||
|
_cache.Add(oBranch, "Get", nID);
|
|||
|
#endregion
|
|||
|
return oBranch;
|
|||
|
}
|
|||
|
|
|||
|
public static ObjectsTemplate<Branch> GetChild(ID bankID)
|
|||
|
{
|
|||
|
#region Cache Header
|
|||
|
ObjectsTemplate<Branch> branchs = _cache["GetChild", bankID] as ObjectsTemplate<Branch>;
|
|||
|
if (branchs != null)
|
|||
|
return branchs;
|
|||
|
#endregion
|
|||
|
try
|
|||
|
{
|
|||
|
branchs = Service.GetChild(bankID);
|
|||
|
}
|
|||
|
catch (ServiceException e)
|
|||
|
{
|
|||
|
throw new Exception(e.Message, e);
|
|||
|
}
|
|||
|
#region Cache Footer
|
|||
|
_cache.Add(branchs, "GetChild", bankID);
|
|||
|
#endregion
|
|||
|
return branchs;
|
|||
|
}
|
|||
|
|
|||
|
public static ObjectsTemplate<Branch> Get(EnumStatus status)
|
|||
|
{
|
|||
|
#region Cache Header
|
|||
|
|
|||
|
ObjectsTemplate<Branch> branchs = _cache["Get",status] as ObjectsTemplate<Branch>;
|
|||
|
if (branchs != null)
|
|||
|
return branchs;
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
try
|
|||
|
{
|
|||
|
branchs = Service.Get(status);
|
|||
|
}
|
|||
|
catch (ServiceException e)
|
|||
|
{
|
|||
|
throw new Exception(e.Message, e);
|
|||
|
}
|
|||
|
|
|||
|
#region Cache Footer
|
|||
|
|
|||
|
_cache.Add(branchs, "Get",status);
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
return branchs;
|
|||
|
}
|
|||
|
|
|||
|
public static Branch GetOldBranchByID(ID branchID)
|
|||
|
{
|
|||
|
#region Cache Header
|
|||
|
|
|||
|
Branch branch = _cache["GetOldBranchByID"] as Branch;
|
|||
|
if (branch != null)
|
|||
|
return branch;
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
try
|
|||
|
{
|
|||
|
branch = Service.GetOldBranchByID(branchID);
|
|||
|
}
|
|||
|
catch (ServiceException e)
|
|||
|
{
|
|||
|
throw new Exception(e.Message, e);
|
|||
|
}
|
|||
|
|
|||
|
#region Cache Footer
|
|||
|
|
|||
|
_cache.Add(branch, "GetOldBranchByID");
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
return branch;
|
|||
|
}
|
|||
|
|
|||
|
public ID Save()
|
|||
|
{
|
|||
|
this.SetAuditTrailProperties();
|
|||
|
return Branch.Service.Save(this);
|
|||
|
}
|
|||
|
|
|||
|
public void Delete(ID id)
|
|||
|
{
|
|||
|
Branch.Service.Delete(id);
|
|||
|
}
|
|||
|
#endregion
|
|||
|
|
|||
|
}
|
|||
|
#endregion
|
|||
|
|
|||
|
#region IBranch Service
|
|||
|
|
|||
|
public interface IBranchService
|
|||
|
{
|
|||
|
Branch Get(ID id);
|
|||
|
ObjectsTemplate<Branch> GetChild(ID bankID);
|
|||
|
ObjectsTemplate<Branch> Get(EnumStatus status);
|
|||
|
Branch GetOldBranchByID(ID branchID);
|
|||
|
ID Save(Branch item);
|
|||
|
void Delete(ID id);
|
|||
|
string GetNextCode();
|
|||
|
}
|
|||
|
|
|||
|
#endregion
|
|||
|
}
|