using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Ease.Core;
using Ease.Core.Model;
using System.Data;




namespace HRM.BO
{
    #region OTProcess

    
    public class OTProcess : AuditTrailBase
    {

        #region Constructor

        public OTProcess()
        {
            //_monthDate = DateTime.MinValue;
            //_employeeID = null;
            //_amount = 0;
            //_termID = null;
            //_termParameterID = null;
            //_empOverTimeID = null;
            //_totalHour = 0;
            //_arrearAmount = 0;
            //_oTMonth = DateTime.MinValue;
            //_empOverTime = null;
            //_PayrollTypeID = null;
        }

        public static DataSet GetOTProcessData(DateTime dateTime, object sEmpID)
        {
            throw new NotImplementedException();
        }

        #endregion

        #region Properties

        public DateTime MonthDate { get; set; }

        public int EmployeeID { get; set; }

        public double Amount { get; set; }

        public int TermID { get; set; }
        public Term TermObj { get; set; }
        //#region Term : ID

        //private Term _term;
        //public Term TermObj
        //{
        //    get 
        //    {
        //        if (_term == null && !this.TermID.IsUnassigned && this.TermID.Integer > 0)
        //        {
        //            _term = Term.Get(this.TermID);
        //        }
        //        return _term; 
        //    }
        //}

        //#endregion

        public TermParameter TermParam { get; set; }
        //#region TermParameter : ID

        //private TermParameter _termParameter;
        //public TermParameter TermParam
        //{
        //    get 
        //    {
        //        if (_termParameter == null && !this.TermParameterID.IsUnassigned && this.ID.Integer > 0)
        //        {
        //            _termParameter = TermParameter.Get(this.TermParameterID);
        //        }
        //        return _termParameter; 
        //    }
        //}

        //#endregion

        public int TermParameterID { get; set; }

        public int EmpOverTimeID { get; set; }

        public double TotalHour { get; set; }

        public EmployeeOverTime EmpOverTime { get; set; }
        //#region EmpOverTime : EmpOverTime

        //private EmployeeOverTime _empOverTime;
        //public EmployeeOverTime EmpOverTime
        //{
        //    get
        //    {
        //        if (_empOverTime == null && !_empOverTimeID.IsUnassigned && _empOverTimeID.Integer>0)
        //        {
        //            _empOverTime = EmployeeOverTime.Get(_empOverTimeID);
        //        }
        //        return _empOverTime;
        //    }
        //    set
        //    {
        //        _empOverTime = value;
        //    }
        //}
        //#endregion

        public double ArrearAmount { get; set; }

        public DateTime OTMonth { get; set; }

        public int PayrollTypeID { get; set; }

        #endregion

        //#region Service Factory IOTProcessService : IOTProcessService

        //internal static IOTProcessService Service
        //{
        //    get { return Services.Factory.CreateService<IOTProcessService>(typeof(IOTProcessService)); }
        //}

        //#endregion

        //#region Functions

        //public static OTProcess Get(ID nID)
        //{
        //    OTProcess oOTProcess = null;
        //    #region Cache Header
        //    oOTProcess = (OTProcess)_cache["Get", nID];
        //    if (oOTProcess != null)
        //        return oOTProcess;
        //    #endregion
        //    oOTProcess = OTProcess.Service.Get(nID);
        //    #region Cache Footer
        //    _cache.Add(oOTProcess, "Get", nID);
        //    #endregion
        //    return oOTProcess;
        //}

        //public static List<OTProcess> Get()
        //{
        //    #region Cache Header

        //    List<OTProcess> oTProcess = _cache["Get"] as List<OTProcess>;
        //    if (oTProcess != null)
        //        return oTProcess;

        //    #endregion

        //    try
        //    {
        //        oTProcess = Service.Get();
        //    }
        //    catch (ServiceException e)
        //    {
        //        throw new Exception(e.Message, e);
        //    }

        //    #region Cache Footer

        //    _cache.Add(oTProcess, "Get");

        //    #endregion

        //    return oTProcess;
        //}

        //public static DataSet GetOTProcessData(DateTime Month,string sEmpID)
        //{
 
        //    DataSet oTProcess = null;
        //    try
        //    {
        //        oTProcess = Service.GetOTProcessData(Month,sEmpID);
        //    }
        //    catch (ServiceException e)
        //    {
        //        throw new Exception(e.Message, e);
        //    }

        //    return oTProcess;
        //}

        //public static List<OTProcess> GetOTProcessDataByMonthAndDeptID(DateTime Month, string deptID)
        //{

        //    #region Cache Header

        //    List<OTProcess> oTProcess = _cache["Get"] as List<OTProcess>;
        //    if (oTProcess != null)
        //        return oTProcess;

        //    #endregion

        //    try
        //    {
        //        oTProcess = Service.GetOTProcessDataByMonthAndDeptID(Month, deptID);
        //    }
        //    catch (ServiceException e)
        //    {
        //        throw new Exception(e.Message, e);
        //    }

        //    #region Cache Footer

        //    _cache.Add(oTProcess, "Get");

        //    #endregion

        //    return oTProcess;
        //}

        //public static DataSet GetOTMonthRangeData(DateTime FDate,DateTime TDate)
        //{

        //    DataSet oTProcess = null;
        //    try
        //    {
        //        oTProcess = Service.GetOTMonthRangeData(FDate,TDate);
        //    }
        //    catch (ServiceException e)
        //    {
        //        throw new Exception(e.Message, e);
        //    }

        //    return oTProcess;
        //}

        //public static DataSet GetBranchWiseOT(DateTime Month)
        //{

        //    DataSet oTProcess = null;
        //    try
        //    {
        //        oTProcess = Service.GetBranchWiseOT(Month);
        //    }
        //    catch (ServiceException e)
        //    {
        //        throw new Exception(e.Message, e);
        //    }

        //    return oTProcess;
        //}

        //public static DataSet GetLocationWiseOT(DateTime FDate, DateTime TDate)
        //{

        //    DataSet oTProcess = null;
        //    try
        //    {
        //        oTProcess = Service.GetLocationWiseOT(FDate, TDate);
        //    }
        //    catch (ServiceException e)
        //    {
        //        throw new Exception(e.Message, e);
        //    }

        //    return oTProcess;
        //}


        //public static List<OTProcess> Get(DateTime dMonthDate)
        //{
        //    #region Cache Header

        //    List<OTProcess> oTProcess = _cache["Get", dMonthDate] as List<OTProcess>;
        //    if (oTProcess != null)
        //        return oTProcess;

        //    #endregion

        //    try
        //    {
        //        oTProcess = Service.Get(dMonthDate);
        //    }
        //    catch (ServiceException e)
        //    {
        //        throw new Exception(e.Message, e);
        //    }

        //    #region Cache Footer

        //    _cache.Add(oTProcess, "Get", dMonthDate);

        //    #endregion

        //    return oTProcess;
        //}

        //public static List<OTProcess> GetbyOtMonth(Hashtable empList,Hashtable monthDate )
        //{
        //    List<OTProcess> oTProcess = null;
        //    string sEmpIDs = string.Empty, sDates = string.Empty;

        //    foreach (int nKey in empList.Keys)
        //    {
        //        sEmpIDs = sEmpIDs + empList[nKey].ToString() + ",";
        //    }
        //    if (sEmpIDs.Length > 0)
        //    {
        //        sEmpIDs = sEmpIDs.Substring(0, sEmpIDs.Length - 1);
        //    }

        //    foreach (DateTime dKey in monthDate.Keys)
        //    {
        //        sDates = sDates + "'" + Convert.ToDateTime(monthDate[dKey].ToString()).ToString("dd MMM yyyy") + "'" + ",";
        //    }
        //    if (sDates.Length > 0)
        //    {
        //        sDates = sDates.Substring(0, sDates.Length - 1);
        //    }
            
        //    try
        //    {
        //        if (sEmpIDs.Length > 0 && sDates.Length > 0)
        //        {
        //            oTProcess = Service.GetbyOtMonth(sEmpIDs, sDates);
        //        }
        //    }
        //    catch (ServiceException e)
        //    {
        //        throw new Exception(e.Message, e);
        //    }

        //    return oTProcess;
        //}

        //public ID Save()
        //{
        //    return OTProcess.Service.Save(this);
        //}

        //public static void Save(List<OTProcess> otProcesses)
        //{
        //    foreach (OTProcess process in otProcesses)
        //    {
        //        process.SetAuditTrailProperties();
        //    }
        //    OTProcess.Service.Save(otProcesses);
        //}

        //public void Delete()
        //{
        //    OTProcess.Service.Delete(ID);
        //}

        //public static bool IsProcessed(DateTime dMonthDate)
        //{
        //    return OTProcess.Service.IsProcessed(dMonthDate,SystemInformation.CurrentSysInfo.PayrollTypeID.Integer);
        //}

        //public static void UndoProcess(DateTime dMonthDate,ID nPayrollTypeID)
        //{
        //    OTProcess.Service.Delete(dMonthDate,nPayrollTypeID);
        //}

        //public static DataSet GetCostCenterWiseOT(DateTime dateTime, string sEmpID)
        //{
        //    DataSet oTProcess = null;
        //    try
        //    {
        //        oTProcess = Service.GetCostCenterWiseOT(dateTime, sEmpID);
        //    }
        //    catch (ServiceException e)
        //    {
        //        throw new Exception(e.Message, e);
        //    }

        //    return oTProcess;
        //}
        //#endregion

    }
    #endregion

    #region IOTProcess Service

    public interface IOTProcessService
    {
        OTProcess Get(int id);
        List<OTProcess> Get();
        int Save(OTProcess item);
        void Delete(int id);
        void Save(List<OTProcess> otProcesses);
        bool IsProcessed(DateTime dMonthDate, int payrollTypeID);
        void Delete(DateTime dMonthDate, int nPayrollTypeID);
        void Process(List<Employee> emps, int userid, int payrolltypeid);

        List<OTProcess> Get(DateTime dMonthDate);
        List<OTProcess> GetbyOtMonth(string sEmpIDs, string sMonths);
        DataSet GetOTProcessData(DateTime Month, string sEmpID);
        DataSet GetOTMonthRangeData(DateTime FDate, DateTime TDate);
        DataSet GetBranchWiseOT(DateTime Month);
        DataSet GetLocationWiseOT(DateTime FDate, DateTime TDate);

        DataSet GetCostCenterWiseOT(DateTime dateTime, string sEmpID);
        DataSet GetCCWiseOTSummary(DateTime dateTime, string sEmpID);
        List<OTProcess> GetOTProcessDataByMonthAndDeptID(DateTime Month, string deptID);
    }

    #endregion
}