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 EmployeeStatus [Serializable] public class EmployeeStatus : BasicBaseObject { #region Cache Store private static Cache _cache = new Cache(typeof(EmployeeStatus)); #endregion #region Constructor public EmployeeStatus() { _empStatus = EnumEmployeeStatus.Live; _description = string.Empty; _continueOwnPartPF = false; _continueCmpPartPF = false; _continueGratuity = false; _gradeSalaryChangeType = null; } #endregion #region Properties #region status : EnumEmployeeStatus private EnumEmployeeStatus _empStatus; public EnumEmployeeStatus EmpStatus { get { return _empStatus; } set { base.OnPropertyChange("EmpStatus", (short)_empStatus, (short)value); _empStatus = value; } } #endregion #region description : string private string _description; public string Description { get { return _description; } set { base.OnPropertyChange("description", _description, value); _description = value; } } #endregion #region continueOwnPartPF : bool private bool _continueOwnPartPF; public bool ContinueOwnPartPF { get { return _continueOwnPartPF; } set { base.OnPropertyChange("continueOwnPartPF", _continueOwnPartPF, value); _continueOwnPartPF = value; } } #endregion #region continueCmpPartPF : bool private bool _continueCmpPartPF; public bool ContinueCmpPartPF { get { return _continueCmpPartPF; } set { base.OnPropertyChange("continueCmpPartPF", _continueCmpPartPF, value); _continueCmpPartPF = value; } } #endregion #region continueGratuity : bool private bool _continueGratuity; public bool ContinueGratuity { get { return _continueGratuity; } set { base.OnPropertyChange("continueGratuity", _continueGratuity, value); _continueGratuity = value; } } #endregion #region ParentID : ID private ID _parentID; public ID ParentID { get { return _parentID; } set { base.OnPropertyChange("ParentID", _parentID, value); _parentID = value; } } #region category : Category private GradeSalaryChangeType _gradeSalaryChangeType; public GradeSalaryChangeType GradeSalaryChangeType { get { if (this.ID != null && !this.ID.IsUnassigned) { if (this.ID.Integer > 0 && _gradeSalaryChangeType == null) { _gradeSalaryChangeType = new GradeSalaryChangeType(); _gradeSalaryChangeType = GradeSalaryChangeType.Get(this.ID); } } return this._gradeSalaryChangeType; } set { _gradeSalaryChangeType = value; } } #endregion #endregion #region Service Factory IEmployeeStatusService : IEmployeeStatusService internal static IEmployeeStatusService Service { get { return Services.Factory.CreateService(typeof(IEmployeeStatusService)); } } #endregion #region EmpStatusComponent [Serializable] public class EmpStatusComponent :ObjectTemplate { #region constructor public EmpStatusComponent() { } #endregion #region properties #region ComponentType :int private int _componentType; public int ComponentType { get { return _componentType; } set { _componentType = value; } } #endregion #region StatusID private ID _statusID; public ID StatusID { get { return _statusID; } set { base.OnPropertyChange("_statusID", _statusID, value); _statusID = value; } } #endregion public new void SetID(ID id) { base.SetID(id); } #endregion } #endregion #region EmpStatusComponents [Serializable] public class EmpStatusComponents : ObjectsTemplate { #region constructor public EmpStatusComponents() { } #endregion public EmpStatusComponent GetItemByEmpStatusID(ID EmpStatusID) { return this.Find(delegate(EmpStatusComponent item) { return item.StatusID == EmpStatusID; }); } } #endregion #region Property EmpStatusComponents private ObjectsTemplate _empStatusComponents; public ObjectsTemplate EmployeeStatusComponents { get { if (_empStatusComponents == null && this.ID != null && !this.ID.IsUnassigned) _empStatusComponents = EmployeeStatus.GetChild(this.ID); return _empStatusComponents; } set { _empStatusComponents = value; } } #endregion #endregion #region Functions public static EmployeeStatus Get(ID nID) { EmployeeStatus oEmployeeStatus = null; #region Cache Header oEmployeeStatus = (EmployeeStatus)_cache["Get", nID]; if (oEmployeeStatus != null) return oEmployeeStatus; #endregion oEmployeeStatus = EmployeeStatus.Service.Get(nID); #region Cache Footer _cache.Add(oEmployeeStatus, "Get", nID); #endregion return oEmployeeStatus; } public static ObjectsTemplate GetChild(ID parentID) { ObjectsTemplate a = new ObjectsTemplate(); a = EmployeeStatus.Service.GetChild(parentID); return a; } public static ObjectsTemplate Get(EnumStatus status) { #region Cache Header ObjectsTemplate employeeStatuses = _cache["Get",status] as ObjectsTemplate; if (employeeStatuses != null) return employeeStatuses; #endregion try { employeeStatuses = Service.Get(status); } catch (ServiceException e) { throw new Exception(e.Message, e); } #region Cache Footer _cache.Add(employeeStatuses, "Get", status); #endregion return employeeStatuses; } public static ObjectsTemplate Get() { #region Cache Header ObjectsTemplate employeeStatuses = _cache["Get"] as ObjectsTemplate; if (employeeStatuses != null) return employeeStatuses; #endregion try { employeeStatuses = Service.Get(); } catch (ServiceException e) { throw new Exception(e.Message, e); } #region Cache Footer _cache.Add(employeeStatuses, "Get"); #endregion return employeeStatuses; } public static ObjectsTemplate GetByEmpStatus(EnumStatus status,EnumEmployeeStatus empStatus) { #region Cache Header ObjectsTemplate employeeStatuses = _cache["Get", status, empStatus] as ObjectsTemplate; if (employeeStatuses != null) return employeeStatuses; #endregion try { employeeStatuses = Service.GetByEmpStatus(status,empStatus); } catch (ServiceException e) { throw new Exception(e.Message, e); } #region Cache Footer _cache.Add(employeeStatuses, "Get", status,empStatus); #endregion return employeeStatuses; } public void SaveStatus() { try { this.SetAuditTrailProperties(); Service.SaveStatus(this); } catch (ServiceException e) { throw new Exception(e.Message, e); } } public void Delete() { EmployeeStatus.Service.Delete(this.ID); } #endregion public void SetObjectID(ID id) { base.SetID(id); } } #endregion #region IEmployeeStatus Service public interface IEmployeeStatusService { EmployeeStatus Get(ID id); ObjectsTemplate Get(); ObjectsTemplate GetChild(ID id); ObjectsTemplate Get(EnumStatus status); ObjectsTemplate GetByEmpStatus(EnumStatus status,EnumEmployeeStatus empStatus); ID Save(EmployeeStatus item); void SaveStatus(EmployeeStatus oEmployeeStatus); void Delete(ID id); } #endregion }