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 Employee [Serializable] public class Employee : AuditTrailBase, IEmployeeFind { #region Cache Store private static Cache _cache = new Cache(typeof(Employee)); #endregion #region Constructor public Employee() { _globalID = string.Empty; _employeeNo = string.Empty; _name = string.Empty; _gender = EnumGender.Male; _birthDate = DateTime.MinValue; _joiningDate = DateTime.MinValue; _endOfContractDate = DateTime.MinValue; _emailAddress = string.Empty; _mobileNo = string.Empty; _tinNo = string.Empty; _categoryID = null; _foreignExPat = false; _continueGratuity = false; _taxCircle = string.Empty; _isConfirmed = false; _status = EnumEmployeeStatus.Live; _isShownInTaxSheet = false; _pFMemberType = EnumPFMembershipType.NotYetLive; _pFMemberShiptDate = DateTime.MinValue; _branchID = null; _accountNo = string.Empty; _outPayBranchID = null; _outPayAccountNo = string.Empty; _departmentID = null; _locationID = null; _religionID = null; _maritalStatus = EnumMaritalStatus.UnMarried; _designationID = null; _gradeID = null; _basicSalary = 0; _prevBasic = 0; _paymentMode = EnumPaymentMode.CashPayment; _outPayPaymentMode = EnumPaymentMode.CashPayment; _fatherName = string.Empty; _isEligibleOT = false; _descriptionText = string.Empty; _desktopUserPass = string.Empty; _payrollTypeID = null; _isAutoProcess = false; _cardID = null; _grossSalary = 0; _photoPath = string.Empty; _payScaleId = null; _taxAmount = 0; _confirDate = DateTime.MinValue; _discontinueDate = DateTime.MinValue; _currentHistoryID = null; _branch = null; _category = null; //_costCenter = null; _department = null; _designation = null; _grade = null; _location = null; //_outPayBranch = null; _religion = null; _monthStatusUpdate = EnumEmployeeStatus.Live; _vendorCode = string.Empty; _role = EnumRole.None; _PersonType = EnumPersonType.None; } #endregion #region Properties private ObjectsTemplate _errorList; public ObjectsTemplate ErrorList { get { return _errorList; } set { _errorList = value; } } #region globalID : string private string _globalID; public string GlobalID { get { return _globalID; } set { base.OnPropertyChange("globalID", _globalID, value); _globalID = value; } } #endregion #region employeeNo : string private string _employeeNo; public string EmployeeNo { get { return _employeeNo; } set { base.OnPropertyChange("employeeNo", _employeeNo, value); _employeeNo = value; } } #endregion #region name : string private string _name; public string Name { get { return _name; } set { base.OnPropertyChange("name", _name, value); _name = value; } } #endregion #region gender : EnumGender private EnumGender _gender; public EnumGender Gender { get { return _gender; } set { base.OnPropertyChange("gender", (short)_gender, (short)value); _gender = value; } } #endregion #region birthDate : DateTime private DateTime _birthDate; public DateTime BirthDate { get { return _birthDate; } set { base.OnPropertyChange("birthDate", _birthDate, value); _birthDate = value; } } #endregion #region joiningDate : DateTime private DateTime _joiningDate; public DateTime JoiningDate { get { return _joiningDate; } set { base.OnPropertyChange("joiningDate", _joiningDate, value); _joiningDate = value; } } #endregion #region endOfContractDate : DateTime private DateTime? _endOfContractDate; public DateTime? EndOfContractDate { get { return _endOfContractDate; } set { base.OnPropertyChange("endOfContractDate", _endOfContractDate, value); _endOfContractDate = value; } } #endregion #region emailAddress : string private string _emailAddress; public string EmailAddress { get { return _emailAddress; } set { base.OnPropertyChange("emailAddress", _emailAddress, value); _emailAddress = value; } } #endregion #region mobileNo : string private string _mobileNo; public string MobileNo { get { return _mobileNo; } set { base.OnPropertyChange("mobileNo", _mobileNo, value); _mobileNo = value; } } #endregion #region tinNo : string private string _tinNo; public string TinNo { get { return _tinNo; } set { base.OnPropertyChange("tinNo", _tinNo, value); _tinNo = value; } } #endregion #region categoryID : ID private ID _categoryID; public ID CategoryID { get { return _categoryID; } set { base.OnPropertyChange("categoryID", _categoryID, value); _categoryID = value; } } #endregion #region foreignExPat : bool private bool _foreignExPat; public bool ForeignExPat { get { return _foreignExPat; } set { base.OnPropertyChange("foreignExPat", _foreignExPat, value); _foreignExPat = value; } } #endregion #region PersonType : EnumPersonType private EnumPersonType _PersonType; public EnumPersonType PersonType { get { return _PersonType; } set { _PersonType = value; } } #endregion #region continueGratuity : bool private bool _continueGratuity; public bool ContinueGratuity { get { return _continueGratuity; } set { base.OnPropertyChange("continueGratuity", _continueGratuity, value); _continueGratuity = value; } } #endregion // Previous System //#region taxCircle : int //private EnumTaxCircle _taxCircle; //public EnumTaxCircle TaxCircle //{ // get { return _taxCircle; } // set // { // base.OnPropertyChange("taxCircle", (short)_taxCircle, (short)value); // _taxCircle = value; // } //} //#endregion // New System #region TaxCircle : string private string _taxCircle; public string TaxCircle { get { return _taxCircle; } set { _taxCircle = value; } } #endregion #region isConfirmed : bool private bool _isConfirmed; public bool IsConfirmed { get { return _isConfirmed; } set { base.OnPropertyChange("isConfirmed", _isConfirmed, value); _isConfirmed = value; } } #endregion #region status : EnumEmployeeStatus private EnumEmployeeStatus _status; public EnumEmployeeStatus Status { get { return _status; } set { base.OnPropertyChange("status", (short)_status, (short)value); _status = value; } } #endregion #region isShownInTaxSheet : bool private bool _isShownInTaxSheet; public bool IsShownInTaxSheet { get { return _isShownInTaxSheet; } set { base.OnPropertyChange("isShownInTaxSheet", _isShownInTaxSheet, value); _isShownInTaxSheet = value; } } #endregion #region pFMemberType : EnumPFMembershipType private EnumPFMembershipType _pFMemberType; public EnumPFMembershipType PFMemberType { get { return _pFMemberType; } set { base.OnPropertyChange("pFMemberType", (short)_pFMemberType, (short)value); _pFMemberType = value; } } #endregion #region pFMemberShiptDate : DateTime private DateTime _pFMemberShiptDate; public DateTime PFMemberShiptDate { get { return _pFMemberShiptDate; } set { base.OnPropertyChange("PFMemberShiptDate", _pFMemberShiptDate, value); _pFMemberShiptDate = value; } } #endregion #region branchID : ID private ID _branchID; public ID BranchID { get { return _branchID; } set { base.OnPropertyChange("branchID", _branchID, value); _branchID = value; } } #endregion #region accountNo : string private string _accountNo; public string AccountNo { get { return _accountNo; } set { base.OnPropertyChange("accountNo", _accountNo, value); _accountNo = value; } } #endregion #region outPayBranchID : ID private ID _outPayBranchID; public ID OutPayBranchID { get { return _outPayBranchID; } set { base.OnPropertyChange("OutPayBranchID", _outPayBranchID, value); _outPayBranchID = value; } } #endregion #region outPayAccountNo : string private string _outPayAccountNo; public string OutPayAccountNo { get { return _outPayAccountNo; } set { base.OnPropertyChange("outPayAccountNo", _outPayAccountNo, value); _outPayAccountNo = 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 religionID : ID private ID _religionID; public ID ReligionID { get { return _religionID; } set { base.OnPropertyChange("religionID", _religionID, value); _religionID = value; } } #endregion #region maritalStatus : EnumMaritalStatus private EnumMaritalStatus _maritalStatus; public EnumMaritalStatus MaritalStatus { get { return _maritalStatus; } set { base.OnPropertyChange("maritalStatus", (short)_maritalStatus, (short)value); _maritalStatus = value; } } #endregion #region designationID : ID private ID _designationID; public ID DesignationID { get { return _designationID; } set { base.OnPropertyChange("designationID", _designationID, value); _designationID = value; } } #endregion #region gradeID : ID private ID _gradeID; public ID GradeID { get { return _gradeID; } set { base.OnPropertyChange("gradeID", _gradeID, value); _gradeID = value; } } #endregion #region basicSalary : double private double _basicSalary; public double BasicSalary { get { return _basicSalary; } set { base.OnPropertyChange("basicSalary", _basicSalary, value); _basicSalary = value; } } #endregion #region CurrentHistoryId : double private ID _currentHistoryID; public ID CurrentHistoryID { get { return _currentHistoryID; } set { base.OnPropertyChange("CurrentHistoryID", _currentHistoryID, value); _currentHistoryID = value; } } #endregion #region prevBasic : double private double _prevBasic; public double PrevBasic { get { return _prevBasic; } set { base.OnPropertyChange("prevBasic", _prevBasic, value); _prevBasic = value; } } #endregion #region paymentMode : EnumPaymentMode private EnumPaymentMode _paymentMode; public EnumPaymentMode PaymentMode { get { return _paymentMode; } set { base.OnPropertyChange("paymentMode", (short)_paymentMode, (short)value); _paymentMode = value; } } #endregion #region OutPayPaymentMode : EnumPaymentMode private EnumPaymentMode _outPayPaymentMode; public EnumPaymentMode OutPayPaymentMode { get { return _outPayPaymentMode; } set { _outPayPaymentMode = value; } } #endregion #region fatherName : string private string _fatherName; public string FatherName { get { return _fatherName; } set { base.OnPropertyChange("fatherName", _fatherName, value); _fatherName = value; } } #endregion #region isEligibleOT : bool private bool _isEligibleOT; public bool IsEligibleOT { get { return _isEligibleOT; } set { base.OnPropertyChange("isEligibleOT", _isEligibleOT, value); _isEligibleOT = value; } } #endregion #region descriptionText : string private string _descriptionText; public string DescriptionText { get { return _descriptionText; } set { base.OnPropertyChange("descriptionText", _descriptionText, value); _descriptionText = value; } } #endregion #region desktopUserPass : string private string _desktopUserPass; public string DesktopUserPass { get { return _desktopUserPass; } set { base.OnPropertyChange("desktopUserPass", _desktopUserPass, value); _desktopUserPass = value; } } #endregion #region payrollTypeID : ID private ID _payrollTypeID; public ID PayrollTypeID { get { return _payrollTypeID; } set { base.OnPropertyChange("payrollTypeID", _payrollTypeID, value); _payrollTypeID = value; } } #endregion #region isAutoProcess : bool private bool _isAutoProcess; public bool IsAutoProcess { get { return _isAutoProcess; } set { base.OnPropertyChange("isAutoProcess", _isAutoProcess, value); _isAutoProcess = value; } } #endregion #region Role : bool private EnumRole _role; public EnumRole Role { get { return _role; } set { base.OnPropertyChange("Role", (short)_role, (short)value); _role = value; } } #endregion #region cardID : ID private ID _cardID; public ID CardID { get { return _cardID; } set { base.OnPropertyChange("cardID", _cardID, value); _cardID = value; } } #endregion #region grossSalary : double private double _grossSalary; public double GrossSalary { get { return _grossSalary; } set { base.OnPropertyChange("grossSalary", _grossSalary, value); _grossSalary = value; } } #endregion #region photoPath : string private string _photoPath; public string PhotoPath { get { return _photoPath; } set { base.OnPropertyChange("photoPath", _photoPath, value); _photoPath = value; } } #endregion #region payScaleId : ID private ID _payScaleId; public ID PayScaleId { get { return _payScaleId; } set { base.OnPropertyChange("payScaleId", _payScaleId, value); _payScaleId = value; } } #endregion #region taxAmount : double private double _taxAmount; public double TaxAmount { get { return _taxAmount; } set { base.OnPropertyChange("taxAmount", _taxAmount, value); _taxAmount = value; } } #endregion #region confirDate : DateTime private DateTime _confirDate; public DateTime ConfirDate { get { return _confirDate; } set { base.OnPropertyChange("confirDate", _confirDate, value); _confirDate = value; } } #endregion #region discontinueDate : DateTime private DateTime _discontinueDate; public DateTime DiscontinueDate { get { return _discontinueDate; } set { base.OnPropertyChange("discontinueDate", _discontinueDate, value); _discontinueDate = value; } } #endregion #region ArrearFrom : string private string _arrearFrom; public string ArrearFrom { get { return _arrearFrom; } set { base.OnPropertyChange("ArrearFrom", _arrearFrom, value); _arrearFrom = value; } } #endregion #region SearchEmployee : SearchEmployee public SearchEmployee SearchEmployee { get { SearchEmployee semp = new SearchEmployee(); semp.EmployeeID = this.ID; semp.DepartmentID = this.DepartmentID; semp.CategoryID = this.CategoryID; semp.LocationID = this.LocationID; semp.GradeID = this.GradeID; semp.EmployeeNo = this.EmployeeNo; semp.Name = this.Name; return semp; } } #endregion #region SalaryFractionate : double private double _salaryFractionate; public double SalaryFractionate { get { return _salaryFractionate; } set { base.OnPropertyChange("SalaryFractionate", _salaryFractionate, value); _salaryFractionate = value; } } #endregion #region MonthStatusUpdate : EnumEmployeeStatus private EnumEmployeeStatus _monthStatusUpdate; public EnumEmployeeStatus MonthStatusUpdate { get { return _monthStatusUpdate; } set { base.OnPropertyChange("MonthStatusUpdate", (short)_monthStatusUpdate, (short)value); _monthStatusUpdate = value; } } #endregion #region branch : Branch private Branch _branch; public Branch Branch { get { if (_branch == null && _branchID != null && _branchID.IsUnassigned == false && _branchID.Integer > 0) { _branch = new Branch(); _branch = Branch.Get(_branchID); } return this._branch; } set { _branch = value; } } #endregion #region category : Category private Category _category; public Category Category { get { if (_categoryID != null && !_categoryID.IsUnassigned) { if (_categoryID.Integer > 0 && _category == null) { _category = new Category(); _category = _category.Get(_categoryID); } } return this._category; } set { _category = value; } } #endregion #region department : Department private Department _department; public Department Department { get { if (_departmentID != null && _departmentID.IsUnassigned == false && _departmentID.Integer > 0 && _department == null) { _department = new Department(); _department = Department.Get(_departmentID); } return this._department; } set { _department = value; } } #endregion #region designation : Designation private Designation _designation; public Designation Designation { get { if (_designationID != null && _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 location : Location private Location _location; public Location Location { get { if (_locationID != null && _locationID.IsUnassigned == false && _locationID.Integer > 0 && _location == null) { _location = new Location(); _location = Location.Get(_locationID); } return this._location; } set { _location = value; } } #endregion #region religion : Religion private Religion _religion; public Religion Religion { get { if (_religionID.Integer > 0 && _religion == null) { _religion = new Religion(); _religion = Religion.Get(_religionID); } return this._religion; } set { _religion = value; } } #endregion #region VendorCode : string private string _vendorCode; public string VendorCode { get { return _vendorCode; } set { base.OnPropertyChange("VendorCode", _vendorCode, value); _vendorCode = value; } } #endregion private EmployeeGradeSalary _employeeGradeSalary; public EmployeeGradeSalary EmployeeGradeSalary { get { if (_employeeGradeSalary == null) { _employeeGradeSalary = new EmployeeGradeSalary(); } return _employeeGradeSalary; } set { _employeeGradeSalary = value; } } private EmpLifeCycle _EmpLifeCycle; public EmpLifeCycle EmpLifeCycle { get { if (_EmpLifeCycle == null) { _EmpLifeCycle = new EmpLifeCycle(); } return _EmpLifeCycle; } set { _EmpLifeCycle = value; } } private ObjectsTemplate _employeeGradeSalarys; public ObjectsTemplate EmployeeGradeSalarys { get { return _employeeGradeSalarys; } set { _employeeGradeSalarys = value; } } private EmployeePosting _employeePosting; public EmployeePosting EmployeePosting { get { if (_employeePosting == null) { _employeePosting = new EmployeePosting(); } return _employeePosting; } set { _employeePosting = value; } } private EmployeeBankAccount _employeeBankAccount; public EmployeeBankAccount EmployeeBankAccount { get { if (_employeeBankAccount == null) { _employeeBankAccount = new EmployeeBankAccount(); } return _employeeBankAccount; } set { _employeeBankAccount = value; } } private EmployeeBankAccount _employeeOPIBankAccount; public EmployeeBankAccount EmployeeOPIBankAccount { get { if (_employeeOPIBankAccount == null) { _employeeOPIBankAccount = new EmployeeBankAccount(); } return _employeeOPIBankAccount; } set { _employeeOPIBankAccount = value; } } #region Service Factory IEmployeeService : IEmployeeService internal static IEmployeeService Service { get { return Services.Factory.CreateService(typeof(IEmployeeService)); } } #endregion #endregion #region Functions public static Employee Get(ID id) { Employee oEmployee = null; #region Cache Header oEmployee = (Employee)_cache["Get", id]; if (oEmployee != null) return oEmployee; #endregion oEmployee = Employee.Service.Get(id); #region Cache Footer _cache.Add(oEmployee, "Get", id); #endregion return oEmployee; } public static Employee GetByCardID(ID id) { Employee oEmployee = null; #region Cache Header oEmployee = (Employee)_cache["GetByCardID", id]; if (oEmployee != null) return oEmployee; #endregion oEmployee = Employee.Service.GetByCardID(id); #region Cache Footer _cache.Add(oEmployee, "GetByCardID", id); #endregion return oEmployee; } public static ObjectsTemplate Get(ObjectsTemplate searchEmployees) { ObjectsTemplate oEmployees = null; oEmployees = Employee.Service.Get(searchEmployees,Payroll.BO.SystemInformation.CurrentSysInfo.PayrollTypeID.Integer); return oEmployees; } public static ObjectsTemplate GetSubordinates(ID employeeID) { ObjectsTemplate oEmployees = null; oEmployees = Employee.Service.GetSubordinates(employeeID); return oEmployees; } public static Employee GetParentEmployee(ID employeeID) { Employee oEmployee = null; #region Cache Header oEmployee = (Employee)_cache["GetParentEmployee", employeeID]; if (oEmployee != null) return oEmployee; #endregion oEmployee = Employee.Service.GetParentEmployee(employeeID); #region Cache Footer _cache.Add(oEmployee, "GetParentEmployee", employeeID); #endregion return oEmployee; } public static ObjectsTemplate GetAllSubordinates(ID nodeiD) { ObjectsTemplate oEmployees = null; oEmployees = Employee.Service.GetAllSubordinates(nodeiD); return oEmployees; } public static DataTable GetDesignationWiseEmployeeCountsByDepartmentID(ID departmentID) { DataTable oDesignationDt = null; oDesignationDt = Employee.Service.GetDesignationWiseEmployeeCountsByDepartmentID(departmentID); return oDesignationDt; } public static DataTable GetDFSL() { DataTable oDFSL = null; oDFSL = Employee.Service.GetDFSL(); return oDFSL; } public static DataTable GetGradeWiseEmployeeCountsByDepartmentID(ID departmentID) { DataTable oGradeDt = null; oGradeDt = Employee.Service.GetGradeWiseEmployeeCountsByDepartmentID(departmentID); return oGradeDt; } public static DataTable GetGradeWiseEmployeeCounts() { DataTable oGradeDt = null; oGradeDt = Employee.Service.GetGradeWiseEmployeeCounts(); return oGradeDt; } public string GenerateLoanNo(string sLonanName) { return Service.GenerateLoanNo(this, sLonanName); } public SearchEmployee GetSearchEmployee() { SearchEmployee oEmployee = new SearchEmployee(); oEmployee.CategoryID = this.CategoryID; oEmployee.DepartmentID = this.DepartmentID; oEmployee.EmployeeID = this.ID; oEmployee.EmployeeNo = this.EmployeeNo; oEmployee.GradeID = this.GradeID; oEmployee.LocationID = this.LocationID; oEmployee.Name = this.Name; return oEmployee; } /// /// if User log-in payroll type assinged,Get the employee by employee No and according to user log-in payroll type. /// other wise only Employee No /// /// /// public static Employee Get(String employeeNo) { Employee oEmployee = null; #region Cache Header oEmployee = (Employee)_cache["Get", employeeNo]; if (oEmployee != null) return oEmployee; #endregion if (User.CurrentUser == null || User.CurrentUser.LogInPayrollTypeID == null) oEmployee = Employee.Service.GetwitoutchekPayrolltype(employeeNo); else oEmployee = Employee.Service.Get(employeeNo,Payroll.BO.SystemInformation.CurrentSysInfo.PayrollTypeID.Integer); #region Cache Footer _cache.Add(oEmployee, "Get", employeeNo); #endregion return oEmployee; } /// /// Get the employee by the employee No /// /// /// public static Employee GetwitoutchekPayrolltype(String employeeNo) { Employee oEmployee = null; oEmployee = Employee.Service.Get(employeeNo,Payroll.BO.SystemInformation.CurrentSysInfo.PayrollTypeID.Integer); return oEmployee; } public static Employee GetByEmailAddress(string empEmail) { Employee oEmployee = null; oEmployee = Employee.Service.GetByEmailAddress(empEmail); return oEmployee; } public static DataSet GetByMonthStartMonthEndForContinueFromDiscontinue(DateTime startmonth, DateTime endmonth) { return Employee.Service.GetByMonthStartMonthEndForContinueFromDiscontinue(startmonth, endmonth,Payroll.BO.SystemInformation.CurrentSysInfo.PayrollTypeID.Integer); } public static ObjectsTemplate Get() { #region Cache Header ObjectsTemplate employees = _cache["Get"] as ObjectsTemplate; if (employees != null) return employees; #endregion try { employees = Service.Get(Payroll.BO.SystemInformation.CurrentSysInfo.PayrollTypeID.Integer); } catch (ServiceException e) { throw new Exception(e.Message, e); } #region Cache Footer _cache.Add(employees, "Get"); #endregion return employees; } public static ObjectsTemplate GetWithDiscontinue() { #region Cache Header ObjectsTemplate employees = _cache["GetWithDiscontinue"] as ObjectsTemplate; if (employees != null) return employees; #endregion try { employees = Service.GetWithDiscontinue(SystemInformation.CurrentSysInfo.PayrollTypeID.Integer); } catch (ServiceException e) { throw new Exception(e.Message, e); } #region Cache Footer _cache.Add(employees, "GetWithDiscontinue"); #endregion return employees; } //new for attendance Process public static ObjectsTemplate GetAbsentEmp(DateTime attnDate, EnumWorkPlanGroup wpGroup) { #region Cache Header ObjectsTemplate employees = _cache["GetAbsentEmp", attnDate, wpGroup] as ObjectsTemplate; if (employees != null) return employees; #endregion try { employees = Service.GetAbsentEmp(attnDate, wpGroup,Payroll.BO.SystemInformation.CurrentSysInfo.PayrollTypeID.Integer); } catch (ServiceException e) { throw new Exception(e.Message, e); } #region Cache Footer _cache.Add(employees, "GetAbsentEmp", attnDate, wpGroup); #endregion return employees; } public static ObjectsTemplate GetAttendaceEmp(EnumWorkPlanGroup wpGroup) { #region Cache Header ObjectsTemplate employees = _cache["GetAttendaceEmp", wpGroup] as ObjectsTemplate; if (employees != null) return employees; #endregion try { employees = Service.GetAttendaceEmp(wpGroup,Payroll.BO.SystemInformation.CurrentSysInfo.PayrollTypeID.Integer); } catch (ServiceException e) { throw new Exception(e.Message, e); } #region Cache Footer _cache.Add(employees, "GetAttendaceEmp", wpGroup); #endregion return employees; } public static ObjectsTemplate GetEmpExceptAutoWP(DateTime attnDate) { #region Cache Header ObjectsTemplate employees = _cache["GetEmpExceptAutoWP", attnDate] as ObjectsTemplate; if (employees != null) return employees; #endregion try { employees = Service.GetEmpExceptAutoWP(attnDate,Payroll.BO.SystemInformation.CurrentSysInfo.PayrollTypeID.Integer); } catch (ServiceException e) { throw new Exception(e.Message, e); } #region Cache Footer _cache.Add(employees, "GetEmpExceptAutoWP", attnDate); #endregion return employees; } public static ObjectsTemplate GetDiscontinueEmp(DateTime attnDate, DateTime currentDate) { #region Cache Header ObjectsTemplate employees = _cache["GetDiscontinueEmp", attnDate, currentDate] as ObjectsTemplate; if (employees != null) return employees; #endregion try { employees = Service.GetDiscontinueEmp(attnDate, currentDate,Payroll.BO.SystemInformation.CurrentSysInfo.PayrollTypeID.Integer); } catch (ServiceException e) { throw new Exception(e.Message, e); } #region Cache Footer _cache.Add(employees, "GetDiscontinueEmp", attnDate, currentDate); #endregion return employees; } // public static ObjectsTemplate Get(int status, DateTime lastDateOfYear) { #region Cache Header ObjectsTemplate employees = _cache["Get"] as ObjectsTemplate; if (employees != null) return employees; #endregion try { employees = Service.Get(status, lastDateOfYear); } catch (ServiceException e) { throw new Exception(e.Message, e); } #region Cache Footer _cache.Add(employees, "Get"); #endregion return employees; } public static DataTable GetEmpIDsOfManager(int status, DateTime lastDateOfYear) { DataTable dataTableOfEmployee = new DataTable("Employee"); try { dataTableOfEmployee = Service.GetEmpIDsOfManager(status, lastDateOfYear); } catch (ServiceException e) { throw new Exception(e.Message, e); } return dataTableOfEmployee; } public static DataTable GetOldEmp() { DataTable dataTableOfEmployee = new DataTable("Employee"); try { dataTableOfEmployee = Service.GetOldEmp(); } catch (ServiceException e) { throw new Exception(e.Message, e); } return dataTableOfEmployee; } public static DataTable GetAllEmp() { DataTable dataTableOfEmployee = new DataTable("AllEmployee"); try { dataTableOfEmployee = Service.GetAllEmp(); } catch (ServiceException e) { throw new Exception(e.Message, e); } return dataTableOfEmployee; } public void SetObjectID(int IdValue) { this.SetID(ID.FromInteger(IdValue)); } public static ObjectsTemplate GetEmpsWithDiscontinue(string empIDs) { #region Cache Header ObjectsTemplate employees = _cache["GetEmpsWithDiscontinue", empIDs] as ObjectsTemplate; if (employees != null) return employees; #endregion try { employees = Service.GetEmpsWithDiscontinue(empIDs,Payroll.BO.SystemInformation.CurrentSysInfo.PayrollTypeID.Integer); } catch (ServiceException e) { throw new Exception(e.Message, e); } #region Cache Footer _cache.Add(employees, "GetEmpsWithDiscontinue", empIDs); #endregion return employees; } public static ObjectsTemplate GetByEmpIDs(string empIDs) { #region Cache Header ObjectsTemplate employees = _cache["GetByEmpIDs", empIDs] as ObjectsTemplate; if (employees != null) return employees; #endregion try { employees = Service.GetByEmpIDs(empIDs,Payroll.BO.SystemInformation.CurrentSysInfo.PayrollTypeID.Integer); } catch (ServiceException e) { throw new Exception(e.Message, e); } #region Cache Footer _cache.Add(employees, "GetByEmpIDs", empIDs); #endregion return employees; } public static ObjectsTemplate GetFssEmp(string empIDs) { #region Cache Header ObjectsTemplate employees = _cache["GetFssEmp", empIDs] as ObjectsTemplate; if (employees != null) return employees; #endregion try { employees = Service.GetFssEmp(empIDs,Payroll.BO.SystemInformation.CurrentSysInfo.PayrollTypeID.Integer); } catch (ServiceException e) { throw new Exception(e.Message, e); } #region Cache Footer _cache.Add(employees, "GetFssEmp", empIDs); #endregion return employees; } public double ServiceDays(DateTime dDate) { double nDays = 0.0; nDays = Ease.CoreV35.Utility.Global.DateFunctions.DateDiff("d", JoiningDate, dDate); return nDays; } public double ServiceYearsRemaining() { double nYears = 0.0; nYears = Ease.CoreV35.Utility.Global.DateFunctions.DateDiff("d", BirthDate, DateTime.Now); if (nYears != 0) nYears = 57 - (nYears / 365); return nYears; } public double ServiceYears(DateTime dDate) { double nYears = 0.0; nYears = Ease.CoreV35.Utility.Global.DateFunctions.DateDiff("d", JoiningDate, dDate); if (nYears != 0) nYears = nYears / 365; return nYears; } public double ServiceMonths(DateTime dDate) { double nMonths = 0.0; nMonths = Ease.CoreV35.Utility.Global.DateFunctions.DateDiff("d", JoiningDate, dDate); if (nMonths != 0) nMonths = nMonths / 12; return nMonths; } public string ServiceLengths(DateTime dDate) { string nMonths = ""; nMonths = Ease.CoreV35.Utility.Global.DateFunctions.DateDiff(JoiningDate, dDate); return nMonths; } public string ServiceLengths2(DateTime dDate) { string nMonths = ""; nMonths = (Math.Round((decimal)Ease.CoreV35.Utility.Global.DateFunctions.DateDiff("d", JoiningDate, dDate) / 365, 1)).ToString(); return nMonths; } public string ServiceLengthsInWords(DateTime dDate) { dDate = dDate.AddDays(-1); string nText = ""; //int nYear = 0; //int nMonth = 0; //int nDays = 0; //DateTime dtJoining = JoiningDate; //while (dtJoining < dDate) //{ // nMonth++; // dtJoining=dtJoining.AddMonths(1); // if(nMonth==12) // { // nYear++; // nMonth = 0; // } //} //if (dtJoining > dDate) //{ // nDays = (DateTime.DaysInMonth(dtJoining.Year, dtJoining.Month) - dtJoining.Day) + (DateTime.DaysInMonth(dDate.Year, dDate.Month) - dDate.Day); //} TimeSpan ts = dDate - JoiningDate; int nTotalDays = ts.Days+1; int nYears = 0; int nMonths = 0; int nDays = 0; if (nTotalDays >= 365) { nYears = nTotalDays / 365; nTotalDays = nTotalDays % 365; } if (nTotalDays >= 30) { nMonths = nTotalDays / 30; nDays = nTotalDays % 30; } if (nYears > 0) nText += nYears.ToString() + " Year(s) "; if (nMonths > 0) nText += nMonths.ToString() + " Month(s) "; if (nDays > 0) nText += nDays.ToString() + " Day(s) "; return nText; } public ID Save() { this.SetAuditTrailProperties(); return Employee.Service.Save(this); } public void SaveIntegration(ObjectsTemplate oEmps) { foreach(Employee emp in oEmps) emp.SetAuditTrailProperties(); Employee.Service.SaveIntegration(oEmps); } public void BulkSave(List items) { Employee.Service.BulkSave(items); } //Save for Excel Upload public void SaveBasicInfo(Employee item) { item.SetAuditTrailProperties(); Employee.Service.SaveBasicInfo(item); } public void SaveShortInfo(ObjectsTemplate items) { foreach (Employee item in items) item.SetAuditTrailProperties(); Employee.Service.SaveShortInfo(items); } public void Delete() { Employee.Service.Delete(ID); } public void DeleteAll() { Employee.Service.DeleteAll(); } public void UpdateStatus(ID employeeID, ID historyID, DateTime effectDate, EnumEmployeeStatus status) { Employee.Service.UpdateStatus(employeeID, historyID, effectDate, status); } //added by Hasib 04.05.10 public void UpdateCardInformation(ID employeeID, ID CardID, bool IsAutoProcess) { Employee.Service.UpdateCardInformation(employeeID, CardID, IsAutoProcess); } //For PF public void UpdatePFMemship(ID empID, EnumPFMembershipType PFType, DateTime dPFEffectDate) { Employee.Service.UpdatePFMemship(empID, PFType, dPFEffectDate); } //For Update Tax Amount public void UpdateTaxAmount(ID employeeID, double TaxAmount) { Employee.Service.UpdateTaxAmount(employeeID, TaxAmount); } // For Confirm Employee public void DoConfirm(ID employeeID, DateTime confirmDate, DateTime pfMShipDate, bool IsConfirm, bool IsPFMember) { Employee.Service.DoConfirm(employeeID, confirmDate, pfMShipDate, IsConfirm, IsPFMember); } // For Undo Confirm public void UndoConfirm(ID employeeID, bool IsConfirm) { Employee.Service.UndoConfirm(employeeID, IsConfirm); } // For Transfer Employee public void UpdatePayrollType(ID employeeID, ID payrollTypeID, DateTime dEffectDate) { Employee.Service.UpdatePayrollType(employeeID, payrollTypeID, dEffectDate); } // For Upload Role public void UpdateEmpRole(Employee oEmp) { Employee.Service.UpdateEmpRole(oEmp); } public static int GetDays(int nPayrollTypeID) { int nDays = 0; nDays = Service.GetDays(nPayrollTypeID); return nDays; } //For Emplyoee Basic Info public static DataSet GetEmpBasicInfo(string sEmpID) { DataSet ds = null; try { ds = Service.GetEmpBasicInfo(sEmpID); } catch (Exception e) { throw new Exception(e.Message, e); } return ds; } public static DataSet GetLineManager(int sEmpID) { DataSet ds = null; try { ds = Service.GetLineManager(sEmpID); } catch (Exception e) { throw new Exception(e.Message, e); } return ds; } public static DataSet GetEmpDetails(string sEmpID) { DataSet ds = null; try { ds = Service.GetEmpDetails(sEmpID); } catch (Exception e) { throw new Exception(e.Message, e); } return ds; } //public static DataSet GetEmployeeCV(string sEmpID) //{ // DataSet ds = null; // try // { // ds = Service.GetEmployeeCV(sEmpID); // } // catch (Exception e) // { // throw new Exception(e.Message, e); // } // return ds; //} public static DataSet GetEmpForLetterOfIntroDuction(string sEmpID, DateTime month) { DataSet ds = null; try { ds = Service.GetEmpForLetterOfIntroDuction(sEmpID, month); } catch (Exception e) { throw new Exception(e.Message, e); } return ds; } public static DataSet GetEmpPosting(string sEmpID) { DataSet ds = null; try { ds = Service.GetEmpPosting(sEmpID); } catch (Exception e) { throw new Exception(e.Message, e); } return ds; } public static DataSet GetEmpConfirmHis(DateTime dEffectDate, DateTime dEffectDate2) { DataSet ds = null; try { ds = Service.GetEmpConfirmHis(dEffectDate, dEffectDate,Payroll.BO.SystemInformation.CurrentSysInfo.PayrollTypeID.Integer); } catch (Exception e) { throw new Exception(e.Message, e); } return ds; } public static DataSet GetEmpPFHis(DateTime dEffectDate) { DataSet ds = null; try { ds = Service.GetEmpPFHis(dEffectDate); } catch (Exception e) { throw new Exception(e.Message, e); } return ds; } public static DataSet GetEmpGradeSalaryChangeInfo(DateTime fromDate, DateTime toDate, string selection) { DataSet ds = null; try { ds = Service.GetEmpGradeSalaryChangeInfo(fromDate, toDate, selection); } catch (Exception ex) { throw new Exception(ex.Message); } return ds; } public static DataSet GetEmpJoining(DateTime dEffectDate, DateTime dEffectDate2) { DataSet ds = null; try { ds = Service.GetEmpJoining(dEffectDate, dEffectDate2); } catch (Exception e) { throw new Exception(e.Message, e); } return ds; } public static DataSet GetEmpJoining4Novartis(DateTime dEffectDate) { DataSet ds = null; try { ds = Service.GetEmpJoining4Novartis(dEffectDate,Payroll.BO.SystemInformation.CurrentSysInfo.PayrollTypeID.Integer); } catch (Exception e) { throw new Exception(e.Message, e); } return ds; } public static string GetInEmpSQL(ObjectsTemplate employees) { string InEmpSQL = ""; if (employees.Count == 0) return string.Empty; foreach (Employee employee in employees) { InEmpSQL = InEmpSQL + employee.ID.Integer + ", "; } InEmpSQL = InEmpSQL.Substring(0, InEmpSQL.Length - 2); return InEmpSQL; } public static ObjectsTemplate GetEmployeesYetNotAssigned() { return Employee.Service.GetEmployeesYetNotAssigned(); } public static ObjectsTemplate GetEmployeesByJoiningMonth(DateTime fromDate, DateTime toDate) { return Employee.Service.GetEmployeesByJoiningMonth(fromDate, toDate); } public static ObjectsTemplate GetByDeptIDs(string sIDs) { return Employee.Service.GetByDeptIDs(sIDs,Payroll.BO.SystemInformation.CurrentSysInfo.PayrollTypeID.Integer); } #endregion public static ObjectsTemplate GetNew(DateTime dt, int payrollTypeID) { #region Cache Header ObjectsTemplate employees = _cache["Get"] as ObjectsTemplate; if (employees != null) return employees; #endregion try { employees = Service.GetNew(dt,Payroll.BO.SystemInformation.CurrentSysInfo.PayrollTypeID.Integer); } catch (ServiceException e) { throw new Exception(e.Message, e); } #region Cache Footer _cache.Add(employees, "Get"); #endregion return employees; } public static DataSet GetITAndBasic(DateTime startdate, DateTime endDate) { return Employee.Service.GetITAndBasic(startdate, endDate); } public static ObjectsTemplate GetAllEmps() { return Employee.Service.GetAllEmps(); } public static DataSet GetCashAdvice(string sEmpIDs, string dSalDate) { DataSet oDataSet = new DataSet(); oDataSet = Employee.Service.GetCashAdvice(sEmpIDs, dSalDate); return oDataSet; } public static DataSet GetEmpBasicInfoForPSlip(string sEmpIDs) { DataSet oDataSet = new DataSet(); oDataSet = Employee.Service.GetEmpBasicInfoForPSlip(sEmpIDs); return oDataSet; } public static DataSet GetEmpBasicInfoForPSlipNew(string sEmpIDs,DateTime dt) { DataSet oDataSet = new DataSet(); oDataSet = Employee.Service.GetEmpBasicInfoForPSlipNew(sEmpIDs, dt); return oDataSet; } public ObjectsTemplate Find() { IEmployeeFind search = new SearchManager((IEmployeeSearch)this, EnumSearchFrom.Employee); return search.Find(); } public static ObjectsTemplate GetForSuperUser() { ObjectsTemplate oEmployees = null; oEmployees = Employee.Service.GetForSuperUser(); return oEmployees; } public static ObjectsTemplate GetJoiningData(DateTime formDate) { ObjectsTemplate oEmployees = null; oEmployees = Employee.Service.GetJoiningData(formDate); return oEmployees; } public static Employee Get4Web(String employeeNo) { Employee oEmployee = null; #region Cache Header oEmployee = (Employee)_cache["Get", employeeNo]; if (oEmployee != null) return oEmployee; #endregion if (User.CurrentUser == null || User.CurrentUser.LogInPayrollTypeID == null) oEmployee = Employee.Service.GetwitoutchekPayrolltype(employeeNo); else oEmployee = Employee.Service.Get4Web(employeeNo); #region Cache Footer _cache.Add(oEmployee, "Get", employeeNo); #endregion return oEmployee; } public Employee GetDepartmentHead() { if (this.DepartmentID == null) return null; return Employee.Service.GetDepartmentHead(EnumOGPositionType.DH, this.DepartmentID); } public static string GetQueryForAllSubordinates(ID nodeiD) { string query = null; query = Employee.Service.GetQueryForAllSubordinates(nodeiD); return query; } public static DataSet GetRCAssignedEmp() { return Employee.Service.GetRCAssignedEmp(); } public static DataSet GetRCNotAssignedEmp() { return Employee.Service.GetRCNotAssignedEmp(); } public static DataSet GetUploadedComponents(DateTime firstDate, DateTime lastDate) { return Employee.Service.GetUploadedComponents(firstDate, lastDate); } public static DataSet GetUploadedComponentDetails(int uploadedComponentId) { return Employee.Service.GetUploadedComponentDetails(uploadedComponentId); } } #endregion public class EmployeesCurrentPosition { public int EmployeeID { get; set; } public string CurrentPosition { get; set; } public string Level1 { get; set; } public string Level2 { get; set; } public string Level3 { get; set; } public string Level4 { get; set; } public string Level5 { get; set; } public string Level6 { get; set; } } #region IEmployee Service public interface IEmployeeService { DataSet GetEmpBasicInfoForPSlip(string sEmpIDs); DataSet GetEmpBasicInfoForPSlipNew(string sEmpIDs,DateTime dt); Employee Get(ID id); ObjectsTemplate GetForSuperUser(); Employee GetByCardID(ID id); Employee Get(string emloyeeNo, int payrollTypeID); Employee GetByEmailAddress(string empEmail); Employee GetwitoutchekPayrolltype(String employeeNo); Employee GetParentEmployee(ID employeeID); Employee GetDepartmentHead(EnumOGPositionType type, ID departmentID); ObjectsTemplate Get(int payrollTypeID); ObjectsTemplate GetAllEmps(); ObjectsTemplate GetWithDiscontinue(int payrollTypeID); ObjectsTemplate GetSubordinates(ID employeeID); ObjectsTemplate GetAllSubordinates(ID nodeID); ObjectsTemplate GetAbsentEmp(DateTime attnDate, EnumWorkPlanGroup wpGroup, int payrollTypeID);//for Attendance Process ObjectsTemplate GetAttendaceEmp(EnumWorkPlanGroup wpGroup, int payrollTypeID);//for Attendance Process ObjectsTemplate GetEmpExceptAutoWP(DateTime attnDate, int payrollTypeID);//for Attendance Process ObjectsTemplate GetDiscontinueEmp(DateTime attnDate, DateTime currentDate, int payrollTypeID);//for Attendance Process ObjectsTemplate Get(int status, DateTime lastDateOfYear); DataTable GetEmpIDsOfManager(int status, DateTime lastDateOfYear); DataTable GetOldEmp(); DataTable GetAllEmp(); void DoConfirm(ID employeeID, DateTime confirmDate, DateTime pfMShipDate, bool IsConfirm, bool IsPFMember); void UndoConfirm(ID employeeID, bool IsPFMember); void UpdateStatus(ID employeeID, ID HistoryID, DateTime effectDate, EnumEmployeeStatus status); void UpdatePFMemship(ID empID, EnumPFMembershipType PFType, DateTime dPFEffectDate); void UpdateTaxAmount(ID empID, double TaxAmount); void UpdateEmpRole(Employee oEmp); ObjectsTemplate GetNew(DateTime dt, int payrollTypeID); void UpdatePayrollType(ID empID, ID payrollTypeID, DateTime dEffectDate); ID Save(Employee item); void SaveIntegration(ObjectsTemplate oEmps); void BulkSave(List items); void Delete(ID id); void DeleteAll(); string GenerateLoanNo(Employee oEmp, string sLoanName); void UpdateCardInformation(ID employeeID, ID CardID, bool IsAutoProcess); ObjectsTemplate Get(ObjectsTemplate searchEmployees, int payrollTypeID); DataSet GetEmpBasicInfo(string sEmpID); DataSet GetLineManager(int sEmpID); DataSet GetEmpDetails(string sEmpID); //DataSet GetEmployeeCV(string sEmpID); DataSet GetEmpForLetterOfIntroDuction(string sEmpID, DateTime month); DataSet GetEmpPosting(string sEmpID); DataSet GetEmpGradeSalaryChangeInfo(DateTime fromDate, DateTime toDate,string selection); DataSet GetEmpJoining(DateTime dEffectDate, DateTime dEffectDate2); DataSet GetEmpConfirmHis(DateTime dEffectDate, DateTime dEffectDate2, int payrollTypeID); DataSet GetEmpPFHis(DateTime dEffectDate); int GetDays(int nPayrollTypeID); void SaveBasicInfo(Employee item); void SaveShortInfo(ObjectsTemplate items); ObjectsTemplate GetByEmpIDs(string empIDs, int payrollTypeID); ObjectsTemplate GetFssEmp(string empIDs, int payrollTypeID); ObjectsTemplate GetEmpsWithDiscontinue(string empIDs, int payrollTypeID); DataSet GetEmpJoining4Novartis(DateTime dEffectDate, int payrollTypeID); ObjectsTemplate GetEmployeesYetNotAssigned(); ObjectsTemplate GetEmployeesByJoiningMonth(DateTime fromDate, DateTime toDate); ObjectsTemplate GetByDeptIDs(string sIDs, int payrollTypeID); DataSet GetByMonthStartMonthEndForContinueFromDiscontinue(DateTime startmonth, DateTime endmonth, int payrollTypeID); DataSet GetITAndBasic(DateTime startdate, DateTime endDate); ObjectsTemplate GetJoiningData(DateTime formDate); DataTable GetDesignationWiseEmployeeCountsByDepartmentID(ID departmentID); DataTable GetDFSL(); DataTable GetGradeWiseEmployeeCountsByDepartmentID(ID departmentID); DataTable GetGradeWiseEmployeeCounts(); Employee Get4Web(string employeeNo); DataSet GetCashAdvice(string sEmpIDs, string dSalDate); string GetQueryForAllSubordinates(ID nodeiD); DataSet GetRCAssignedEmp(); DataSet GetRCNotAssignedEmp(); DataSet GetUploadedComponents(DateTime firstDate, DateTime lastDate); DataSet GetUploadedComponentDetails(int uploadedComponentId); } #endregion }