using System; using Ease.Core.Model; using System; using System.Collections.Generic; using System.Data; using System.Linq; namespace HRM.BO { #region EmployeeUnAuthorizeLeave public enum EnumLeaveEntryType { Normal = 1, PaidLeave = 2 } public class EmployeeUnAuthorizeLeave : AuditTrailBase { #region Constructor public EmployeeUnAuthorizeLeave() { _employeeID = 0; _unAuthorizeleaveID = 0; _monthDate = DateTime.MinValue; _leaveMonth = DateTime.MinValue; _toDate = DateTime.MinValue; _fromDate = DateTime.MinValue; _referenceID = 0; _Type = EnumLeaveEntryType.Normal; _leaveDays = 0; _ParamID = 0; AdjustedDays = 0; _isLateAttendanceRelated = false; } public EmployeeUnAuthorizeLeave(int empid, int unauleaveid, DateTime mdate, DateTime lmonth, DateTime tdate, DateTime fdate , int? rid, double ldays, int pid, bool isLateAttn) { _employeeID = empid; _unAuthorizeleaveID = unauleaveid; _monthDate = mdate; _leaveMonth = lmonth; _toDate = tdate; _fromDate = fdate; _Type = EnumLeaveEntryType.Normal; _leaveDays = ldays; _ParamID = pid; _isLateAttendanceRelated = isLateAttn; _createdBy = 0; _createdDate = DateTime.Today; } #endregion #region Properties #region EmployeeID : ID private int _employeeID; public int EmployeeID { get { return _employeeID; } set { _employeeID = value; } } #endregion public Employee EmployeeObj { get; set; } public UnAuthorizeLeaveParam Param { get; set; } public UnAuthorizeLeave UALeave { get; set; } public int PayrollTypeID { get; set; } //#region Employee : Employee //private Employee _Employee = null; //public Employee EmployeeObj //{ // get // { // if(_Employee ==null && !_employeeID.IsUnassigned && _employeeID>0) // { // _Employee = Employee.Get(_employeeID); // } // return _Employee; // } //} //#endregion //#region Param : UnAuthorizeLeaveParameter //private UnAuthorizeLeaveParam _Param; //public UnAuthorizeLeaveParam Param //{ // get // { // if (_Param == null && !this.ParamID.IsUnassigned && this.ParamID > 0) // { // _Param = UnAuthorizeLeaveParam.Get(this.ParamID); // } // return _Param; // } // set // { // _Param = value; // } //} //#endregion #region ParamID : ID private int _ParamID; public int ParamID { get { return _ParamID; } set { _ParamID = value; } } #endregion #region ReferenceID : ID private int _referenceID; public int ReferenceID { get { return _referenceID; } set { _referenceID = value; } } #endregion #region UnAuthorizeleaveID : ID private int _unAuthorizeleaveID; public int UnAuthorizeleaveID { get { return _unAuthorizeleaveID; } set { _unAuthorizeleaveID = value; } } #endregion //#region UnAuthorizeleave : UnAuthorizeleave //private UnAuthorizeLeave _unAuthorizeleave = null; //public UnAuthorizeLeave UALeave //{ // get // { // if (_unAuthorizeleave == null && !_unAuthorizeleaveID.IsUnassigned && _unAuthorizeleaveID > 0) // { // _unAuthorizeleave = UnAuthorizeLeave.Get(_unAuthorizeleaveID); // } // return _unAuthorizeleave; // } //} //#endregion #region monthDate : DateTime private DateTime _monthDate; public DateTime MonthDate { get { return _monthDate; } set { _monthDate = value; } } #endregion #region leaveDays : double private double _leaveDays; public double LeaveDays { get { return _leaveDays; } set { _leaveDays = value; } } #endregion public int AdjustedDays { get; set; } //#region AdjustedDays : int //private int _adjustedDays; //public int AdjustedDays //{ // get // { // if (_adjustedDays == 0 && this.ReferenceID != 0) // { // _adjustedDays = GetAdjestedDays(this.ReferenceID); // } // return _adjustedDays; // } //} //#endregion #region leaveMonth : DateTime private DateTime _leaveMonth; public DateTime LeaveMonth { get { return _leaveMonth; } set { _leaveMonth = value; } } #endregion #region FromDate : DateTime private DateTime _fromDate; public DateTime FromDate { get { return _fromDate; } set { _fromDate = value; } } #endregion #region ToMonth : DateTime private DateTime _toDate; public DateTime ToDate { get { return _toDate; } set { _toDate = value; } } #endregion #region EnumLeaveEntryType : int private EnumLeaveEntryType _Type; public EnumLeaveEntryType Type { get { return _Type; } set { _Type = value; } } #endregion #region IsLateAttendanceRelated : bool private bool _isLateAttendanceRelated; public bool IsLateAttendanceRelated { get { return _isLateAttendanceRelated; } set { _isLateAttendanceRelated = value; } } #endregion public string employeeNoView { get; set; } public string employeeNameView { get; set; } public string leaveNameView { get; set; } #region Service Factory IEmployeeUnAuthorizeLeaveService : IEmployeeUnAuthorizeLeaveService internal static IEmployeeUnAuthorizeLeaveService Service { get { return Services.Factory.CreateService(typeof(IEmployeeUnAuthorizeLeaveService)); } } #endregion #endregion //#region Functions //public static EmployeeUnAuthorizeLeave Get(int nID) //{ // EmployeeUnAuthorizeLeave oEmployeeUnAuthorizeLeave = null; // #region Cache Header // oEmployeeUnAuthorizeLeave = (EmployeeUnAuthorizeLeave)_cache["Get", nID]; // if (oEmployeeUnAuthorizeLeave != null) // return oEmployeeUnAuthorizeLeave; // #endregion // oEmployeeUnAuthorizeLeave = EmployeeUnAuthorizeLeave.Service.Get(nID); // #region Cache Footer // _cache.Add(oEmployeeUnAuthorizeLeave, "Get", nID); // #endregion // return oEmployeeUnAuthorizeLeave; //} //public static List Get(EnumLeaveEntryType type, DateTime month) //{ // #region Cache Header // List employeeUnAuthorizeLeaves = _cache["Get", type] as List; // if (employeeUnAuthorizeLeaves != null) // return employeeUnAuthorizeLeaves; // #endregion // try // { // employeeUnAuthorizeLeaves = Service.Get(type,month ); // } // catch (ServiceException e) // { // throw new Exception(e.Message, e); // } // #region Cache Footer // _cache.Add(employeeUnAuthorizeLeaves, "Get", type); // #endregion // return employeeUnAuthorizeLeaves; //} //public static List Get(DateTime fromDate, DateTime todate, EnumLeaveEntryType type) //{ // #region Cache Header // List employeeUnAuthorizeLeaves = _cache["Get", type] as List; // if (employeeUnAuthorizeLeaves != null) // return employeeUnAuthorizeLeaves; // #endregion // try // { // employeeUnAuthorizeLeaves = Service.Get(fromDate, todate, type); // } // catch (ServiceException e) // { // throw new Exception(e.Message, e); // } // #region Cache Footer // _cache.Add(employeeUnAuthorizeLeaves, "Get", type); // #endregion // return employeeUnAuthorizeLeaves; //} //public static List Get() //{ // #region Cache Header // List employeeUnAuthorizeLeaves = _cache["Get"] as List; // if (employeeUnAuthorizeLeaves != null) // return employeeUnAuthorizeLeaves; // #endregion // try // { // employeeUnAuthorizeLeaves = Service.Get(); // } // catch (ServiceException e) // { // throw new Exception(e.Message, e); // } // #region Cache Footer // _cache.Add(employeeUnAuthorizeLeaves, "Get"); // #endregion // return employeeUnAuthorizeLeaves; //} //public static List GetByEmployee(int nEmpID,EnumLeaveEntryType type) //{ // #region Cache Header // List employeeUnAuthorizeLeaves = _cache["GetByEmployee", nEmpID, type] as List; // if (employeeUnAuthorizeLeaves != null) // return employeeUnAuthorizeLeaves; // #endregion // try // { // employeeUnAuthorizeLeaves = Service.GetByEmployee(nEmpID, type); // } // catch (ServiceException e) // { // throw new Exception(e.Message, e); // } // #region Cache Footer // _cache.Add(employeeUnAuthorizeLeaves, "GetByEmployee", nEmpID, type); // #endregion // return employeeUnAuthorizeLeaves; //} //public static List GetByEmployeeID(int nEmpID) //{ // #region Cache Header // List employeeUnAuthorizeLeaves = _cache["GetByEmployeeID", nEmpID] as List; // if (employeeUnAuthorizeLeaves != null) // return employeeUnAuthorizeLeaves; // #endregion // try // { // employeeUnAuthorizeLeaves = Service.GetByEmployeeID(nEmpID); // } // catch (ServiceException e) // { // throw new Exception(e.Message, e); // } // #region Cache Footer // _cache.Add(employeeUnAuthorizeLeaves, "GetByEmployeeID", nEmpID); // #endregion // return employeeUnAuthorizeLeaves; //} //public static List GetBySalaryMonth(DateTime salaryMonth) //{ // #region Cache Header // List employeeUnAuthorizeLeaves = _cache["GetBySalaryMonth", salaryMonth] as List; // if (employeeUnAuthorizeLeaves != null) // return employeeUnAuthorizeLeaves; // #endregion // try // { // employeeUnAuthorizeLeaves = Service.GetBySalaryMonth(salaryMonth); // } // catch (ServiceException e) // { // throw new Exception(e.Message, e); // } // #region Cache Footer // _cache.Add(employeeUnAuthorizeLeaves, "GetBySalaryMonth", salaryMonth); // #endregion // return employeeUnAuthorizeLeaves; //} //public static List GetByEmployee(int nEmpID,int nUALeaveID, EnumLeaveEntryType type) //{ // #region Cache Header // List employeeUnAuthorizeLeaves = _cache["GetByEmployee", nEmpID,nUALeaveID, type] as List; // if (employeeUnAuthorizeLeaves != null) // return employeeUnAuthorizeLeaves; // #endregion // try // { // employeeUnAuthorizeLeaves = Service.GetByEmployee(nEmpID, nUALeaveID, type); // } // catch (ServiceException e) // { // throw new Exception(e.Message, e); // } // #region Cache Footer // _cache.Add(employeeUnAuthorizeLeaves, "GetByEmployee", nEmpID,nUALeaveID, type); // #endregion // return employeeUnAuthorizeLeaves; //} //public static List GetDeductedLeaves(int nEmpID, int nLeaveID, EnumLeaveEntryType type) //{ // #region Cache Header // List employeeUnAuthorizeLeaves = _cache["GetDeductedLeaves", nEmpID, nLeaveID, type] as List; // if (employeeUnAuthorizeLeaves != null) // return employeeUnAuthorizeLeaves; // #endregion // try // { // employeeUnAuthorizeLeaves = Service.GetDeductedLeaves(nEmpID, nLeaveID, type, SystemInformation.CurrentSysInfo.NextPayProcessDate); // } // catch (ServiceException e) // { // throw new Exception(e.Message, e); // } // #region Cache Footer // _cache.Add(employeeUnAuthorizeLeaves, "GetDeductedLeaves", nEmpID, nLeaveID, type); // #endregion // return employeeUnAuthorizeLeaves; //} //public static List GetByEmployee(int nEmpID, DateTime dMonth, EnumLeaveEntryType type) //{ // #region Cache Header // List employeeUnAuthorizeLeaves = _cache["GetByEmployee", nEmpID, dMonth, type] as List; // if (employeeUnAuthorizeLeaves != null) // return employeeUnAuthorizeLeaves; // #endregion // try // { // employeeUnAuthorizeLeaves = Service.GetByEmployee(nEmpID, dMonth, type); // } // catch (ServiceException e) // { // throw new Exception(e.Message, e); // } // #region Cache Footer // _cache.Add(employeeUnAuthorizeLeaves, "GetByEmployee", nEmpID, dMonth, type); // #endregion // return employeeUnAuthorizeLeaves; //} //public static EmployeeUnAuthorizeLeave GetLeaveTypeByEmployee(int nEmpID, DateTime dMonth, EnumLeaveEntryType type) //{ // #region Cache Header // EmployeeUnAuthorizeLeave employeeUnAuthorizeLeave = null; // if (employeeUnAuthorizeLeave != null) // return employeeUnAuthorizeLeave; // #endregion // try // { // employeeUnAuthorizeLeave = Service.GetLeaveTypeByEmployee(nEmpID, dMonth, type); // } // catch (ServiceException e) // { // throw new Exception(e.Message, e); // } // #region Cache Footer // _cache.Add(employeeUnAuthorizeLeave, "GetByEmployee", nEmpID, dMonth, type); // #endregion // return employeeUnAuthorizeLeave; //} //public int AuthorizedDays(DateTime dMonth) //{ // int authorizedday = 0; // try // { // authorizedday = Service.AdjustedDays(this.ID, dMonth); // } // catch (ServiceException e) // { // throw new Exception(e.Message, e); // } // return authorizedday; //} //private int GetAdjestedDays(int nID) //{ // return Service.AdjustedDays(nID); //} //public EmployeeUnAuthorizeLeave GetClone() //{ // EmployeeUnAuthorizeLeave item = new EmployeeUnAuthorizeLeave(); // item.EmployeeID = this.EmployeeID ; // item.UnAuthorizeleaveID = this.UnAuthorizeleaveID; // item.MonthDate = this.MonthDate ; // item.LeaveMonth=this.LeaveMonth; // item.ToDate = this.ToDate; // item.FromDate = this.FromDate; // item.ReferenceID = this.ReferenceID; // item.Type = this.Type; // item.LeaveDays = this.LeaveDays; // item.ParamID = this.ParamID ; // return item; //} //public int Save() //{ // this.SetAuditTrailProperties(); // return EmployeeUnAuthorizeLeave.Service.Save(this); //} //public void Delete() //{ // EmployeeUnAuthorizeLeave.Service.Delete(this.ID); //} //public void DeleteAll(List empLeaves) //{ // EmployeeUnAuthorizeLeave.Service.DeleteAll(empLeaves); //} //public static void Save(List empLeaves) //{ // foreach (EmployeeUnAuthorizeLeave leave in empLeaves) // { // leave.SetAuditTrailProperties(); // } // EmployeeUnAuthorizeLeave.Service.Save(empLeaves); //} //public static void SaveAuthrizedLeave(int employeeID, DateTime month, List empLeaves) //{ // foreach (EmployeeUnAuthorizeLeave leave in empLeaves) // { // leave.SetAuditTrailProperties(); // } // EmployeeUnAuthorizeLeave.Service.Save(empLeaves); //} ////By A MonthRange //public static DataSet GetUnAuthorizeLeave(DateTime date) //{ // DataSet UnAuthoLeaves = null; // try // { // UnAuthoLeaves = Service.GetUnAuthorizeLeave(date); // } // catch (ServiceException e) // { // throw new Exception(e.Message, e); // } // return UnAuthoLeaves; //} //#endregion } #endregion #region IEmployeeUnAuthorizeLeave Service public interface IEmployeeUnAuthorizeLeaveService { void DeleteAll(List empLeaves); int Save(EmployeeUnAuthorizeLeave item); void Delete(int id); void Save(List empLeaves); void SaveAuthorizeLeave(int employeeId, DateTime month, List empLeaves); int AdjustedDays(int nID); int AdjustedDays(int nID, DateTime month); EmployeeUnAuthorizeLeave Get(int id); List Get(int payrollTypeID, DateTime? salaryMonth, int? empid); } #endregion }