CEL_Payroll/Payroll.BO/PF/PFTransaction.cs

199 lines
4.8 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;
using System.Data;
namespace Payroll.BO
{
#region PFTransaction
[Serializable]
public class PFTransaction : AuditTrailBase
{
#region Cache Store
private static Cache _cache = new Cache(typeof(PFTransaction));
#endregion
#region Constructor
public PFTransaction()
{
_employeeID = null;
_monthDate = DateTime.MinValue;
_tranAmount = 0;
_tranType = 0;
}
#endregion
#region Properties
#region EmployeeID : ID
private ID _employeeID;
public ID EmployeeID
{
get { return _employeeID; }
set
{
base.OnPropertyChange<ID>("EmployeeID", _employeeID, value);
_employeeID = value;
}
}
#endregion
#region monthDate : DateTime
private DateTime _monthDate;
public DateTime MonthDate
{
get { return _monthDate; }
set
{
base.OnPropertyChange<DateTime>("monthDate", _monthDate, value);
_monthDate = value;
}
}
#endregion
#region tranAmount : double
private double _tranAmount;
public double TranAmount
{
get { return _tranAmount; }
set
{
base.OnPropertyChange<double>("tranAmount", _tranAmount, value);
_tranAmount = value;
}
}
#endregion
#region tranType : EnumPFTranType
private EnumPFTranType _tranType;
public EnumPFTranType TranType
{
get { return _tranType; }
set
{
base.OnPropertyChange<short>("tranType", (short)_tranType, (short)value);
_tranType = value;
}
}
#endregion
#region Service Factory IPFTransactionService : IPFTransactionService
internal static IPFTransactionService Service
{
get { return Services.Factory.CreateService<IPFTransactionService>(typeof(IPFTransactionService)); }
}
#endregion
#endregion
#region Functions
public static ObjectsTemplate<PFTransaction> Get()
{
#region Cache Header
ObjectsTemplate<PFTransaction> pFTransactions = _cache["Get"] as ObjectsTemplate<PFTransaction>;
if (pFTransactions != null)
return pFTransactions;
#endregion
try
{
pFTransactions = Service.Get();
}
catch (ServiceException e)
{
throw new Exception(e.Message, e);
}
#region Cache Footer
_cache.Add(pFTransactions, "Get");
#endregion
return pFTransactions;
}
public static double GetPFAmount(int nEmployeeID)
{
double nAmount = 0;
nAmount = Service.GetPFAmount(nEmployeeID);
return nAmount;
}
public static DataSet GetPFBalance(int nEmployeeID, DateTime saalryMonth)
{
DataSet pfBalance = null;
pfBalance = Service.GetPFBalance(nEmployeeID, saalryMonth);
return pfBalance;
}
public static DataSet GetPFBalance(DateTime dMonth)
{
DataSet pfBalance = null;
pfBalance = Service.GetPFBalance(dMonth);
return pfBalance;
}
public void SetAuditTrail()
{
this.SetAuditTrailProperties();
}
public ID Save()
{
SetAuditTrail();
return PFTransaction.Service.Save(this);
}
public void SaveAll(List<PFTransaction> items)
{
foreach (PFTransaction oItem in items)
{
oItem.SetAuditTrailProperties();
}
PFTransaction.Service.SaveAll(items);
}
public void Delete(ID employeeId, DateTime month, EnumPFTranType type)
{
PFTransaction.Service.Delete(employeeId, month, type);
}
#endregion
}
#endregion
#region IPFTransaction Service
public interface IPFTransactionService
{
ObjectsTemplate<PFTransaction> Get();
ID Save(PFTransaction item);
void SaveAll(List<PFTransaction> items);
void Delete(ID emloyeeId, DateTime month, EnumPFTranType type);
double GetPFAmount(int nEmployeeID);
DataSet GetPFBalance(int nEmpID, DateTime salaryMonth);
DataSet GetPFBalance(DateTime salaryMonth);
}
#endregion
}