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 { [Serializable] public class EmpLifeCycle : BasicBaseObject { #region Cache Store private static Cache _cache = new Cache(typeof(EmpLifeCycle)); #endregion #region Constructor public EmpLifeCycle() { _effectDate = DateTime.MinValue; _nodeID = null; _gradeID = null; _categoryID = null; _companyID = null; _functionID = null; _designationID = null; _costCenterID = null; _locationID = null; _location = null; _departmentID = null; _department = null; _employeeID = null; _status = EnumEmployeeStatus.Live; _statusDetailID = null; _remarks = ""; _description = ""; _salaryMonth = DateTime.Today; _gradeSalaryAssesmentID = null; _empCCID = null; _employeeGradeSalary = null; _grossSalary = null; _basicSalary = null; _isConfirm = null; _isDiscontinue = null; _isContinue = null; _isCurrentMonthIncluded = false; _pFMemberType = null; _role = EnumRole.None; _designationText = ""; } #endregion #region Properties #region GradeSalaryAssesmentID : ID private ID _gradeSalaryAssesmentID; public ID GradeSalaryAssesmentID { get { return _gradeSalaryAssesmentID; } set { _gradeSalaryAssesmentID = value; } } #endregion #region EmpCCID : ID private ID _empCCID; public ID EmployeeCCID { get { return _empCCID; } set { _empCCID = value; } } #endregion #region EffectDate : DateTime private DateTime _effectDate; public DateTime EffectDate { get { return _effectDate; } set { _effectDate = value; } } #endregion #region NodeID : ID private ID _nodeID; public ID NodeID { get { return _nodeID; } set { _nodeID = value; } } #endregion #region CostCenterID : ID private ID _costCenterID; public ID CostCenterID { get { return _costCenterID; } set { _costCenterID = value; } } #endregion #region GradeID : ID private ID _gradeID; public ID GradeID { get { return _gradeID; } set { _gradeID = value; } } #endregion #region CategoryID : ID private ID _categoryID; public ID CategoryID { get { return _categoryID; } set { _categoryID = value; } } #endregion #region CompanyID : ID private ID _companyID; public ID CompanyID { get { return _companyID; } set { _companyID = value; } } #endregion #region FunctionID : ID private ID _functionID; public ID FunctionID { get { return _functionID; } set { _functionID = value; } } #endregion #region DesignationID : ID private ID _designationID; public ID DesignationID { get { return _designationID; } set { _designationID = value; } } #endregion #region LocationID : ID private ID _locationID; public ID LocationID { get { return _locationID; } set { _locationID = value; } } #endregion #region DepartmentID : ID private ID _departmentID; public ID DepartmentID { get { return _departmentID; } set { _departmentID = value; } } #endregion #region IsConfirm : bool private bool? _isConfirm; public bool? IsConfirm { get { return _isConfirm; } set { _isConfirm = value; } } #endregion #region pFMemberType : EnumPFMembershipType private EnumPFMembershipType? _pFMemberType; public EnumPFMembershipType? PFMemberType { get { return _pFMemberType; } set { _pFMemberType = value; } } #endregion #region EmployeeID : ID private ID _employeeID; public ID EmployeeID { get { return _employeeID; } set { _employeeID = value; } } #endregion private Employee _employee; public Employee Employee { get { if (_employee == null && _employeeID != null && _employeeID.IsUnassigned == false && _employeeID.Integer > 0) { _employee = new Employee(); _employee = Employee.Get(_employeeID); } return this._employee; } set { _employee = value; } } #region StatusDetailID : ID private ID _statusDetailID; public ID StatusDetailID { get { return _statusDetailID; } set { _statusDetailID = value; } } #endregion #region GrossSalary : double private double? _grossSalary; public double? GrossSalary { get { return _grossSalary; } set { _grossSalary = value; } } #endregion #region BasicSalary : double private double? _basicSalary; public double? BasicSalary { get { return _basicSalary; } set { _basicSalary = value; } } #endregion #region IsDiscontinue : double private bool? _isDiscontinue; public bool? IsDiscontinue { get { return _isDiscontinue; } set { _isDiscontinue = value; } } #endregion #region IsContinue : double private bool? _isContinue; public bool? IsContinue { get { return _isContinue; } set { _isContinue = value; } } #endregion #region Status : EnumEmployeeStatus private EnumEmployeeStatus _status; public EnumEmployeeStatus Status { get { return _status; } set { _status = value; } } #endregion #region Remarks : string private string _remarks; public string Remarks { get { return _remarks; } set { _remarks = value; } } #endregion #region Description : string private string _description; public string Description { get { return _description; } set { _description = value; } } #endregion #region DesignationText : string private string _designationText; public string DesignationText { get { return _designationText; } set { _designationText = value; } } #endregion #region SalaryMonth : DateTime private DateTime _salaryMonth; public DateTime SalaryMonth { get { return _salaryMonth; } set { _salaryMonth = value; } } #endregion #region Gradesalaries : ObjectsTemplate private ObjectsTemplate _gradesalaries; public ObjectsTemplate Gradesalaries { get { return _gradesalaries; } set { _gradesalaries = value; } } #endregion #region IsCurrentMonthIncluded : bool private bool _isCurrentMonthIncluded; public bool IsCurrentMonthIncluded { get { return _isCurrentMonthIncluded; } set { _isCurrentMonthIncluded = value; } } #endregion #region Role : EnumRole private EnumRole _role; public EnumRole Role { get { return _role; } set { _role = value; } } #endregion #region Employee : Employee private HREmployee _hremployee; public HREmployee HREmployee { get { if (_employeeID.Integer > 0 && _hremployee == null) { _hremployee = new HREmployee(); _hremployee = HREmployee.Get(_employeeID); } return this._hremployee; } set { _hremployee = value; } } private ObjectsTemplate _employeeCostCenters = null; public ObjectsTemplate EmployeeCostCenters { get { if (_costCenterID != null && !_costCenterID.IsUnassigned) { if (_costCenterID.Integer > 0 && _employeeCostCenters == null) { _employeeCostCenters = new ObjectsTemplate(); _employeeCostCenters = EmployeeCostCenter.GetByEmpIDCCID(_costCenterID, _employeeID); } } return this._employeeCostCenters; } set { _employeeCostCenters = value; } } private EmployeeGradeSalary _employeeGradeSalary; public EmployeeGradeSalary EmployeeGradeSalary { get { return this._employeeGradeSalary; } set { _employeeGradeSalary = value; } } #region OrganogramEmployee : OrganogramEmployee private ObjectsTemplate _orgemployees; public ObjectsTemplate Orgemployees { get { if (_nodeID != null && !_nodeID.IsUnassigned) { if (_nodeID.Integer > 0 && _orgemployees == null) { _orgemployees = new ObjectsTemplate(); _orgemployees = OrganogramEmployee.Get(_nodeID); } } return this._orgemployees; } set { _orgemployees = value; } } #endregion #region department : Department private Department _department; public Department Department { get { if (_departmentID.IsUnassigned == false && _departmentID.Integer > 0 && _department == null) { _department = new Department(); _department = Department.Get(_departmentID); } return this._department; } set { _department = value; } } #endregion #region Costcenter : Costcenter private Costcenter _costcenter; public Costcenter Costcenter { get { if (_costCenterID.IsUnassigned == false && _costCenterID.Integer > 0 && _costcenter == null) { _costcenter = new Costcenter(); _costcenter = Costcenter.Get(_costCenterID); } return this._costcenter; } set { _costcenter = value; } } #endregion #region location : Location private Location _location; public Location Location { get { if (_locationID.IsUnassigned == false && _locationID.Integer > 0 && _location == null) { _location = new Location(); _location = Location.Get(_locationID); } return this._location; } set { _location = value; } } #endregion #region category : Category private Category _category; public Category Category { get { if (_categoryID.Integer > 0 && _category == null) { _category = new Category(); _category = _category.Get(_categoryID); } return this._category; } set { _category = value; } } #endregion #region designation : Designation private Designation _designation; public Designation Designation { get { if (_designationID.IsUnassigned == false && _designationID.Integer > 0 && _designation == null) { _designation = new Designation(); _designation = Designation.Get(_designationID); } return this._designation; } set { _designation = value; } } #endregion #region grade : Grade private Grade _grade; public Grade Grade { get { if (_gradeID != null && !_gradeID.IsUnassigned) { if (_gradeID.Integer > 0 && _grade == null) { _grade = new Grade(); _grade = Grade.Get(_gradeID); } } return this._grade; } set { _grade = value; } } #endregion #region Service Factory IEmpLifeCycleService : IEmpLifeCycleService internal static IEmpLifeCycleService Service { get { return Services.Factory.CreateService(typeof(IEmpLifeCycleService)); } } #endregion #endregion #region IsProcessed : bool private bool _isProcessed; public bool IsProcessed { get { return _isProcessed; } set { _isProcessed = value; } } #endregion #endregion #region Functions public static EmpLifeCycle Get(ID nID) { EmpLifeCycle oEmpLifeCycle = null; #region Cache Header oEmpLifeCycle = (EmpLifeCycle)_cache["Get", nID]; if (oEmpLifeCycle != null) return oEmpLifeCycle; #endregion oEmpLifeCycle = EmpLifeCycle.Service.Get(nID); #region Cache Footer _cache.Add(oEmpLifeCycle, "Get", nID); #endregion return oEmpLifeCycle; } public static ObjectsTemplate GetByEmpID(ID employeeID) { #region Cache Header ObjectsTemplate EmpLifeCycles = _cache["GetByEmpID", employeeID] as ObjectsTemplate; if (EmpLifeCycles != null) return EmpLifeCycles; #endregion try { EmpLifeCycles = Service.GetEmpID(employeeID); } catch (ServiceException e) { throw new Exception(e.Message, e); } #region Cache Footer _cache.Add(EmpLifeCycles, "GetByEmpID", employeeID); #endregion return EmpLifeCycles; } public static ObjectsTemplate GetByDate(DateTime from, DateTime to) { #region Cache Header ObjectsTemplate EmpLifeCycles = _cache["GetByDate", from, to] as ObjectsTemplate; if (EmpLifeCycles != null) return EmpLifeCycles; #endregion try { EmpLifeCycles = Service.GetByDate(from, to, SystemInformation.CurrentSysInfo.PayrollTypeID); } catch (ServiceException e) { throw new Exception(e.Message, e); } #region Cache Footer _cache.Add(EmpLifeCycles, "GetByDate", from, to); #endregion return EmpLifeCycles; } public static ObjectsTemplate GetByCreateDate(DateTime from, DateTime to) { #region Cache Header ObjectsTemplate EmpLifeCycles = _cache["GetByCreateDate", from, to] as ObjectsTemplate; if (EmpLifeCycles != null) return EmpLifeCycles; #endregion try { EmpLifeCycles = Service.GetByCreateDate(from, to, SystemInformation.CurrentSysInfo.PayrollTypeID.Integer); } catch (ServiceException e) { throw new Exception(e.Message, e); } #region Cache Footer _cache.Add(EmpLifeCycles, "GetByCreateDate", from, to); #endregion return EmpLifeCycles; } public static ObjectsTemplate GetByDate(DateTime from, DateTime to,bool approveID) { #region Cache Header ObjectsTemplate EmpLifeCycles = _cache["GetByDate", from, to] as ObjectsTemplate; if (EmpLifeCycles != null) return EmpLifeCycles; #endregion try { EmpLifeCycles = Service.GetByDate(from, to, SystemInformation.CurrentSysInfo.PayrollTypeID, approveID); } catch (ServiceException e) { throw new Exception(e.Message, e); } #region Cache Footer _cache.Add(EmpLifeCycles, "GetByDate", from, to); #endregion return EmpLifeCycles; } public static ObjectsTemplate Get(ID nEmpID, DateTime effectDate) { #region Cache Header ObjectsTemplate EmpLifeCycles = _cache["Get", nEmpID] as ObjectsTemplate; if (EmpLifeCycles != null) return EmpLifeCycles; #endregion try { EmpLifeCycles = Service.GetEmpID(nEmpID, effectDate); } catch (ServiceException e) { throw new Exception(e.Message, e); } #region Cache Footer _cache.Add(EmpLifeCycles, "Get", nEmpID); #endregion return EmpLifeCycles; } public static EmpLifeCycle GetLastPosition(int nEmpID) { EmpLifeCycle oEmpLifeCycle = new EmpLifeCycle(); try { oEmpLifeCycle = Service.GetLastPosition(nEmpID); } catch (ServiceException e) { throw new Exception(e.Message, e); } return oEmpLifeCycle; } public static ObjectsTemplate Get(EnumStatus sts) { ObjectsTemplate oEmpLifeCycles = new ObjectsTemplate(); try { oEmpLifeCycles = Service.Get(sts, SystemInformation.CurrentSysInfo.PayrollTypeID); } catch (ServiceException e) { throw new Exception(e.Message, e); } return oEmpLifeCycles; } public static ObjectsTemplate getByStatus(int p, DateTime startDate, DateTime endDate) { ObjectsTemplate oEmpLifeCycle = new ObjectsTemplate(); try { oEmpLifeCycle = Service.getByStatus(p, startDate, endDate); } catch (ServiceException e) { throw new Exception(e.Message, e); } return oEmpLifeCycle; } public static int GetPrvGradeId(ID nEmpID, ID nGradeID) { int GradeID = 0; GradeID = Service.GetPrvGradeId(nEmpID, nGradeID); return GradeID; } public static int GetPrvLocationId(ID nEmpID, ID nLocID) { int LocID = 0; LocID = Service.GetPrvLocationId(nEmpID, nLocID); return LocID; } public static int GetPrvDesigId(ID nEmpID, ID nDesigID) { int DesigID = 0; DesigID = Service.GetPrvDesigId(nEmpID, nDesigID); return DesigID; } public static int GetPrvRCId(ID nEmpID) { int nCCID = 0; nCCID = Service.GetPrvRCId(nEmpID); return nCCID; } public ID Save() { this.SetAuditTrailProperties(); return EmpLifeCycle.Service.Save(this); } public ID Save(ObjectsTemplate LifeCycles) { this.SetAuditTrailProperties(); return EmpLifeCycle.Service.Save(LifeCycles); } public void Save2(ObjectsTemplate oEmpLifeCycles) { this.SetAuditTrailProperties(); EmpLifeCycle.Service.Save2(oEmpLifeCycles); } public void Delete() { EmpLifeCycle.Service.Delete(this); } public static int? EmpPrevDesg(ID employeeID) { return EmpLifeCycle.Service.EmpPrevDesg(employeeID); } #endregion } #region IEmpLifeCycle Service public interface IEmpLifeCycleService { EmpLifeCycle Get(ID lifecycleID); ObjectsTemplate Get(EnumStatus sts, ID PayrolltypeID); ObjectsTemplate GetEmpID(ID nEmpID); ObjectsTemplate GetEmpID(ID nEmpID, DateTime effectDate); EmpLifeCycle GetLastPosition(int nEmpID); ID Save(EmpLifeCycle item); ID Save(ObjectsTemplate item); void Save2(ObjectsTemplate oEmpLifeCycles); void Delete(EmpLifeCycle item); int GetPrvGradeId(ID nEmpID, ID nGradeID); int GetPrvLocationId(ID nEmpID, ID nLocationID); int GetPrvDesigId(ID nEmpID, ID nDesigID); int GetPrvRCId(ID nEmpID); int? EmpPrevDesg(ID employeeID); ObjectsTemplate getByStatus(int p, DateTime startDate, DateTime endDate); ObjectsTemplate GetByDate(DateTime from, DateTime to, ID PayrolltypeID); ObjectsTemplate GetByDate(DateTime from, DateTime to, ID PayrolltypeID,bool ApproveID); ObjectsTemplate GetByCreateDate(DateTime from, DateTime to, int payrollTypeID); } #endregion }