using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Ease.CoreV35.DataAccess;
using System.Data;
using System.Data.SqlClient;
using HRM.BO;
using Ease.Core.DataAccess;

namespace HRM.DA
{
    internal class ActingResponsibilitySetupDA
    {
        #region Constructor

        private ActingResponsibilitySetupDA()
        {
        }

        #endregion

        #region Insert function

        internal static void Insert(TransactionContext tc, ActingResponsibilitySetup item)
        {
            tc.ExecuteNonQuery(
                "INSERT INTO ActingResponsibilitySetup(ActingResponsibilitySetupID, EmployeeID, ShiftID, FromDate, ToDate, " +
                "CREATEDBY, CREATIONDATE, WorkPlanGroupID, GradeID, Remarks, Amount, SalaryMonth, payrollTypeID,CLAIMWFSTATUS,ISHOLIDAY)" +
                " VALUES(%n, %n, %n, %d, %d, %n, %d, %n, %n, %s, %n, %d, %n, %n,%b)", item.ID, item.EmployeeID,
                item.ShiftID, item.FromDate, item.ToDate, item.CreatedBy, item.CreatedDate,
                item.WorkPlanGroupID, DataReader.GetNullValue(item.GradeID, 0),
                item.Remarks, item.Amount, item.SalaryMonth, item.payrollTypeID, (int)item.ClaimWFStatus, item.IsHoliday);
        }

        #endregion

        #region Update Function

        internal static void Update(TransactionContext tc, ActingResponsibilitySetup item)
        {
            tc.ExecuteNonQuery(
                "UPDATE ActingResponsibilitySetup SET EmployeeID=%n, ShiftID=%n, FromDate=%d, ToDate=%d,  MODIFIEDBY=%n, MODIFIEDDATE=%d,WorkPlanGroupID=%n, GradeID=%n, Remarks=%s, Amount=%n, SalaryMonth=%d, CLAIMWFSTATUS=%n, ISHOLIDAY=%b " +
                " WHERE ActingResponsibilitySetupID=%n", item.EmployeeID, item.ShiftID,
                item.FromDate, item.ToDate, item.ModifiedBy, item.ModifiedDate,
                item.WorkPlanGroupID, DataReader.GetNullValue(item.GradeID, 0),
                item.Remarks, item.Amount, item.SalaryMonth, (int)item.ClaimWFStatus, item.IsHoliday, item.ID);
        }

        #endregion

        #region Get Function

        internal static IDataReader GetWithPayrollType(TransactionContext tc, int PayrollTypeID)
        {
            return tc.ExecuteReader(
                "SELECT * FROM ActingResponsibilitySetup a Inner join Employee e on e.employeeID=a.employeeID Where e.payrollTypeID=%n Order By a.FromDate asc",
                PayrollTypeID);
        }

        internal static IDataReader GetTemporaryShiftEmployee(TransactionContext tc)
        {
            return tc.ExecuteReader(
                "SELECT * FROM ACTINGRESPONSIBILITYSETUP a Inner join Employee e on e.employeeID=a.employeeID Where e.payrollTypeID=%n And a.GRADEID IS NULL ORDER BY a.EmployeeID asc",
                1);
        }

        internal static IDataReader GetTemporaryShiftEmployee(TransactionContext tc, DateTime attnDate)
        {
            // return tc.ExecuteReader("SELECT * FROM ACTINGRESPONSIBILITYSETUP WHERE GRADEID IS NULL ORDER BY EmployeeID asc");

            return tc.ExecuteReader(
                "SELECT * FROM ACTINGRESPONSIBILITYSETUP WHERE GRADEID IS NULL AND CLAIMWFSTATUS = 2 AND %d>=FROMDATE AND (%d<=TODATE OR TODATE IS null)",
                attnDate, attnDate);
        }

        internal static IDataReader GetbyEmpID(TransactionContext tc, DateTime fromDate, DateTime toDate, int empid)
        {
            string sql =
                SQLParser.MakeSQL(
                    @"SELECT * FROM ACTINGRESPONSIBILITYSETUP WHERE 
                        FROMDATE<%d AND (toDate BETWEEN %d AND %d OR ToDate>%d)
                         and EmployeeID=%n",
                    toDate, fromDate, toDate, toDate, empid);
            return tc.ExecuteReader(sql);
        }
        internal static IDataReader Get(TransactionContext tc, DateTime fromDate, DateTime toDate, int empid, EnumClaimWFStatus enumClaimWFStatus)
        {
            string sql = string.Empty;
            string whareClause = string.Empty;
            if (enumClaimWFStatus != EnumClaimWFStatus.None)
            {
                whareClause += SQLParser.MakeSQL(" AND ars.CLAIMWFSTATUS = %n ", enumClaimWFStatus);
            }
            if (empid != 0)
            {
                whareClause += SQLParser.MakeSQL(" AND ars.EMPLOYEEID IN (%q) ", empid);
            }

            sql = SQLParser.MakeSQL(@"
            SELECT e.employeeNo, e.Name EmployeeName, ars.*
            FROM ACTINGRESPONSIBILITYSETUP ars
            JOIN EMPLOYEE e ON ars.EMPLOYEEID = e.EMPLOYEEID
            WHERE ((%d BETWEEN ars.FROMDATE AND ars.TODATE) OR
            (%d BETWEEN ars.FROMDATE AND ars.TODATE) OR
            (ars.FROMDATE BETWEEN %d AND %d) OR
            (ars.TODATE BETWEEN %d AND %d))",
            fromDate, 
            toDate, 
            fromDate, toDate,
            fromDate, toDate);

            sql += whareClause;

            #region cmnt
            //if (enumClaimWFStatus != EnumClaimWFStatus.None)
            //{
            //    if (empid != 0)
            //    {
            //        sql =
            //                SQLParser.MakeSQL(
            //                    @"SELECT ars.*, e.employeeNo, e.Name EmployeeName FROM ACTINGRESPONSIBILITYSETUP ars 
            //        inner join employee e on ars.employeeid = e.employeeid WHERE 
            //            ars.FROMDATE<%d AND (ars.toDate BETWEEN %d AND %d OR ars.ToDate>%d)
            //             and ars.EmployeeID=%n and ars.CLAIMWFSTATUS=%n",
            //                    toDate, fromDate, toDate, toDate, empid, (int)enumClaimWFStatus);
            //    }
            //    else
            //    {
            //        sql =
            //                SQLParser.MakeSQL(
            //                    @"SELECT ars.*, e.employeeNo, e.Name EmployeeName FROM ACTINGRESPONSIBILITYSETUP ars 
            //        inner join employee e on ars.employeeid = e.employeeid WHERE 
            //            ars.FROMDATE<%d AND (ars.toDate BETWEEN %d AND %d OR ars.ToDate>%d)
            //             and ars.CLAIMWFSTATUS=%n",
            //                    toDate, fromDate, toDate, toDate, (int)enumClaimWFStatus);
            //    } 
            //}
            //else
            //{
            //    if (empid != 0)
            //    {
            //        sql =
            //                SQLParser.MakeSQL(
            //                    @"SELECT ars.*, e.employeeNo, e.Name EmployeeName FROM ACTINGRESPONSIBILITYSETUP ars 
            //        inner join employee e on ars.employeeid = e.employeeid WHERE 
            //            ars.FROMDATE<%d AND (ars.toDate BETWEEN %d AND %d OR ars.ToDate>%d)
            //             and ars.EmployeeID=%n",
            //                    toDate, fromDate, toDate, toDate, empid);
            //    }
            //    else
            //    {
            //        sql =
            //                SQLParser.MakeSQL(
            //                    @"SELECT ars.*, e.employeeNo, e.Name EmployeeName FROM ACTINGRESPONSIBILITYSETUP ars 
            //        inner join employee e on ars.employeeid = e.employeeid WHERE 
            //            ars.FROMDATE<%d AND (ars.toDate BETWEEN %d AND %d OR ars.ToDate>%d)
            //             ",
            //                    toDate, fromDate, toDate, toDate);
            //    }
            //} 
            #endregion
            return tc.ExecuteReader(sql);
        }

        internal static IDataReader GetForApprove(TransactionContext tc, DateTime fromDate, DateTime toDate, int lmID, EnumClaimWFStatus enumClaimWFStatus)
        {
            string sql = string.Empty;
            sql =
                            SQLParser.MakeSQL(
                                @"SELECT ars.*, e.employeeNo, e.Name EmployeeName FROM ACTINGRESPONSIBILITYSETUP ars 
                    inner join employee e on ars.employeeid = e.employeeid WHERE 
                        ars.FROMDATE<%d AND (ars.toDate BETWEEN %d AND %d OR ars.ToDate>%d)
                         and ars.EmployeeIDIN (SELECT EmployeeID FROM EMPLOYEE WHERE LINEMANAGERID IN
(SELECT                     EmployeeID FROM EMPLOYEE WHERE LINEMANAGERID = %n)) and ars.CLAIMWFSTATUS=%n",
                                toDate, fromDate, toDate, toDate, lmID, (int)enumClaimWFStatus);
                
            return tc.ExecuteReader(sql);
        }


        internal static IDataReader Get(TransactionContext tc, DateTime fromDate, DateTime toDate, int payrollTypeID)
        {
            string sql =
                SQLParser.MakeSQL(
                    @"SELECT ars.*, e.employeeNo, e.Name EmployeeName FROM ACTINGRESPONSIBILITYSETUP ars 
                    inner join employee e on ars.employeeid = e.employeeid WHERE 
                        ars.FROMDATE<%d AND (ars.toDate BETWEEN %d AND %d OR ars.ToDate>%d)
                         and e.PAYROLLTYPEID=%n",
                    toDate, fromDate, toDate, toDate, payrollTypeID);
            return tc.ExecuteReader(sql);
        }
        internal static IDataReader GetByStatus(TransactionContext tc, DateTime fromDate, DateTime toDate, int payrollTypeID, EnumClaimWFStatus enumClaimWFStatus)
        {
            string sql =
                SQLParser.MakeSQL(
                    @"SELECT ars.*, e.employeeNo, e.Name EmployeeName FROM ACTINGRESPONSIBILITYSETUP ars 
                    inner join employee e on ars.employeeid = e.employeeid WHERE 
                        ars.FROMDATE<%d AND (ars.toDate BETWEEN %d AND %d OR ars.ToDate>%d)
                         and e.PAYROLLTYPEID=%n AND ars.CLAIMWFSTATUS = %n",
                    toDate, fromDate, toDate, toDate, payrollTypeID, (int)enumClaimWFStatus);
            return tc.ExecuteReader(sql);
        }
        internal static IDataReader GetById(TransactionContext tc, int ID)
        {
            return tc.ExecuteReader("SELECT * FROM ACTINGRESPONSIBILITYSETUP WHERE ACTINGRESPONSIBILITYSETUPID=%n", ID);
        }
        internal static IDataReader GetOnwardByEmpID(TransactionContext tc, DateTime fromDate, int employeeid)
        {
            string sql =
                SQLParser.MakeSQL(
                    @"SELECT * FROM ACTINGRESPONSIBILITYSETUP WHERE 
                        FROMDATE<=%d AND toDate > %d
                         and employeeid=%n",
                    fromDate, fromDate,employeeid);
            return tc.ExecuteReader(sql);
        }
        internal static IDataReader GetBySalaryMonth(TransactionContext tc, DateTime salaryMonth, int PayrollTypeID)
        {
            string sql =
                SQLParser.MakeSQL(
                    "SELECT * FROM ACTINGRESPONSIBILITYSETUP a Inner join Employee e on e.employeeID=a.employeeID WHERE a.Salarymonth =%d and e.PayrollTypeID=%n and a.GRADEID is not null",
                    salaryMonth, PayrollTypeID);
            return tc.ExecuteReader(sql);
        }

        internal static IDataReader Get(TransactionContext tc, int employeeid)
        {
            return tc.ExecuteReader("SELECT * FROM ActingResponsibilitySetup WHERE EmployeeID=%n", employeeid);
        }

        #endregion

        #region Delete

        internal static void Delete(TransactionContext tc, int nID)
        {
            tc.ExecuteNonQuery("DELETE FROM ActingResponsibilitySetup WHERE ActingResponsibilitySetupID=%n", nID);
        }

        internal static void Delete(TransactionContext tc, int empid, DateTime fromDate, DateTime toDate)
        {
            tc.ExecuteNonQuery("DELETE FROM ActingResponsibilitySetup WHERE EmployeeID=%n and FromDate=%d and ToDate=%d", empid, fromDate, toDate);
        }


        #endregion

        internal static IDataReader GetByEmployeeID(TransactionContext tc, int employeeID, DateTime effectDate)
        {
            string sSQL = SQLParser.MakeSQL(@"SELECT * FROM ACTINGRESPONSIBILITYSETUP 
                            WHERE GRADEID IS NULL AND ( %d<=TODATE OR TODATE IS null) 
                            and EmployeeID=%n", effectDate, employeeID);

            return tc.ExecuteReader(sSQL);
        }
        internal static void Update(TransactionContext tc, ActingResponsibilitySetup osetup, DateTime dt)
        {
            tc.ExecuteNonQuery("UPDATE ActingResponsibilitySetup SET ToDate = %d  WHERE ActingResponsibilitySetupID = %n", dt, osetup.ID);
        }
internal static IDataReader GetTempShiftByID(TransactionContext tc, int ID)
        {
            return tc.ExecuteReader("SELECT * FROM ActingResponsibilitySetup WHERE ActingResponsibilitySetupID=%n", ID);
        }

        internal static IDataReader GetAllTemporaryShiftEmployee(TransactionContext tc)
        {
            return tc.ExecuteReader(
                "SELECT * FROM ACTINGRESPONSIBILITYSETUP a Where a.GRADEID IS NULL ORDER BY a.EmployeeID asc");
        }

        internal static DataSet GetByLineManager(TransactionContext tc, int linemanagerID)
        {
            string sql1 = SQLParser.MakeSQL(
                @"SELECT act.ACTINGRESPONSIBILITYSETUPID EmployeeWorkPlanSetUPID , e.EmployeeID, e.EMPLOYEENO EmployeeNo , e.NAME Name, FROMdate FromDate, todate ToDate, g.NAME ActualShift,
                                 (SELECT  Name FROM  WORKPLANGROUP gg WHERE
                                gg.workplangroupid = act.WORKPLANGROUPID) CurrentShift , g.workplangroupid ShiftID, act.ClaimWFStatus  FROM ActingResponsibilitySetup act, employeeworkplansetup wp, WORKPLANGROUP g, Employee e WHERE act.EMPLOYEEID IN(
                                SELECT employeeid FROM EMPLOYEE WHERE LINEMANAGERID = %n)
                                AND(FROMDATE >= %d OR TODATE > %d)
                                AND act.employeeid = wp.employeeid AND  wp.workplangroupid = g.workplangroupid
                                AND e.employeeid = act.employeeid and act.ClaimWFStatus=%n", linemanagerID,
                DateTime.Today, DateTime.Today, EnumClaimWFStatus.LMApproved);
            DataSet obj = tc.ExecuteDataSet(
                @"SELECT act.ACTINGRESPONSIBILITYSETUPID EmployeeWorkPlanSetUPID , e.EmployeeID, e.EMPLOYEENO EmployeeNo , e.NAME Name, FROMdate FromDate, todate ToDate, g.NAME ActualShift,
                                 (SELECT  Name FROM  WORKPLANGROUP gg WHERE
                                gg.workplangroupid = act.WORKPLANGROUPID) CurrentShift , g.workplangroupid ShiftID, act.ClaimWFStatus  FROM ActingResponsibilitySetup act, employeeworkplansetup wp, WORKPLANGROUP g, Employee e WHERE act.EMPLOYEEID IN(
                                SELECT employeeid FROM EMPLOYEE WHERE LINEMANAGERID = %n)
                                AND(TODATE >= %d OR TODATE is null )
                                AND act.employeeid = wp.employeeid AND  wp.workplangroupid = g.workplangroupid
                                AND e.employeeid = act.employeeid and act.ClaimWFStatus=%n", linemanagerID,
                DateTime.Today, EnumClaimWFStatus.LMApproved);
            return obj;
        }

        internal static IDataReader GetAllTemporaryShiftEmployeeByLM(TransactionContext tc, int lmID)
        {
            return tc.ExecuteReader(
                "SELECT * FROM ACTINGRESPONSIBILITYSETUP  Where GRADEID IS NULL and EmployeeID in (Select EmployeeID from Employee Where LineManagerID=%n) ORDER BY EmployeeID asc",
                lmID);
        }

        internal static IDataReader GetTemporaryShiftEmployee(TransactionContext tc, DateTime attnDate, int employeeID)
        {
            // return tc.ExecuteReader("SELECT * FROM ACTINGRESPONSIBILITYSETUP WHERE GRADEID IS NULL ORDER BY EmployeeID asc");

            return tc.ExecuteReader(
                "SELECT * FROM ACTINGRESPONSIBILITYSETUP WHERE GRADEID IS NULL AND CAST ( TO_DATE(%d, 'DD MM YYYY') as DATE)>=CAST(to_date(FROMDATE,'DD MM YYYY') as Date ) AND (CAST ( TO_DATE(%d, 'DD MM YYYY') as DATE)<=(CAST(to_date(TODATE,'DD MM YYYY') as date)) OR TODATE IS null) and EmployeeID=%n",
                attnDate, attnDate, employeeID);
        }

        internal static bool IsEmployeeExistOnSameDate(TransactionContext tc, int employeeid, DateTime fromDate)
        {
            bool isExist = false;
            object obj =
                tc.ExecuteScalar(
                    "SELECT Count(*) from ActingResponsibilitySetup Where GradeID is Not Null and EmployeeID=%n And SalaryMonth=%d",
                    employeeid, fromDate);
            isExist = Convert.ToInt32(obj) > 0 ? true : false;
            return isExist;
        }

        internal static bool IsEmployeeExist(TransactionContext tc, int employeeid, DateTime fromDate, DateTime toDate)
        {
            bool isExist = false;
            string sql1 = SQLParser.MakeSQL(@"SELECT Count(*) FROM ACTINGRESPONSIBILITYSETUP 
                                             WHERE GRADEID IS NULL AND EmployeeID=%n 
                                             AND CAST ( TO_DATE(%d, 'DD MM YYYY') as DATE)>=CAST(to_date(FROMDATE,'DD MM YYYY') as Date ) 
                                             AND (CAST ( TO_DATE(%d, 'DD MM YYYY') as DATE)<=(CAST(to_date(TODATE,'DD MM YYYY') as date)) OR TODATE IS null)",
                employeeid, fromDate, toDate);

            string sql2 = SQLParser.MakeSQL(@"SELECT Count(*) FROM ACTINGRESPONSIBILITYSETUP 
                                             WHERE GRADEID IS NULL AND EmployeeID=%n AND (

                                            CAST ( TO_DATE(%d, 'DD MM YYYY') as DATE) BETWEEN CAST(to_date(FROMDATE,'DD MM YYYY') as Date) AND (CAST(to_date(ISNULL(TODATE, '1 Jan 0001'),'DD MM YYYY') as date)) OR
                                            CAST ( TO_DATE(%d, 'DD MM YYYY') as DATE)   BETWEEN CAST(to_date(FROMDATE,'DD MM YYYY') as Date) AND (CAST(to_date(ISNULL(TODATE, '1 Jan 0001'),'DD MM YYYY') as date)) OR
                                            CAST(to_date(FROMDATE,'DD MM YYYY') as Date) BETWEEN CAST ( TO_DATE(%d, 'DD MM YYYY') as DATE) AND CAST (TO_DATE(%d, 'DD MM YYYY') as DATE))",
                employeeid, fromDate, toDate, fromDate, toDate);

            string sql = SQLParser.MakeSQL(@"SELECT Count(*) FROM ACTINGRESPONSIBILITYSETUP 
                                             WHERE GRADEID IS NULL AND EmployeeID=%n AND 

                                            %d BETWEEN FROMDATE
                                            AND TODATE OR
                                            %d
                                            BETWEEN FROMDATE AND TODATE
                                            OR
                                            FROMDATE BETWEEN %d AND %d", employeeid, fromDate, toDate, fromDate,
                toDate);
            object obj = tc.ExecuteScalar(sql);
            isExist = Convert.ToInt32(obj) > 0 ? true : false;
            return isExist;
        }
        internal static int GetTotalDayOff(TransactionContext tc, int empId, DateTime fromDate, DateTime toDate)
        {
            int totalDayOff = 0;
            string sql = SQLParser.MakeSQL(@"
            SELECT count(ACTINGRESPONSIBILITYSETUPID) 
            FROM ACTINGRESPONSIBILITYSETUP
            WHERE EMPLOYEEID = %n AND ISHOLIDAY = %b
            AND FROMDATE BETWEEN %d AND %d", empId, true, fromDate, toDate);
            object obj = tc.ExecuteScalar(sql);
            totalDayOff = Convert.ToInt32(obj);
            return totalDayOff;
        }

        internal static void SaveTemporaryShift(TransactionContext tc, UpdateRosterModel oUpdateRosterModel)
        {
            // delete overlapping tempshift
            string sql1 = SQLParser.MakeSQL(@"
            DELETE FROM ACTINGRESPONSIBILITYSETUP
            WHERE EMPLOYEEID IN (%q) AND
            ((%d BETWEEN FROMDATE AND TODATE) OR
            (%d BETWEEN FROMDATE AND TODATE) OR
            (FROMDATE BETWEEN %d AND %d) OR
            (TODATE BETWEEN %d AND %d))",
            oUpdateRosterModel.GetEmpIds(),
            oUpdateRosterModel.FromDate, 
            oUpdateRosterModel.ToDate,
            oUpdateRosterModel.FromDate, oUpdateRosterModel.ToDate,
            oUpdateRosterModel.FromDate, oUpdateRosterModel.ToDate);

            tc.ExecuteNonQuery(sql1);

            // 5000 rows can generate upto 25000000 rows in cross Join
            // it will generate range of date for each emp automatically
            // generate ActingResponsibility Data and insert it
            string sql = SQLParser.MakeSQL(@"
            WITH cte AS (
	            SELECT TOP 5000 * FROM sys.all_columns
            ),
            cte2 AS (
	            SELECT 
	            TOP (DATEDIFF(dd, %d, %d) + 1)
	            CONVERT(DATETIME, DATEADD(dd, ROW_NUMBER() OVER(ORDER BY(SELECT NULL)) - 1, %d)) AS WorkDate
	            FROM cte AS ac1 
	            CROSS JOIN cte AS ac2
            ),
            cte3 AS (
	            SELECT
	            ROW_NUMBER() OVER(ORDER BY EMPLOYEEID) + (SELECT ISNULL(max(ACTINGRESPONSIBILITYSETUPID), 0) FROM ACTINGRESPONSIBILITYSETUP) AS ACTINGRESPONSIBILITYSETUPID,
	            e.EMPLOYEEID,
	            CASE
	                WHEN DATEPART(WEEKDAY, WorkDate) = 1 THEN %n
	                WHEN DATEPART(WEEKDAY, WorkDate) = 2 THEN %n
	                WHEN DATEPART(WEEKDAY, WorkDate) = 3 THEN %n
	                WHEN DATEPART(WEEKDAY, WorkDate) = 4 THEN %n
	                WHEN DATEPART(WEEKDAY, WorkDate) = 5 THEN %n
	                WHEN DATEPART(WEEKDAY, WorkDate) = 6 THEN %n
	                WHEN DATEPART(WEEKDAY, WorkDate) = 7 THEN %n
	            END AS SHIFTID,
	            WorkDate AS FROMDATE, WorkDate AS TODATE, 1 AS CREATEDBY, getdate() AS CREATIONDATE, NULL AS MODIFIEDBY, NULL AS MODIFIEDDATE,
	            NULL AS WORKPLANGROUPID, NULL AS GRADEID, '' AS REMARKS, 0 AS AMOUNT, NULL AS SALARYMONTH, NULL AS SENIORTECHNICIANID,
	            NULL AS APPROVERID, NULL AS APPROVEDATE, 2 AS CLAIMWFSTATUS, NULL AS payrollTypeID,
	            CASE
		            WHEN (DATEPART(WEEKDAY, WorkDate) = %n OR DATEPART(WEEKDAY, WorkDate) = %n) THEN 1 ELSE 0
	            END AS ISHOLIDAY
	            FROM cte2 AS  c
	            CROSS JOIN EMPLOYEE as e
	            WHERE e.EMPLOYEEID IN (%q)
            )
            INSERT INTO ACTINGRESPONSIBILITYSETUP
            SELECT * FROM cte3",
            oUpdateRosterModel.FromDate, oUpdateRosterModel.ToDate,
            oUpdateRosterModel.FromDate,
            oUpdateRosterModel.SundayShiftId,
            oUpdateRosterModel.MondayShiftId,
            oUpdateRosterModel.TuesdayShiftId,
            oUpdateRosterModel.WednessdayShiftId,
            oUpdateRosterModel.ThursdayShiftId,
            oUpdateRosterModel.FridayShiftId,
            oUpdateRosterModel.SaturdayShiftId,
            oUpdateRosterModel.Holiday1, oUpdateRosterModel.Holiday2,
            oUpdateRosterModel.GetEmpIds());

            tc.ExecuteNonQuery(sql);
        }
    }
}