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 EmployeePosting [Serializable] public class EmployeePosting : AuditTrailBase { #region Cache Store private static Cache _cache = new Cache(typeof(EmployeePosting)); #endregion #region Constructor public EmployeePosting() { _employeeID = null; _effectDate = DateTime.MinValue; _departmentID = null; _locationID = null; _designationID = null; _employee = null; _department = null; _location = null; _designation = null; } #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 departmentID : ID private ID _departmentID; public ID DepartmentID { get { return _departmentID; } set { base.OnPropertyChange("departmentID", _departmentID, value); _departmentID = value; } } #endregion #region locationID : ID private ID _locationID; public ID LocationID { get { return _locationID; } set { base.OnPropertyChange("locationID", _locationID, value); _locationID = value; } } #endregion #region designationID : ID private ID _designationID; public ID DesignationID { get { return _designationID; } set { base.OnPropertyChange("designationID", _designationID, value); _designationID = value; } } #endregion #region employee : Employee private Employee _employee; public Employee Employee { get { if (_employeeID.Integer > 0 && _employee == null) { _employee = new Employee(); _employee = Employee.Get(_employeeID); } return this._employee; } set { _employee = value; } } #endregion #region department : Department private Department _department; public Department Department { get { if (_departmentID.Integer > 0 && _department == null) { _department = new Department(); _department = Department.Get(_departmentID); } return this._department; } set { _department = value; } } #endregion #region location : Location private Location _location; public Location Location { get { if (_locationID.Integer > 0 && _location == null) { _location = new Location(); _location = Location.Get(_locationID); } return this._location; } set { _location = value; } } #endregion #region designation : Designation private Designation _designation; public Designation Designation { get { if (_designationID.Integer > 0 && _designation == null) { _designation = new Designation(); _designation = Designation.Get(_designationID); } return this._designation; } set { _designation = value; } } #endregion #region Service Factory IEmployeePostingService : IEmployeePostingService internal static IEmployeePostingService Service { get { return Services.Factory.CreateService(typeof(IEmployeePostingService)); } } #endregion #endregion #region Functions public static EmployeePosting Get(ID nEmpID,DateTime dPostingDate) { EmployeePosting oEmployeePosting = null; #region Cache Header oEmployeePosting = (EmployeePosting)_cache["Get", nEmpID,dPostingDate]; if (oEmployeePosting != null) return oEmployeePosting; #endregion oEmployeePosting = EmployeePosting.Service.Get(nEmpID,dPostingDate,Payroll.BO.SystemInformation.CurrentSysInfo.PayrollTypeID.Integer); #region Cache Footer _cache.Add(oEmployeePosting, "Get", nEmpID,dPostingDate); #endregion return oEmployeePosting; } public void SetObjectID(int IdValue) { this.SetID(ID.FromInteger(IdValue)); } public static ObjectsTemplate Get() { #region Cache Header ObjectsTemplate employeePostings = _cache["Get"] as ObjectsTemplate; if (employeePostings != null) return employeePostings; #endregion try { employeePostings = Service.Get(); } catch (ServiceException e) { throw new Exception(e.Message, e); } #region Cache Footer _cache.Add(employeePostings, "Get"); #endregion return employeePostings; } public static ObjectsTemplate GetByEmpID(ID nID) { #region Cache Header ObjectsTemplate employeePostings = _cache["Get"] as ObjectsTemplate; if (employeePostings != null) return employeePostings; #endregion try { employeePostings = Service.GetByEmpID(nID); } catch (ServiceException e) { throw new Exception(e.Message, e); } #region Cache Footer _cache.Add(employeePostings, "Get"); #endregion return employeePostings; } public static DataSet GetEmpCurrentPosting(DateTime EffectDate) { DataSet ds = null; try { ds = Service.GetEmpCurrentPosting(EffectDate,Payroll.BO.SystemInformation.CurrentSysInfo.PayrollTypeID.Integer); } catch (Exception e) { throw new Exception(e.Message, e); } return ds; } public static DataSet GetEmpPrvPosting(DateTime EffectDate) { DataSet ds = null; try { ds = Service.GetEmpPrvPosting(EffectDate,Payroll.BO.SystemInformation.CurrentSysInfo.PayrollTypeID.Integer); } catch (Exception e) { throw new Exception(e.Message, e); } return ds; } public ID Save() { base.SetAuditTrailProperties(); return EmployeePosting.Service.Save(this); } public void Delete() { EmployeePosting.Service.Delete(ID); } public void DeleteAll() { EmployeePosting.Service.DeleteAll(); } #endregion } #endregion #region IEmployeePosting Service public interface IEmployeePostingService { // EmployeePosting Get(ID id); ObjectsTemplate Get(); EmployeePosting Get(ID nEmpID, DateTime dPostingDate, int payrollTypeID); ObjectsTemplate GetByEmpID(ID nID); DataSet GetEmpCurrentPosting(DateTime EffectDate, int payrollTypeID); DataSet GetEmpPrvPosting(DateTime EffectDate, int payrollTypeID); ID Save(EmployeePosting item); void Delete(ID id); void DeleteAll(); } #endregion }