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 EmployeeHistory [Serializable] public class EmployeeHistory : AuditTrailBase { #region Cache Store private static Cache _cache = new Cache(typeof(EmployeeHistory)); #endregion #region Constructor public EmployeeHistory() { _employeeID = null; _effectDate = DateTime.MinValue; _endDate = DateTime.MinValue; _employeeStatus = EnumEmployeeStatus.Live; _remarks = string.Empty; } #endregion #region Properties #region employeeID : ID private ID _employeeID; public ID EmployeeID { get { return _employeeID; } set { base.OnPropertyChange("employeeID", _employeeID, value); _employeeID = value; } } #endregion #region effectDate : DateTime private DateTime _effectDate; public DateTime EffectDate { get { return _effectDate; } set { base.OnPropertyChange("effectDate", _effectDate, value); _effectDate = value; } } #endregion #region endDate : DateTime private DateTime _endDate; public DateTime EndDate { get { return _endDate; } set { base.OnPropertyChange("endDate", _endDate, value); _endDate = value; } } #endregion #region employeeStatus : EnumEmployeeStatus private EnumEmployeeStatus _employeeStatus; public EnumEmployeeStatus EmployeeStatus { get { return _employeeStatus; } set { base.OnPropertyChange("employeeStatus", (short)_employeeStatus, (short)value); _employeeStatus = value; } } #endregion #region remarks : string private string _remarks; public string Remarks { get { return _remarks; } set { base.OnPropertyChange("remarks", _remarks, value); _remarks = value; } } #endregion #region Service Factory IEmployeeHistoryService : IEmployeeHistoryService internal static IEmployeeHistoryService Service { get { return Services.Factory.CreateService(typeof(IEmployeeHistoryService)); } } #endregion #endregion #region Functions public static EmployeeHistory Get(ID nID) { EmployeeHistory oEmployeeHistory = null; #region Cache Header oEmployeeHistory = (EmployeeHistory)_cache["Get", nID]; if (oEmployeeHistory != null) return oEmployeeHistory; #endregion oEmployeeHistory = EmployeeHistory.Service.Get(nID); #region Cache Footer _cache.Add(oEmployeeHistory, "Get", nID); #endregion return oEmployeeHistory; } public static EmployeeHistory GetByEmpID(ID nEmpID) { EmployeeHistory oEmployeeHistory = null; #region Cache Header oEmployeeHistory = (EmployeeHistory)_cache["Get", nEmpID]; if (oEmployeeHistory != null) return oEmployeeHistory; #endregion oEmployeeHistory = EmployeeHistory.Service.GetByEmpID(nEmpID); #region Cache Footer _cache.Add(oEmployeeHistory, "Get", nEmpID); #endregion return oEmployeeHistory; } public static EmployeeHistory GetEmpLastHistory(ID nEmpID) { EmployeeHistory oEmployeeHistory = null; #region Cache Header oEmployeeHistory = (EmployeeHistory)_cache["GetEmpLastHistory", nEmpID]; if (oEmployeeHistory != null) return oEmployeeHistory; #endregion oEmployeeHistory = EmployeeHistory.Service.GetEmpLastHistory(nEmpID); #region Cache Footer _cache.Add(oEmployeeHistory, "GetEmpLastHistory", nEmpID); #endregion return oEmployeeHistory; } public static ObjectsTemplate Get() { #region Cache Header ObjectsTemplate employeeHistorys = _cache["Get"] as ObjectsTemplate; if (employeeHistorys != null) return employeeHistorys; #endregion try { employeeHistorys = Service.Get(); } catch (ServiceException e) { throw new Exception(e.Message, e); } #region Cache Footer _cache.Add(employeeHistorys, "Get"); #endregion return employeeHistorys; } public ID Save(bool disAfterCurrmonth, bool continuePF) { this.SetAuditTrailProperties(); return EmployeeHistory.Service.Save(this,disAfterCurrmonth, continuePF); } //public void SaveConfirm(bool confirmEmpPF, EnumEmployeeOtherStatus IsConfirm) //{ // this.SetAuditTrailProperties(); // EmployeeHistory.Service.SaveConfirm(this,confirmEmpPF,IsConfirm); //} public void DoContinue(bool continuePF) { this.SetAuditTrailProperties(); EmployeeHistory.Service.DoContinue(this, continuePF); } public void Delete() { EmployeeHistory.Service.Delete(ID); } public void DeleteByEmpID(ID nEmpID) { EmployeeHistory.Service.DeleteByEmpID(nEmpID); } public static DataSet GetEmpHistory(DateTime dEffectDate, DateTime dEffectDate2) { DataSet ds = null; try { ds = Service.GetEmpHistory(dEffectDate, dEffectDate2,Payroll.BO.SystemInformation.CurrentSysInfo.PayrollTypeID.Integer); } catch (Exception e) { throw new Exception(e.Message, e); } return ds; } public static DateTime GetDate(int nEmpID, EnumEmployeeStatus ParamID) { DateTime dt ; dt = Service.GetDate(nEmpID,ParamID); return dt; } #endregion } #endregion #region IEmployeeHistory Service public interface IEmployeeHistoryService { EmployeeHistory Get(ID id); EmployeeHistory GetByEmpID(ID nEmpID); EmployeeHistory GetEmpLastHistory(ID nEmpID); ObjectsTemplate Get(); ID Save(EmployeeHistory item, bool disAfterCurrmonth, bool continuePF); // void SaveConfirm(EmployeeHistory item,bool confirmEmpPF,EnumEmployeeOtherStatus IsConfirm); ID DoContinue(EmployeeHistory item,bool continuePF); void Delete(ID id); void DeleteByEmpID(ID nEmpID); DataSet GetEmpHistory(DateTime dEffectDate, DateTime dEffectDate2, int payrollTypeID); DateTime GetDate(int nEmpID, EnumEmployeeStatus ParamID); } #endregion }