using System;
using System.Data;
using System.Globalization;
using System.IO;
using System.Resources;
using System.Threading;
using System.Web.UI;
using CrystalDecisions.CrystalReports.Engine;
using CrystalDecisions.ReportSource;
using CrystalDecisions.Shared;
using CrystalDecisions.Web;
public partial class Reports_ReportViewer : Base.BasePage
{
    #region Variable Declaration
    public DataTable dtHdr, dtSource, dtSource1, dtSourceDetails, rptHeader, rptHeaderLabels, dtMovShiftNotAllocated, dtSourceShift, dtMontlyAttendance2;
    ResourceManager rm;
    CultureInfo ci;
    cls_Common objCommon = new cls_Common();
    ReportDocument rptDoc = new ReportDocument();
    GetReports rptEmp = new GetReports();
    PayrollConfigurationEventData objPayrollData = new PayrollConfigurationEventData();
    HeaderInformation hdrTable = new HeaderInformation();
    Rpt_Common rptcommon = new Rpt_Common();
    EmailConfiguration objEmailConfiguration = new EmailConfiguration();
    CrystalReportViewer rptview = new CrystalReportViewer();
    int shft = 0, rptType = 0, ContAbsentDays = 0, YrSettingID = 0, absentType = 0, EmployeeCategory = 0, EmployeeType = 0, NoOfDays, Designation, AllSwipesReportType, RawDataDashboard, ProcessType = 0;
    string rptFileName, Level = string.Empty, employeeName = string.Empty, empName = string.Empty, empId = string.Empty, CanteenReportType = string.Empty;
    int ParentLevelid = 0;
    string dtFrom, dtTo, UserGroupName, GradeLevel, ReportName, Normal, Status, LeaveType, MinWorkHours, EmpStatus, TableDescription, Operation, MonthClosureId, YearSettingsId, DeviceId;
    string strSwipOpt = "", strSwipeCard = "", strMaxDeviationHrs = string.Empty, strPunchType = string.Empty;
    string Gender = string.Empty, ReportType = string.Empty, TotalDays = string.Empty, OverTimeReportType = string.Empty, LeaveReportType = string.Empty, SanctionType = string.Empty, SummaryOrDetail = string.Empty; string strReportType = string.Empty; string dtIntime, dtOutTime;
    Boolean blnCheckDataExits = true;
    DataSet dsEmp = new DataSet();
    DataSet dsOverTimewithAmount = new DataSet();
    int MonthlydataLoading = 0;
    string punchTypeValue = "All";
    DataTable dtDate = new DataTable();
    string Dashboard = "";
    string isPresent = "";
    string Filters = string.Empty;
    string strEmpAutoId = "0";
    string strLeavePlanned = string.Empty;
    string strLeaveWI = string.Empty;
    string strLeaveWOI = string.Empty;
    int chkunplan = 0;
    public DataTable dtMonthName;
    string MinExceptkHours = "";
    //string dtFrom = "", dtTo = "";
    String CommonUTCTime = "";
    DateTime ConvertUTCTime = new DateTime();
    string hours = "", Minutes = "";
    #endregion
    #region Page Load Events
    protected void Page_Init(object sender, EventArgs e)
    {
        string source_Language;
        if (Session["Session_ActiveLanguage"] != null)
        {
            source_Language = Convert.ToString(Session["Session_ActiveLanguage"]);
            rm = new ResourceManager(source_Language, System.Reflection.Assembly.Load("App_GlobalResources"));
            ci = Thread.CurrentThread.CurrentCulture;
            int exportFormatFlags = (int)(CrystalDecisions.Shared.ViewerExportFormats.PdfFormat | CrystalDecisions.Shared.ViewerExportFormats.ExcelFormat | CrystalDecisions.Shared.ViewerExportFormats.XmlFormat);
        }
        rptViewer.ToolPanelView = CrystalDecisions.Web.ToolPanelViewType.None;
        #region GetQueryStringValues
        if (Request.QueryString["ScheduleId"] == null)
        {
            if (Request.QueryString["Level"] != null)
                Level = Request.QueryString["Level"];
            if (Request.QueryString["EmpName"] != null)
            {
                employeeName = Request.QueryString["EmpName"];
                employeeName = employeeName.Replace("%", " ");
                employeeName = employeeName.Replace("''", "'");
            }
            if (Request.QueryString["empid"] != null)
                empId = Request.QueryString["empid"];
            if (Request.QueryString["dtFrom"] != null)
                dtFrom = Request.QueryString["dtFrom"];
            if (Request.QueryString["dtTo"] != null)
                dtTo = Request.QueryString["dtTo"];
            if (Request.QueryString["EmpCategory"] != null)
                EmployeeCategory = Convert.ToInt32(Request.QueryString["EmpCategory"]);
            if (Request.QueryString["EmpType"] != null)
                EmployeeType = Convert.ToInt32(Request.QueryString["EmpType"]);
            if (Request.QueryString["ParentLevelId"] != null)
            {
                string str = Convert.ToString(Request.QueryString["ParentLevelId"]);
                if (str == "" || str == string.Empty)
                    ParentLevelid = 0;
                else
                    ParentLevelid = Convert.ToInt16(str);
            }
            if (Request.QueryString["UserGroupName"] != null)
                UserGroupName = Request.QueryString["UserGroupName"];
            if (Request.QueryString["GradeLevel"] != null)
                GradeLevel = Request.QueryString["GradeLevel"];
            if (Request.QueryString["ReportName"] != null)
                ReportName = Request.QueryString["ReportName"];
            if (Request.QueryString["TotalDays"] != null)
                TotalDays = Request.QueryString["TotalDays"];
            if (Request.QueryString["MaxDeviationHrs"] != null)
                strMaxDeviationHrs = Convert.ToString(Request.QueryString["MaxDeviationHrs"]);
            if (Request.QueryString["PunchType"] != null)
                strPunchType = Convert.ToString(Request.QueryString["PunchType"]);
            if (Request.QueryString["absentType"] != null)
            {
                absentType = Convert.ToInt16(Request.QueryString["absentType"]);
            }
            if (Session["ReportsBasedOn"] != null)
            {
                if (Convert.ToString(Session["ReportsBasedOn"]) == "False")
                    strEmpAutoId = "0";
                else
                    strEmpAutoId = Convert.ToString(Session["EmpAutoID"]);
            }
            //Added by karthikeyan for the mycalendar report loaded 
            if (Request.QueryString["MyEmpAutoID"] != null)
                strEmpAutoId = Convert.ToString(Request.QueryString["MyEmpAutoID"]);
            if (Request.QueryString["ProcessType"] != null)
                ProcessType = Convert.ToInt16(Request.QueryString["ProcessType"]);
            if (Request.QueryString["Planned"] != null)
                chkunplan = Convert.ToInt32(Request.QueryString["Planned"]);
            if (Request.QueryString["SanctionType"] != null)
                SanctionType = Convert.ToString(Request.QueryString["SanctionType"]);
            if (Request.QueryString["ReportType"] != null)
                ReportType = Convert.ToString(Request.QueryString["ReportType"]);
            if (Request.QueryString["AllSwipesReportType"] != null)
                AllSwipesReportType = Convert.ToInt32(Request.QueryString["AllSwipesReportType"]);
            if (Request.QueryString["OverTimeReportType"] != null)
                OverTimeReportType = Convert.ToString(Request.QueryString["OverTimeReportType"]);
            if (Request.QueryString["LeaveReportType"] != null)
                LeaveReportType = Convert.ToString(Request.QueryString["LeaveReportType"]);
            if (Request.QueryString["OutTime"] != null)
                dtOutTime = Request.QueryString["OutTime"];
            if (Request.QueryString["InTime"] != null)
                dtIntime = Request.QueryString["InTime"];
            if (Request.QueryString["Gender"] != null)
                Gender = Request.QueryString["Gender"];
            if (Request.QueryString["Designation"] != null)
                Designation = Convert.ToInt32(Request.QueryString["Designation"]);
            if (Request.QueryString["SwipOpt"] != null)
                strSwipOpt = Convert.ToString(Request.QueryString["SwipOpt"]);
            if (Request.QueryString["SwipeCard"] != null)
                strSwipeCard = Convert.ToString(Request.QueryString["SwipeCard"]);
            if (Request.QueryString["MonthlydataLoadingVer"] != null)
                MonthlydataLoading = Convert.ToInt32(Request.QueryString["MonthlydataLoadingVer"]);
            if (Request.QueryString["punchTypeValue"] != null)
                punchTypeValue = Convert.ToString(Request.QueryString["punchTypeValue"]);
            if (Request.QueryString["RawDataDashboard"] != null)
                RawDataDashboard = Convert.ToInt16(Request.QueryString["RawDataDashboard"]);
            if (Request.QueryString["DeviceId"] != null)
                DeviceId = Convert.ToString(Request.QueryString["DeviceId"]);
            Level = rptcommon.getNodes(Convert.ToInt16(ParentLevelid), Convert.ToString(Session["LevelRights"]));
        }
        else
        {
            if (Request.QueryString["Language"] != null)
            {
                string strLang_name = string.Empty;
                if (Encryption.Decrypt(Convert.ToString(Request.QueryString["Language"]), "") == "English_US")
                    strLang_name = "Resources.Resource_EN";
                else
                    strLang_name = "Resources.Resource_AR";
                source_Language = strLang_name;
                rm = new ResourceManager(source_Language, System.Reflection.Assembly.Load("App_GlobalResources"));
                ci = Thread.CurrentThread.CurrentCulture;
            }
            if (Request.QueryString["DateFormat"] != null)
                if (Encryption.Decrypt(Convert.ToString(Request.QueryString["DateFormat"]), "") != string.Empty)
                    Session["MDateFormat"] = Encryption.Decrypt(Convert.ToString(Request.QueryString["DateFormat"]), "");
            if (Request.QueryString["TimeFormat"] != null)
                if (Encryption.Decrypt(Convert.ToString(Request.QueryString["TimeFormat"]), "") != string.Empty)
                    Session["MTimeFormat"] = Encryption.Decrypt(Convert.ToString(Request.QueryString["TimeFormat"]), "");
        }

        /****************************************************************************************************************************
        * Project Name    : TimeCheck                                 Started Date  : 10-Jan-2024
        * Module          : UTC Common Function for all report        Last Modified : 31-Jan-2024
        * Programmer      : Hariharan.J
        * Modified by     : Hariharan.J
        *****************************************************************************************************************************/

        String EmployeeID = Convert.ToString(Session["EmployeeId"]);
        org_levelsEventData getUtcEmployeeCheck = new org_levelsEventData();
        DataSet ds_UTC = new DataSet();
        String TimeFormat = Convert.ToString(Session["ITimeFormat"]);
        String DateFormat = Convert.ToString(Session["IDateFormat"]);
        if (EmployeeID == "admin" || EmployeeID == "Admin")
        {
            String UTCD = DateTime.Now.ToString("dd/MM/yyyy");
            if (Convert.ToString(TimeFormat) == "HH:mm")
            {
                CommonUTCTime = DateTime.Now.ToString();

            }
            else
            {
                CommonUTCTime = DateTime.Now.ToString();
            }


            String cccc = Convert.ToString(CommonUTCTime);
            Session["EmployeeCountryGetDateTime"] = Convert.ToString(CommonUTCTime);
            //String ch = Convert.ToString( DateTime.Now.ToString("yyyy/MM/dd"));
            //string Check = objCommon.DateConvertion(Convert.ToString(Session["MDateFormat"]), DateTime.Now.ToString("yyyy/MM/dd"));
            //ViewState["EmployeeCountryGetDateTime"] = objCommon.DateConvertion(Convert.ToString(Session["MDateFormat"]), DateTime.Now.ToString("yyyy/MM/dd"));
        }
        else
        {

            ds_UTC = getUtcEmployeeCheck.GetUTCTimeZoneEmployeeCheck(EmployeeID);
            int Counts = ds_UTC.Tables[0].Rows.Count;
            if (Counts != 0)
            {

                Session["HoursToBeAdded"] = ds_UTC.Tables[0].Rows[0]["HoursToBeAdded"].ToString();
                Session["MinToBeAdded"] = ds_UTC.Tables[0].Rows[0]["MinToBeAdded"].ToString();


                hours = Convert.ToString(ds_UTC.Tables[0].Rows[0]["HoursToBeAdded"]);
                Minutes = Convert.ToString(ds_UTC.Tables[0].Rows[0]["MinToBeAdded"]);
                ConvertUTCTime = objCommon.TimezoneGetDateTime(Convert.ToInt32(hours), Convert.ToInt32(Minutes));

                Session["EmployeeCountryGetDateTime"] = Convert.ToString(ConvertUTCTime);

                //ViewState["CountryGetDateTime"] = ConvertUTCTime;

                //ViewState["EmployeeCountryGetDateTime"] = objCommon.DateConvertion(Convert.ToString(Session["MDateFormat"])+" "+ Convert.ToString(Session["MTimeFormat"])
                //, Convert.ToString (ConvertUTCTime));
            }
        }

        /*****************************************************************************************************************************/

        if (Request.QueryString["ScheduleId"] != null)
        {
            DataSet dsEmailSchedule = new DataSet();
            dsEmailSchedule = objEmailConfiguration.SelectEmailScheduleBasedOnId(Convert.ToInt32(Encryption.Decrypt(Request.QueryString["ScheduleId"], "")));
            if (dsEmailSchedule.Tables[0].Rows.Count > 0)
            {
                Filters = Convert.ToString(dsEmailSchedule.Tables[0].Rows[0]["Filters"]);
                ParentLevelid = Convert.ToInt16(dsEmailSchedule.Tables[0].Rows[0]["CompanyId"]);
                ReportName = Convert.ToString(dsEmailSchedule.Tables[0].Rows[0]["displayName"]);
                dtFrom = Encryption.Decrypt(Convert.ToString(Request.QueryString["FromDate"]), "");
                dtFrom = objCommon.DateConvertion(Convert.ToString(Session["MDateFormat"]), dtFrom);
                dtTo = Encryption.Decrypt(Convert.ToString(Request.QueryString["ToDate"]), "");
                dtTo = objCommon.DateConvertion(Convert.ToString(Session["MDateFormat"]), dtTo);
                Filters = Filters.Replace(" Duration_From ", dtFrom);
                Filters = Filters.Replace(" Duration_To ", dtTo);
                ReportType = Convert.ToString(dsEmailSchedule.Tables[0].Rows[0]["ReportType"]);
                if (ReportName == "Report_Late_Entry")
                {
                    switch (ReportType)
                    {
                        case "LateEntry":
                            ReportName = "Report_Late_Entry";
                            break;
                        case "EarlyExit":
                            ReportName = "Report_Early_Exit";
                            break;
                        case "EarlyEntry":
                            ReportName = "Report_EarltEntry";
                            break;
                        case "LateExit":
                            ReportName = "Report_Late_Exit";
                            break;
                    }
                }
                else if (ReportName == "Report_RawData" && ReportType == "0")
                    ReportName = "RawDataDetailed";
            }
        }
        #endregion
        rptview.ID = ReportName;
        switch (ReportName)
        {
            //Sohit Admin
            case "PayrollDetail":
                #region PayrollDetail
                if (!IsPostBack)
                    LoadPayrollDetails();
                if (blnCheckDataExits == true)
                {
                    LoadReport("PayrollDetail");
                    Page.Header.Title = "PayrollDetail";
                }
                return;
            #endregion
            //Sohit Admin
            case "DailyWagesPenalty":
                #region DailyWagesPenalty
                if (!IsPostBack)
                    LoadDailyWagesPenalty();
                if (blnCheckDataExits == true)
                {
                    LoadReport("DailyWagesPenalty");
                    Page.Header.Title = "DailyWagesPenalty";
                }
                return;
            #endregion
            case "NearestShift":
                #region NearestShift
                if (!IsPostBack)
                    NearestShiftDetails();
                if (blnCheckDataExits == true)
                {
                    LoadReport("NearestShift");
                    Page.Header.Title = "NearestShift";
                }
                return;
            #endregion
            case "DeviationWorkHours":
                #region DeviationWorkHours
                if (!IsPostBack)
                    LoadDeviationWorkHours();
                if (blnCheckDataExits == true)
                {
                    LoadReport("DeviationWorkHours");
                    Page.Header.Title = "ARMIS & Cumulative Work Hours Deviation Report";
                }
                return;
            #endregion
            case "ForPayroll":
                #region ForPayroll
                if (!IsPostBack)
                    LoadWorkedDaysDetails();
                if (blnCheckDataExits == true)
                {
                    LoadReport("ForPayroll");
                    Page.Header.Title = "Worked Days Report";
                }
                if (Request.QueryString["isPDFExcel"] != null)
                    Response.End();
                return;
            #endregion
            case "InPunchDeviationHrs":
                #region InPunchDeviationHrs
                if (!IsPostBack)
                    LoadInPunchDeviationHrs();
                if (blnCheckDataExits == true)
                {
                    LoadReport("InPunchDeviationHrs");
                    Page.Header.Title = "In Punch Deviation Hours Report";
                }
                if (Request.QueryString["isPDFExcel"] != null)
                {
                    ExportMethod(ReportName, Request.QueryString["isPDFExcel"]);
                    Response.End();
                }
                return;
            #endregion
            case "DailyDeviation":
                #region DailyDeviation
                if (!IsPostBack)
                    LoadDailyDeviationReport();
                if (blnCheckDataExits == true)
                {
                    LoadReport("DailyDeviation");
                    Page.Header.Title = "Daily Minimum Work Hours Deviation Report";
                }
                return;
            #endregion
            case "GeneralMonthlyAttendance":
            case "Report_GeneralMonthly_Attendance":
                #region GeneralMonthlyAttendance
                if (!IsPostBack)
                {
                    shft = Convert.ToInt32(Request.QueryString["shft"]);
                    LoadGeneralMonthlyAttendanceReport();
                }
                if (blnCheckDataExits == true)
                {
                    LoadReport("GeneralMonthlyAttendance");
                    Page.Header.Title = "General Monthly Attendance Report";
                }
                return;

            case "ContractorAttendanceReport":
                if (!IsPostBack)
                {
                    shft = Convert.ToInt32(Request.QueryString["shft"]);
                    LoadGenerateContractor();

                }
                if (blnCheckDataExits == true)
                {
                    LoadReport("ContractorAttendanceReport");
                    Page.Header.Title = "Contractor Attendance Report";
                }
                return;
            #endregion
            //Added by Manjula.P on 09-Jan2014 for loading Countfactor workingdays
            case "CountfactorWorkingdays":
            case "Report_CountFactor_WorkingDays":
                #region CountfactorWorkingdays
                if (!IsPostBack)
                    LoadCountfactorWorkingdays();
                if (blnCheckDataExits == true)
                {
                    LoadReport("CountfactorWorkingdays");
                    Page.Header.Title = "CountfactorWorkingdays";
                }
                return;
            #endregion
            case "LessHoursWorked":
            case "Report_LessHoursWorked":
                #region LessHoursWorked
                if (Request.QueryString["shft"] != null)
                {
                    shft = Convert.ToInt32(Request.QueryString["shft"]);
                    SummaryOrDetail = Request.QueryString["LessHoursWorked_SummaryOrDetail"];
                }
                else
                {
                    if (ReportType == "0")
                        SummaryOrDetail = "D";
                    else
                        SummaryOrDetail = "s";
                }
                if (!IsPostBack)
                {
                    LoadLessHoursWorkedReport();
                }
                if (blnCheckDataExits == true)
                {
                    LoadReport("LessHoursWorked");
                    Page.Header.Title = "LessHoursWorked";
                }
                if (Request.QueryString["isPDFExcel"] != null)
                {
                    ExportMethod(ReportName, Request.QueryString["isPDFExcel"]);
                }
                return;
            #endregion
            case "EarlyEntry":
            case "Report_EarltEntry":
                #region EarlyEntry
                if (!IsPostBack)
                    LoadEarlyEntryReport();
                if (blnCheckDataExits == true)
                {
                    LoadReport("EarlyEntry");
                    Page.Header.Title = "Early Entry Report";
                }
                return;
            #endregion
            case "EmployeeInOut_Old":
                #region EmployeeInOut_Old
                if (!IsPostBack)
                {
                    strReportType = Convert.ToString(Request.QueryString["ReportType"]);
                    LoadEmployeeInOutReportNew();
                }
                if (blnCheckDataExits == true)
                {
                    rptDoc.PrintOptions.PaperSize = CrystalDecisions.Shared.PaperSize.PaperCsheet;
                    LoadReport("EmployeeInOut");
                    Page.Header.Title = "Mustor Report";
                }
                return;
            #endregion
            case "EmployeeInOut":
            case "MustoRollReport":
                #region MustoRollReport
                if (Request.QueryString["ReportType"] != null)
                    strReportType = Convert.ToString(Request.QueryString["ReportType"]);
                else
                {
                    switch (ReportType)
                    {
                        case "0":
                            strReportType = "Summary";
                            break;
                        case "1":
                            strReportType = "Details";
                            break;
                    }
                }
                if (strReportType == "Details")
                    rptDoc.PrintOptions.PaperSize = CrystalDecisions.Shared.PaperSize.DefaultPaperSize;
                if (!IsPostBack)
                {
                    if (Request.QueryString["ReportType"] != null)
                        strReportType = Convert.ToString(Request.QueryString["ReportType"]);
                    LoadEmployeeInOutReportNew();
                }
                if (blnCheckDataExits == true)
                {
                    LoadReport("EmployeeInOut");
                    Page.Header.Title = "Muster Report";
                }
                return;
            #endregion
            case "InOutReport":
                #region InOutReport
                if (!IsPostBack)
                {
                    LoadInOutReport();
                }
                if (blnCheckDataExits == true)
                {
                    LoadReport("InOutReport");
                    Page.Header.Title = "Employee In Out Report";
                }
                return;
            #endregion
            case "EmployeeHistory":
                #region EmployeeHistory
                if (!IsPostBack)
                {
                    LoadEmployeeHistoryReport();
                }
                if (blnCheckDataExits == true)
                {
                    rptDoc.PrintOptions.PaperSize = CrystalDecisions.Shared.PaperSize.PaperA4;
                    LoadReport("EmployeeHistory");
                    Page.Header.Title = "Employee History Report";
                }
                return;
            #endregion
            case "AllSwipes":
            case "Report_All_Swipes":
                #region AllSwipes
                if (Request.QueryString["shft"] != null)
                    shft = Convert.ToInt32(Request.QueryString["shft"]);
                if (Request.QueryString["rptType"] != null)
                    rptType = Convert.ToInt32(Request.QueryString["rptType"]);
                if (!IsPostBack)
                {
                    LoadAllSwipesReport();
                }
                if (blnCheckDataExits == true)
                {
                    LoadReport("AllSwipes");
                    Page.Header.Title = "All Swipes Report";
                }
                return;
            #endregion
            case "MatchedAllSwipes":
                #region MatchedAllSwipes
                shft = Convert.ToInt32(Request.QueryString["shft"]);
                if (!IsPostBack)
                {
                    LoadMatchedAllSwipesReport();
                }
                if (blnCheckDataExits == true)
                {
                    LoadReport("MatchedAllSwipes");
                    Page.Header.Title = "All Swipes Report";
                }
                return;
            #endregion
            case "Absentees":
            case "Report_Absent":
                #region Absentees
                if (Request.QueryString["ScheduleId"] == null)
                {
                    shft = Convert.ToInt32(Request.QueryString["shft"]);
                    Normal = Convert.ToString(Request.QueryString["Normal"]);
                    ContAbsentDays = Convert.ToInt32(Request.QueryString["ContAbsentDays"]);
                }
                if (!IsPostBack)
                {
                    LoadAbsentReport();
                }
                if (blnCheckDataExits == true)
                {
                    LoadReport("Absentees");
                    Page.Header.Title = "Absent Report";
                }
                if (Request.QueryString["isPDFExcel"] != null)
                {
                    ExportMethod(ReportName, Request.QueryString["isPDFExcel"]);
                    Response.End();
                }
                return;
            #endregion
            case "LateEntry":
            case "Report_Late_Entry":
                #region LateEntry
                if (Request.QueryString["Normal"] != null)
                {
                    Normal = Convert.ToString(Request.QueryString["Normal"]);
                }
                if (Request.QueryString["shft"] != null)
                {
                    shft = Convert.ToInt32(Request.QueryString["shft"]);
                }
                if (!IsPostBack)
                {
                    LoadLateEntryReport();
                }
                LoadReport("LateEntry");
                Page.Header.Title = "Late Entry Report";
                if (Request.QueryString["isPDFExcel"] != null)
                {
                    ExportMethod(ReportName, Request.QueryString["isPDFExcel"]);
                }
                return;
            #endregion
            case "Exception":
                #region Exception
                if (Request.QueryString["shft"] != null)
                {
                    shft = Convert.ToInt32(Request.QueryString["shft"]);
                }
                if (!IsPostBack)
                {
                    LoadAllExceptionReport();
                }
                if (blnCheckDataExits == true)
                {
                    LoadReport("Exception");
                }
                return;
            #endregion
            case "EarlyExit":
            case "Report_Early_Exit":
                #region EarlyExit
                if (Request.QueryString["Normal"] != null)
                {
                    Normal = Convert.ToString(Request.QueryString["Normal"]);
                }
                if (Request.QueryString["shft"] != null)
                {
                    shft = Convert.ToInt32(Request.QueryString["shft"]);
                }
                if (!IsPostBack)
                {
                    LoadEarlyExitReport();
                }
                LoadReport("EarlyExit");
                Page.Header.Title = "Early Exit Report";
                if (Request.QueryString["isPDFExcel"] != null)
                {
                    ExportMethod(ReportName, Request.QueryString["isPDFExcel"]);
                }
                return;
            #endregion
            case "LateExit":
            case "Report_Late_Exit":
                #region LateExit
                if (Request.QueryString["shft"] != null)
                    shft = Convert.ToInt32(Request.QueryString["shft"]);
                if (!IsPostBack)
                {
                    LoadLateExitReport();
                }
                if (blnCheckDataExits == true)
                {
                    LoadReport("LateExit");
                    Page.Header.Title = "Late Exit Report";
                }
                return;
            #endregion
            case "OverTime":
            case "Report_Overtime":
                #region OverTime
                if (Request.QueryString["shft"] != null)
                    shft = Convert.ToInt32(Request.QueryString["shft"]);
                if (Request.QueryString["Status"] != null)
                    Status = Convert.ToString(Request.QueryString["Status"]);
                else
                    SanctionType = ReportType;
                if (!IsPostBack)
                {
                    LoadOverTimeReport();
                }
                if (blnCheckDataExits == true)
                {
                    LoadReport("OverTime");
                    Page.Header.Title = "Overtime Report";
                }
                if (Request.QueryString["isPDFExcel"] != null)
                {
                    ExportMethod(ReportName, Request.QueryString["isPDFExcel"]);
                }
                return;
            #endregion
            case "OverTimewithAmount":
                #region OverTimewithAmount
                shft = Convert.ToInt32(Request.QueryString["shft"]);
                Status = Convert.ToString(Request.QueryString["Status"]);
                if (!IsPostBack)
                {
                    LoadOverTimewithAmountReport();
                }
                if (blnCheckDataExits == true)
                {
                    LoadReport("OverTimewithAmount");
                    Page.Header.Title = "Overtime with Amount Report";
                }
                return;
            #endregion
            case "Leave_Angler":
                #region Leave_Angler
                LeaveType = Request.QueryString["LeaveType"].ToString();
                Status = Request.QueryString["Status"].ToString();
                //Added by Manjula.P on 08-May-2014 for leave status of multiple selection
                if (Status == "-Select Status-")
                {
                    Status = null;
                }
                else if (Status == "All")
                {
                    Status = null;
                }
                if (Status != null && Status != "")
                {
                    Status = Status.Replace(",", "','");
                }
                Normal = (Request.QueryString["Normal"]).ToString();
                shft = Convert.ToInt32(Request.QueryString["shft"]);
                if (!IsPostBack)
                {
                    LoadLeaveReport_Angler();
                }
                if (blnCheckDataExits == true)
                {
                    LoadReport("Leave");
                    Page.Header.Title = "Unplanned (WI & WOI) Leave Report";
                }
                if (Request.QueryString["isPDFExcel"] != null)
                {
                    ExportMethod(ReportName, Request.QueryString["isPDFExcel"]);
                    Response.End();
                }
                return;
            #endregion
            case "Leave":
            case "Report_Leave":
                #region Leave
                if (Request.QueryString["LeaveType"] != null)
                    LeaveType = Convert.ToString(Request.QueryString["LeaveType"]);
                if (Request.QueryString["Status"] != null)
                    Status = Convert.ToString(Request.QueryString["Status"]);
                if (Request.QueryString["Normal"] != null)
                    Normal = Convert.ToString(Request.QueryString["Normal"]);
                if (Request.QueryString["shft"] != null)
                    shft = Convert.ToInt32(Request.QueryString["shft"]);
                if (Request.QueryString["YrSettingID"] != null)
                    YrSettingID = Convert.ToInt32(Request.QueryString["YrSettingID"]);
                if (!IsPostBack)
                {
                    LoadLeaveReport();
                }
                if (blnCheckDataExits == true)
                {
                    LoadReport("Leave");
                    Page.Header.Title = "Leave Report";
                }
                if (Request.QueryString["isPDFExcel"] != null)
                {
                    ExportMethod(ReportName, Request.QueryString["isPDFExcel"]);
                }
                return;
            #endregion
            case "DetailedAttendance":
            case "Report_Detailed_Attendance":
                #region DetailedAttendance
                if (Request.QueryString["Normal"] != null)
                    Normal = Convert.ToString(Request.QueryString["Normal"]);
                else
                    Normal = "True";
                //Set the Normal id standard in the link email schedule
                if (!IsPostBack)
                {
                    LoadDetailedAttendanceReport();
                }
                if (blnCheckDataExits == true)
                {
                    LoadReport("DetailedAttendance");
                    Page.Header.Title = "Detailed Attendance Report";
                }
                return;
            #endregion
            case "DetailedAttendanceSummary":
                #region DetailedAttendanceSummary-VeoliaClient
                if (!IsPostBack)
                    LoadDetailedAttendanceSummaryReport();
                if (blnCheckDataExits == true)
                    LoadReport("DetailedAttendanceSummary");
                Page.Header.Title = "Detailed Attendance Summary Report";
                return;
            #endregion
            case "Report_Monthly_Attendance":
                #region Report_Monthly_Attendance
                if (Request.QueryString["MinWorkHours"] != null)
                    MinWorkHours = Convert.ToString(Request.QueryString["MinWorkHours"]);
                if (Request.QueryString["shft"] != null)
                    shft = Convert.ToInt32(Request.QueryString["shft"]);
                rptDoc.PrintOptions.PaperSize = CrystalDecisions.Shared.PaperSize.PaperA3;
                if (ReportType == "1")
                {
                    if (!IsPostBack)
                        LoadMonthlyAttendanceReportDetail();
                    if (blnCheckDataExits == true)
                    {
                        LoadReport("MonthlyAttendanceDetail");
                        Page.Header.Title = "Monthly Attendance Detail Report";
                    }
                    return;
                }
                else
                {
                    if (Request.QueryString["Dashboard"] != null)
                        Dashboard = Convert.ToString(Request.QueryString["Dashboard"]);
                    if (Request.QueryString["isPresentReport"] != null)
                        isPresent = Convert.ToString(Request.QueryString["isPresentReport"]);
                    if (!IsPostBack)
                        LoadMonthlyAttendanceReport(ReportName);
                    if (blnCheckDataExits == true)
                    {
                        LoadReport("MonthlyAttendance");
                        Page.Header.Title = "Monthly Attendance Report";
                    }
                    if (Request.QueryString["isPDFExcel"] != null)
                    {
                        if (Dashboard == "MonthlyAtt" && isPresent == "0")
                        {
                            ReportName = "Attendance Summary";
                        }
                        else if (Dashboard == "MonthlyAtt" && isPresent == "1")
                        {
                            ReportName = "Present";
                        }
                        ExportMethod(ReportName, Request.QueryString["isPDFExcel"]);
                    }
                    return;
                }
            #endregion
            case "MonthlyAttendance":
            case "MonthlyAttendanceBreakHours":
            case "LabourMonthlyAttendance":
            case "TawazunMonthlyAttendance":
                #region MonthlyAttendance
                if (Request.QueryString["ScheduleId"] == null)
                {
                    MinWorkHours = Convert.ToString(Request.QueryString["MinWorkHours"]);
                }
                rptDoc.PrintOptions.PaperSize = CrystalDecisions.Shared.PaperSize.PaperA3;
                if (Request.QueryString["shft"] != null)
                    shft = Convert.ToInt32(Request.QueryString["shft"]);
                if (Request.QueryString["Dashboard"] != null)
                    Dashboard = Convert.ToString(Request.QueryString["Dashboard"]);
                if (Request.QueryString["isPresentReport"] != null)
                    isPresent = Convert.ToString(Request.QueryString["isPresentReport"]);
                if (!IsPostBack)
                    LoadMonthlyAttendanceReport(ReportName);
                if (blnCheckDataExits == true)
                {
                    LoadReport("MonthlyAttendance");
                    Page.Header.Title = "Monthly Attendance Report";
                }
                if (Request.QueryString["isPDFExcel"] != null)
                {
                    if (Dashboard == "MonthlyAtt" && isPresent == "0")
                    {
                        ReportName = "Attendance Summary";
                    }
                    else if (Dashboard == "MonthlyAtt" && isPresent == "1")
                    {
                        ReportName = "Present";
                    }
                    ExportMethod(ReportName, Request.QueryString["isPDFExcel"]);
                }
                return;
            #endregion
            case "CanteenReport":
                #region CanteenReport
                rptDoc.PrintOptions.PaperSize = CrystalDecisions.Shared.PaperSize.PaperA3;
                if (Request.QueryString["shft"] != null)
                    shft = Convert.ToInt32(Request.QueryString["shft"]);
                if (Request.QueryString["CanteenReportType"] != null)
                    CanteenReportType = Convert.ToString(Request.QueryString["CanteenReportType"]);
                if (CanteenReportType == "Detailed")
                {
                    if (!IsPostBack)
                        LoadCanteenReport(ReportName);
                    if (blnCheckDataExits == true)
                    {
                        LoadReport("CanteenReport");
                        Page.Header.Title = "Occasion wise Employee Detail Report";
                    }
                    return;
                }
                else if (CanteenReportType == "Summary")
                {
                    if (!IsPostBack)
                        LoadCanteenReportSummary(ReportName);
                    if (blnCheckDataExits == true)
                    {
                        LoadReport("CanteenReport");
                        Page.Header.Title = "Occasion wise Summary (Employee count) Report";
                    }
                    return;
                }
                return;
            #endregion
            case "DailyAttendanceReport":
                #region DailyAttendanceReport
                rptDoc.PrintOptions.PaperSize = CrystalDecisions.Shared.PaperSize.PaperA3;
                if (Request.QueryString["shft"] != null)
                    shft = Convert.ToInt32(Request.QueryString["shft"]);
                if (Request.QueryString["Dashboard"] != null)
                    Dashboard = Convert.ToString(Request.QueryString["Dashboard"]);
                if (!IsPostBack)
                    LoadDailyAttendanceReport(ReportName);
                if (blnCheckDataExits == true)
                {
                    LoadReport("DailyAttendance");
                    Page.Header.Title = "Daily Attendance Report";
                }
                return;
            #endregion
            case "MonthlyAttendanceDetail":
                #region MonthlyAttendanceDetail
                MinWorkHours = Convert.ToString(Request.QueryString["MinWorkHours"]);
                shft = Convert.ToInt32(Request.QueryString["shft"]);
                if (!IsPostBack)
                {
                    LoadMonthlyAttendanceReportDetail();
                }
                if (blnCheckDataExits == true)
                {
                    LoadReport("MonthlyAttendanceDetail");
                    Page.Header.Title = "Monthly Attendance Detail Report";
                }
                return;
            #endregion
            case "TotalDays":
                #region TotalDays
                NoOfDays = Convert.ToInt32(Request.QueryString["NoOfDays"]);
                if (!IsPostBack)
                {
                    LoadTotalDaysReport();
                }
                if (blnCheckDataExits == true)
                {
                    LoadReport("TotalDays");
                    Page.Header.Title = "Total Days Report";
                }
                return;
            #endregion
            case "Punctuality":
            case "Report_Punctuality":
                #region Punctuality
                if (Request.QueryString["Normal"] != null)
                    Normal = Convert.ToString(Request.QueryString["Normal"]);
                else
                    Normal = "True";
                if (Request.QueryString["shft"] != null)
                    shft = Convert.ToInt32(Request.QueryString["shft"]);
                if (!IsPostBack)
                {
                    LoadPunctualityReport();
                }
                if (blnCheckDataExits == true)
                {
                    LoadReport("Punctuality");
                    Page.Header.Title = "Punctuality Report";
                }
                if (Request.QueryString["isPDFExcel"] != null)
                {
                    ExportMethod(ReportName, Request.QueryString["isPDFExcel"]);
                }
                return;
            #endregion
            case "Discrepancy":
            case "Report_Discrepancy":
                #region Discrepancy
                shft = Convert.ToInt32(Request.QueryString["shft"]);
                if (!IsPostBack)
                {
                    LoadDiscrepancyReport();
                }
                if (blnCheckDataExits == true)
                {
                    LoadReport("Discrepancy");
                    Page.Header.Title = "Discrepancy Report";
                }
                if (Request.QueryString["isPDFExcel"] != null)
                {
                    ExportMethod(ReportName, Request.QueryString["isPDFExcel"]);
                }
                return;
            #endregion
            case "Shift":
                #region Shift
                shft = Convert.ToInt32(Request.QueryString["shft"]);
                if (!IsPostBack)
                {
                    LoadShiftReport();
                }
                if (blnCheckDataExits == true)
                {
                    LoadReport("Shift");
                    Page.Header.Title = "Shift Report";
                }
                return;
            #endregion
            case "Shiftwise":
                #region
                shft = Convert.ToInt32(Request.QueryString["shft"]);
                DateTime date = Convert.ToDateTime(Request.QueryString["dtFrom"]);

                String ShiftDate = date.ToString("yyyy-MM-dd");

                int level = Convert.ToInt32(Request.QueryString["Level"]);
                if (!IsPostBack)
                {
                    LoadShiftwiseReport(shft, ShiftDate, level);
                }
                if (blnCheckDataExits == true)
                {
                    LoadReport("ShiftWise");
                    Page.Header.Title = "Shiftwise Attendance Report";
                }
                return;
            #endregion
            case "EmployeeShiftAllocation":
            case "Report_Employee_Shift_Allocation":
                #region EmployeeShiftAllocation
                if (ReportName == "Report_Employee_Shift_Allocation")
                {
                    if (ReportType == "1")
                    {
                        if (!IsPostBack)
                        {
                            LoadShiftNotAllocatedReport();
                        }
                        if (blnCheckDataExits == true)
                        {
                            LoadReport("ShiftNotAllocated");
                            Page.Header.Title = "Shift Not Allocated Report";
                        }
                    }
                    else
                    {
                        if (!IsPostBack)
                        {
                            LoadEmployeeShiftAllocationReport();
                        }
                        if (blnCheckDataExits == true)
                        {
                            LoadReport("EmployeeShiftAllocation");
                            Page.Header.Title = "Shift Allocation Report";
                        }
                    }
                }
                else
                {
                    if (!IsPostBack)
                    {
                        LoadEmployeeShiftAllocationReport();
                    }
                    if (blnCheckDataExits == true)
                    {
                        LoadReport("EmployeeShiftAllocation");
                        Page.Header.Title = "Shift Allocation Report";
                    }
                }
                return;
            #endregion
            case "EmployeeDetails":
                #region EmployeeDetails
                EmpStatus = Convert.ToString(Request.QueryString["EmpStatus"]);
                if (!IsPostBack)
                {
                    LoadEmployeeDetailsReport();
                }
                if (blnCheckDataExits == true)
                {
                    LoadReport("EmployeeDetails");
                    Page.Header.Title = "Employee Details Report";
                }
                return;
            #endregion
            case "DocumentExpiry":
                #region DocumentExpiry
                if (!IsPostBack)
                {
                    LoadDocumentExpiryReport();
                }
                if (blnCheckDataExits == true)
                {
                    LoadReport("DocumentExpiry");
                    Page.Header.Title = "Document Expiry Report";
                }
                return;
            #endregion
            case "AuditTrail":
                #region AuditTrail
                TableDescription = Convert.ToString(Request.QueryString["TableDescription"]);
                Operation = Convert.ToString(Request.QueryString["Operation"]);
                if (!IsPostBack)
                {
                    LoadAuditTrailReport();
                }
                if (blnCheckDataExits == true)
                {
                    LoadReport("AuditTrail");
                    Page.Header.Title = "Audit Trail Report";
                }
                return;
            #endregion
            case "MonthClosure":
                #region MonthClosure
                MonthClosureId = Convert.ToString(Request.QueryString["MonthClosureId"]);
                if (!IsPostBack)
                {
                    LoadMonthClosureReport();
                }
                if (blnCheckDataExits == true)
                {
                    LoadReport("MonthClosure");
                    Page.Header.Title = "Month Closure Report";
                }
                return;
            #endregion
            case "YearClosure":
                #region YearClosure
                YearSettingsId = Convert.ToString(Request.QueryString["YearSettingsId"]);
                if (!IsPostBack)
                {
                    LoadYearClosureReport();
                }
                if (blnCheckDataExits == true)
                {
                    LoadReport("YearClosure");
                    Page.Header.Title = "Year Closure Report";
                }
                return;
            #endregion
            case "Permission":
            case "Report_Permission":
                #region Permission
                if (Request.QueryString["Status"] != null)
                    Status = Convert.ToString(Request.QueryString["Status"]);
                if (!IsPostBack)
                {
                    LoadPermissionReport();
                }
                if (blnCheckDataExits == true)
                {
                    LoadReport("Permission");
                    Page.Header.Title = "Permission Report";
                }
                if (Request.QueryString["isPDFExcel"] != null)
                {
                    ExportMethod(ReportName, Request.QueryString["isPDFExcel"]);
                }
                return;
            #endregion
            case "ManualTimeEntry":
            case "Report_ManualTimeEntry":
                #region ManualTimeEntry
                if (Request.QueryString["Status"] != null)
                    Status = Convert.ToString(Request.QueryString["Status"]);
                if (!IsPostBack)
                {
                    LoadManualTimeEntryReport();
                }
                if (blnCheckDataExits == true)
                {
                    LoadReport("ManualTimeEntry");
                    Page.Header.Title = "Manual Time Entry Report";
                }
                return;
            #endregion
            //Added by Gopinath for OD Report on 01.02.2014
            case "OnDutyEntry":
            case "Report_OnDutyEntry":
                #region OnDutyEntry
                if (Request.QueryString["Status"] != null)
                    Status = Convert.ToString(Request.QueryString["Status"]);
                if (!IsPostBack)
                {
                    LoadOnDutyEntryReport();
                }
                if (blnCheckDataExits == true)
                {
                    LoadReport("OnDutyEntry");
                    Page.Header.Title = "OnDuty Entry Report";
                }
                if (Request.QueryString["isPDFExcel"] != null)
                {
                    ExportMethod(ReportName, Request.QueryString["isPDFExcel"]);
                }
                return;
            #endregion
            case "ShiftNotAllocated":
                #region ShiftNotAllocated
                if (!IsPostBack)
                {
                    LoadShiftNotAllocatedReport();
                }
                if (blnCheckDataExits == true)
                {
                    LoadReport("ShiftNotAllocated");
                    Page.Header.Title = "Shift Not Allocated Report";
                }
                if (Request.QueryString["isPDFExcel"] != null)
                {
                    ExportMethod(ReportName, Request.QueryString["isPDFExcel"]);
                }
                return;
            #endregion
            case "LeavePolicyNotAllocated":
                #region LeavePolicyNotAllocated
                if (!IsPostBack)
                {
                    LoadLeavePolicyNotAllocatedReport();
                }
                if (blnCheckDataExits == true)
                {
                    LoadReport("LeavePolicyNotAllocated");
                    Page.Header.Title = "Leave Policy Not Allocated Report";
                }
                return;
            #endregion
            case "TimeSheet":
                #region TimeSheet
                if (!IsPostBack)
                {
                    LoadTimeSheetReport();
                }
                if (blnCheckDataExits == true)
                {
                    LoadReport("TimeSheet");
                    Page.Header.Title = "Time Sheet Report";
                }
                return;
            #endregion
            case "SummaryReport":
            case "Report_SummaryReport":
                #region SummaryReport
                if (Request.QueryString["Shft"] != null)
                    shft = Convert.ToInt32(Request.QueryString["Shft"]);
                if (!IsPostBack)
                {
                    LoadSummaryReport();
                }
                if (blnCheckDataExits == true)
                {
                    LoadReport("SummaryReport");
                    Page.Header.Title = "Summary Report";
                }
                return;
            #endregion
            case "RawData":
            case "RawDataDetailed":
                #region RawData
                if (!IsPostBack)
                {
                    RawData();    //this is for Detailed Raw Punches
                }
                if (blnCheckDataExits == true)
                {
                    LoadReport("RawData");
                    Page.Header.Title = "Raw Data Report";
                }
                if (Request.QueryString["isPDFExcel"] != null)
                {
                    ExportMethod(ReportName, Request.QueryString["isPDFExcel"]);
                }
                return;
            #endregion
            case "RawData_Latest":
            case "Report_RawData":
                #region RawData_Latest
                if (!IsPostBack)
                {
                    RawData_Latest();  //this is for Recent Raw Punches
                }
                if (blnCheckDataExits == true)
                {
                    LoadReport("RawData_Latest");
                    Page.Header.Title = "Raw Data Report";
                }
                if (Request.QueryString["isPDFExcel"] != null) // isPDFExcel not sent in query string
                {
                    ExportMethod(ReportName, Request.QueryString["isPDFExcel"]);
                }
                return;
            #endregion
            case "WeeklyWorkHours":
            case "Report_WeeklyWorkHours":
                #region WeeklyWorkHours
                shft = Convert.ToInt32(Request.QueryString["shft"]);
                if (!IsPostBack)
                {
                    LoadWeeklyWorkHours();
                }
                if (blnCheckDataExits == true)
                {
                    LoadReport("WeeklyWorkHours");
                    Page.Header.Title = "Cumulative Weekly Work Hours";
                }
                return;
            #endregion
            case "LeaveAnalysis":
                #region LeaveAnalysis
                strLeavePlanned = Request.QueryString["strLeavePlanned"].Replace(" ", "+").ToString();
                strLeaveWI = Request.QueryString["strLeaveWI"].Replace(" ", "+").ToString();
                strLeaveWOI = Request.QueryString["strLeaveWOI"].Replace(" ", "+").ToString();
                if (!IsPostBack)
                {
                    LoadLeaveAnalysisReport();
                }
                if (blnCheckDataExits == true)
                {
                    LoadReport("LeaveAnalysis");
                    Page.Header.Title = "Leave Analysis Report";
                }
                if (Request.QueryString["isPDFExcel"] != null)
                {
                    ExportMethod(ReportName, Request.QueryString["isPDFExcel"]);
                    Response.End();
                }
                return;
            #endregion
            case "WeeklyWorkHours_Angler":
                #region WeeklyWorkHours_Angler
                shft = Convert.ToInt32(Request.QueryString["shft"]);
                if (!IsPostBack)
                {
                    LoadWeeklyWorkHours_Angler();
                }
                if (blnCheckDataExits == true)
                {
                    LoadReport("WeeklyWorkHours_Angler");
                    Page.Header.Title = "Cumulative Weekly Work Hours";
                }
                return;
            #endregion
            case "Blocking 240Days":
            case "Blocking_240Days":
                #region Blocking_240Days

                if (!IsPostBack)
                {
                    LoadBlocking240DaysReport(dtFrom);
                }
                if (blnCheckDataExits == true)
                {
                    LoadReport("Blocking 240Days");
                    Page.Header.Title = "Blocking_240Days";
                }
                if (Request.QueryString["isPDFExcel"] != null)
                {
                    ExportMethod(ReportName, Request.QueryString["isPDFExcel"]);
                    Response.End();
                }
                return;
            #endregion
            //ContinuosWorking
            case "8DaysWokring":
            case "ContinuosWorking":
                #region Continuos_Working
                if (!IsPostBack)
                {
                    LoadContinuosWorkingReport();
                }
                if (blnCheckDataExits == true)
                {
                    LoadReport("ContinuosWorking");
                    Page.Header.Title = "ContinuosWorking";
                }
                if (Request.QueryString["isPDFExcel"] != null)
                {
                    ExportMethod(ReportName, Request.QueryString["isPDFExcel"]);
                    Response.End();
                }
                return;
            #endregion
            case "Payslip":
                #region Payslip Report

                if (!IsPostBack)
                {
                    shft = Convert.ToInt32(Request.QueryString["shft"]);
                    LoadPayslip();
                }
                if (blnCheckDataExits == true)
                {
                    LoadReport("Payslip");
                    Page.Header.Title = "Payslip";
                }
                #endregion
                break;
        }
    }

    private void LoadShiftwiseReport(int shiftId, string shiftDate, int level)
    {

        DataSet dsShiftwise = new DataSet();
        dsShiftwise = rptEmp.SelectEmployeeShiftwiseReport(shiftId, shiftDate, Level);
        //dsEmployee.Tables[0].DefaultView.RowFilter = "Report_Exclude = False";
        //DataTable dtEmployeeFiltered = new DataTable();
        //dtEmployeeFiltered = dsEmployee.Tables[0].DefaultView.ToTable();
        //dsEmployee.Tables.Clear();
        //dsEmployee.Tables.Add(dtEmployeeFiltered);
        //string employeeId = string.Empty, notMonth = string.Empty, notYear = string.Empty;
        //int ShiftCount = 0;
        //DataTable dtShiftNotAllocated = new DataTable();
        //dtShiftNotAllocated.TableName = "dtShiftwise";
        //DataColumn dcShiftId = new DataColumn("ShiftId", System.Type.GetType("System.Int32"));
        //DataColumn dcEmployeeId = new DataColumn("EmployeeId", System.Type.GetType("System.Int32"));
        //DataColumn dcEmployee_Code_Id = new DataColumn("Employee_Code_Id");
        //DataColumn dcShift_shortName = new DataColumn("Shift_ShortName");
        //DataColumn dcempname = new DataColumn("empname");
        //DataColumn dcname = new DataColumn("name");
        //DataColumn dcTitleName = new DataColumn("TitleName");
        //DataColumn dcGender = new DataColumn("Gender");
        //dtShiftNotAllocated.Columns.Add(dcShiftId);
        //dtShiftNotAllocated.Columns.Add(dcEmployeeId);
        //dtShiftNotAllocated.Columns.Add(dcEmployee_Code_Id);
        //dtShiftNotAllocated.Columns.Add(dcShift_shortName);
        //dtShiftNotAllocated.Columns.Add(dcempname);
        //dtShiftNotAllocated.Columns.Add(dcname);
        //dtShiftNotAllocated.Columns.Add(dcTitleName);
        //dtShiftNotAllocated.Columns.Add(dcGender);
        //DataRow dRowShiftNotAllocated;
        //foreach (DataRow drEmpName in dsEmployee.Tables[0].Rows)
        //{
        //    string strDay = "Day" + DateTime.Parse(dtFrom).Day + "Shift";
        //    ShiftCount = rptEmp.SelectShiftNotAllocatedEmployees(strDay, Convert.ToInt32(drEmpName["empAutoId"]), DateTime.Parse(dtFrom).Year, DateTime.Parse(dtFrom).Month);
        //    if (ShiftCount == 0)
        //    {
        //        dRowShiftNotAllocated = dtShiftNotAllocated.NewRow();
        //        dRowShiftNotAllocated["ShiftId"] = 0;
        //        dRowShiftNotAllocated["EmployeeId"] = Convert.ToInt32(drEmpName["empAutoId"]);
        //        dRowShiftNotAllocated["Employee_Code_Id"] = drEmpName["Employee_Id"];
        //        dRowShiftNotAllocated["Shift_shortName"] = "Not Allocated";
        //        dRowShiftNotAllocated["empname"] = drEmpName["empname"];
        //        dRowShiftNotAllocated["name"] = drEmpName["name"];
        //        dRowShiftNotAllocated["TitleName"] = drEmpName["TitleName"];
        //        dRowShiftNotAllocated["Gender"] = drEmpName["Gender"];
        //        dRowShiftNotAllocated.EndEdit();
        //        dtShiftNotAllocated.Rows.Add(dRowShiftNotAllocated);
        //    }
        //}
        //DataSet dsPermanentShift = new DataSet();
        //dsPermanentShift = rptEmp.SelectPermanentShiftReport(dtFrom, Level, empId, employeeName, EmployeeCategory, EmployeeType, Convert.ToString(Session["UserGroupName"]), GradeLevel, strSwipeCard, Convert.ToInt16(ParentLevelid), Convert.ToInt32(Designation), Gender, shft, Convert.ToInt64(strEmpAutoId));
        //DataSet dsTempShift = new DataSet();
        //dsTempShift = rptEmp.SelectTempShiftReport(dtFrom, Level, empId, employeeName, EmployeeCategory, EmployeeType, Convert.ToString(Session["UserGroupName"]), GradeLevel, strSwipeCard, Convert.ToInt16(ParentLevelid), Convert.ToInt32(Designation), Gender, shft, Convert.ToInt64(strEmpAutoId));
        DataSet dsHeader = new DataSet();
        DataTable dt = new DataTable();
        if (Convert.ToInt16(ParentLevelid) != 0)
        {
            dt = rptEmp.getHeader(Convert.ToInt16(ParentLevelid));
            Session["Ses_rptHeader_Shiftwise"] = dt;
        }
        else
        {
            Session["Ses_rptHeader_Shiftwise"] = dt;
        }

        //DataTable dtPermanentShift = new DataTable();
        //if ((dsPermanentShift.Tables["Table"] == null || dsPermanentShift.Tables["Table"].Rows.Count == 0) && (dsTempShift != null || dsTempShift.Tables.Count != 0))
        //{
        //    if (dtShiftNotAllocated.Rows.Count == 0)
        //    {
        //        blnCheckDataExits = false;
        //        MessagewithClose(rm.GetString("Alert_Thereisnorecord", ci));
        //        return;
        //    }
        //    else
        //    {
        //        if (dsTempShift.Tables.Count > 0 && dsTempShift.Tables[0].Rows.Count > 0)
        //        {
        //            dsPermanentShift = dsTempShift;
        //            dtPermanentShift = dsTempShift.Tables[0].Copy();
        //        }
        //        else if (dtShiftNotAllocated.Rows.Count == 0)
        //        {
        //            blnCheckDataExits = false;
        //            MessagewithClose(rm.GetString("Alert_Thereisnorecord", ci));
        //            return;
        //        }
        //    }
        //}
        //else
        //{
        //    dtPermanentShift = dsPermanentShift.Tables["Table"].Copy();
        //    foreach (DataRow dRow in dtPermanentShift.Rows)
        //    {
        //        if (Convert.ToInt32(dRow["ShiftId"]) == -1)
        //        {
        //            dRow["Shift_ShortName"] = rm.GetString("lbl_Off", ci);
        //        }
        //        else if (Convert.ToInt32(dRow["ShiftId"]) == 0)
        //        {
        //            dRow["Shift_ShortName"] = rm.GetString("Report_ShiftNotAllocated", ci);
        //        }
        //    }
        //}
        ////Check the  Temporary Shift Allocation table is Empty
        //DataTable dtTempShift = new DataTable();
        //if (dsTempShift.Tables["Table"] == null || dsTempShift.Tables["Table"].Rows.Count == 0)
        //{
        //}
        //else
        //{
        //    dtTempShift = dsTempShift.Tables["Table"].Copy();
        //    foreach (DataRow dRow in dtTempShift.Rows)
        //    {
        //        if (Convert.ToInt32(dRow["ShiftId"]) == -1)
        //        {
        //            dRow["Shift_ShortName"] = rm.GetString("lbl_Off", ci);
        //        }
        //        else if (Convert.ToInt32(dRow["ShiftId"]) == 0)
        //        {
        //            dRow["Shift_ShortName"] = rm.GetString("Report_ShiftNotAllocated", ci);
        //        }
        //    }
        //}
        //foreach (DataRow dPermanentShiftRow in dtPermanentShift.Rows)
        //{
        //    foreach (DataRow dTempShiftRow in dtTempShift.Rows)
        //    {
        //        if (Convert.ToInt32(dTempShiftRow["EmployeeId"]) == Convert.ToInt32(dPermanentShiftRow["EmployeeId"]))
        //        {
        //            if (Convert.ToInt32(dTempShiftRow["ShiftId"]) != 0)
        //            {
        //                dPermanentShiftRow["Shift_ShortName"] = dTempShiftRow["Shift_ShortName"];
        //                dPermanentShiftRow["ShiftId"] = dTempShiftRow["ShiftId"];
        //            }
        //        }
        //    }
        //}
        //DataRow dRowPermanentShiftRow;
        //foreach (DataRow dTempShiftRow in dtTempShift.Rows)
        //{
        //    dtPermanentShift.DefaultView.RowFilter = "EmployeeId=" + Convert.ToInt32(dTempShiftRow["EmployeeId"]);
        //    if (dtPermanentShift.DefaultView.Count == 0)
        //    {
        //        dRowPermanentShiftRow = dtPermanentShift.NewRow();
        //        dRowPermanentShiftRow["ShiftId"] = Convert.ToInt32(dTempShiftRow["ShiftId"]);
        //        dRowPermanentShiftRow["EmployeeId"] = Convert.ToInt32(dTempShiftRow["EmployeeId"]);
        //        dRowPermanentShiftRow["Employee_Code_Id"] = dTempShiftRow["Employee_Code_Id"];
        //        dRowPermanentShiftRow["Shift_shortName"] = dTempShiftRow["Shift_shortName"];
        //        dRowPermanentShiftRow["empname"] = dTempShiftRow["empname"];
        //        dRowPermanentShiftRow["name"] = dTempShiftRow["name"];
        //        dRowPermanentShiftRow["TitleName"] = dTempShiftRow["TitleName"];
        //        dRowPermanentShiftRow["Gender"] = dTempShiftRow["Gender"];
        //        dRowPermanentShiftRow.EndEdit();
        //        dtPermanentShift.Rows.Add(dRowPermanentShiftRow);
        //    }
        //}
        ////Add the link column
        //dtPermanentShift.TableName = "Table";
        //if (dtPermanentShift.Rows.Count == 0)
        //{
        //    dtPermanentShift = dtShiftNotAllocated.Copy();
        //}
        //else
        //{
        //    DataRow dRowPermanentShiftRowNotAllocated;
        //    foreach (DataRow dShiftNotAllocatedRow in dtShiftNotAllocated.Rows)
        //    {
        //        dtPermanentShift.DefaultView.RowFilter = "EmployeeId=" + Convert.ToInt32(dShiftNotAllocatedRow["EmployeeId"]);
        //        if (dtPermanentShift.DefaultView.Count == 0)
        //        {
        //            dRowPermanentShiftRowNotAllocated = dtPermanentShift.NewRow();
        //            dRowPermanentShiftRowNotAllocated["ShiftId"] = 0;
        //            dRowPermanentShiftRowNotAllocated["EmployeeId"] = Convert.ToInt32(dShiftNotAllocatedRow["EmployeeId"]);
        //            dRowPermanentShiftRowNotAllocated["Employee_Code_Id"] = dShiftNotAllocatedRow["Employee_Code_Id"];
        //            dRowPermanentShiftRowNotAllocated["Shift_shortName"] = "Not Allocated";
        //            dRowPermanentShiftRowNotAllocated["empname"] = dShiftNotAllocatedRow["empname"];
        //            dRowPermanentShiftRowNotAllocated["name"] = dShiftNotAllocatedRow["name"];
        //            dRowPermanentShiftRowNotAllocated["TitleName"] = dShiftNotAllocatedRow["TitleName"];
        //            dRowPermanentShiftRowNotAllocated["Gender"] = dShiftNotAllocatedRow["Gender"];
        //            dRowPermanentShiftRowNotAllocated.EndEdit();
        //            dtPermanentShift.Rows.Add(dRowPermanentShiftRowNotAllocated);
        //        }
        //    }
        //}

        DataTable dtHdr1 = GetReportHeader();
        dtHdr = dtHdr1;
        dtSource = dsShiftwise.Tables[0];
        rptFileName = Getreportpath(rm.GetString("rptShiftWiseAttendance", ci));
        Session["Ses_dtHdr_Shiftwise"] = dtHdr;
        Session["Ses_dtSource_Shiftwise"] = dtSource;
        //dsShiftwise.Tables[0].WriteXmlSchema(@"E:\shiftwise.xml");
        Session["ses_rptFileName_Shiftwise"] = rptFileName;


    }

    private void LoadGenerateContractor()
    {
        if (Request.QueryString["ScheduleId"] != null)
        {
            dsEmp = rptEmp.SelectReportData(Filters, ReportName, ReportType);
        }
        else
        {
            dsEmp = rptEmp.GetContractorAttendanceReport(dtFrom, dtTo, employeeName, Level, empId, EmployeeCategory, EmployeeType, Convert.ToString(Session["UserGroupName"]), GradeLevel, strSwipeCard, Convert.ToInt16(ParentLevelid), Convert.ToInt32(Designation), Gender, shft, Convert.ToInt32(strEmpAutoId));
        }

        //Check the Empty table 
        if (dsEmp.Tables["Table"] == null || dsEmp.Tables["Table"].Rows.Count == 0)
        {
            blnCheckDataExits = false;
            MessagewithClose(rm.GetString("Alert_Thereisnorecord", ci));
            return;
        }
        DataSet dsHeader = new DataSet();
        DataTable dt = new DataTable();
        if (Convert.ToInt16(ParentLevelid) != 0)
        {
            dt = rptEmp.getHeader(Convert.ToInt16(ParentLevelid));
            Session["Ses_rptHeader_GeneralContractorAttendance"] = dt;
        }
        else
        {
            Session["Ses_rptHeader_GeneralContractorAttendance"] = dt;
        }
        DataTable dtHdr1 = GetReportHeaderContactor();
        dtHdr = dtHdr1;
        dtSource = dsEmp.Tables[0];
        rptFileName = Server.MapPath(rm.GetString("rptGeneralContractorAttendance", ci));
        Session["Ses_dtHdr_GeneralContractorAttendance"] = dtHdr;
        Session["Ses_dtSource_GeneralContractorAttendance"] = dtSource;
        Session["Ses_rptFileName_GeneralContractorAttendance"] = rptFileName;

        if (dsEmp.Tables.Count > 1)
        {
            Session["Ses_dtSource1_ContractorAttendance"] = dsEmp.Tables[1];
            //dsEmp.Tables[1].WriteXmlSchema(@"E:\monthlyattTot.xml");
        }
    }
    #endregion
    #region User Defined Functions
    /// <summary>
    /// Export functionality for dashboard page.
    /// </summary>
    public void ExportMethod(string Reportname, string Filetype)
    {
        try
        {
            ExportFormatType formatType = ExportFormatType.NoFormat;
            switch (Filetype)
            {
                case "Word":
                    formatType = ExportFormatType.WordForWindows;
                    break;
                case "PDF":
                    formatType = ExportFormatType.PortableDocFormat;
                    break;
                case "Excel":
                    formatType = ExportFormatType.Excel;
                    break;
            }
            rptDoc.ExportToHttpResponse(formatType, Response, true, Reportname);
            Response.End();
        }
        catch (Exception ex)
        {
            Response.Write(ex.Message);
        }
    }
    public void LoadWeeklyWorkHours_Angler()
    {
        //Create the datatable ,that holds the header information
        string strReportType = Request.QueryString["ReportType"] == null ? "WeeklyWorkHours_Angler" : Request.QueryString["ReportType"].Replace(" ", "+");
        DataTable dtHdr1 = new DataTable();
        dtHdr1 = hdrTable.CreateHeader();
        dtHdr1.TableName = "Header";
        //Add the Header information
        DataRow drHdr = dtHdr1.NewRow();
        drHdr["Link"] = 1;
        drHdr["Hdr1"] = "";
        drHdr["Hdr2"] = "";
        drHdr["Address1"] = "";
        drHdr["Address2"] = "";
        drHdr["ReportName"] = strReportType == "WeeklyWorkHours_Angler" ? "Cumulative Weekly Work Hours Detailed" : "Cumulative Weekly Work Hours Summary";
        if (dtFrom != "")
        {
            DateTime tmpFrom = DateTime.Parse(dtFrom);
            drHdr["FromDate"] = tmpFrom.ToString(Session["MDateFormat"].ToString());
        }
        else
            drHdr["FromDate"] = "";
        if (dtTo != "")
        {
            DateTime tmpTo = DateTime.Parse(dtTo);
            drHdr["ToDate"] = tmpTo.ToString(Session["MDateFormat"].ToString());
        }
        else
            drHdr["ToDate"] = "";
        dtHdr1.Rows.Add(drHdr);
        empName = Convert.ToString(Request.QueryString["EmpName"]);
        dsEmp = rptEmp.SelectWeeklyWorkHours_Angler(empId, Level, dtFrom, dtTo, empName, EmployeeCategory, EmployeeType, Convert.ToString(Session["UserGroupName"]), Convert.ToString(Session["GradeLevel"]), strSwipeCard, Convert.ToInt32(strEmpAutoId), Convert.ToInt16(ParentLevelid), shft);
        if (dsEmp.Tables["Table"] == null || dsEmp.Tables["Table"].Rows.Count == 0)
        {
            blnCheckDataExits = false;
            MessagewithClose(rm.GetString("Alert_Thereisnorecord", ci));
            return;
        }
        DataSet dsHeader = new DataSet();
        DataTable dt = new DataTable();
        if (Convert.ToInt16(ParentLevelid) != 0)
        {
            Session["Ses_rptHeader_Cumulative"] = dt;
        }
        else
        {
            Session["Ses_rptHeader_Cumulative"] = dt;
        }
        DataTable dtWeekly = dsEmp.Tables["Table1"].Copy();
        dtHdr = dtHdr1;
        dtSource = dtWeekly;
        dtSourceDetails = dsEmp.Tables["Table"].Copy();
        rptFileName = Server.MapPath(rm.GetString(strReportType == "SummaryReport" ? "WeeklyWorkHoursSummary_Angler" : "WeeklyWorkHours_Angler", ci));
        Session["Ses_dtHdr_Cumulative"] = dtHdr;
        Session["Ses_dtSource_Cumulative"] = dtSource;
        Session["Ses_rptFileName_Cumulative"] = rptFileName;
        Session["Ses_rptFileName_CumulativeDetails"] = dtSourceDetails;
    }
    /// <summary>
    /// Mustor roll report
    /// </summary>
    public void LoadEmployeeInOutReportNew()
    {
        string employeeCategory = string.Empty, employeeType = string.Empty;
        string strMustorFromDate = string.Empty;
        string strMustorToDate = string.Empty;
        string empName = "", empId = "";
        DataTable dtRptHeader = new DataTable();
        DataTable dtHdr1 = new DataTable();
        dtHdr1 = hdrTable.CreateHeader();
        dtHdr1.TableName = "Header";
        //Add the Header information
        DataRow drHdr = dtHdr1.NewRow();
        drHdr["Link"] = 1;
        drHdr["Hdr1"] = "";
        drHdr["Hdr2"] = "";
        drHdr["Address1"] = "";
        drHdr["Address2"] = 0;
        drHdr["ReportName"] = "Form 25 Report";
        if (Request.QueryString["EmpName"] != null)
            empName = Convert.ToString(Request.QueryString["EmpName"]);
        if (Request.QueryString["empid"] != null)
            empId = Convert.ToString(Request.QueryString["empid"]);
        if (Request.QueryString["EmpCategory"] != null)
        {
            if (Convert.ToString(Request.QueryString["EmpCategory"]) != "-Select-" && Convert.ToString(Request.QueryString["EmpCategory"]) != "")
                employeeCategory = Convert.ToString(Request.QueryString["EmpCategory"]);
            else
                employeeCategory = string.Empty;
        }
        if (Request.QueryString["EmpType"] != null)
        {
            if (Convert.ToString(Request.QueryString["EmpType"]) != "-Select-" && Convert.ToString(Request.QueryString["EmpType"]) != "")
                employeeType = Convert.ToString(Request.QueryString["EmpType"]);
            else
                employeeType = string.Empty;
        }
        else
            employeeType = string.Empty;
        if (Request.QueryString["dtFrom"] != null)
            strMustorFromDate = Convert.ToString(Request.QueryString["dtFrom"]);
        else
            strMustorFromDate = Convert.ToString(dtFrom);
        if (Request.QueryString["dtTo"] != null)
            strMustorToDate = Convert.ToString(Request.QueryString["dtTo"]);
        else
            strMustorToDate = Convert.ToString(dtTo);
        dtDate = rptEmp.GetDateMonth(strMustorFromDate, strMustorToDate);
        if (dtDate.Rows.Count > 0)
        {
            drHdr["FromDate"] = dtDate.Rows[0][0];
            drHdr["ToDate"] = dtDate.Rows[0][1];
        }
        else
        {
            drHdr["ToDate"] = "";
            drHdr["FromDate"] = "";
        }
        dtHdr1.Rows.Add(drHdr);
        //Get the Report source from the Server and load this into the report table
        DataSet dsHeader = new DataSet();
        DataTable dt = new DataTable();
        if (Convert.ToInt16(ParentLevelid) != 0)
        {
            dt = rptEmp.getHeader(Convert.ToInt16(ParentLevelid));
            Session["reportHeader"] = dt;
        }
        else
        {
            Session["reportHeader"] = dt;
        }
        dtRptHeader = dt;
        DataSet dsEmpcode = new DataSet();
        DataTable dt1 = new DataTable();
        DataTable dt2 = new DataTable();
        DataSet dsEmp = new DataSet();
        if (Request.QueryString["ScheduleId"] != null)
        {
            dsEmp = rptEmp.SelectReportData(Filters, ReportName, ReportType);
            if (strReportType == "Summary")
                rptFileName = Server.MapPath(rm.GetString("rptEmployeeInOutSummary", ci)); //EmployeeInOutSummarySaradhambika
            else if (strReportType == "Details")
                rptFileName = Server.MapPath(rm.GetString("rptEmployeeInOut", ci));
        }
        else
        {
            if (strReportType == "Summary")
            {
                //Product Procedure
                if (Session["Ses_MusterRollData"] != null)
                    dsEmp = (DataSet)Session["Ses_MusterRollData"];
                else
                    dsEmp = rptEmp.SelectInOutEmployeeSummary(empId, employeeName, Level, employeeCategory, employeeType, Convert.ToString(Session["UserGroupName"]), Convert.ToString(Session["GradeLevel"]), strSwipeCard, Convert.ToInt16(ParentLevelid), strMustorFromDate, strMustorToDate, Convert.ToInt32(Designation), Gender, Convert.ToInt32(strEmpAutoId));
                //rptFileName = Server.MapPath(rm.GetString("rptEmployeeInOutSummary", ci));
                rptFileName = Getreportpath(rm.GetString("rptEmployeeInOutSummary", ci));
                //Saradhambika
                //dsEmp = rptEmp.SelectInOutEmployeeSummary_saradhambika(empId, employeeName, Level, employeeCategory, employeeType, Convert.ToString(Session["UserGroupName"]), Convert.ToString(Session["GradeLevel"]), strSwipeCard, Convert.ToInt16(ParentLevelid), strMustorFromDate, strMustorToDate, Convert.ToInt32(Designation), Gender, Convert.ToInt32(strEmpAutoId));
                //rptFileName = Server.MapPath(rm.GetString("rptEmployeeInOutSummary_Saradhambika", ci));
            }
            else if (strReportType == "Details")
            {
                if (Session["Ses_MusterRollData"] != null)
                    dsEmp = (DataSet)Session["Ses_MusterRollData"];
                else
                    dsEmp = rptEmp.SelectInOutEmployeeNew(empId, employeeName, Level, employeeCategory, employeeType, Convert.ToString(Session["UserGroupName"]), Convert.ToString(Session["GradeLevel"]), strSwipeCard, Convert.ToInt16(ParentLevelid), strMustorFromDate, strMustorToDate, Convert.ToInt32(Designation), Gender, Convert.ToInt32(strEmpAutoId));
                //rptFileName = Server.MapPath(rm.GetString("rptEmployeeInOut", ci));
                rptFileName = Getreportpath(rm.GetString("rptEmployeeInOut", ci));
            }
        }
        if (dsEmp.Tables[0].Rows.Count == 0)
        {
            blnCheckDataExits = false;
            MessagewithClose(rm.GetString("Alert_Thereisnorecord", ci));
            return;
        }
        dtSource = dt1 = dsEmp.Tables[0];
        dt2 = dsEmp.Tables[1];
        //dt1.WriteXmlSchema(@"E:\MusterRollSummaryData.xml");
        Session["SessTable2"] = dt1;
        Session["sessTable3"] = dt2;
        Session["Ses_rptFileName_EmployeeInOut"] = rptFileName;
        Session["Ses_dtHdr_EmployeeInOut"] = dtHdr1;
        Session["Ses_dtSource_EmployeeInOut"] = dtSource;
        Session["Ses_rptHeader_EmployeeInOut"] = dtRptHeader;
    }
    public void LoadEmployeeInOutReportNew_0()
    {
        string employeeCategory = string.Empty, employeeType = string.Empty;
        int iWorkingDays = 0;
        DataSet dsTot = new DataSet();
        dsTot = rptEmp.SelectTotalWorkingDays(Convert.ToString(Request.QueryString["dtMonth"]), Convert.ToString(Request.QueryString["dtYear"]));
        if (dsTot != null && dsTot.Tables.Count > 0 && dsTot.Tables[0].Rows.Count > 0 && dsTot.Tables[0].Rows[0]["TotalWokingDays"] != DBNull.Value)
        {
            iWorkingDays = Convert.ToInt32(dsTot.Tables[0].Rows[0]["TotalWokingDays"]);
        }
        DataTable dtRptHeader = new DataTable();
        DataTable dtHdr1 = new DataTable();
        dtHdr1 = hdrTable.CreateHeader();
        dtHdr1.TableName = "Header";
        DataRow drHdr = dtHdr1.NewRow();
        drHdr["Link"] = 1;
        drHdr["Hdr1"] = "";
        drHdr["Hdr2"] = "";
        drHdr["Address1"] = "";
        drHdr["Address2"] = iWorkingDays;
        drHdr["ReportName"] = "Form 25 Report";
        string strMustorFromDate = string.Empty;
        string strMustorToDate = string.Empty;
        strMustorFromDate = Convert.ToString(Request.QueryString["dtFrom"]);
        strMustorToDate = Convert.ToString(Request.QueryString["dtTo"]);
        DateTime dtMustorFromDate = new DateTime();
        DateTime dtMustorToDate = new DateTime();
        dtMustorFromDate = DateTime.Parse(strMustorFromDate);
        dtMustorToDate = DateTime.Parse(strMustorToDate);
        dtDate = rptEmp.GetDateMonth(strMustorFromDate, strMustorToDate);
        if (dtDate.Rows.Count > 0)
        {
            drHdr["FromDate"] = dtDate.Rows[0][0];
            drHdr["ToDate"] = dtDate.Rows[0][1];
        }
        else
        {
            drHdr["ToDate"] = "";
            drHdr["FromDate"] = "";
        }
        //drHdr["FromDate"] = dtMustorFromDate.ToString("dd-MMM-yyyy");
        //drHdr["ToDate"] = dtMustorToDate.ToString("dd-MMM-yyyy");
        dtHdr1.Rows.Add(drHdr);
        string empName = "", empId = "";
        empName = Convert.ToString(Request.QueryString["EmpName"]);
        empId = Convert.ToString(Request.QueryString["empid"]);
        // set employee category and type
        if (Convert.ToString(Request.QueryString["EmpCategory"]) != "-Select-" && Convert.ToString(Request.QueryString["EmpCategory"]) != "")
        {
            employeeCategory = Convert.ToString(Request.QueryString["EmpCategory"]);
        }
        else
        {
            employeeCategory = string.Empty;
        }
        if (Convert.ToString(Request.QueryString["EmpType"]) != "-Select-" && Convert.ToString(Request.QueryString["EmpType"]) != "")
        {
            employeeType = Convert.ToString(Request.QueryString["EmpType"]);
        }
        else
        {
            employeeType = string.Empty;
        }
        DataSet dsForm25 = new DataSet();
        string employeeName = Convert.ToString(Request.QueryString["EmpName"]).Replace("'", "''");
        string SelectedMonth = Convert.ToString(Request.QueryString["dtMonth"]);
        string SelectedYear = Convert.ToString(Request.QueryString["dtYear"]);
        DataSet dsHeader = new DataSet();
        DataTable dt = new DataTable();
        if (Convert.ToInt16(ParentLevelid) != 0)
        {
            dt = rptEmp.getHeader(Convert.ToInt16(ParentLevelid));
            Session["reportHeader"] = dt;
        }
        else
        {
            Session["reportHeader"] = dt;
        }
        dtRptHeader = dt;
        Session["parentLevelId"] = null;
        DataTable NewDT = new DataTable();
        DataColumn DC1 = new DataColumn();
        DC1.ColumnName = "Name";
        NewDT.Columns.Add(DC1);
        DataColumn DC2 = new DataColumn();
        DC2.ColumnName = "FatherName";
        NewDT.Columns.Add(DC2);
        DataColumn DC3 = new DataColumn();
        DC3.ColumnName = "Designation";
        NewDT.Columns.Add(DC3);
        DataColumn DC9 = new DataColumn();
        DC9.ColumnName = "Employee_Code_Id";
        NewDT.Columns.Add(DC9);
        DataColumn DC4 = new DataColumn();
        DC4.ColumnName = "Present";
        NewDT.Columns.Add(DC4);
        DataColumn DC5 = new DataColumn();
        DC5.ColumnName = "Absent";
        NewDT.Columns.Add(DC5);
        DataColumn DC6 = new DataColumn();
        DC6.ColumnName = "Leave";
        NewDT.Columns.Add(DC6);
        DataColumn dcHoliday = new DataColumn();
        dcHoliday.ColumnName = "Holiday";
        NewDT.Columns.Add(dcHoliday);
        DataColumn dcOT = new DataColumn();
        dcOT.ColumnName = "TotalOT";
        NewDT.Columns.Add(dcOT);
        for (int j = 1; j <= 31; j++)
        {
            DataColumn DC = new DataColumn();
            DC.ColumnName = "Day" + j;
            NewDT.Columns.Add(DC);
        }
        DataSet dsEmp = new DataSet();
        if (strReportType == "Summary")
        {
            dsEmp = rptEmp.SelectInOutEmployeeSummary(empId, employeeName, Level, employeeCategory, employeeType, Convert.ToString(Session["UserGroupName"]), Convert.ToString(Session["GradeLevel"]), strSwipeCard, Convert.ToInt16(ParentLevelid), strMustorFromDate, strMustorToDate, Convert.ToInt32(Designation), Gender, Convert.ToInt32(Session["EmpAutoID"]));
            rptFileName = Server.MapPath(rm.GetString("rptEmployeeInOutSummary", ci));
        }
        else if (strReportType == "Details")
        {
            dsEmp = rptEmp.SelectInOutEmployeeNew(empId, employeeName, Level, employeeCategory, employeeType, Convert.ToString(Session["UserGroupName"]), Convert.ToString(Session["GradeLevel"]), strSwipeCard, Convert.ToInt16(ParentLevelid), strMustorFromDate, strMustorToDate, Convert.ToInt32(Designation), Gender, Convert.ToInt32(Session["EmpAutoID"]));
            rptFileName = Server.MapPath(rm.GetString("rptEmployeeInOut", ci));
        }
        if (dsEmp.Tables[0].Rows.Count > 0)
        {
            foreach (DataRow drEmpCode in dsEmp.Tables[0].Rows)
            {
                NewDT = (DataTable)dsEmp.Tables[0];
            }
        }
        if (NewDT.Rows.Count == 0)
        {
            blnCheckDataExits = false;
            MessagewithClose(rm.GetString("Alert_Thereisnorecord", ci));
            return;
        }
        NewDT.TableName = "Table";
        dtHdr = dtHdr1;
        dtSource = NewDT;
        rptHeader = dtRptHeader;
        Session["Ses_rptFileName_EmployeeInOut"] = rptFileName;
        Session["Ses_dtHdr_EmployeeInOut"] = dtHdr;
        Session["Ses_dtSource_EmployeeInOut"] = dtSource;
        Session["Ses_rptHeader_EmployeeInOut"] = rptHeader;
    }
    public void LoadEarlyEntryReport()
    {
        DataSet dsHeader = new DataSet();
        DataTable dtRptHeader = new DataTable();
        DataTable dt = new DataTable();
        if (Convert.ToInt16(ParentLevelid) != 0)
        {
            dt = rptEmp.getHeader(Convert.ToInt16(ParentLevelid));
            Session["Ses_rptHeader_EarlyEntry"] = dt;
        }
        else
        {
            Session["Ses_rptHeader_EarlyEntry"] = dt;
        }
        DataSet dsLateIns = new DataSet();
        if (Request.QueryString["ScheduleId"] != null)
        {
            dsLateIns = rptEmp.SelectReportData(Filters, ReportName, ReportType);
        }
        else
        {
            if (Request.QueryString["MinExceptHours"] != null)
                MinExceptkHours = Convert.ToString(Request.QueryString["MinExceptHours"]);
            dsLateIns = rptEmp.SelectEarlyEntryReport(empId, Level, dtFrom, dtTo, employeeName, shft, EmployeeCategory, EmployeeType, Convert.ToString(Session["UserGroupName"]), GradeLevel, strSwipeCard, Convert.ToInt16(ParentLevelid), Designation, Gender, 1, MinExceptkHours, Convert.ToInt32(Session["EmpAutoID"]));
        }
        DataTable dtLate = new DataTable();
        dtLate = dsLateIns.Tables["Table"].Copy();
        DataColumn dcLink = new DataColumn("Link", Type.GetType("System.Int32"));
        dtLate.Columns.Add(dcLink);
        for (int i = 0; i < dtLate.Rows.Count; i++)
        {
            dtLate.Rows[i]["Link"] = 1;
        }
        rptFileName = Server.MapPath(rm.GetString("ReportFile_Earlyentry", ci));
        DataTable dtHdr1 = GetReportHeader();
        dtHdr = dtHdr1;
        dtSource = dtLate;
        Session["Ses_dtHdr_EarlyEntry"] = dtHdr;
        Session["Ses_dtSource_EarlyEntry"] = dtSource;
        Session["Ses_rptFileName_EarlyEntry"] = rptFileName;
        if (dsLateIns.Tables["Table"] == null || dsLateIns.Tables["Table"].Rows.Count == 0)
        {
            blnCheckDataExits = false;
            MessagewithClose(rm.GetString("Alert_Thereisnorecord", ci));
            return;
        }
    }
    /// <summary>
    /// Late Entry Report
    /// </summary>
    public void LoadLateEntryReport()
    {
        DataSet dsHeader = new DataSet();
        DataTable dt = new DataTable();
        if (Convert.ToInt16(ParentLevelid) != 0)
        {
            dt = rptEmp.getHeader(Convert.ToInt16(ParentLevelid));
            Session["Ses_rptHeader_LateEntry"] = dt;
        }
        else
        {
            Session["Ses_rptHeader_LateEntry"] = dt;
        }
        //Get the Report source from the Server and load this into the report table
        DataSet dsLateIns = new DataSet();
        if (Request.QueryString["ScheduleId"] != null)
        {
            dsLateIns = rptEmp.SelectReportData(Filters, ReportName, ReportType);
        }
        else
        {
            if (Request.QueryString["MinExceptHours"] != null)
                MinExceptkHours = Convert.ToString(Request.QueryString["MinExceptHours"]);
            dsLateIns = rptEmp.SelectLateInstanceReport(empId, Level, dtFrom, dtTo, employeeName, shft, EmployeeCategory, EmployeeType, Convert.ToString(Session["UserGroupName"]), GradeLevel, strSwipeCard, Convert.ToInt16(ParentLevelid), Convert.ToInt32(Designation), Gender, Convert.ToInt64(strEmpAutoId), 1, MinExceptkHours);
        }
        if (Normal == "Graph")
        {
            rptFileName = Server.MapPath(rm.GetString("rptLateEntryGraph", ci));
        }
        else
        {
            rptFileName = Getreportpath(rm.GetString("rptLateEntry", ci));
        }
        DataTable dtHdr1 = GetReportHeader();
        dtHdr = dtHdr1;
        dtSource = dsLateIns.Tables[0];
        Session["Ses_dtHdr_LateEntry"] = dtHdr;
        Session["Ses_dtSource_LateEntry"] = dtSource;
        Session["Ses_rptFileName_LateEntry"] = rptFileName;
    }
    private string Getreportpath(string path)
    {
        #region IFFCO
        //PACKAGEID 156
        if (Convert.ToString(Session["packageID"]) != "")
            if (Convert.ToString(Session["packageID"]) == "156")
                path = "iffco/" + path;
        #endregion
        return Server.MapPath(path);
    }
    /// <summary>
    /// Late Entry Report
    /// </summary>
    public void LoadAllExceptionReport()
    {
        //Get the Report source from the Server and load this into the report table
        DataSet dsLateIns = new DataSet();
        if (Request.QueryString["ScheduleId"] != null)
        {
            //dsLateIns = rptEmp.SelectReportData(Filters, ReportName, ReportType);
        }
        else
        {
            if (Request.QueryString["MinExceptHours"] != null)
                MinExceptkHours = Convert.ToString(Request.QueryString["MinExceptHours"]);
            dsLateIns = rptEmp.SelectExceptionReport(empId, Level, dtFrom, dtTo, employeeName, shft, EmployeeCategory, EmployeeType, Convert.ToString(Session["UserGroupName"]), GradeLevel, strSwipeCard, Convert.ToInt16(ParentLevelid), Convert.ToInt32(Designation), Gender, MinExceptkHours, Convert.ToInt32(strEmpAutoId));
        }
        //Check the Empty table
        if (dsLateIns.Tables["Table"] == null || dsLateIns.Tables["Table"].Rows.Count == 0)
        {
            blnCheckDataExits = false;
            MessagewithClose(rm.GetString("Alert_Thereisnorecord", ci));
            return;
        }
        DataSet dsHeader = new DataSet();
        DataTable dt = new DataTable();
        if (Convert.ToInt16(ParentLevelid) != 0)
        {
            dt = rptEmp.getHeader(Convert.ToInt16(ParentLevelid));
            Session["Ses_rptHeader_Exception"] = dt;
        }
        else
        {
            Session["Ses_rptHeader_Exception"] = dt;
        }
        rptFileName = Server.MapPath(rm.GetString("rptExceptionReport", ci));
        DataTable dtHdr1 = GetReportHeader();
        dtHdr = dtHdr1;
        dtSource = dsLateIns.Tables[0];
        Session["Ses_dtHdr_Exception"] = dtHdr;
        Session["Ses_dtSource_Exception"] = dtSource;
        Session["Ses_rptFileName_Exception"] = rptFileName;
    }
    /// <summary>
    /// Early Exit report
    /// </summary>
    public void LoadEarlyExitReport()
    {
        DataSet dsHeader = new DataSet();
        DataTable dt = new DataTable();
        if (Convert.ToInt16(ParentLevelid) != 0)
        {
            dt = rptEmp.getHeader(Convert.ToInt16(ParentLevelid));
            Session["Ses_rptHeader_EarlyExit"] = dt;
        }
        else
        {
            Session["Ses_rptHeader_EarlyExit"] = dt;
        }
        DataSet dsEarlyOut = new DataSet();
        if (Request.QueryString["ScheduleId"] != null)
        {
            dsEarlyOut = rptEmp.SelectReportData(Filters, ReportName, ReportType);
        }
        else
        {
            if (Request.QueryString["MinExceptHours"] != null)
                MinExceptkHours = Convert.ToString(Request.QueryString["MinExceptHours"]);
            dsEarlyOut = rptEmp.SelectEarlyOutReportNew(dtFrom, dtTo, empId, shft, employeeName, Level, EmployeeCategory, EmployeeType, Convert.ToString(Session["UserGroupName"]), GradeLevel, strSwipeCard, Convert.ToInt16(ParentLevelid), Convert.ToInt32(Designation), Gender, 1, MinExceptkHours, Convert.ToInt32(strEmpAutoId));
        }
        if (Normal == "Graph")
        {
            rptFileName = Server.MapPath(rm.GetString("rptEarlyExitGraph", ci));
        }
        else
        {
            rptFileName = Server.MapPath(rm.GetString("rptEarlyExit", ci));
        }
        DataTable dtHdr1 = GetReportHeader();
        dtHdr = dtHdr1;
        dtSource = dsEarlyOut.Tables[0];
        Session["Ses_rptFileName_EarlyExit"] = rptFileName;
        Session["Ses_dtHdr_EarlyExit"] = dtHdr;
        Session["Ses_dtSource_EarlyExit"] = dtSource;
    }
    /// <summary>
    /// Late Exit Report
    /// </summary>
    public void LoadLateExitReport()
    {
        if (Request.QueryString["ScheduleId"] != null)
        {
            dsEmp = rptEmp.SelectReportData(Filters, ReportName, ReportType);
        }
        else
        {
            if (Request.QueryString["MinExceptHours"] != null)
                MinExceptkHours = Convert.ToString(Request.QueryString["MinExceptHours"]);
            dsEmp = rptEmp.SelectLateExit(dtFrom, dtTo, empId, shft, employeeName, Level, EmployeeCategory, EmployeeType, Convert.ToString(Session["UserGroupName"]), GradeLevel, strSwipeCard, Convert.ToInt16(ParentLevelid), Convert.ToInt32(Designation), Gender, MinExceptkHours, Convert.ToInt32(strEmpAutoId));
        }
        //Check the Empty table
        if (dsEmp.Tables["Table"] == null || dsEmp.Tables["Table"].Rows.Count == 0)
        {
            blnCheckDataExits = false;
            MessagewithClose(rm.GetString("Alert_Thereisnorecord", ci));
            return;
        }
        DataSet dsHeader = new DataSet();
        DataTable dt = new DataTable();
        if (Convert.ToInt16(ParentLevelid) != 0)
        {
            dt = rptEmp.getHeader(Convert.ToInt16(ParentLevelid));
            Session["Ses_rptHeader_LateExit"] = dt;
        }
        else
        {
            Session["Ses_rptHeader_LateExit"] = dt;
        }
        DataTable dtHdr1 = GetReportHeader();
        dtHdr = dtHdr1;
        dtSource = dsEmp.Tables[0];
        //rptFileName = Server.MapPath(rm.GetString("rptLateExit", ci));
        rptFileName = Getreportpath(rm.GetString("rptLateExit", ci));
        Session["Ses_dtHdr_LateExit"] = dtHdr;
        Session["Ses_dtSource_LateExit"] = dtSource;
        Session["Ses_rptFileName_LateExit"] = rptFileName;
    }
    /// <summary>
    /// Over Time Report
    /// </summary>
    public void LoadOverTimeReport()
    {
        if (Request.QueryString["ScheduleId"] != null)
        {
            dsEmp = rptEmp.SelectReportData(Filters, ReportName, ReportType);
        }
        else
        {
            if (SanctionType == "OTCompOff")
                dsEmp = rptEmp.SelectOverTimeCompOff(dtFrom, dtTo, empId, shft, employeeName, Level, EmployeeCategory, EmployeeType, Convert.ToString(Session["UserGroupName"]), GradeLevel, Status, strSwipeCard, Convert.ToInt16(ParentLevelid), Convert.ToInt32(Designation), Gender, Convert.ToInt32(strEmpAutoId));
            else
                dsEmp = rptEmp.SelectOverTime(dtFrom, dtTo, empId, shft, employeeName, Level, EmployeeCategory, EmployeeType, Convert.ToString(Session["UserGroupName"]), GradeLevel, Status, strSwipeCard, Convert.ToInt16(ParentLevelid), Convert.ToInt32(Designation), Gender, SanctionType, Convert.ToInt32(strEmpAutoId));
        }
        //Check the Empty table
        if (dsEmp.Tables["Table"] == null || dsEmp.Tables["Table"].Rows.Count == 0)
        {
            blnCheckDataExits = false;
            MessagewithClose(rm.GetString("Alert_Thereisnorecord", ci));
            return;
        }
        DataSet dsHeader = new DataSet();
        DataTable dt = new DataTable();
        if (Convert.ToInt16(ParentLevelid) != 0)
        {
            dt = rptEmp.getHeader(Convert.ToInt16(ParentLevelid));
            Session["Ses_rptHeader_OverTime"] = dt;
        }
        else
        {
            Session["Ses_rptHeader_OverTime"] = dt;
        }
        DataTable dtHdr1 = GetReportHeader();
        dtHdr = dtHdr1;
        dtSource = dsEmp.Tables[0];
        if (SanctionType == "CompOff")
        {
            rptFileName = Server.MapPath(rm.GetString("CompensationReport", ci));
        }
        else if (SanctionType == "OverTime")
        {
            rptFileName = Getreportpath(rm.GetString("overTimeReport", ci));
        }
        else if (SanctionType == "OTCompOff")
        {
            rptFileName = Server.MapPath(rm.GetString("OTCompensationReport", ci));
        }
        Session["Ses_dtHdr_OverTimewithAmount"] = dtHdr;
        Session["Ses_dtSource_OverTimewithAmount"] = dtSource;
        Session["Ses_rptFileName_OverTimeAmount"] = rptFileName;
    }
    /// <summary>
    /// Work days report
    /// </summary>
    public void LoadWorkedDaysDetails()
    {
        //Create the datatable ,that holds the header information
        int iReportType = Request.QueryString["ReportType"] == null ? 1 : Convert.ToInt32(Request.QueryString["ReportType"]);
        DataTable dtHdr1 = new DataTable();
        dtHdr1 = hdrTable.CreateHeader();
        dtHdr1.TableName = "Header";
        //Add the Header information
        DataRow drHdr = dtHdr1.NewRow();
        drHdr["Link"] = 1;
        drHdr["Hdr1"] = "";
        drHdr["Hdr2"] = "";
        drHdr["Address1"] = "";
        drHdr["Address2"] = "";
        drHdr["ReportName"] = "Worked Days Report";
        if (dtFrom != "")
        {
            DateTime tmpFrom = DateTime.Parse(dtFrom);
            drHdr["FromDate"] = tmpFrom.ToString("dd-MMM-yyyy");
        }
        else
            drHdr["FromDate"] = "";
        if (dtTo != "")
        {
            DateTime tmpTo = DateTime.Parse(dtTo);
            drHdr["ToDate"] = tmpTo.ToString("dd-MMM-yyyy");
        }
        else
            drHdr["ToDate"] = "";
        dtHdr1.Rows.Add(drHdr);
        dsEmp = rptEmp.SelectWorkedDaysDetailsWithDeviations_Angler(empId, Level, dtFrom, dtTo, employeeName, EmployeeCategory, EmployeeType, Session["UserGroupName"].ToString(), Convert.ToString(Session["GradeLevel"]), strSwipeCard, Convert.ToInt32(strEmpAutoId), Designation, Convert.ToInt16(ParentLevelid), Gender);
        if (dsEmp.Tables[0].Rows.Count <= 0)
        {
            blnCheckDataExits = false;
            MessagewithClose(rm.GetString("Alert_Thereisnorecord", ci));
            return;
        }
        //Report Header
        int orgID = Convert.ToInt32(ParentLevelid);
        if (orgID == 0)
        {
            //orgID = 1;
            DataSet dsOrgid = new DataSet();
            dsOrgid = rptEmp.getMinLevel();
            if (dsOrgid.Tables[0].Rows.Count > 0)
            {
                if (dsOrgid.Tables[0].Rows[0]["minID"] != DBNull.Value)
                {
                    orgID = Convert.ToInt16(dsOrgid.Tables[0].Rows[0]["minID"]);
                }
            }
        }
        int lid = 0;
        org_levelsEventData getOrg = new org_levelsEventData();
        getOrg.GetOrgParentLevels_FromID(orgID);
        DataSet ds_getOrg = new DataSet();
        ds_getOrg = getOrg.GetOrgParentLevels();
        if (ds_getOrg.Tables[0].Rows.Count > 0)
        {
            lid = Convert.ToInt16(ds_getOrg.Tables[0].Rows[0]["levelID"]);
        }
        DataTable dtRptHeader = new DataTable();
        dtRptHeader = rptEmp.getHeader(lid);
        rptHeader = dtRptHeader;
        //End of Report Header        
        //Set the session variable that holds the report table and report header table
        dtHdr = dtHdr1;
        dtSource = dsEmp.Tables["Table"].Copy();
        rptFileName = Server.MapPath(rm.GetString("WorkedDaysReport", ci));
        dtHdr = dtHdr1;
        Session["Ses_rptFileName_WorkedDaysNew"] = rptFileName;
        Session["Ses_dtHdr_WorkedDaysNew"] = dtHdr;
        Session["Ses_dtSource_WorkedDaysNew"] = dtSource;
        Session["Ses_rptHeader_WorkedDaysNew"] = rptHeader;
    }
    /// <summary>
    /// Over Time with Amount Report
    /// </summary>
    public void LoadOverTimewithAmountReport()
    {
        //Create the datatable ,that holds the header information
        DataTable dtHdr1 = new DataTable();
        dtHdr1 = hdrTable.CreateHeader();
        dtHdr1.TableName = "Header";
        //Add the Header information
        DataRow drHdr = dtHdr1.NewRow();
        drHdr["Link"] = 1;
        drHdr["Hdr1"] = "";
        drHdr["Hdr2"] = "";
        drHdr["Address1"] = "";
        drHdr["Address2"] = "";
        drHdr["ReportName"] = "Over Time withAmount Report";
        dtDate = rptEmp.GetDateMonth(dtFrom, dtTo);
        if (dtDate.Rows.Count > 0)
        {
            drHdr["FromDate"] = dtDate.Rows[0][0];
            drHdr["ToDate"] = dtDate.Rows[0][1];
        }
        else
        {
            drHdr["ToDate"] = "";
            drHdr["FromDate"] = "";
        }
        dtHdr1.Rows.Add(drHdr);
        decimal Amount = 0;
        if (OverTimeReportType == "Details")
        {
            dsOverTimewithAmount = rptEmp.SelectOverTimewithAmountDetails(dtFrom, dtTo, empId, shft, employeeName, Level, EmployeeCategory, EmployeeType, Convert.ToString(Session["UserGroupName"]), GradeLevel, Status, strSwipeCard, Convert.ToInt16(ParentLevelid), Convert.ToInt32(Designation), Gender, Amount, Convert.ToInt32(strEmpAutoId));
            rptFileName = Server.MapPath(rm.GetString("OverTime_withAmount_SummaryReport", ci));
        }
        else if (OverTimeReportType == "Summary")
        {
            dsOverTimewithAmount = rptEmp.SelectOverTimewithAmountSummary();
            rptFileName = Server.MapPath(rm.GetString("OverTimewithAmount_DetailsReport", ci));
        }
        //Check the Empty table
        if (dsOverTimewithAmount.Tables["Table"] == null || dsOverTimewithAmount.Tables["Table"].Rows.Count == 0)
        {
            blnCheckDataExits = false;
            MessagewithClose(rm.GetString("Alert_Thereisnorecord", ci));
            return;
        }
        DataSet dsHeader = new DataSet();
        DataTable dt = new DataTable();
        if (Convert.ToInt16(ParentLevelid) != 0)
        {
            dt = rptEmp.getHeader(Convert.ToInt16(ParentLevelid));
            Session["Ses_rptHeader_OverTimewithAmount"] = dt;
        }
        else
        {
            Session["Ses_rptHeader_OverTimewithAmount"] = dt;
        }
        dtHdr = dtHdr1;
        dtSource = dsOverTimewithAmount.Tables[0];
        Session["Ses_dtHdr_OverTimewithAmount"] = dtHdr;
        Session["Ses_dtSource_OverTimewithAmount"] = dtSource;
        Session["Ses_rptFileName_OverTimewithAmount"] = rptFileName;
    }
    /// <summary>
    /// Leave Report
    /// </summary>
    public void LoadLeaveReport()
    {
        if (Request.QueryString["ScheduleId"] != null)
        {
            dsEmp = rptEmp.SelectReportData(Filters, ReportName, ReportType);
            if (ReportType == "0")
            {
                rptFileName = Server.MapPath(rm.GetString("leaveReport", ci));
            }
            else
            {
                rptFileName = Server.MapPath(rm.GetString("RptLeave_SummaryReport", ci));
            }
        }
        else
        {
            if (LeaveReportType == "Details")
            {
                dsEmp = rptEmp.SelectLeave(dtFrom, dtTo, empId, shft, employeeName, Level, LeaveType, Status, EmployeeCategory, EmployeeType, Convert.ToString(Session["UserGroupName"]), GradeLevel, strSwipeCard, Convert.ToInt16(ParentLevelid), Convert.ToInt32(Designation), Gender, Convert.ToInt32(strEmpAutoId));
                rptFileName = Server.MapPath(rm.GetString("leaveReport", ci));
            }
            else if (LeaveReportType == "Summary")
            {
                dsEmp = rptEmp.SelectLeaveSummary(dtFrom, dtTo, empId, shft, employeeName, LeaveType, Status, EmployeeCategory, EmployeeType, Convert.ToString(Session["UserGroupName"]), GradeLevel, strSwipeCard, Convert.ToInt16(ParentLevelid), Convert.ToInt32(Designation), Gender, Convert.ToInt32(strEmpAutoId), YrSettingID);
                rptFileName = Server.MapPath(rm.GetString("RptLeave_SummaryReport_Product", ci));
            }
        }
        // dsEmp.WriteXmlSchema(@"E:\LeaveDetail.xml"); ;
        //Check the Empty table
        if (dsEmp.Tables["Table"] == null || dsEmp.Tables["Table"].Rows.Count == 0)
        {
            blnCheckDataExits = false;
            MessagewithClose(rm.GetString("Alert_Thereisnorecord", ci));
            return;
        }
        DataSet dsHeader = new DataSet();
        DataTable dt = new DataTable();
        if (Convert.ToInt16(ParentLevelid) != 0)
        {
            dt = rptEmp.getHeader(Convert.ToInt16(ParentLevelid));
            Session["Ses_rptHeader_Leave"] = dt;
        }
        else
        {
            Session["Ses_rptHeader_Leave"] = dt;
        }
        DataTable dtHdr1 = GetReportHeader();
        dtHdr = dtHdr1;
        dtSource = dsEmp.Tables[0];
        Session["Ses_dtHdr_Leave"] = dtHdr;
        Session["Ses_dtSource_Leave"] = dtSource;
        Session["Ses_rptFileName_Leave"] = rptFileName;
    }
    /// <summary>
    /// Leave Angler Report
    /// </summary>
    public void LoadLeaveReport_Angler()
    {
        //Create the datatable ,that holds the header information
        DataTable dtHdr1 = new DataTable();
        dtHdr1 = hdrTable.CreateHeader();
        dtHdr1.TableName = "Header";
        //Add the Header information
        DataRow drHdr = dtHdr1.NewRow();
        drHdr["Link"] = 1;
        drHdr["Hdr1"] = "";
        drHdr["Hdr2"] = "";
        drHdr["Address1"] = "";
        drHdr["Address2"] = "";
        drHdr["ReportName"] = " Unplanned (WI And WOI) Leave Report";
        if (dtFrom != "")
        {
            DateTime tmpFrom = DateTime.Parse(dtFrom);
            drHdr["FromDate"] = tmpFrom.ToString(Session["MDateFormat"].ToString());
        }
        else
            drHdr["FromDate"] = "";
        if (dtTo != "")
        {
            DateTime tmpTo = DateTime.Parse(dtTo);
            drHdr["ToDate"] = tmpTo.ToString(Session["MDateFormat"].ToString());
        }
        else
            drHdr["ToDate"] = "";
        dtHdr1.Rows.Add(drHdr);
        if (LeaveReportType == "Details")
        {
            dsEmp = rptEmp.SelectLeave_Angler(dtFrom, dtTo, empId, shft, employeeName, Level, LeaveType, Status, EmployeeCategory, EmployeeType, Session["UserGroupName"].ToString(), GradeLevel, strSwipeCard, Convert.ToInt64(strEmpAutoId), chkunplan, Convert.ToInt16(ParentLevelid), Convert.ToInt32(Designation), Gender);
            rptFileName = Server.MapPath(rm.GetString(chkunplan == 0 ? "leaveReport_Angler" : "UnPlanedLeaveReport", ci));
        }
        else if (LeaveReportType == "Summary")
        {
            //dsEmp = rptEmp.SelectLeaveSummary_Angler(dtFrom, dtTo, empId, shft, employeeName, LeaveType, Status, EmployeeCategory, EmployeeType, Session["UserGroupName"].ToString(), GradeLevel, strSwipeCard, Convert.ToInt16(ParentLevelid), Convert.ToInt32(Designation), Gender);
            rptFileName = Server.MapPath(rm.GetString("RptLeave_SummaryReport", ci));
        }
        //Check the Empty table
        if (dsEmp.Tables["Table"] == null || dsEmp.Tables["Table"].Rows.Count == 0)
        {
            blnCheckDataExits = false;
            MessagewithClose(rm.GetString("Alert_Thereisnorecord", ci));
            return;
        }
        ////Report Header
        //int orgID = Convert.ToInt16(ParentLevelid);
        //if (orgID == 0)
        //{
        //    //orgID = 1;
        //    DataSet dsOrgid = new DataSet();
        //    dsOrgid = rptEmp.getMinLevel();
        //    if (dsOrgid.Tables[0].Rows.Count > 0)
        //    {
        //        if (dsOrgid.Tables[0].Rows[0]["minID"] != DBNull.Value)
        //        {
        //            orgID = Convert.ToInt16(dsOrgid.Tables[0].Rows[0]["minID"]);
        //        }
        //    }
        //}
        //int lid = 0;
        //org_levelsEventData getOrg = new org_levelsEventData();
        //getOrg.GetOrgParentLevels_FromID(orgID);
        //DataSet ds_getOrg = new DataSet();
        //ds_getOrg = getOrg.GetOrgParentLevels();
        //if (ds_getOrg.Tables[0].Rows.Count > 0)
        //{
        //    lid = Convert.ToInt16(ds_getOrg.Tables[0].Rows[0]["levelID"]);
        //}
        //DataSet dsHeader = new DataSet();
        //dsHeader = rptEmp.getHeader(lid);
        //if (dsHeader.Tables[0].Rows.Count > 0)
        //{
        //    DataTable dtRptHeader = new DataTable();
        //    dtRptHeader = dsHeader.Tables[0].Copy();
        //    rptHeader = dtRptHeader;
        //    Session["Ses_rptHeader_Leave"] = rptHeader;
        //}
        ////End of Report Header
        DataSet dsHeader = new DataSet();
        DataTable dt = new DataTable();
        if (Convert.ToInt16(ParentLevelid) != 0)
        {
            dt = rptEmp.getHeader(Convert.ToInt16(ParentLevelid));
            Session["Ses_rptHeader_Leave"] = dt;
        }
        else
        {
            Session["Ses_rptHeader_Leave"] = dt;
        }
        //DataTable dtLeave = new DataTable();
        //dtLeave = dsEmp.Tables["Table"].Copy();
        ////Add the link column
        //DataColumn dcLink = new DataColumn("Link", Type.GetType("System.Int32"));
        //dtLeave.Columns.Add(dcLink);
        if (LeaveReportType == "Details")
        {
            dtMonthName = dsEmp.Tables["Table1"].Copy();
            Session.Add("Session_dtMonthName", dtMonthName);
        }
        else if (LeaveReportType == "Summary")
        {
            dtMonthName = dsEmp.Tables["Table"].Copy();
            Session.Add("Session_dtMonthName", dtMonthName);
        }
        //for (int i = 0; i < dtLeave.Rows.Count; i++)
        //{
        //    dtLeave.Rows[i]["Link"] = 1;
        //}
        //  WRITE XML SCHEMA TO DISK - THIS IS ONLY REQUIRED DURING DEVELOPMENT TO BUILD THE REPORT
        //Set the session variable that holds the report table and report header table
        dtHdr = dtHdr1;
        dtSource = dsEmp.Tables[0];
        //if (Normal == "True")
        // {
        //  rptFileName = Server.MapPath(rm.GetString("leaveReport", ci));
        //}
        //else
        //{
        //  rptFileName = Server.MapPath(rm.GetString("rptLeaveGraph", ci));
        //}
        Session["Ses_dtHdr_Leave"] = dtHdr;
        Session["Ses_dtSource_Leave"] = dtSource;
        Session["Ses_rptFileName_Leave"] = rptFileName;
    }
    /// <summary>
    /// Detailed Attendance Summary Report
    /// </summary>
    public void LoadDetailedAttendanceSummaryReport()
    {
        //Create the datatable ,that holds the header information
        DataTable dtHdr1 = new DataTable();
        dtHdr1 = hdrTable.CreateHeader();
        dtHdr1.TableName = "Header";
        //Add the Header information
        DataRow drHdr = dtHdr1.NewRow();
        drHdr["Link"] = 1;
        drHdr["Hdr1"] = "";
        drHdr["Hdr2"] = "";
        drHdr["Address1"] = "";
        drHdr["Address2"] = "";
        drHdr["ReportName"] = "Detailed Attendance Summary Report";
        dtDate = rptEmp.GetDateMonth(dtFrom, dtTo);
        if (dtDate.Rows.Count > 0)
        {
            drHdr["FromDate"] = dtDate.Rows[0][0];
            drHdr["ToDate"] = dtDate.Rows[0][1];
        }
        else
        {
            drHdr["ToDate"] = "";
            drHdr["FromDate"] = "";
        }
        dtHdr1.Rows.Add(drHdr);
        if (Request.QueryString["ScheduleId"] != null)
            dsEmp = rptEmp.SelectReportData(Filters, ReportName, ReportType);
        else
        {
            dsEmp = rptEmp.SelectDetailAttendSummary
                (
                dtFrom, dtTo, empId, employeeName, Level, Convert.ToString(Session["UserGroupName"]),
                GradeLevel, Convert.ToInt16(ParentLevelid), Convert.ToInt32(Designation), Gender,
                Convert.ToInt16(EmployeeCategory), Convert.ToInt16(EmployeeType),
                Convert.ToInt32(strEmpAutoId)
                );
        }
        //Check the Empty table
        if (dsEmp.Tables["Table"] == null || dsEmp.Tables["Table"].Rows.Count == 0)
        {
            blnCheckDataExits = false;
            string strMsg;
            strMsg = "<script language='javascript'>";
            strMsg = strMsg + "alert('" + rm.GetString("Alert_Thereisnorecord", ci) + "');window.close();";
            strMsg = strMsg + "</script>";
            Page.RegisterStartupScript("Display Message", strMsg);
            return;
        }
        DataSet dsHeader = new DataSet();
        DataTable dt = new DataTable();
        if (Convert.ToInt16(ParentLevelid) != 0)
        {
            dt = rptEmp.getHeader(Convert.ToInt16(ParentLevelid));
            Session["Ses_rptHeader_DetailedAttendanceSummary"] = dt;
        }
        else Session["Ses_rptHeader_DetailedAttendanceSummary"] = dt;
        rptFileName = Server.MapPath(rm.GetString("rptDetailedAttendanceSummary", ci));
        Session["Ses_dtHdr_DetailedAttendanceSummary"] = dtHdr1;
        Session["Ses_dtSource_DetailedAttendanceSummary"] = dsEmp.Tables[0];
        Session["Ses_rptFileName_DetailedAttendanceSummary"] = rptFileName;
    }
    /// <summary>
    /// Detailed Attendance Report
    /// </summary>
    /// 
    public void LoadDetailedAttendanceReport()
    {
        //Create the datatable ,that holds the header information
        int payrollConfig = 0;
        if (Request.QueryString["ScheduleId"] != null)
        {
            dsEmp = rptEmp.SelectReportData(Filters, ReportName, ReportType);
        }
        else
        {
            payrollConfig = objCommon.CheckPageExistsInLicense(185);
            /*Below parameter is used for Angler*/
            if (payrollConfig == 0)
            {
                dsEmp = rptEmp.SelectDetailAttend(dtFrom, dtTo, empId, employeeName, Level, Convert.ToString(Session["UserGroupName"]), GradeLevel, strSwipeCard, Convert.ToInt16(ParentLevelid), Convert.ToInt32(Designation), Gender, Convert.ToInt16(EmployeeCategory), Convert.ToInt16(EmployeeType), Convert.ToInt32(strEmpAutoId));
                switch (Normal)
                {
                    case "True":
                        rptFileName = Getreportpath(rm.GetString("detailedAttendanceReport", ci));
                        break;
                    case "False":
                        rptFileName = Getreportpath(rm.GetString("rptDetailedAttendanceGraph", ci));
                        break;
                }
                if (dsEmp.Tables[0].Columns.Contains("EmployeeCategory"))
                    dsEmp.Tables[0].Columns.Remove("EmployeeCategory");
                if (dsEmp.Tables[0].Columns.Contains("EmpCategory"))
                    dsEmp.Tables[0].Columns.Remove("EmpCategory");
                if (dsEmp.Tables[0].Columns.Contains("EmployeeType"))
                    dsEmp.Tables[0].Columns.Remove("EmployeeType");
                if (dsEmp.Tables[0].Columns.Contains("SwipeCardNo"))
                {
                    dsEmp.Tables[0].Columns.Remove("SwipeCardNo");
                }
                if (dsEmp.Tables[0].Columns.Contains("Gender"))
                {
                    dsEmp.Tables[0].Columns.Remove("Gender");
                }
                //if (dsEmp.Tables[0].Columns.Contains("WD Spec.OT1"))
                //{
                //    dsEmp.Tables[0].Columns.Remove("WD Spec.OT1");
                //}
                if (dsEmp.Tables[0].Columns.Contains("WD Spec.OT2"))
                {
                    dsEmp.Tables[0].Columns.Remove("WD Spec.OT2");
                }
                //if (dsEmp.Tables[0].Columns.Contains("WO Spec.OT1"))
                //{
                //    dsEmp.Tables[0].Columns.Remove("WO Spec.OT1");
                //}
                if (dsEmp.Tables[0].Columns.Contains("WO Spec.OT2"))
                {
                    dsEmp.Tables[0].Columns.Remove("WO Spec.OT2");
                }
                //if (dsEmp.Tables[0].Columns.Contains("H Spec.OT1"))
                //{
                //    dsEmp.Tables[0].Columns.Remove("H Spec.OT1");
                //}
                if (dsEmp.Tables[0].Columns.Contains("H Spec.OT2"))
                {
                    dsEmp.Tables[0].Columns.Remove("H Spec.OT2");
                }
            }
            else
            {
                dsEmp = rptEmp.SelectDetailAttend_Old(dtFrom, dtTo, empId, employeeName, Level, Session["UserGroupName"].ToString(), Convert.ToString(Session["GradeLevel"]), strSwipeCard, Convert.ToInt64(strEmpAutoId), Convert.ToInt32(Designation), Gender, Convert.ToInt16(ParentLevelid), 0);
                rptFileName = Server.MapPath(rm.GetString("detailedAttendanceReport_Angler", ci));
            }
        }
        //Check the Empty table
        if (dsEmp.Tables["Table"] == null || dsEmp.Tables["Table"].Rows.Count == 0)
        {
            blnCheckDataExits = false;
            MessagewithClose(rm.GetString("Alert_Thereisnorecord", ci));
            return;
        }
        //dynamic report
        int iField = 1;
        int iInc = 0;
        DataTable dtHeaderLabel = new DataTable();
        dtHeaderLabel.TableName = "HeaderLabels";
        if (dsEmp.Tables[0].Columns.Count > 11)
        {
            // total columns = 16  This code is for generate Ifield to meet 5 Leave type fields
            if (payrollConfig == 0)
            {
                if (dsEmp.Tables[0].Columns.Count < 36)
                {
                    int iDiff = (31 - dsEmp.Tables[0].Columns.Count);
                    for (int iDum = 0; iDum < iDiff; iDum++)
                    {
                        dsEmp.Tables[0].Columns.Add(new DataColumn("iField" + iInc, System.Type.GetType("System.Int32")));
                        iInc = iInc + 1;
                    }
                }
            }
            else
            {
                if (dsEmp.Tables[0].Columns.Count < 17)
                {
                    int iDiff = (16 - dsEmp.Tables[0].Columns.Count);
                    for (int iDum = 0; iDum < iDiff; iDum++)
                    {
                        dsEmp.Tables[0].Columns.Add(new DataColumn("iField" + iInc, System.Type.GetType("System.String")));
                        iInc = iInc + 1;
                    }
                }
            }
            DataRow dsRow = dtHeaderLabel.NewRow();
            int iIcont = 1;
            for (int iRow = 0; iRow < dsEmp.Tables[0].Columns.Count; iRow++)
            {
                dtHeaderLabel.Columns.Add(new DataColumn("Header" + iIcont, System.Type.GetType("System.String")));
                if (dsEmp.Tables[0].Columns[iRow].ColumnName != "Others")
                {
                    dsRow[iRow] = dsEmp.Tables[0].Columns[iRow].ColumnName;
                }
                else if (dsEmp.Tables[0].Columns[iRow].ColumnName == "Others")
                {
                    dsRow[iRow] = rm.GetString("Employee_Others", ci);
                }
                iIcont = iIcont + 1;
            }
            int iCheckFlag = 0;
            dtHeaderLabel.Rows.InsertAt(dsRow, 0);
            if (payrollConfig == 0)
            {
                for (int iCol = 36; iCol < dsEmp.Tables[0].Columns.Count; iCol++)
                {
                    if (dsEmp.Tables[0].Columns[iCol].ColumnName != "Others")
                    {
                        dsEmp.Tables[0].Columns[iCol].ColumnName = "Field" + iField;
                        iField = iField + 1;
                    }
                    else
                    {
                        iCheckFlag = 1;
                    }
                }
            }
            else
            {
                for (int iCol = 21; iCol < dsEmp.Tables[0].Columns.Count; iCol++)
                {
                    if (dsEmp.Tables[0].Columns[iCol].ColumnName != "Others")
                    {
                        dsEmp.Tables[0].Columns[iCol].ColumnName = "Field" + iField;
                        iField = iField + 1;
                    }
                    else
                    {
                        iCheckFlag = 1;
                    }
                }
            }
            if (iCheckFlag == 0)
            {
                //dsEmp.Tables[0].Columns[16].ColumnName = "Others";
                //dsEmp.Tables[0].Columns[16].ColumnName = rm.GetString("Employee_Others", ci);
            }
        }
        rptHeaderLabels = dtHeaderLabel;
        DataSet dsHeader = new DataSet();
        DataTable dt = new DataTable();
        if (Convert.ToInt16(ParentLevelid) != 0)
        {
            dt = rptEmp.getHeader(Convert.ToInt16(ParentLevelid));
            Session["Ses_rptHeader_DetailedAttendance"] = dt;
        }
        else
        {
            Session["Ses_rptHeader_DetailedAttendance"] = dt;
        }
        DataTable dtHdr1 = GetReportHeader();
        dtHdr = dtHdr1;
        dtSource = dsEmp.Tables[0];
        if (rptFileName.IndexOf("detailedAttendance.rpt") > 0)
        {
            rptHeaderLabels = dtHeaderLabel;
        }
        if (rptFileName.IndexOf("detailedAttendance_AR.rpt") > 0)
        {
            rptHeaderLabels = dtHeaderLabel;
        }
        Session["Ses_dtHdr_DetailedAttendance"] = dtHdr;
        Session["Ses_dtSource_DetailedAttendance"] = dtSource;
        //dtSource.WriteXmlSchema(@"E:detailedAttendance.xml");
        Session["Ses_rptFileName_DetailedAttendance"] = rptFileName;
        Session["Ses_rptHeaderLabels_DetailedAttendance"] = rptHeaderLabels;
    }

    //public void LoadDetailedAttendanceReport()
    //{
    //    //Create the datatable ,that holds the header information
    //    int payrollConfig = 0;
    //    if (Request.QueryString["ScheduleId"] != null)
    //    {
    //        dsEmp = rptEmp.SelectReportData(Filters, ReportName, ReportType);
    //    }
    //    else
    //    {
    //        payrollConfig = objCommon.CheckPageExistsInLicense(185);
    //        /*Below parameter is used for Angler*/
    //        if (payrollConfig == 0)
    //        {
    //            dsEmp = rptEmp.SelectDetailAttend(dtFrom, dtTo, empId, employeeName, Level, Convert.ToString(Session["UserGroupName"]), GradeLevel, strSwipeCard, Convert.ToInt16(ParentLevelid), Convert.ToInt32(Designation), Gender, Convert.ToInt16(EmployeeCategory), Convert.ToInt16(EmployeeType), Convert.ToInt32(strEmpAutoId));
    //            switch (Normal)
    //            {
    //                case "True":
    //                    rptFileName = Getreportpath(rm.GetString("detailedAttendanceReport", ci));
    //                    break;
    //                case "False":
    //                    rptFileName = Getreportpath(rm.GetString("rptDetailedAttendanceGraph", ci));
    //                    break;
    //            }
    //            if (dsEmp.Tables[0].Columns.Contains("EmployeeCategory"))
    //                dsEmp.Tables[0].Columns.Remove("EmployeeCategory");
    //            if (dsEmp.Tables[0].Columns.Contains("EmpCategory"))
    //                dsEmp.Tables[0].Columns.Remove("EmpCategory");
    //            if (dsEmp.Tables[0].Columns.Contains("EmployeeType"))
    //                dsEmp.Tables[0].Columns.Remove("EmployeeType");
    //            if (dsEmp.Tables[0].Columns.Contains("SwipeCardNo"))
    //            {
    //                dsEmp.Tables[0].Columns.Remove("SwipeCardNo");
    //            }
    //            if (dsEmp.Tables[0].Columns.Contains("Gender"))
    //            {
    //                dsEmp.Tables[0].Columns.Remove("Gender");
    //            }
    //            //if (dsEmp.Tables[0].Columns.Contains("WD Spec.OT1"))
    //            //{
    //            //    dsEmp.Tables[0].Columns.Remove("WD Spec.OT1");
    //            //}
    //            if (dsEmp.Tables[0].Columns.Contains("WD Spec.OT2"))
    //            {
    //                dsEmp.Tables[0].Columns.Remove("WD Spec.OT2");
    //            }
    //            //if (dsEmp.Tables[0].Columns.Contains("WO Spec.OT1"))
    //            //{
    //            //    dsEmp.Tables[0].Columns.Remove("WO Spec.OT1");
    //            //}
    //            if (dsEmp.Tables[0].Columns.Contains("WO Spec.OT2"))
    //            {
    //                dsEmp.Tables[0].Columns.Remove("WO Spec.OT2");
    //            }
    //            //if (dsEmp.Tables[0].Columns.Contains("H Spec.OT1"))
    //            //{
    //            //    dsEmp.Tables[0].Columns.Remove("H Spec.OT1");
    //            //}
    //            if (dsEmp.Tables[0].Columns.Contains("H Spec.OT2"))
    //            {
    //                dsEmp.Tables[0].Columns.Remove("H Spec.OT2");
    //            }
    //        }
    //        else
    //        {
    //            dsEmp = rptEmp.SelectDetailAttend_Old(dtFrom, dtTo, empId, employeeName, Level, Session["UserGroupName"].ToString(), Convert.ToString(Session["GradeLevel"]), strSwipeCard, Convert.ToInt64(strEmpAutoId), Convert.ToInt32(Designation), Gender, Convert.ToInt16(ParentLevelid), 0);
    //            rptFileName = Server.MapPath(rm.GetString("detailedAttendanceReport_Angler", ci));
    //        }
    //    }
    //    //Check the Empty table
    //    if (dsEmp.Tables["Table"] == null || dsEmp.Tables["Table"].Rows.Count == 0)
    //    {
    //        blnCheckDataExits = false;
    //        MessagewithClose(rm.GetString("Alert_Thereisnorecord", ci));
    //        return;
    //    }
    //    //dynamic report
    //    int iField = 1;
    //    int iInc = 0;
    //    DataTable dtHeaderLabel = new DataTable();
    //    dtHeaderLabel.TableName = "HeaderLabels";
    //    if (dsEmp.Tables[0].Columns.Count > 11)
    //    {
    //        // total columns = 16  This code is for generate Ifield to meet 5 Leave type fields
    //        if (payrollConfig == 0)
    //        {
    //            if (dsEmp.Tables[0].Columns.Count < 32)
    //            {
    //                int iDiff = (31 - dsEmp.Tables[0].Columns.Count);
    //                for (int iDum = 0; iDum < iDiff; iDum++)
    //                {
    //                    dsEmp.Tables[0].Columns.Add(new DataColumn("iField" + iInc, System.Type.GetType("System.Int32")));
    //                    iInc = iInc + 1;
    //                }
    //            }
    //        }
    //        else
    //        {
    //            if (dsEmp.Tables[0].Columns.Count < 17)
    //            {
    //                int iDiff = (16 - dsEmp.Tables[0].Columns.Count);
    //                for (int iDum = 0; iDum < iDiff; iDum++)
    //                {
    //                    dsEmp.Tables[0].Columns.Add(new DataColumn("iField" + iInc, System.Type.GetType("System.String")));
    //                    iInc = iInc + 1;
    //                }
    //            }
    //        }
    //        DataRow dsRow = dtHeaderLabel.NewRow();
    //        int iIcont = 1;
    //        for (int iRow = 0; iRow < dsEmp.Tables[0].Columns.Count; iRow++)
    //        {
    //            dtHeaderLabel.Columns.Add(new DataColumn("Header" + iIcont, System.Type.GetType("System.String")));
    //            if (dsEmp.Tables[0].Columns[iRow].ColumnName != "Others")
    //            {
    //                dsRow[iRow] = dsEmp.Tables[0].Columns[iRow].ColumnName;
    //            }
    //            else if (dsEmp.Tables[0].Columns[iRow].ColumnName == "Others")
    //            {
    //                dsRow[iRow] = rm.GetString("Employee_Others", ci);
    //            }
    //            iIcont = iIcont + 1;
    //        }
    //        int iCheckFlag = 0;
    //        dtHeaderLabel.Rows.InsertAt(dsRow, 0);
    //        if (payrollConfig == 0)
    //        {
    //            for (int iCol = 26; iCol < dsEmp.Tables[0].Columns.Count; iCol++)
    //            {
    //                if (dsEmp.Tables[0].Columns[iCol].ColumnName != "Others")
    //                {
    //                    dsEmp.Tables[0].Columns[iCol].ColumnName = "Field" + iField;
    //                    iField = iField + 1;
    //                }
    //                else
    //                {
    //                    iCheckFlag = 1;
    //                }
    //            }
    //        }
    //        else
    //        {
    //            for (int iCol = 21; iCol < dsEmp.Tables[0].Columns.Count; iCol++)
    //            {
    //                if (dsEmp.Tables[0].Columns[iCol].ColumnName != "Others")
    //                {
    //                    dsEmp.Tables[0].Columns[iCol].ColumnName = "Field" + iField;
    //                    iField = iField + 1;
    //                }
    //                else
    //                {
    //                    iCheckFlag = 1;
    //                }
    //            }
    //        }
    //        if (iCheckFlag == 0)
    //        {
    //            //dsEmp.Tables[0].Columns[16].ColumnName = "Others";
    //            //dsEmp.Tables[0].Columns[16].ColumnName = rm.GetString("Employee_Others", ci);
    //        }
    //    }
    //    rptHeaderLabels = dtHeaderLabel;
    //    DataSet dsHeader = new DataSet();
    //    DataTable dt = new DataTable();
    //    if (Convert.ToInt16(ParentLevelid) != 0)
    //    {
    //        dt = rptEmp.getHeader(Convert.ToInt16(ParentLevelid));
    //        Session["Ses_rptHeader_DetailedAttendance"] = dt;
    //    }
    //    else
    //    {
    //        Session["Ses_rptHeader_DetailedAttendance"] = dt;
    //    }
    //    DataTable dtHdr1 = GetReportHeader();
    //    dtHdr = dtHdr1;
    //    dtSource = dsEmp.Tables[0];
    //    if (rptFileName.IndexOf("detailedAttendance.rpt") > 0)
    //    {
    //        rptHeaderLabels = dtHeaderLabel;
    //    }
    //    if (rptFileName.IndexOf("detailedAttendance_AR.rpt") > 0)
    //    {
    //        rptHeaderLabels = dtHeaderLabel;
    //    }
    //    Session["Ses_dtHdr_DetailedAttendance"] = dtHdr;
    //    Session["Ses_dtSource_DetailedAttendance"] = dtSource;
    //    //dtSource.WriteXmlSchema(@"E:detailedAttendance.xml");
    //    Session["Ses_rptFileName_DetailedAttendance"] = rptFileName;
    //    Session["Ses_rptHeaderLabels_DetailedAttendance"] = rptHeaderLabels;
    //}
    /// <summary>
    /// Monthly Attendance Report
    /// </summary>
    public void LoadMonthlyAttendanceReport(string reportName)
    {
        int payrollConfig = 0;
        if (Request.QueryString["ScheduleId"] != null)
        {
            dsEmp = rptEmp.SelectReportData(Filters, ReportName, ReportType);
        }
        else
        {
            if (Dashboard == "MonthlyAtt")
            {
                if (Convert.ToString(Session["packageID"]) != "" && Convert.ToString(Session["packageID"]) == "161") //from dashboard calling of monthly attendance
                {
                    //Ardlysis NeyveliPowerPlant - TimecheckV2.7
                    dsEmp = rptEmp.SelectMonthlyAttendance_Ardlysis(MinWorkHours, dtFrom, dtTo, employeeName, Level, empId, EmployeeCategory, EmployeeType, Convert.ToString(Session["UserGroupName"]), GradeLevel, strSwipeCard, Convert.ToInt16(ParentLevelid), Convert.ToInt32(Designation), Gender, shft, MonthlydataLoading, Convert.ToInt64(strEmpAutoId), 1,0);
                }
                else
                {
                    if (isPresent == "1")
                    {
                        dsEmp = rptEmp.SelectMonthlyAttendanceReportDashboard(MinWorkHours, dtFrom, dtTo, employeeName, Level, empId, EmployeeCategory, EmployeeType, Convert.ToString(Session["UserGroupName"]), GradeLevel, strSwipeCard, Convert.ToInt16(ParentLevelid), Convert.ToInt32(Designation), Gender, shft, MonthlydataLoading, Convert.ToInt64(strEmpAutoId));
                    }
                    else
                    {
                        if (reportName == "LabourMonthlyAttendance")
                        {
                            dsEmp = rptEmp.SelectMonthlyAttendanceReport("Proc_TA_RptMonthlyAttendanceLabour", MinWorkHours, dtFrom, dtTo, employeeName, Level, empId, EmployeeCategory, EmployeeType, Convert.ToString(Session["UserGroupName"]), GradeLevel, strSwipeCard, Convert.ToInt16(ParentLevelid), Convert.ToInt32(Designation), Gender, shft, MonthlydataLoading, Convert.ToInt64(strEmpAutoId), 0,0);
                        }
                        else if (reportName == "MonthlyAttendanceBreakHours")
                        {
                            dsEmp = rptEmp.SelectMonthlyAttendanceReport("Proc_TA_RptMonthlyAttendanceBreakHours", MinWorkHours, dtFrom, dtTo, employeeName, Level, empId, EmployeeCategory, EmployeeType, Convert.ToString(Session["UserGroupName"]), GradeLevel, strSwipeCard, Convert.ToInt16(ParentLevelid), Convert.ToInt32(Designation), Gender, shft, MonthlydataLoading, Convert.ToInt64(strEmpAutoId), 0,0);
                        }
                        else
                        {
                            dsEmp = rptEmp.SelectMonthlyAttendanceReport("Proc_TA_RptMonthlyAttendance", MinWorkHours, dtFrom, dtTo, employeeName, Level, empId, EmployeeCategory, EmployeeType, Convert.ToString(Session["UserGroupName"]), GradeLevel, strSwipeCard, Convert.ToInt16(ParentLevelid), Convert.ToInt32(Designation), Gender, shft, MonthlydataLoading, Convert.ToInt64(strEmpAutoId), 0,0);
                        }
                    }
                }
            }
            else
            {
                if (reportName == "LabourMonthlyAttendance")
                {
                    Session["MonthlyAttendanceVertical"] = null;
                }
                else if (reportName == "MonthlyAttendanceBreakHours")
                {
                    Session["MonthlyAttendanceVertical"] = null;
                    Session["MonthlyAttendanceHorizontal"] = null;
                    if (Convert.ToString(Session["MonthlyAttendanceBreakHours"]) != "")
                    {
                        dsEmp = (DataSet)Session["MonthlyAttendanceBreakHours"];

                    }
                }
                else if (Convert.ToString(Session["MonthlyAttendanceVertical"]) != "")
                {
                    dsEmp = (DataSet)Session["MonthlyAttendanceVertical"];
                }
                else
                {
                    if (Convert.ToString(Session["packageID"]) != "" && Convert.ToString(Session["packageID"]) == "161")//from Reports calling of monthly attendance
                    {
                        //Ardlysis NeyveliPowerPlant - TimecheckV2.7
                        dsEmp = rptEmp.SelectMonthlyAttendance_Ardlysis(MinWorkHours, dtFrom, dtTo, employeeName, Level, empId, EmployeeCategory, EmployeeType, Convert.ToString(Session["UserGroupName"]), GradeLevel, strSwipeCard, Convert.ToInt16(ParentLevelid), Convert.ToInt32(Designation), Gender, shft, MonthlydataLoading, Convert.ToInt64(strEmpAutoId), 0,0);
                    }
                    else
                    {
                        //dsEmp = rptEmp.SelectMonthlyAttendanceReport((reportName == "LabourMonthlyAttendance") ? "Proc_TA_RptMonthlyAttendanceLabour" : "Proc_TA_RptMonthlyAttendance", MinWorkHours, dtFrom, dtTo, employeeName, Level, empId, EmployeeCategory, EmployeeType, Convert.ToString(Session["UserGroupName"]), GradeLevel, strSwipeCard, Convert.ToInt16(ParentLevelid), Convert.ToInt32(Designation), Gender, shft, MonthlydataLoading, Convert.ToInt64(strEmpAutoId), 0);
                        if (reportName == "LabourMonthlyAttendance")
                        {
                            dsEmp = rptEmp.SelectMonthlyAttendanceReport("Proc_TA_RptMonthlyAttendanceLabour", MinWorkHours, dtFrom, dtTo, employeeName, Level, empId, EmployeeCategory, EmployeeType, Convert.ToString(Session["UserGroupName"]), GradeLevel, strSwipeCard, Convert.ToInt16(ParentLevelid), Convert.ToInt32(Designation), Gender, shft, MonthlydataLoading, Convert.ToInt64(strEmpAutoId), 0,0);
                        }
                        else if (reportName == "MonthlyAttendanceBreakHours")
                        {
                            dsEmp = rptEmp.SelectMonthlyAttendanceReport("Proc_TA_RptMonthlyAttendanceBreakHours", MinWorkHours, dtFrom, dtTo, employeeName, Level, empId, EmployeeCategory, EmployeeType, Convert.ToString(Session["UserGroupName"]), GradeLevel, strSwipeCard, Convert.ToInt16(ParentLevelid), Convert.ToInt32(Designation), Gender, shft, MonthlydataLoading, Convert.ToInt64(strEmpAutoId), 0,0);
                        }
                        else
                        {
                            dsEmp = rptEmp.SelectMonthlyAttendanceReport("Proc_TA_RptMonthlyAttendance", MinWorkHours, dtFrom, dtTo, employeeName, Level, empId, EmployeeCategory, EmployeeType, Convert.ToString(Session["UserGroupName"]), GradeLevel, strSwipeCard, Convert.ToInt16(ParentLevelid), Convert.ToInt32(Designation), Gender, shft, MonthlydataLoading, Convert.ToInt64(strEmpAutoId), 0,0);
                        }
                    }
                }
            }
        }
        //Check the Empty table 
        if (dsEmp.Tables["Table"] == null || dsEmp.Tables["Table"].Rows.Count == 0)
        {
            blnCheckDataExits = false;
            MessagewithClose(rm.GetString("Alert_Thereisnorecord", ci));
            return;
        }
        DataSet dsHeader = new DataSet();
        DataTable dt = new DataTable();
        if (Convert.ToInt16(ParentLevelid) != 0)
        {
            dt = rptEmp.getHeader(Convert.ToInt16(ParentLevelid));
            Session["Ses_rptHeader_MonthlyAttendance"] = dt;
        }
        else
        {
            Session["Ses_rptHeader_MonthlyAttendance"] = dt;
        }
        //dt.WriteXmlSchema(@"E:/monthlyattenComp.xml");
        DataTable dtHdr1 = GetReportHeader();
        dtHdr = dtHdr1;
        payrollConfig = objCommon.CheckPageExistsInLicense(185);
        /*Below parameter is used for Angler*/
        if (payrollConfig == 1)
        {
            rptFileName = Server.MapPath(rm.GetString("rptMonthlyAttendance_Angler", ci));
        }
        else
        {
            switch (Convert.ToString(Session["packageID"]))
            {
                case "155"://Eastman
                case "156"://iffco
                    if (reportName == "LabourMonthlyAttendance")
                    {
                        rptFileName = Getreportpath(rm.GetString("RptLabourMonthlyAttendance", ci));
                    }
                    else
                    {
                        if (Request.QueryString["Iscustomizedrpt"] != null)
                        {
                            if (Convert.ToInt16(Request.QueryString["Iscustomizedrpt"]) == 0)//old report
                            {
                                rptFileName = Getreportpath(rm.GetString("rptMonthlyAttendance", ci));
                            }
                            else
                            {
                                rptFileName = Getreportpath(rm.GetString("rptMonthlyAttendanceCustomized", ci));//new report
                            }
                        }
                    }
                    break;
                case "159":
                    rptFileName = Getreportpath(rm.GetString("rptMonthlyAttendance", ci));
                    break;
                case "161": //Need to put Ardlysis Package Id
                    rptFileName = Getreportpath(rm.GetString("RptMonthlyAttendance_Ardlysis", ci));
                    break;
                default:
                    if (Convert.ToString(Request.QueryString["isStraightReport"]) == "2")
                        rptFileName = Getreportpath(rm.GetString("rptMonthlyAttendance_straightShift", ci));
                    else if (Convert.ToString(Request.QueryString["isStraightReport"]) == "3")
                        rptFileName = Getreportpath(rm.GetString("RptMonthlyAttendanceLevel", ci));
                    else if (Convert.ToString(Request.QueryString["isStraightReport"]) == "4")
                        rptFileName = Getreportpath(rm.GetString("rptMonthlyAttendanceBreakHours", ci));
                    else
                        rptFileName = Getreportpath(rm.GetString("rptMonthlyAttendance", ci));
                    break;
            }
        }
        if (Dashboard == "MonthlyAtt" && isPresent == "0")
            rptFileName = Server.MapPath("~/Reports/RptAttendanceSummary.rpt");
        else if (Dashboard == "MonthlyAtt" && isPresent == "1")
            rptFileName = Server.MapPath("~/Reports/RptPresent.rpt");
        Session["Ses_dtHdr_MonthlyAttendance"] = dtHdr;
        //dtHdr.WriteXmlSchema(@"E:\monthlyattHdr.xml");
        Session["Ses_dtSource_MonthlyAttendance"] = dsEmp.Tables[0];
        //dsEmp.Tables[0].WriteXmlSchema(@"D:\MonthlyAttendance.xml");
        if (dsEmp.Tables.Count > 1)
        {
            Session["Ses_dtSource1_MonthlyAttendance"] = dsEmp.Tables[1];
            //dsEmp.Tables[1].WriteXmlSchema(@"E:\monthlyattTot.xml");
        }
        Session["Ses_rptFileName_MonthlyAttendance"] = rptFileName;
    }
    private DataTable GetReportHeader()
    {
        DataTable dtHdr1 = new DataTable();
        dtHdr1 = hdrTable.CreateHeader();
        dtHdr1.TableName = "Header";
        //Add the Header information
        DataRow drHdr = dtHdr1.NewRow();
        drHdr["Link"] = 1;
        drHdr["Hdr1"] = "";
        drHdr["Hdr2"] = "";
        drHdr["Address1"] = "";
        drHdr["Address2"] = "";
        drHdr["ReportName"] = "Monthly Attendance Report";
        dtDate = rptEmp.GetDateMonth(dtFrom, dtTo);
        if (dtDate.Rows.Count > 0)
        {
            drHdr["FromDate"] = dtDate.Rows[0][0];
            drHdr["ToDate"] = dtDate.Rows[0][1];
        }
        else
        {
            drHdr["ToDate"] = "";
            drHdr["FromDate"] = "";
        }
        dtHdr1.Rows.Add(drHdr);
        return dtHdr1;
    }
    private DataTable GetReportHeaderContactor()
    {
        DataTable dtHdr1 = new DataTable();
        dtHdr1 = hdrTable.CreateHeader();
        dtHdr1.TableName = "Header";
        //Add the Header information
        DataRow drHdr = dtHdr1.NewRow();
        drHdr["Link"] = 1;
        drHdr["Hdr1"] = "";
        drHdr["Hdr2"] = "";
        drHdr["Address1"] = "";
        drHdr["Address2"] = "";
        drHdr["ReportName"] = "Contractor Attendance Report";
        dtDate = rptEmp.GetDateMonth(dtFrom, dtTo);
        if (dtDate.Rows.Count > 0)
        {
            drHdr["FromDate"] = dtDate.Rows[0][0];
            drHdr["ToDate"] = dtDate.Rows[0][1];
        }
        else
        {
            drHdr["ToDate"] = "";
            drHdr["FromDate"] = "";
        }
        dtHdr1.Rows.Add(drHdr);
        return dtHdr1;

    }

    private DataTable GetDailyReportHeader()
    {
        DataTable dtHdr1 = new DataTable();
        dtHdr1 = hdrTable.CreateHeader();
        dtHdr1.TableName = "Header";
        //Add the Header information
        DataRow drHdr = dtHdr1.NewRow();
        drHdr["Link"] = 1;
        drHdr["Hdr1"] = "";
        drHdr["Hdr2"] = "";
        drHdr["Address1"] = "";
        drHdr["Address2"] = "";
        drHdr["ReportName"] = "Daily Attendance Report  -";
        dtDate = rptEmp.GetDateMonth(dtFrom, dtTo);
        if (dtDate.Rows.Count > 0)
        {
            drHdr["FromDate"] = dtDate.Rows[0][0];
            drHdr["ToDate"] = dtDate.Rows[0][1];
        }
        else
        {
            drHdr["ToDate"] = "";
            drHdr["FromDate"] = "";
        }
        dtHdr1.Rows.Add(drHdr);
        return dtHdr1;
    }
    /// <summary>
    /// Monthly Attendance Report Details
    /// Added by Gopinath on 24 Dec 2013
    /// </summary>
    public void LoadMonthlyAttendanceReportDetail()
    {
        if (Request.QueryString["ScheduleId"] != null)
        {
            dsEmp = rptEmp.SelectReportData(Filters, ReportName, ReportType);
        }
        else
        {
            if (Session["MonthlyAttendanceHorizontal"] != null)
            {
                dsEmp = (DataSet)Session["MonthlyAttendanceHorizontal"];
            }
            else
            {
                blnCheckDataExits = false;
                MessagewithClose(rm.GetString("Alert_Thereisnorecord", ci));
                return;
            }
        }
        DataSet dsHeader = new DataSet();
        DataTable dt = new DataTable();
        if (Convert.ToInt16(ParentLevelid) != 0)
        {
            dt = rptEmp.getHeader(Convert.ToInt16(ParentLevelid));
            Session["Ses_rptHeader_MonthlyAttendanceDetail"] = dt;
        }
        //End of Report Header
        DataTable dtMonthlyAttendance = new DataTable();
        dtMonthlyAttendance = dsEmp.Tables["Table"].Copy();
        DataTable dt2 = new DataTable();
        dt2 = dsEmp.Tables[1];
        Session["sessTable3"] = dt2;
        DataTable dtHdr1 = GetReportHeader();
        dtHdr = dtHdr1;
        dtSource = dtMonthlyAttendance;
        rptFileName = Getreportpath(rm.GetString("rptMonthlyAttendanceDetail", ci));
        Session["Ses_dtHdr_MonthlyAttendanceDetail"] = dtHdr;
        Session["Ses_dtSource_MonthlyAttendanceDetail"] = dtSource;
        Session["Ses_rptFileName_MonthlyAttendanceDetail"] = rptFileName;
        Session["Ses_dtSource_MonthlyAttendanceDetailData2"] = dt2;
    }
    public void LoadCanteenReport(string reportName)
    {
        dsEmp = (DataSet)Session["CanteenReportData"];
        //Check the Empty table 
        if (dsEmp.Tables["Table"] == null || dsEmp.Tables["Table"].Rows.Count == 0)
        {
            blnCheckDataExits = false;
            MessagewithClose(rm.GetString("Alert_Thereisnorecord", ci));
            return;
        }
        DataSet dsHeader = new DataSet();
        DataTable dt = new DataTable();
        if (Convert.ToInt16(ParentLevelid) != 0)
        {
            dt = rptEmp.getHeader(Convert.ToInt16(ParentLevelid));
            Session["Ses_rptHeader_CanteenReport"] = dt;
        }
        else
        {
            Session["Ses_rptHeader_CanteenReport"] = dt;
        }
        DataTable dtHdr1 = GetReportHeader();
        dtHdr = dtHdr1;
        rptFileName = Server.MapPath(rm.GetString("CanteenReportFile", ci));
        Session["Ses_dtHdr_CanteenReport"] = dtHdr;
        Session["Ses_dtSource_CanteenReport"] = dsEmp.Tables[0];
        Session["Ses_rptFileName_CanteenReport"] = rptFileName;
    }
    public void LoadCanteenReportSummary(string reportName)
    {
        dsEmp = (DataSet)Session["CanteenReportData"];
        //Check the Empty table 
        if (dsEmp.Tables["Table1"] == null || dsEmp.Tables["Table1"].Rows.Count == 0)
        {
            blnCheckDataExits = false;
            MessagewithClose(rm.GetString("Alert_Thereisnorecord", ci));
            return;
        }
        DataSet dsHeader = new DataSet();
        DataTable dt = new DataTable();
        if (Convert.ToInt16(ParentLevelid) != 0)
        {
            dt = rptEmp.getHeader(Convert.ToInt16(ParentLevelid));
            Session["Ses_rptHeader_CanteenReport"] = dt;
        }
        else
        {
            Session["Ses_rptHeader_CanteenReport"] = dt;
        }
        DataTable dtHdr1 = GetReportHeader();
        dtHdr = dtHdr1;
        rptFileName = Server.MapPath(rm.GetString("CanteenReportSummary", ci));
        Session["Ses_dtHdr_CanteenReport"] = dtHdr;
        Session["Ses_dtSource_CanteenReport"] = dsEmp.Tables[1];
        Session["Ses_rptFileName_CanteenReport"] = rptFileName;
    }
    public void LoadDailyAttendanceReport(string reportName)
    {
        if (reportName == "DailyAttendanceReport")
        {
            if (Convert.ToString(Session["DailyAttendanceHorizontal"]) != "")
            {
                dsEmp = (DataSet)Session["DailyAttendanceHorizontal"];
            }
        }
        //Check the Empty table 
        if (dsEmp.Tables["Table"] == null || dsEmp.Tables["Table"].Rows.Count == 0)
        {
            blnCheckDataExits = false;
            MessagewithClose(rm.GetString("Alert_Thereisnorecord", ci));
            return;
        }
        DataSet dsHeader = new DataSet();
        DataTable dt = new DataTable();
        if (Convert.ToInt16(ParentLevelid) != 0)
        {
            dt = rptEmp.getHeader(Convert.ToInt16(ParentLevelid));
            Session["Ses_rptHeader_DailyAttendance"] = dt;
        }
        else
        {
            Session["Ses_rptHeader_DailyAttendance"] = dt;
        }
        DataTable dtHdr1 = GetDailyReportHeader();
        dtHdr = dtHdr1;
        rptFileName = Server.MapPath(rm.GetString("DailyAttendanceReportFile", ci));
        Session["Ses_dtHdr_DailyAttendance"] = dtHdr;
        Session["Ses_dtSource_DailyAttendance"] = dsEmp.Tables[0];
        Session["Ses_rptFileName_DailyAttendance"] = rptFileName;
    }
    /// <summary>
    /// Total Days report
    /// </summary>
    public void LoadTotalDaysReport()
    {
        dsEmp = rptEmp.SelectTotalDaysWorkedReport(dtFrom, dtTo, employeeName, Level, empId, EmployeeCategory, EmployeeType, NoOfDays, Convert.ToString(Session["UserGroupName"]), GradeLevel, strSwipeCard, Convert.ToInt16(ParentLevelid), Convert.ToInt32(Designation), Gender, TotalDays, Convert.ToInt32(strEmpAutoId));
        if (dsEmp.Tables["Table"] == null || dsEmp.Tables["Table"].Rows.Count == 0)
        {
            blnCheckDataExits = false;
            MessagewithClose(rm.GetString("Alert_Thereisnorecord", ci));
            return;
        }
        DataSet dsHeader = new DataSet();
        DataTable dt = new DataTable();
        if (Convert.ToInt16(ParentLevelid) != 0)
        {
            dt = rptEmp.getHeader(Convert.ToInt16(ParentLevelid));
            Session["Ses_rptHeader_TotalDays"] = dt;
        }
        else
        {
            Session["Ses_rptHeader_TotalDays"] = dt;
        }
        DataTable dtHdr1 = GetReportHeader();
        dtHdr = dtHdr1;
        dtSource = dsEmp.Tables[0];
        rptFileName = Server.MapPath(rm.GetString("rptTotalDays", ci));
        Session["Ses_dtHdr_TotalDays"] = dtHdr;
        Session["Ses_dtSource_TotalDays"] = dtSource;
        Session["Ses_rptFileName_TotalDays"] = rptFileName;
    }
    /// <summary>
    /// Punctuality report
    /// </summary>
    public void LoadPunctualityReport()
    {
        if (Request.QueryString["ScheduleId"] != null)
        {
            dsEmp = rptEmp.SelectReportData(Filters, ReportName, ReportType);
        }
        else
        {
            if (Normal == "True")
            {
                dsEmp = rptEmp.SelectPunctuality(dtFrom, dtTo, empId, shft, employeeName, Level, EmployeeCategory, EmployeeType, Session["UserGroupName"].ToString(), GradeLevel, strSwipeCard, Convert.ToInt16(ParentLevelid), Convert.ToInt32(Designation), Gender, Convert.ToInt64(strEmpAutoId), 1);
            }
            else
            {
                dsEmp = rptEmp.Select_Graph_Late_PunctualityReport(empId, Level, dtFrom, dtTo, employeeName, shft, EmployeeCategory, EmployeeType, Convert.ToString(Session["UserGroupName"]), GradeLevel, strSwipeCard, Convert.ToInt32(strEmpAutoId));
            }
        }
        //Check the Empty table
        if (dsEmp.Tables["Table"] == null || dsEmp.Tables["Table"].Rows.Count == 0)
        {
            blnCheckDataExits = false;
            MessagewithClose(rm.GetString("Alert_Thereisnorecord", ci));
            return;
        }
        DataSet dsHeader = new DataSet();
        DataTable dt = new DataTable();
        if (Convert.ToInt16(ParentLevelid) != 0)
        {
            dt = rptEmp.getHeader(Convert.ToInt16(ParentLevelid));
            Session["Ses_rptHeader_Punctuality"] = dt;
        }
        else
        {
            Session["Ses_rptHeader_Punctuality"] = dt;
        }
        DataTable dtHdr1 = GetReportHeader();
        dtHdr = dtHdr1;
        dtSource = dsEmp.Tables[0];
        if (Normal == "True")
        {
            rptFileName = Getreportpath(rm.GetString("rptPunctuality", ci));
        }
        else
        {
            rptFileName = Server.MapPath("LatePunctualityGraph.rpt");
        }
        Session["Ses_dtHdr_Punctuality"] = dtHdr;
        Session["Ses_dtSource_Punctuality"] = dtSource;
        Session["Ses_rptFileName_Punctuality"] = rptFileName;
    }
    /// <summary>
    /// Discrepancy report
    /// </summary>
    public void LoadDiscrepancyReport()
    {
        if (Request.QueryString["ScheduleId"] != null)
        {
            dsEmp = rptEmp.SelectReportData(Filters, ReportName, ReportType);
        }
        else
        {
            dsEmp = rptEmp.SelectDiscrepancy(dtFrom, dtTo, empId, shft, employeeName, Level, EmployeeCategory, EmployeeType, Convert.ToString(Session["UserGroupName"]), GradeLevel, strSwipeCard, Convert.ToInt16(ParentLevelid), Convert.ToInt32(Designation), Gender, Convert.ToInt64(strEmpAutoId), 1);
        }
        //Check the Empty table
        if (dsEmp.Tables["Table"] == null || dsEmp.Tables["Table"].Rows.Count == 0)
        {
            blnCheckDataExits = false;
            MessagewithClose(rm.GetString("Alert_Thereisnorecord", ci));
            return;
        }
        DataSet dsHeader = new DataSet();
        DataTable dt = new DataTable();
        if (Convert.ToInt16(ParentLevelid) != 0)
        {
            dt = rptEmp.getHeader(Convert.ToInt16(ParentLevelid));
            Session["Ses_rptHeader_Discrepancy"] = dt;
        }
        else
        {
            Session["Ses_rptHeader_Discrepancy"] = dt;
        }
        DataTable dtHdr1 = GetReportHeader();
        dtHdr = dtHdr1;
        dtSource = dsEmp.Tables[0];
        rptFileName = Getreportpath(rm.GetString("discrepancyReport", ci));
        Session["Ses_dtHdr_Discrepancy"] = dtHdr;
        Session["Ses_dtSource_Discrepancy"] = dtSource;
        Session["Ses_rptFileName_Discrepancy"] = rptFileName;
    }
    /// <summary>
    /// Shift Report
    /// </summary>
    public void LoadShiftReport()
    {
        DataSet dsEmployee = new DataSet();
        dsEmployee = rptEmp.SelectEmployeeShiftNotAlloc("", DateTime.Now.ToShortDateString(), empId, 0, employeeName, Level, EmployeeCategory, EmployeeType, "Active", Convert.ToString(Session["UserGroupName"]), GradeLevel, strSwipeCard, Convert.ToInt16(ParentLevelid), Convert.ToInt32(Designation), Gender, Convert.ToInt64(strEmpAutoId));
        dsEmployee.Tables[0].DefaultView.RowFilter = "Report_Exclude = False";
        DataTable dtEmployeeFiltered = new DataTable();
        dtEmployeeFiltered = dsEmployee.Tables[0].DefaultView.ToTable();
        dsEmployee.Tables.Clear();
        dsEmployee.Tables.Add(dtEmployeeFiltered);
        string employeeId = string.Empty, notMonth = string.Empty, notYear = string.Empty;
        int ShiftCount = 0;
        DataTable dtShiftNotAllocated = new DataTable();
        dtShiftNotAllocated.TableName = "dtShiftNotAllocated";
        DataColumn dcShiftId = new DataColumn("ShiftId", System.Type.GetType("System.Int32"));
        DataColumn dcEmployeeId = new DataColumn("EmployeeId", System.Type.GetType("System.Int32"));
        DataColumn dcEmployee_Code_Id = new DataColumn("Employee_Code_Id");
        DataColumn dcShift_shortName = new DataColumn("Shift_ShortName");
        DataColumn dcempname = new DataColumn("empname");
        DataColumn dcname = new DataColumn("name");
        DataColumn dcTitleName = new DataColumn("TitleName");
        DataColumn dcGender = new DataColumn("Gender");
        dtShiftNotAllocated.Columns.Add(dcShiftId);
        dtShiftNotAllocated.Columns.Add(dcEmployeeId);
        dtShiftNotAllocated.Columns.Add(dcEmployee_Code_Id);
        dtShiftNotAllocated.Columns.Add(dcShift_shortName);
        dtShiftNotAllocated.Columns.Add(dcempname);
        dtShiftNotAllocated.Columns.Add(dcname);
        dtShiftNotAllocated.Columns.Add(dcTitleName);
        dtShiftNotAllocated.Columns.Add(dcGender);
        DataRow dRowShiftNotAllocated;
        foreach (DataRow drEmpName in dsEmployee.Tables[0].Rows)
        {
            string strDay = "Day" + DateTime.Parse(dtFrom).Day + "Shift";
            ShiftCount = rptEmp.SelectShiftNotAllocatedEmployees(strDay, Convert.ToInt32(drEmpName["empAutoId"]), DateTime.Parse(dtFrom).Year, DateTime.Parse(dtFrom).Month);
            if (ShiftCount == 0)
            {
                dRowShiftNotAllocated = dtShiftNotAllocated.NewRow();
                dRowShiftNotAllocated["ShiftId"] = 0;
                dRowShiftNotAllocated["EmployeeId"] = Convert.ToInt32(drEmpName["empAutoId"]);
                dRowShiftNotAllocated["Employee_Code_Id"] = drEmpName["Employee_Id"];
                dRowShiftNotAllocated["Shift_shortName"] = "Not Allocated";
                dRowShiftNotAllocated["empname"] = drEmpName["empname"];
                dRowShiftNotAllocated["name"] = drEmpName["name"];
                dRowShiftNotAllocated["TitleName"] = drEmpName["TitleName"];
                dRowShiftNotAllocated["Gender"] = drEmpName["Gender"];
                dRowShiftNotAllocated.EndEdit();
                dtShiftNotAllocated.Rows.Add(dRowShiftNotAllocated);
            }
        }
        DataSet dsPermanentShift = new DataSet();
        dsPermanentShift = rptEmp.SelectPermanentShiftReport(dtFrom, Level, empId, employeeName, EmployeeCategory, EmployeeType, Convert.ToString(Session["UserGroupName"]), GradeLevel, strSwipeCard, Convert.ToInt16(ParentLevelid), Convert.ToInt32(Designation), Gender, shft, Convert.ToInt64(strEmpAutoId));
        DataSet dsTempShift = new DataSet();
        dsTempShift = rptEmp.SelectTempShiftReport(dtFrom, Level, empId, employeeName, EmployeeCategory, EmployeeType, Convert.ToString(Session["UserGroupName"]), GradeLevel, strSwipeCard, Convert.ToInt16(ParentLevelid), Convert.ToInt32(Designation), Gender, shft, Convert.ToInt64(strEmpAutoId));
        DataSet dsHeader = new DataSet();
        DataTable dt = new DataTable();
        if (Convert.ToInt16(ParentLevelid) != 0)
        {
            dt = rptEmp.getHeader(Convert.ToInt16(ParentLevelid));
            Session["Ses_rptHeader_Shift"] = dt;
        }
        else
        {
            Session["Ses_rptHeader_Shift"] = dt;
        }
        DataTable dtPermanentShift = new DataTable();
        if ((dsPermanentShift.Tables["Table"] == null || dsPermanentShift.Tables["Table"].Rows.Count == 0) && (dsTempShift != null || dsTempShift.Tables.Count != 0))
        {
            if (dtShiftNotAllocated.Rows.Count == 0)
            {
                blnCheckDataExits = false;
                MessagewithClose(rm.GetString("Alert_Thereisnorecord", ci));
                return;
            }
            else
            {
                if (dsTempShift.Tables.Count > 0 && dsTempShift.Tables[0].Rows.Count > 0)
                {
                    dsPermanentShift = dsTempShift;
                    dtPermanentShift = dsTempShift.Tables[0].Copy();
                }
                else if (dtShiftNotAllocated.Rows.Count == 0)
                {
                    blnCheckDataExits = false;
                    MessagewithClose(rm.GetString("Alert_Thereisnorecord", ci));
                    return;
                }
            }
        }
        else
        {
            dtPermanentShift = dsPermanentShift.Tables["Table"].Copy();
            foreach (DataRow dRow in dtPermanentShift.Rows)
            {
                if (Convert.ToInt32(dRow["ShiftId"]) == -1)
                {
                    dRow["Shift_ShortName"] = rm.GetString("lbl_Off", ci);
                }
                else if (Convert.ToInt32(dRow["ShiftId"]) == 0)
                {
                    dRow["Shift_ShortName"] = rm.GetString("Report_ShiftNotAllocated", ci);
                }
            }
        }
        //Check the  Temporary Shift Allocation table is Empty
        DataTable dtTempShift = new DataTable();
        if (dsTempShift.Tables["Table"] == null || dsTempShift.Tables["Table"].Rows.Count == 0)
        {
        }
        else
        {
            dtTempShift = dsTempShift.Tables["Table"].Copy();
            foreach (DataRow dRow in dtTempShift.Rows)
            {
                if (Convert.ToInt32(dRow["ShiftId"]) == -1)
                {
                    dRow["Shift_ShortName"] = rm.GetString("lbl_Off", ci);
                }
                else if (Convert.ToInt32(dRow["ShiftId"]) == 0)
                {
                    dRow["Shift_ShortName"] = rm.GetString("Report_ShiftNotAllocated", ci);
                }
            }
        }
        foreach (DataRow dPermanentShiftRow in dtPermanentShift.Rows)
        {
            foreach (DataRow dTempShiftRow in dtTempShift.Rows)
            {
                if (Convert.ToInt32(dTempShiftRow["EmployeeId"]) == Convert.ToInt32(dPermanentShiftRow["EmployeeId"]))
                {
                    if (Convert.ToInt32(dTempShiftRow["ShiftId"]) != 0)
                    {
                        dPermanentShiftRow["Shift_ShortName"] = dTempShiftRow["Shift_ShortName"];
                        dPermanentShiftRow["ShiftId"] = dTempShiftRow["ShiftId"];
                    }
                }
            }
        }
        DataRow dRowPermanentShiftRow;
        foreach (DataRow dTempShiftRow in dtTempShift.Rows)
        {
            dtPermanentShift.DefaultView.RowFilter = "EmployeeId=" + Convert.ToInt32(dTempShiftRow["EmployeeId"]);
            if (dtPermanentShift.DefaultView.Count == 0)
            {
                dRowPermanentShiftRow = dtPermanentShift.NewRow();
                dRowPermanentShiftRow["ShiftId"] = Convert.ToInt32(dTempShiftRow["ShiftId"]);
                dRowPermanentShiftRow["EmployeeId"] = Convert.ToInt32(dTempShiftRow["EmployeeId"]);
                dRowPermanentShiftRow["Employee_Code_Id"] = dTempShiftRow["Employee_Code_Id"];
                dRowPermanentShiftRow["Shift_shortName"] = dTempShiftRow["Shift_shortName"];
                dRowPermanentShiftRow["empname"] = dTempShiftRow["empname"];
                dRowPermanentShiftRow["name"] = dTempShiftRow["name"];
                dRowPermanentShiftRow["TitleName"] = dTempShiftRow["TitleName"];
                dRowPermanentShiftRow["Gender"] = dTempShiftRow["Gender"];
                dRowPermanentShiftRow.EndEdit();
                dtPermanentShift.Rows.Add(dRowPermanentShiftRow);
            }
        }
        //Add the link column
        dtPermanentShift.TableName = "Table";
        if (dtPermanentShift.Rows.Count == 0)
        {
            dtPermanentShift = dtShiftNotAllocated.Copy();
        }
        else
        {
            DataRow dRowPermanentShiftRowNotAllocated;
            foreach (DataRow dShiftNotAllocatedRow in dtShiftNotAllocated.Rows)
            {
                dtPermanentShift.DefaultView.RowFilter = "EmployeeId=" + Convert.ToInt32(dShiftNotAllocatedRow["EmployeeId"]);
                if (dtPermanentShift.DefaultView.Count == 0)
                {
                    dRowPermanentShiftRowNotAllocated = dtPermanentShift.NewRow();
                    dRowPermanentShiftRowNotAllocated["ShiftId"] = 0;
                    dRowPermanentShiftRowNotAllocated["EmployeeId"] = Convert.ToInt32(dShiftNotAllocatedRow["EmployeeId"]);
                    dRowPermanentShiftRowNotAllocated["Employee_Code_Id"] = dShiftNotAllocatedRow["Employee_Code_Id"];
                    dRowPermanentShiftRowNotAllocated["Shift_shortName"] = "Not Allocated";
                    dRowPermanentShiftRowNotAllocated["empname"] = dShiftNotAllocatedRow["empname"];
                    dRowPermanentShiftRowNotAllocated["name"] = dShiftNotAllocatedRow["name"];
                    dRowPermanentShiftRowNotAllocated["TitleName"] = dShiftNotAllocatedRow["TitleName"];
                    dRowPermanentShiftRowNotAllocated["Gender"] = dShiftNotAllocatedRow["Gender"];
                    dRowPermanentShiftRowNotAllocated.EndEdit();
                    dtPermanentShift.Rows.Add(dRowPermanentShiftRowNotAllocated);
                }
            }
        }
        DataTable dtHdr1 = GetReportHeader();
        dtHdr = dtHdr1;
        dtSource = dtPermanentShift;
        rptFileName = Getreportpath(rm.GetString("rptShift", ci));
        Session["Ses_dtHdr_Shift"] = dtHdr;
        Session["Ses_dtSource_Shift"] = dtSource;
        Session["ses_rptFileName_Shift"] = rptFileName;
    }
    /// <summary>
    /// Shift Allocation Report
    /// </summary>
    public void LoadEmployeeShiftAllocationReport()
    {
        DataSet dsShiftAllocation = new DataSet();
        DataTable dtTempShiftAllocation = new DataTable();
        //Create the datatable ,that holds the header information       
        if (Request.QueryString["ScheduleId"] != null)
        {
            dsShiftAllocation = rptEmp.SelectReportData(Filters, ReportName, ReportType);
        }
        else
        {
            if (Convert.ToString(Session["packageID"]) != "" && Convert.ToString(Session["packageID"]) == "158")
            {
                //Hotel Surguru
                dsShiftAllocation = rptEmp.SelectShiftAllocationReport_Surguru(dtFrom, dtTo, employeeName, Level, empId, EmployeeCategory, EmployeeType, Convert.ToString(Session["UserGroupName"]), GradeLevel, strSwipeCard, Convert.ToInt16(ParentLevelid), Convert.ToInt32(Designation), Gender, 0, Convert.ToInt64(strEmpAutoId));
            }
            else
            {
                dsShiftAllocation = rptEmp.SelectShiftAllocationReport(dtFrom, dtTo, employeeName, Level, empId, EmployeeCategory, EmployeeType, Convert.ToString(Session["UserGroupName"]), GradeLevel, strSwipeCard, Convert.ToInt16(ParentLevelid), Convert.ToInt32(Designation), Gender, 0, Convert.ToInt64(strEmpAutoId));
            }
            // Call to Temporary Shift Allocation function, it returns the data as DataTable
            dtTempShiftAllocation = TempShiftAllocation(dtFrom, dtTo, employeeName, Level, empId, EmployeeCategory, EmployeeType, Convert.ToString(Session["UserGroupName"]), GradeLevel, strSwipeCard, Convert.ToInt16(ParentLevelid), Convert.ToInt32(Designation), Gender);
        }
        DataSet dsHeader = new DataSet();
        DataTable dt = new DataTable();
        if (Convert.ToInt16(ParentLevelid) != 0)
        {
            dt = rptEmp.getHeader(Convert.ToInt16(ParentLevelid));
            Session["Ses_rptHeader_EmployeeShiftAllocation"] = dt;
        }
        else
        {
            Session["Ses_rptHeader_EmployeeShiftAllocation"] = dt;
        }
        DataTable dtSift = new DataTable();
        //Check the Empty table 
        if ((dsShiftAllocation.Tables["Table"] == null || dsShiftAllocation.Tables["Table"].Rows.Count == 0) && (dtTempShiftAllocation != null && dtTempShiftAllocation.Rows.Count != 0))
        {
            dtSift = dtTempShiftAllocation;
        }
        else if ((dsShiftAllocation.Tables["Table"] == null || dsShiftAllocation.Tables["Table"].Rows.Count == 0) && (dtTempShiftAllocation == null || dtTempShiftAllocation.Rows.Count == 0))
        {
            blnCheckDataExits = false;
            MessagewithClose(rm.GetString("Alert_Thereisnorecord", ci));
            return;
        }
        else
        {
            int fromDay = 0;
            int fromMonth = 0;
            int fromYear = 0;
            int toMonth = 0;
            int toDay = 0;
            int toYear = 0;
            DataTable dtmonthdayYear = new DataTable();
            dtmonthdayYear = rptEmp.GetDateMonthYear(dtFrom, dtTo);
            if (dtmonthdayYear.Rows.Count > 0)
            {
                fromDay = Convert.ToInt32(dtmonthdayYear.Rows[0][2]);
                fromMonth = Convert.ToInt32(dtmonthdayYear.Rows[0][1]);
                fromYear = Convert.ToInt32(dtmonthdayYear.Rows[0][0]);
                toMonth = Convert.ToInt32(dtmonthdayYear.Rows[1][1]);
                toDay = Convert.ToInt32(dtmonthdayYear.Rows[1][2]);
                toYear = Convert.ToInt32(dtmonthdayYear.Rows[1][0]);
            }
            //int fromDay = DateTime.Parse(dtFrom).Day;
            //int fromMonth = DateTime.Parse(dtFrom).Month;
            //int fromYear = DateTime.Parse(dtFrom).Year;
            //int toMonth = DateTime.Parse(dtTo).Month;
            //int toDay = DateTime.Parse(dtTo).Day;
            //int toYear = DateTime.Parse(dtTo).Year;
            int j = 0;
            DataTable dtShiftShortName = new DataTable();
            dtShiftShortName = rptEmp.GetShiftShortNameWithOutTime();
            for (int k = 0; k <= dsShiftAllocation.Tables[0].Columns.Count - 5; k++)
            {
                if (k == 0)
                {
                    dtSift.Columns.Add("Employee Name");
                }
                else if (k == 1)
                {
                    dtSift.Columns.Add("Employee Id");
                }
                else if (k == 2)
                {
                    dtSift.Columns.Add("Year");
                }
                else if (k == 3)
                {
                    dtSift.Columns.Add("Month");
                }
                else if (k == dsShiftAllocation.Tables[0].Columns.Count - 5)
                {
                    dtSift.Columns.Add("Gender");
                }
                else
                {
                    dtSift.Columns.Add(Convert.ToString((k - 3)));
                }
            }
            foreach (DataRow dr in dsShiftAllocation.Tables[0].Rows)
            {
                j = j + 1;
                dtSift.Rows.Add();
                for (int i = 0; i <= dsShiftAllocation.Tables[0].Columns.Count - 5; i++)
                {
                    if (i == 4 && Convert.ToInt32(dr["Month"]) == fromMonth)
                    {
                        if (Convert.ToInt32(dr["Year"]) != fromYear)
                        {
                        }
                        else
                        {
                            i = fromDay + 3;
                        }
                    }
                    if (i > 3 && i < dsShiftAllocation.Tables[0].Columns.Count - 5)
                    {
                        foreach (DataRow dRow in dtShiftShortName.Rows)
                        {
                            if (Convert.ToString(dr[i]) == Convert.ToString(dRow["Shift_Id"]))
                            {
                                dtSift.Rows[j - 1][i] = dRow["Shift_ShortName"];
                            }
                            else if (Convert.ToString(dr[i]) == "-1")
                            {
                                dtSift.Rows[j - 1][i] = rm.GetString("lbl_Off", ci);
                            }
                        }
                    }
                    else if (i == 3)
                    {
                        DateTimeFormatInfo dtfi = new CultureInfo("en-US", true).DateTimeFormat;
                        string temp = dtfi.GetMonthName(Convert.ToInt32(dr[i]));
                        dtSift.Rows[j - 1][i] = temp;
                    }
                    else if (i == dsShiftAllocation.Tables[0].Columns.Count - 5)
                    {
                        dtSift.Rows[j - 1][i] = dr["Gender"];
                    }
                    else
                    {
                        dtSift.Rows[j - 1][i] = dr[i];
                    }
                    if (toDay + 3 == i && Convert.ToInt32(dr["Month"]) == toMonth && Convert.ToInt32(dr["Year"]) == toYear)
                    {
                        i = dsShiftAllocation.Tables[0].Columns.Count - 6;
                    }
                }
            }
            //Check Temporary shift Exists or not 
            Boolean boolTempShiftExists = false;
            if (dtTempShiftAllocation != null)
            {
                foreach (DataRow dRowTempShift in dtTempShiftAllocation.Rows)
                {
                    boolTempShiftExists = false;
                    foreach (DataRow dRowPermanentShift in dtSift.Rows)
                    {
                        if (Convert.ToString(dRowTempShift["Employee Id"]) == Convert.ToString(dRowPermanentShift["Employee Id"]) && Convert.ToString(dRowTempShift["Year"]) == Convert.ToString(dRowPermanentShift["Year"]) && Convert.ToString(dRowTempShift["Month"]) == Convert.ToString(dRowPermanentShift["Month"]))
                        {
                            boolTempShiftExists = true;
                            for (int i = 0; i <= dtTempShiftAllocation.Columns.Count - 1; i++)
                            {
                                if (i > 3)
                                {
                                    if (Convert.ToString(dRowTempShift[i]) == "0" || Convert.ToString(dRowTempShift[i]) == "")
                                    {
                                    }
                                    else
                                    {
                                        dRowPermanentShift[i] = dRowTempShift[i];
                                    }
                                }
                            }
                        }
                    }
                    if (boolTempShiftExists == false)
                    {
                        DataRow dRowTemp;
                        dRowTemp = dRowTempShift;
                        dtSift.ImportRow(dRowTemp);
                    }
                }
            }
        }
        //Add the link column
        dtSift.TableName = "Table";
        DataTable dtHdr1 = GetReportHeader();
        dtHdr = dtHdr1;
        dtSource = dtSift;
        rptFileName = Server.MapPath(rm.GetString("shiftAllocationReport", ci));
        if (Convert.ToString(Session["packageID"]) != "")
            if (Convert.ToString(Session["packageID"]) == "158")
            {
                //Hotel Surguru
                rptFileName = Server.MapPath("Surguru/" + rm.GetString("shiftAllocationReport", ci));
            }
        Session["Ses_dtHdr_EmployeeShiftAllocation"] = dtHdr;
        Session["Ses_dtSource_EmployeeShiftAllocation"] = dtSource;
        Session["Ses_rptFileName_EmployeeShiftAllocation"] = rptFileName;
        if (Convert.ToString(Session["packageID"]) != "")
            if (Convert.ToString(Session["packageID"]) == "158")
            {
                //Hotel Surguru
                dtSourceShift = dsShiftAllocation.Tables[1];
                Session["Ses_dtSource2_EmployeeShiftAllocationtbl2"] = dtSourceShift;
            }
    }
    /// <summary>
    /// Employee Report
    /// </summary>
    public void LoadEmployeeDetailsReport()
    {
        if (Session["Export_ExcelData"] != null)
        {
            dsEmp = (DataSet)Session["Export_ExcelData"];
        }
        else
        {
            int expiryDays = 0;
            if (Convert.ToString(Request.QueryString["expiryDays"]) != "")
            {
                expiryDays = Convert.ToInt32(Request.QueryString["expiryDays"]);
            }
            dsEmp = rptEmp.SelectEmployee(dtFrom, dtTo, empId, shft, employeeName, Level, EmployeeCategory, EmployeeType, EmpStatus, Convert.ToString(Session["UserGroupName"]), GradeLevel, strSwipOpt, strSwipeCard, Convert.ToInt16(ParentLevelid), Convert.ToInt32(Designation), Gender, Convert.ToInt32(strEmpAutoId), expiryDays);
        }
        //Check the Empty table
        if (dsEmp.Tables["Table"] == null || dsEmp.Tables["Table"].Rows.Count == 0)
        {
            blnCheckDataExits = false;
            MessagewithClose(rm.GetString("Alert_Thereisnorecord", ci));
            return;
        }
        DataSet dsHeader = new DataSet();
        DataTable dt = new DataTable();
        if (Convert.ToInt16(ParentLevelid) != 0)
        {
            dt = rptEmp.getHeader(Convert.ToInt16(ParentLevelid));
            Session["Ses_rptHeader_EmployeeDetails"] = dt;
        }
        else
        {
            Session["Ses_rptHeader_EmployeeDetails"] = dt;
        }
        DataTable dtHdr1 = GetReportHeader();
        dtHdr = dtHdr1;
        dtSource = dsEmp.Tables[0];
        rptFileName = Server.MapPath(rm.GetString("rptEmployee", ci));
        Session["Ses_dtHdr_EmployeeDetails"] = dtHdr;
        Session["Ses_dtSource_EmployeeDetails"] = dtSource;
        Session["Ses_rptFileName_EmployeeDetails"] = rptFileName;
    }
    /// <summary>
    /// Document Expiry Report
    /// </summary>
    public void LoadDocumentExpiryReport()
    {
        dsEmp = rptEmp.SelectDocumentExpiry(dtFrom, dtTo, empId, shft, employeeName, Level, EmployeeCategory, EmployeeType, Convert.ToString(Session["UserGroupName"]), GradeLevel, strSwipeCard, Convert.ToInt16(ParentLevelid), Convert.ToInt32(Designation), Gender, Convert.ToInt32(strEmpAutoId));
        //Check the Empty table
        if (dsEmp.Tables["Table"] == null || dsEmp.Tables["Table"].Rows.Count == 0)
        {
            blnCheckDataExits = false;
            MessagewithClose(rm.GetString("Alert_Thereisnorecord", ci));
            return;
        }
        DataSet dsHeader = new DataSet();
        DataTable dt = new DataTable();
        if (Convert.ToInt16(ParentLevelid) != 0)
        {
            dt = rptEmp.getHeader(Convert.ToInt16(ParentLevelid));
            Session["Ses_rptHeader_DocumentExpiry"] = dt;
        }
        else
        {
            Session["Ses_rptHeader_DocumentExpiry"] = dt;
        }
        DataTable dtHdr1 = GetReportHeader();
        dtHdr = dtHdr1;
        dtSource = dsEmp.Tables[0];
        rptFileName = Server.MapPath(rm.GetString("rptDocExpiry", ci));
        Session["Ses_dtHdr_DocumentExpiry"] = dtHdr;
        Session["Ses_dtSource_DocumentExpiry"] = dtSource;
        Session["Ses_rptFileName_DocumentExpiry"] = rptFileName;
    }
    /// <summary>
    /// Audit Trial Report
    /// </summary>
    public void LoadAuditTrailReport()
    {
        dsEmp = rptEmp.SelectAuditTrailReport(dtFrom, dtTo, TableDescription, Operation);
        //Check the Empty table
        if (dsEmp.Tables["Table"] == null || dsEmp.Tables["Table"].Rows.Count == 0)
        {
            blnCheckDataExits = false;
            MessagewithClose(rm.GetString("Alert_Thereisnorecord", ci));
            return;
        }
        DataSet dsHeader = new DataSet();
        DataTable dt = new DataTable();
        if (Convert.ToInt16(ParentLevelid) != 0)
        {
            dt = rptEmp.getHeader(Convert.ToInt16(ParentLevelid));
            Session["Ses_rptHeader_AuditTrail"] = dt;
        }
        else
        {
            Session["Ses_rptHeader_AuditTrail"] = dt;
        }
        DataTable dtAuditTrail = new DataTable();
        dtAuditTrail = dsEmp.Tables["Table"].Copy();
        //Add the link column
        DataColumn dcLink = new DataColumn("Link", Type.GetType("System.Int32"));
        dtAuditTrail.Columns.Add(dcLink);
        for (int i = 0; i < dtAuditTrail.Rows.Count; i++)
        {
            dtAuditTrail.Rows[i]["Link"] = 1;
        }
        DataTable dtHdr1 = GetReportHeader();
        dtHdr = dtHdr1;
        dtSource = dtAuditTrail;
        rptFileName = Server.MapPath(rm.GetString("rptAuditTrail", ci));
        Session["Ses_dtHdr_AuditTrail"] = dtHdr;
        Session["Ses_dtSource_AuditTrail"] = dtSource;
        Session["Ses_rptFileName_AuditTrail"] = rptFileName;
    }
    /// <summary>
    /// Month Closure Report
    /// </summary>
    public void LoadMonthClosureReport()
    {
        dsEmp = rptEmp.SelectPayrollReport(Level, employeeName, MonthClosureId, empId, EmployeeCategory, EmployeeType, Convert.ToString(Session["UserGroupName"]), GradeLevel, strSwipeCard, Convert.ToInt16(ParentLevelid), Convert.ToInt32(Designation), Gender, Convert.ToInt32(strEmpAutoId));
        //Check the Empty table 
        if (dsEmp.Tables["Table"] == null || dsEmp.Tables["Table"].Rows.Count == 0)
        {
            blnCheckDataExits = false;
            MessagewithClose(rm.GetString("Alert_Thereisnorecord", ci));
            return;
        }
        DataSet dsHeader = new DataSet();
        DataTable dt = new DataTable();
        if (Convert.ToInt16(ParentLevelid) != 0)
        {
            dt = rptEmp.getHeader(Convert.ToInt16(ParentLevelid));
            Session["Ses_rptHeader_MonthClosure"] = dt;
        }
        else
        {
            Session["Ses_rptHeader_MonthClosure"] = dt;
        }
        DataTable dtHdr1 = GetReportHeader();
        dtHdr = dtHdr1;
        dtSource = dsEmp.Tables[0];
        if (Convert.ToString(Session["packageID"]) != "")
            if (Convert.ToString(Session["packageID"]) == "156") /*IFFCO_TimecheckV2.6*/
            {
                rptFileName = Getreportpath(rm.GetString("PayRollrpt", ci));
            }
            else
            {
                rptFileName = Server.MapPath(rm.GetString("PayRollrpt", ci));
            }
        Session["Ses_dtHdr_MonthClosure"] = dtHdr;
        Session["Ses_dtSource_MonthClosure"] = dtSource;
        Session["Ses_rptFileName_MonthClosure"] = rptFileName;
    }
    /// <summary>
    /// Year Closure Report
    /// </summary>
    public void LoadYearClosureReport()
    {
        dsEmp = rptEmp.SelectYearClosureReport(Level, employeeName, YearSettingsId, empId, EmployeeCategory, EmployeeType, Convert.ToString(Session["UserGroupName"]), GradeLevel, strSwipeCard, Convert.ToInt16(ParentLevelid), Convert.ToInt32(Designation), Gender, Convert.ToInt32(strEmpAutoId));
        if (dsEmp.Tables["Table"] == null || dsEmp.Tables["Table"].Rows.Count == 0)
        {
            blnCheckDataExits = false;
            MessagewithClose(rm.GetString("Alert_Thereisnorecord", ci));
            return;
        }
        DataSet dsHeader = new DataSet();
        DataTable dt = new DataTable();
        if (Convert.ToInt16(ParentLevelid) != 0)
        {
            dt = rptEmp.getHeader(Convert.ToInt16(ParentLevelid));
            Session["Ses_rptHeader_YearClosure"] = dt;
        }
        else
        {
            Session["Ses_rptHeader_YearClosure"] = dt;
        }
        DataTable dtHdr1 = GetReportHeader();
        dtHdr = dtHdr1;
        dtSource = dsEmp.Tables[0];
        rptFileName = Server.MapPath(rm.GetString("rptYearClosure", ci));
        Session["Ses_dtHdr_YearClosure"] = dtHdr;
        Session["Ses_dtSource_YearClosure"] = dtSource;
        Session["Ses_rptFileName_YearClosure"] = rptFileName;
    }
    /// <summary>
    /// Permission Report
    /// </summary>
    public void LoadPermissionReport()
    {

        if (Request.QueryString["ScheduleId"] != null)
        {
            dsEmp = rptEmp.SelectReportData(Filters, ReportName, ReportType);
        }
        else
        {
            dsEmp = rptEmp.SelectPermissionReport(dtFrom, dtTo, employeeName, Level, empId, EmployeeCategory, EmployeeType, Convert.ToString(Session["UserGroupName"]), GradeLevel, Status, strSwipeCard, Convert.ToInt16(ParentLevelid), Convert.ToInt32(Designation), Gender, Convert.ToInt64(strEmpAutoId));
        }
        //Check the Empty table 
        if (dsEmp.Tables["Table"] == null || dsEmp.Tables["Table"].Rows.Count == 0)
        {
            blnCheckDataExits = false;
            MessagewithClose(rm.GetString("Alert_Thereisnorecord", ci));
            return;
        }
        DataSet dsHeader = new DataSet();
        DataTable dt = new DataTable();
        if (Convert.ToInt16(ParentLevelid) != 0)
        {
            dt = rptEmp.getHeader(Convert.ToInt16(ParentLevelid));
            Session["Ses_rptHeader_Permission"] = dt;
        }
        else
        {
            Session["Ses_rptHeader_Permission"] = dt;
        }
        DataTable dtHdr1 = GetReportHeader();
        dtHdr = dtHdr1;
        dtSource = dsEmp.Tables[0];
        rptFileName = Server.MapPath(rm.GetString("PermissionReport", ci));
        Session["Ses_dtHdr_Permission"] = dtHdr;
        Session["Ses_dtSource_Permission"] = dtSource;
        //dtSource.WriteXmlSchema(@"E://Permission.xml");
        Session["Ses_rptFileName_Permission"] = rptFileName;
    }
    /// <summary>
    /// Manual Time Entry Report
    /// </summary>
    public void LoadManualTimeEntryReport()
    {
        if (Request.QueryString["ScheduleId"] != null)
        {
            dsEmp = rptEmp.SelectReportData(Filters, ReportName, ReportType);
        }
        else
        {
            dsEmp = rptEmp.SelectManualTimeEntryReport(employeeName, empId, dtFrom, dtTo, Level, EmployeeCategory, EmployeeType, Convert.ToString(Session["UserGroupName"]), GradeLevel, Status, strSwipeCard, Convert.ToInt16(ParentLevelid), Convert.ToInt32(Designation), Gender, Convert.ToInt32(strEmpAutoId));
        }
        if (dsEmp.Tables["Table"].Rows.Count == 0)
        {
            blnCheckDataExits = false;
            MessagewithClose(rm.GetString("Alert_Thereisnorecord", ci));
            return;
        }
        DataSet dsHeader = new DataSet();
        DataTable dt = new DataTable();
        if (Convert.ToInt16(ParentLevelid) != 0)
        {
            dt = rptEmp.getHeader(Convert.ToInt16(ParentLevelid));
            Session["Ses_rptHeader_ManualTimeEntry"] = dt;
        }
        else
        {
            Session["Ses_rptHeader_ManualTimeEntry"] = dt;
        }
        DataTable dtHdr1 = GetReportHeader();
        dtHdr = dtHdr1; ;
        dtSource = dsEmp.Tables[0];
        rptFileName = Getreportpath(rm.GetString("rptManualTimeEntry", ci));
        Session["Ses_dtHdr_ManualTimeEntry"] = dtHdr;
        Session["Ses_dtSource_ManualTimeEntry"] = dtSource;
        //dtSource.WriteXmlSchema(@"E://manualTimeEnry.xml");
        Session["Ses_rptFileName_ManualTimeEntry"] = rptFileName;
    }
    /// <summary> 
    /// OnDuty Entry Report
    /// </summary>
    public void LoadOnDutyEntryReport()
    {
        if (Request.QueryString["ScheduleId"] != null)
        {
            dsEmp = rptEmp.SelectReportData(Filters, ReportName, ReportType);
        }
        else
        {
            dsEmp = rptEmp.SelectOnDutyEntryReport(employeeName, empId, dtFrom, dtTo, Level, EmployeeCategory, EmployeeType, Convert.ToString(Session["UserGroupName"]), GradeLevel, Status, strSwipeCard, Convert.ToInt16(ParentLevelid), Convert.ToInt32(Designation), Gender, Convert.ToInt32(strEmpAutoId));
        }
        if (dsEmp.Tables["Table"].Rows.Count == 0)
        {
            blnCheckDataExits = false;
            MessagewithClose(rm.GetString("Alert_Thereisnorecord", ci));
            return;
        }
        DataSet dsHeader = new DataSet();
        DataTable dt = new DataTable();
        if (Convert.ToInt16(ParentLevelid) != 0)
        {
            dt = rptEmp.getHeader(Convert.ToInt16(ParentLevelid));
            Session["Ses_rptHeader_OnDutyEntry"] = dt;
        }
        else
        {
            Session["Ses_rptHeader_OnDutyEntry"] = dt;
        }
        DataTable dtHdr1 = GetReportHeader();
        dtHdr = dtHdr1; ;
        dtSource = dsEmp.Tables[0];
        rptFileName = Server.MapPath(rm.GetString("rptOnDutyEntry", ci));
        Session["Ses_dtHdr_OnDutyEntry"] = dtHdr;
        Session["Ses_dtSource_OnDutyEntry"] = dtSource;
        //dtSource.WriteXmlSchema(@"E://OnDuty.xml");
        Session["Ses_rptFileName_OnDutyEntry"] = rptFileName;
    }
    /// <summary>
    /// Shift Not Allocation Report
    /// </summary>
    public void LoadShiftNotAllocatedReport()
    {
        DataSet dsHeader = new DataSet();
        DataTable dt = new DataTable();
        if (Convert.ToInt16(ParentLevelid) != 0)
        {
            dt = rptEmp.getHeader(Convert.ToInt16(ParentLevelid));
            Session["Ses_rptHeader_ShiftNotAllocated"] = dt;
        }
        else
        {
            Session["Ses_rptHeader_ShiftNotAllocated"] = dt;
        }
        DataSet dsShiftNotAllocated = new DataSet();
        if (Request.QueryString["ScheduleId"] != null)
        {
            dsShiftNotAllocated = rptEmp.SelectReportData(Filters, ReportName, ReportType);
        }
        else
        {
            dsShiftNotAllocated = rptEmp.SelectNotAllocationReport(dtFrom, dtTo, employeeName, Level, empId, EmployeeCategory, EmployeeType, Convert.ToString(Session["UserGroupName"]), GradeLevel, strSwipeCard, Convert.ToInt16(ParentLevelid), Convert.ToInt32(Designation), Gender, Convert.ToInt64(strEmpAutoId));
        }
        if (dsShiftNotAllocated.Tables[0].Rows.Count <= 0)
        {
            blnCheckDataExits = false;
            MessagewithClose(rm.GetString("Alert_Thereisnorecord", ci));
            return;
        }
        DataTable dtHdr1 = GetReportHeader();
        dtHdr = dtHdr1;
        dtSource = dsShiftNotAllocated.Tables[0];
        rptFileName = Server.MapPath(rm.GetString("shiftNotAllocatedReport", ci));
        Session["Ses_dtHdr_ShiftNotAllocated"] = dtHdr;
        Session["Ses_dtSource_ShiftNotAllocated"] = dtSource;
        Session["Ses_rptFileName_ShiftNotAllocated"] = rptFileName;
    }
    public void LoadContinuosWorkingReport()
    {
        DataSet dsEmp;
        Normal = (Request.QueryString["Normal"]).ToString();

        dsEmp = rptEmp.SelectContinuosWokring(dtFrom, Normal);

        // Check if the table is empty
        if (dsEmp.Tables["Table"] == null || dsEmp.Tables["Table"].Rows.Count == 0)
        {
            blnCheckDataExits = false;
            MessagewithClose(rm.GetString("Alert_Thereisnorecord", ci));
            return;
        }

        DataSet dsHeader = new DataSet();
        DataTable dt = new DataTable();

        if (Convert.ToInt16(ParentLevelid) != 0)
        {
            dt = rptEmp.getHeader(Convert.ToInt16(ParentLevelid));
            Session["Ses_rptHeader_ContinuosWorking"] = dt;
        }
        else
        {
            Session["Ses_rptHeader_ContinuosWorking"] = dt;
        }
        //dt.WriteXmlSchema(@"d://Continuos_WorkingHeader.xml");
        DataTable dtHdr1 = GetReportHeader();
        dtHdr = dtHdr1;
        dtSource = dsEmp.Tables[0];
        //dtHdr.WriteXmlSchema(@"d://Continuos_WorkingHeaderTable.xml");
        if (Normal == "True" || Request.QueryString["ScheduleId"] != null)
        {
            rptFileName = Getreportpath(rm.GetString("ContinuosWorking", ci));
        }
        else
        {
            rptFileName = Server.MapPath(rm.GetString("ContinuosWorking", ci));
        }
        //dtSource.WriteXmlSchema(@"d://Continuos_Working.xml");
        Session["Ses_dtHdr_ContinuosWorking"] = dtHdr;
        Session["Ses_dtSource_ContinuosWorking"] = dtSource;
        Session["Ses_rptFileName_ContinuosWorking"] = rptFileName;
    }
    //Blocking_240Days
    public void LoadBlocking240DaysReport(string dtFromdates)
    {

        DataSet dsEmp;

        dsEmp = rptEmp.SelectBlocking_240Days(dtFromdates);

        // Check if the table is empty
        if (dsEmp.Tables["Table"] == null || dsEmp.Tables["Table"].Rows.Count == 0)
        {
            blnCheckDataExits = false;
            MessagewithClose(rm.GetString("Alert_Thereisnorecord", ci));
            return;
        }

        DataSet dsHeader = new DataSet();
        DataTable dt = new DataTable();

        if (Convert.ToInt16(ParentLevelid) != 0)
        {
            dt = rptEmp.getHeader(Convert.ToInt16(ParentLevelid));
            Session["Ses_rptHeader_Blocking_240Days"] = dt;
        }
        else
        {
            Session["Ses_rptHeader_Blocking_240Days"] = dt;
        }

        DataTable dtHdr1 = GetReportHeader();
        dtHdr = dtHdr1;
        dtSource = dsEmp.Tables[0];

        if (Normal == "True" || Request.QueryString["ScheduleId"] != null)
        {
            rptFileName = Getreportpath(rm.GetString("Blocking240DaysReport", ci));
        }
        else
        {
            rptFileName = Server.MapPath(rm.GetString("Blocking240DaysReport", ci));
        }
        //dtSource.WriteXmlSchema(@"d://Blocking_240Days.xml");
        Session["Ses_dtHdr_Blocking_240Days"] = dtHdr;
        Session["Ses_dtSource_Blocking_240Days"] = dtSource;
        Session["Ses_rptFileName_Blocking_240Days"] = rptFileName;
    }

    /// <summary>
    /// Absent Report
    /// </summary>
    public void LoadAbsentReport()
    {
        if (Request.QueryString["ScheduleId"] == null)
        {
            if (Convert.ToString(Session["Absent_Data"]) != "")
                dsEmp = (DataSet)(Session["Absent_Data"]);
            else
                dsEmp = rptEmp.SelectAbsent(dtFrom, dtTo, empId, shft, employeeName, Level, EmployeeCategory, EmployeeType, Convert.ToString(Session["UserGroupName"]), GradeLevel, strSwipeCard, Convert.ToInt16(ParentLevelid), Convert.ToInt32(Designation), Gender, absentType, Convert.ToInt64(strEmpAutoId), 0, ContAbsentDays);
        }
        else
        {
            dsEmp = rptEmp.SelectReportData(Filters, ReportName, ReportType);
        }
        //Check the Empty table
        if (dsEmp.Tables["Table"] == null || dsEmp.Tables["Table"].Rows.Count == 0)
        {
            blnCheckDataExits = false;
            MessagewithClose(rm.GetString("Alert_Thereisnorecord", ci));
            return;
        }
        DataSet dsHeader = new DataSet();
        DataTable dt = new DataTable();
        if (Convert.ToInt16(ParentLevelid) != 0)
        {
            dt = rptEmp.getHeader(Convert.ToInt16(ParentLevelid));
            Session["Ses_rptHeader_Absentees"] = dt;
        }
        else
        {
            Session["Ses_rptHeader_Absentees"] = dt;
        }
        DataTable dtHdr1 = GetReportHeader();
        dtHdr = dtHdr1;
        dtSource = dsEmp.Tables[0];
        if (Normal == "True" || Request.QueryString["ScheduleId"] != null)
            rptFileName = Getreportpath(rm.GetString("absentReport", ci));
        else
            rptFileName = Server.MapPath(rm.GetString("rptAbsentGraph", ci));
        Session["Ses_dtHdr_Absentees"] = dtHdr;
        Session["Ses_dtSource_Absentees"] = dtSource;
        Session["Ses_rptFileName_Absentees"] = rptFileName;
    }
    #region LoadLessHoursWorkedReport()
    public void LoadLessHoursWorkedReport()
    {
        if (Request.QueryString["ScheduleId"] != null)
        {
            dsEmp = rptEmp.SelectReportData(Filters, ReportName, ReportType);
        }
        else
        {
            dsEmp = rptEmp.SelectLessHoursWorkedReport(empId, dtFrom, dtTo, employeeName, shft, EmployeeCategory, EmployeeType,
                Convert.ToString(Session["UserGroupName"]), GradeLevel, strSwipeCard, Convert.ToInt16(ParentLevelid),
                Convert.ToInt32(Designation), Gender, SummaryOrDetail, Convert.ToInt64(strEmpAutoId));
        }
        if (dsEmp.Tables["Table"] == null || dsEmp.Tables["Table"].Rows.Count == 0)
        {
            blnCheckDataExits = false;
            MessagewithClose(rm.GetString("Alert_Thereisnorecord", ci));
            return;
        }
        DataSet dsHeader = new DataSet();
        DataTable dt = new DataTable();
        if (Convert.ToInt16(ParentLevelid) != 0)
        {
            dt = rptEmp.getHeader(Convert.ToInt16(ParentLevelid));
            Session["Ses_rptHeader_LessHoursWorked"] = dt;
        }
        else
        {
            Session["Ses_rptHeader_LessHoursWorked"] = dt;
        }
        DataTable dtHdr1 = GetReportHeader();
        dtHdr = dtHdr1;
        dtSource = dsEmp.Tables[0];
        if (SummaryOrDetail == "D")
        {
            rptFileName = Server.MapPath(rm.GetString("rptLessHoursWorked", ci));
        }
        else
        {
            rptFileName = Server.MapPath(rm.GetString("rptLessHoursWorked_Summary", ci));
        }
        Session["Ses_dtHdr_LessHoursWorked"] = dtHdr;
        Session["Ses_dtSource_LessHoursWorked"] = dtSource;
        Session["Ses_rptFileName_LessHoursWorked"] = rptFileName;
    }
    /// <summary>
    /// Added by Manjula.P on 09-Jan-2014 for loading countfactor working days count : New development report
    /// </summary>
    public void LoadCountfactorWorkingdays()
    {
        if (Request.QueryString["ScheduleId"] != null)
        {
            dsEmp = rptEmp.SelectReportData(Filters, ReportName, ReportType);
        }
        else
        {
            dsEmp = rptEmp.SelectCountfactorWorkingdays(employeeName, empId, dtFrom, dtTo, Level, EmployeeCategory, EmployeeType,
                Convert.ToString(Session["UserGroupName"]), GradeLevel, strSwipeCard,
                Convert.ToInt16(ParentLevelid), Convert.ToInt32(Designation), Gender, Convert.ToInt32(strEmpAutoId));
        }
        dtSource = dsEmp.Tables[0];
        rptFileName = Server.MapPath(rm.GetString("rptCountfactorWorkingDays", ci));
        Session["Ses_dtSource_CountfactorWorkingdays"] = dtSource;
        Session["Ses_rptFileName_CountfactorWorkingdays"] = rptFileName;
        DataTable dt = new DataTable();
        if (Convert.ToInt16(ParentLevelid) != 0)
        {
            dt = rptEmp.getHeader(Convert.ToInt16(ParentLevelid));
            Session["Ses_rptHeader_CountfactorWorkingdays"] = dt;
        }
        else
        {
            Session["Ses_rptHeader_CountfactorWorkingdays"] = dt;
        }
        DataTable dtHdr1 = GetReportHeader();
        dtHdr = dtHdr1;
        Session["Ses_dtHdr_CountfactorWorkingdays"] = dtHdr;
        if (dsEmp.Tables["Table"] == null || dsEmp.Tables["Table"].Rows.Count == 0)
        {
            blnCheckDataExits = false;
            MessagewithClose(rm.GetString("Alert_Thereisnorecord", ci));
            return;
        }
    }
    private DataTable getDTImage()
    {
        DataTable dtImages = new DataTable();
        dtImages.Columns.Add(new DataColumn("logo", Type.GetType("System.Byte[]")));
        dtImages.Columns.Add(new DataColumn("name", Type.GetType("System.String")));
        dtImages.Columns.Add(new DataColumn("city", Type.GetType("System.String")));
        dtImages.TableName = "dt_Logo";
        return dtImages;
    }
    private DataTable LoadImages(DataTable dtImg, DataTable dtOrg)
    {
        DataRow dr = dtImg.NewRow();
        byte[] bteLogo = (byte[])dtOrg.Rows[0]["logo"];
        MemoryStream stream = new MemoryStream(bteLogo);
        System.Drawing.Image img = System.Drawing.Image.FromStream(stream);
        dr["logo"] = bteLogo;
        dr["name"] = Convert.ToString(dtOrg.Rows[0]["name"]);
        dr["city"] = Convert.ToString(dtOrg.Rows[0]["city"]);
        dtImg.Rows.Add(dr);
        return dtImg;
    }
    #endregion
    /// <summary>
    /// Employee History Report
    /// </summary>
    public void LoadEmployeeHistoryReport()
    {
        if (Convert.ToString(Session["Session_ActiveLanguage"]) == "Resources.Resource_EN")
        {
            dsEmp = rptEmp.SelectEmployeeHistory(dtFrom, dtTo, empId, shft, employeeName, Level, EmployeeCategory, EmployeeType, Convert.ToString(Session["UserGroupName"]), GradeLevel, strSwipeCard, Convert.ToInt16(ParentLevelid), Convert.ToInt32(Designation), Gender, Convert.ToInt32(strEmpAutoId));
        }
        else if (Convert.ToString(Session["Session_ActiveLanguage"]) == "Resources.Resource_AR")
        {
            dsEmp = rptEmp.SelectEmployeeHistory_Arabic(dtFrom, dtTo, empId, shft, employeeName, Level, EmployeeCategory, EmployeeType, Convert.ToString(Session["UserGroupName"]), GradeLevel, strSwipeCard, Convert.ToInt16(ParentLevelid), Convert.ToInt32(Designation), Gender, Convert.ToInt32(strEmpAutoId));
        }
        //Check the Empty table
        if (dsEmp.Tables["Table"] == null || dsEmp.Tables["Table"].Rows.Count == 0)
        {
            blnCheckDataExits = false;
            MessagewithClose(rm.GetString("Alert_Thereisnorecord", ci));
            return;
        }
        DataSet dsHeader = new DataSet();
        DataTable dt = new DataTable();
        if (Convert.ToInt16(ParentLevelid) != 0)
        {
            dt = rptEmp.getHeader(Convert.ToInt16(ParentLevelid));
            Session["Ses_rptHeader_EmployeeHistory"] = dt;
        }
        else
        {
            Session["Ses_rptHeader_EmployeeHistory"] = dt;
        }
        DataTable dtHdr1 = GetReportHeader();
        dtHdr = dtHdr1;
        dtSource = dsEmp.Tables[0];
        rptFileName = Server.MapPath(rm.GetString("rptEmployeeHistory", ci));
        Session["Ses_dtHdr_EmployeeHistory"] = dtHdr;
        Session["Ses_dtSource_EmployeeHistory"] = dtSource;
        Session["Ses_rptFileName_EmployeeHistory"] = rptFileName;
    }
    /// <summary>
    /// Employee In Out Report
    /// </summary>
    public void LoadInOutReport()
    {
        if (Session["EmployeeInOutData"] != null)
        {
            DataTable dtEmployeeInOut = (DataTable)Session["EmployeeInOutData"];
            dsEmp.Tables.Add(dtEmployeeInOut.Copy());
        }
        else
        {
            dsEmp = rptEmp.EmployeeInOutDetails(empId, dtFrom, dtTo, employeeName, shft, EmployeeCategory, EmployeeType, Convert.ToString(Session["UserGroupName"]), GradeLevel, strSwipeCard, Convert.ToInt16(ParentLevelid), Convert.ToInt32(Designation), Gender, Convert.ToInt32(strEmpAutoId));
        }
        if (dsEmp.Tables["Table"].Rows.Count == 0)
        {
            blnCheckDataExits = false;
            MessagewithClose(rm.GetString("Alert_Thereisnorecord", ci));
            return;
        }
        DataSet dsHeader = new DataSet();
        DataTable dt = new DataTable();
        if (Convert.ToInt16(ParentLevelid) != 0)
        {
            dt = rptEmp.getHeader(Convert.ToInt16(ParentLevelid));
            Session["Ses_rptHeader_InOutReport"] = dt;
        }
        else
        {
            Session["Ses_rptHeader_InOutReport"] = dt;
        }
        DataTable dtHdr1 = GetReportHeader();
        dtHdr = dtHdr1;
        dtSource = dsEmp.Tables[0];
        rptFileName = Server.MapPath(rm.GetString("EmployeeInOut_ReportFile", ci));
        Session["Ses_dtHdr_InOutReport"] = dtHdr;
        Session["Ses_dtSource_InOutReport"] = dtSource;
        Session["Ses_rptFileName_InOutReport"] = rptFileName;
    }
    /// <summary>
    /// All Swipes Report
    /// </summary>
    public void LoadAllSwipesReport()
    {
        if (Request.QueryString["ScheduleId"] != null)
        {
            dsEmp = rptEmp.SelectReportData(Filters, ReportName, ReportType);
        }
        else
        {
            if (Session["AllSwipesData"] != null)
            {
                dsEmp = (DataSet)Session["AllSwipesData"];
            }
            else
            {
                blnCheckDataExits = false;
                MessagewithClose(rm.GetString("Alert_Thereisnorecord", ci));
                return;
            }
        }
        DataSet dsHeader = new DataSet();
        DataTable dt = new DataTable();
        if (Convert.ToInt16(ParentLevelid) != 0)
        {
            dt = rptEmp.getHeader(Convert.ToInt16(ParentLevelid));
            Session["Ses_rptHeader_AllSwipes"] = dt;
        }
        else
        {
            Session["Ses_rptHeader_AllSwipes"] = dt;
        }
        DataTable dtHdr1 = GetReportHeader();
        dtHdr = dtHdr1;
        dtSource = dsEmp.Tables[0];
        if (AllSwipesReportType == 3)
        {
            rptFileName = Server.MapPath(rm.GetString("rptAllSwipesWithOutMatched", ci));
        }
        else if (AllSwipesReportType != 1)
        {
            ///Veolia Customer file
            if (rptType == 1)
            {
                rptFileName = Server.MapPath(rm.GetString("rptAllSwipesCust", ci));
            }
            else
                rptFileName = Server.MapPath(rm.GetString("rptAllSwipes", ci));
        }
        else
        {
            rptFileName = Server.MapPath(rm.GetString("rptAllSwipesFirstAndLast", ci));
        }
        Session["Ses_dtHdr_AllSwipes"] = dtHdr;
        Session["Ses_dtSource_AllSwipes"] = dtSource;
        //dtSource.WriteXmlSchema(@"E://AllswipesBreakhours.xml");
        Session["Ses_rptFileName_AllSwipes"] = rptFileName;
    }
    /// <summary>
    /// Matched All Swipes Report
    /// </summary>
    public void LoadMatchedAllSwipesReport()
    {
        if (Session["AllSwipesData"] != null)
        {
            dsEmp = (DataSet)Session["AllSwipesData"];
        }
        else
        {
            blnCheckDataExits = false;
            MessagewithClose(rm.GetString("Alert_Thereisnorecord", ci));
            return;
        }
        DataSet dsHeader = new DataSet();
        DataTable dt = new DataTable();
        if (Convert.ToInt16(ParentLevelid) != 0)
        {
            dt = rptEmp.getHeader(Convert.ToInt16(ParentLevelid));
            Session["Ses_rptHeader_MatchedAllSwipes"] = dt;
        }
        else
        {
            Session["Ses_rptHeader_MatchedAllSwipes"] = dt;
        }
        DataTable dtHdr1 = GetReportHeader();
        dtHdr = dtHdr1;
        dtSource = dsEmp.Tables[0];
        if (AllSwipesReportType == 2)
            rptFileName = Server.MapPath(rm.GetString("RptMatchedMovementsEntry", ci));
        else
            rptFileName = Server.MapPath(rm.GetString("RptOtherMovementsEntry", ci));
        Session["Ses_dtHdr_MatchedAllSwipes"] = dtHdr;
        Session["Ses_dtSource_MatchedAllSwipes"] = dtSource;
        Session["Ses_rptFileName_MatchedAllSwipes"] = rptFileName;
    }
    /// <summary>
    /// Leave Policy Not Allocation Report
    /// </summary>
    public void LoadLeavePolicyNotAllocatedReport()
    {
        DataSet dsHeader = new DataSet();
        DataTable dt = new DataTable();
        if (Convert.ToInt16(ParentLevelid) != 0)
        {
            dt = rptEmp.getHeader(Convert.ToInt16(ParentLevelid));
            Session["Ses_rptHeader_LeavePolicyNotAllocated"] = dt;
        }
        else
        {
            Session["Ses_rptHeader_LeavePolicyNotAllocated"] = dt;
        }
        DataSet dsLeavePolicyNotAllocated = new DataSet();
        dsLeavePolicyNotAllocated = rptEmp.LeavePolicyNotAllocationReport(dtFrom, dtTo, employeeName, Level, empId, EmployeeCategory, EmployeeType, Convert.ToString(Session["UserGroupName"]), GradeLevel, strSwipeCard, Convert.ToInt16(ParentLevelid), Convert.ToInt32(Designation), Gender, Convert.ToInt32(strEmpAutoId));
        if (dsLeavePolicyNotAllocated.Tables[0].Rows.Count <= 0)
        {
            blnCheckDataExits = false;
            MessagewithClose(rm.GetString("Alert_Thereisnorecord", ci));
            return;
        }
        DataTable dtHdr1 = GetReportHeader();
        dtHdr = dtHdr1;
        dtSource = dsLeavePolicyNotAllocated.Tables[0];
        rptFileName = Server.MapPath(rm.GetString("LeavePolicyNotAllocatedReport", ci));
        Session["Ses_dtHdr_LeavePolicyNotAllocated"] = dtHdr;
        Session["Ses_dtSource_LeavePolicyNotAllocated"] = dtSource;
        Session["Ses_rptFileName_LeavePolicyNotAllocated"] = rptFileName;
    }
    public void LoadWeeklyWorkHours()
    {
        //Create the datatable ,that holds the header information
        string strReportType = Request.QueryString["ReportType"] == null ? "WeeklyWorkHours" : Request.QueryString["ReportType"].Replace(" ", "+");
        empName = employeeName;
        if (Request.QueryString["ScheduleId"] != null)
        {
            if (ReportType == "0")
            {
                strReportType = "DetailedReport";
            }
            else
            {
                strReportType = "SummaryReport";
            }
            dsEmp = rptEmp.SelectReportData(Filters, ReportName, ReportType);
        }
        else
        {
            dsEmp = rptEmp.SelectWeeklyWorkHours(empId, Level, dtFrom, dtTo, empName, EmployeeCategory, EmployeeType, Convert.ToString(Session["UserGroupName"]), Convert.ToString(Session["GradeLevel"]), strSwipeCard, Convert.ToInt16(ParentLevelid), shft, Designation, Gender, Convert.ToInt32(strEmpAutoId));
        }
        if (dsEmp.Tables["Table"] == null || dsEmp.Tables["Table"].Rows.Count == 0)
        {
            blnCheckDataExits = false;
            MessagewithClose(rm.GetString("Alert_Thereisnorecord", ci));
            return;
        }
        DataSet dsHeader = new DataSet();
        DataTable dt = new DataTable();
        if (Convert.ToInt16(ParentLevelid) != 0)
        {
            dt = rptEmp.getHeader(Convert.ToInt16(ParentLevelid));
            Session["Ses_rptHeader_Cumulative"] = dt;
        }
        else
        {
            Session["Ses_rptHeader_Cumulative"] = dt;
        }
        //End of Report Header
        DataTable dtWeekly = dsEmp.Tables["Table1"].Copy();
        DataTable dtSourceDetails;
        DataTable dtHdr1 = GetReportHeader();
        dtHdr = dtHdr1;
        dtSource = dtWeekly;
        dtSourceDetails = dsEmp.Tables["Table"].Copy();
        rptFileName = Server.MapPath(rm.GetString(strReportType == "SummaryReport" ? "WeeklyWorkHoursSummary" : "WeeklyWorkHours", ci));
        Session["Report_Type"] = strReportType;
        Session["Ses_dtHdr_Cumulative"] = dtHdr;
        Session["Ses_dtSource_Cumulative"] = dtSource;
        Session["Ses_rptFileName_Cumulative"] = rptFileName;
        Session["Ses_dtSourceDetails_Cumulative"] = dtSourceDetails;
    }
    public void LoadTimeSheetReport()
    {
        //Create the datatable ,that holds the header information
        string strReportType = Request.QueryString["ReportType"] == null ? "TimeSheet" : Request.QueryString["ReportType"].Replace(" ", "+");
        empName = employeeName;
        if (Request.QueryString["Status"] != null)
            Status = Convert.ToString(Request.QueryString["Status"]);
        dsEmp = rptEmp.TimeSheetReport
            (
            dtFrom,
            dtTo,
            employeeName,
            Level,
            empId,
            EmployeeCategory,
            EmployeeType,
            Convert.ToString(Session["UserGroupName"]),
            GradeLevel,
            strSwipeCard,
            Convert.ToInt16(ParentLevelid),
            Convert.ToInt32(Designation),
            Gender,
            Convert.ToInt32(strEmpAutoId),
            0,
            Status);
        if (dsEmp.Tables["Table"] == null || dsEmp.Tables["Table"].Rows.Count == 0)
        {
            blnCheckDataExits = false;
            MessagewithClose(rm.GetString("Alert_Thereisnorecord", ci));
            return;
        }
        DataSet dsHeader = new DataSet();
        DataTable dt = new DataTable();
        if (Convert.ToInt16(ParentLevelid) != 0)
        {
            dt = rptEmp.getHeader(Convert.ToInt16(ParentLevelid));
            Session["Ses_rptHeader_TimeSheet"] = dt;
        }
        else
        {
            Session["Ses_rptHeader_TimeSheet"] = dt;
        }
        //End of Report Header
        //DataTable dtWeekly = dsEmp.Tables["Table1"].Copy();
        DataTable dtSourceDetails;
        DataTable dtHdr1 = GetReportHeader();
        dtHdr = dtHdr1;
        //dtSource = dtWeekly;
        dtSourceDetails = dsEmp.Tables["Table"].Copy();
        rptFileName = Server.MapPath(rm.GetString("TimeSheetReport", ci));
        Session["Ses_dtHdr_TimeSheet"] = dtHdr;
        Session["Ses_dtSource_TimeSheet"] = dtSourceDetails;
        //dtSourceDetails.WriteXmlSchema(@"E://TimeSheetData.xml");
        Session["Ses_rptFileName_TimeSheet"] = rptFileName;
        //Session["Ses_dtSourceDetails_TimeSheet"] = dtSourceDetails;
    }
    public void RawData()
    {
        string employeeCategory = string.Empty, employeeType = string.Empty;
        DataTable dtRptHeader = new DataTable();
        DataTable dtHdr1 = new DataTable();
        dtHdr1 = hdrTable.CreateHeader();
        dtHdr1.TableName = "Header";
        //Add the Header information
        DataRow drHdr = dtHdr1.NewRow();
        drHdr["Link"] = 1;
        drHdr["Hdr1"] = "";
        drHdr["Hdr2"] = "";
        drHdr["Address1"] = "";
        drHdr["Address2"] = "";
        drHdr["ReportName"] = "Form 25 Report";
        string dtFrom = "", dtTo = "";
        string strMustorFromDate = string.Empty;
        string strMustorToDate = string.Empty;
        dtFrom = Convert.ToString(Request.QueryString["dtFrom"]);
        dtTo = Convert.ToString(Request.QueryString["dtTo"]);
        dtDate = rptEmp.GetDateMonth(dtFrom, dtTo);
        if (dtDate.Rows.Count > 0)
        {
            drHdr["FromDate"] = dtDate.Rows[0][0];
            drHdr["ToDate"] = dtDate.Rows[0][1];
        }
        else
        {
            drHdr["ToDate"] = "";
            drHdr["FromDate"] = "";
        }
        dtHdr1.Rows.Add(drHdr);
        string empName = "", empId = "";
        empName = Convert.ToString(Request.QueryString["EmpName"]);
        empId = Convert.ToString(Request.QueryString["empid"]);
        //dtHdr1.Rows.Add(drHdr);
        if (Convert.ToString(Request.QueryString["EmpCategory"]) != "-Select-" && Convert.ToString(Request.QueryString["EmpCategory"]) != "")
        {
            employeeCategory = Convert.ToString(Request.QueryString["EmpCategory"]);
        }
        else
        {
            employeeCategory = string.Empty;
        }
        if (Convert.ToString(Request.QueryString["EmpType"]) != "-Select-" && Convert.ToString(Request.QueryString["EmpType"]) != "")
        {
            employeeType = Convert.ToString(Request.QueryString["EmpType"]);
        }
        else
        {
            employeeType = string.Empty;
        }
        DataSet dsHeader = new DataSet();
        DataTable dt = new DataTable();
        if (Convert.ToInt16(ParentLevelid) != 0)
        {
            dt = rptEmp.getHeader(Convert.ToInt16(ParentLevelid));
            Session["Ses_rptHeader_RawData"] = dt;
        }
        else
        {
            Session["Ses_rptHeader_RawData"] = dt;
        }
        DataSet dsRawData = new DataSet();
        DataTable dtRaw = new DataTable();
        if (Request.QueryString["ScheduleId"] != null)
        {
            dsRawData = rptEmp.SelectReportData(Filters, ReportName, ReportType);
            dtRaw = dsRawData.Tables["Table"].Copy();
            rptFileName = Server.MapPath(rm.GetString("ReportFile_RawData", ci));
        }
        else
        {
            if (RawDataDashboard == 1)
            {
                dsRawData = rptEmp.RawData(dtFrom, dtTo, empId, employeeName, Convert.ToString(Session["UserGroupName"]), Convert.ToInt16(ParentLevelid), EmployeeCategory, EmployeeType, Convert.ToInt32(Designation), Gender, ProcessType, Convert.ToInt32(strEmpAutoId), DeviceId);
                dtRaw = dsRawData.Tables["Table"].Copy();
                rptFileName = Server.MapPath(rm.GetString("ReportFile_RawData", ci));  //calls RptRawData.rpt
            }
            else
            {
                dsRawData = rptEmp.RawDataDashBoard(dtFrom, dtTo, empId, employeeName, Convert.ToString(Session["UserGroupName"]), Convert.ToInt16(ParentLevelid), EmployeeCategory, EmployeeType, Convert.ToInt32(Designation), Gender, Convert.ToInt32(strEmpAutoId));
                dtRaw = dsRawData.Tables["Table"].Copy();
                rptFileName = Server.MapPath("RptRawDataDashboard.rpt");
            }
        }
        dtHdr = dtHdr1;
        dtSource = dtRaw;
        Session["Ses_dtHdr_RawData"] = dtHdr;
        Session["Ses_dtSource_RawData"] = dtSource;
        Session["Ses_rptFileName_RawData"] = rptFileName;
        if (dsRawData.Tables["Table"] == null || dsRawData.Tables["Table"].Rows.Count == 0)
        {
            blnCheckDataExits = false;
            MessagewithClose(rm.GetString("Alert_Thereisnorecord", ci));
            return;
        }
    }
    public void RawData_Latest()
    {
        string employeeCategory = string.Empty, employeeType = string.Empty;
        DataTable dtRptHeader = new DataTable();
        DataTable dtHdr1 = new DataTable();
        dtHdr1 = hdrTable.CreateHeader();
        dtHdr1.TableName = "Header";
        //Add the Header information
        DataRow drHdr = dtHdr1.NewRow();
        drHdr["Link"] = 1;
        drHdr["Hdr1"] = "";
        drHdr["Hdr2"] = "";
        drHdr["Address1"] = "";
        drHdr["Address2"] = "";
        drHdr["ReportName"] = "Form 25 Report";
        string strMustorFromDate = string.Empty;
        string strMustorToDate = string.Empty;
        if (Request.QueryString["ScheduleId"] == null)
        {
            dtFrom = ""; dtTo = "";
            dtFrom = Convert.ToString(Request.QueryString["dtFrom"]);
            dtTo = Convert.ToString(Request.QueryString["dtTo"]);
        }
        dtDate = rptEmp.GetDateMonth(dtFrom, dtTo);
        if (dtDate.Rows.Count > 0)
        {
            drHdr["FromDate"] = dtDate.Rows[0][0];
            drHdr["ToDate"] = dtDate.Rows[0][1];
        }
        else
        {
            drHdr["ToDate"] = "";
            drHdr["FromDate"] = "";
        }
        dtHdr1.Rows.Add(drHdr);
        string empName = "", empId = "";
        empName = Convert.ToString(Request.QueryString["EmpName"]);
        empId = Convert.ToString(Request.QueryString["empid"]);
        //dtHdr1.Rows.Add(drHdr);
        if (Convert.ToString(Request.QueryString["EmpCategory"]) != "-Select-" && Convert.ToString(Request.QueryString["EmpCategory"]) != "")
        {
            employeeCategory = Convert.ToString(Request.QueryString["EmpCategory"]);
        }
        else
        {
            employeeCategory = string.Empty;
        }
        if (Convert.ToString(Request.QueryString["EmpType"]) != "-Select-" && Convert.ToString(Request.QueryString["EmpType"]) != "")
        {
            employeeType = Convert.ToString(Request.QueryString["EmpType"]);
        }
        else
        {
            employeeType = string.Empty;
        }
        DataSet dsHeader = new DataSet();
        DataTable dt = new DataTable();
        if (Convert.ToInt16(ParentLevelid) != 0)
        {
            dt = rptEmp.getHeader(Convert.ToInt16(ParentLevelid));
            Session["Ses_rptHeader_RawData_Latest"] = dt;
        }
        else
        {
            Session["Ses_rptHeader_RawData_Latest"] = dt;
        }
        DataSet dsRawData = new DataSet();
        DataTable dtRaw = new DataTable();
        if (Request.QueryString["ScheduleId"] != null)
        {
            dsRawData = rptEmp.SelectReportData(Filters, ReportName, ReportType);
            dtRaw = dsRawData.Tables["Table"].Copy();
            rptFileName = Server.MapPath(rm.GetString("ReportFile_RawDataLatest", ci));
        }
        else
        {
            if (RawDataDashboard == 1)
            {
                dsRawData = rptEmp.RawData(dtFrom, dtTo, empId, employeeName, Convert.ToString(Session["UserGroupName"]), Convert.ToInt16(ParentLevelid), EmployeeCategory, EmployeeType, Convert.ToInt32(Designation), Gender, ProcessType, Convert.ToInt32(strEmpAutoId), DeviceId);
                dtRaw = dsRawData.Tables["Table"].Copy();
                rptFileName = Server.MapPath(rm.GetString("ReportFile_RawDataLatest", ci)); //rptRawDataLatestPunch.rpt comes for product
            }
            else
            {
                dsRawData = rptEmp.RawDataDashBoard(dtFrom, dtTo, empId, employeeName, Convert.ToString(Session["UserGroupName"]), Convert.ToInt16(ParentLevelid), EmployeeCategory, EmployeeType, Convert.ToInt32(Designation), Gender, Convert.ToInt32(strEmpAutoId));
                dtRaw = dsRawData.Tables["Table"].Copy();
                rptFileName = Server.MapPath(rm.GetString("ReportFile_RptRawDataDashboard", ci));
            }
        }
        dtHdr = dtHdr1;
        dtSource = dtRaw;
        Session["Ses_dtHdr_RawData_Latest"] = dtHdr;
        Session["Ses_dtSource_RawData_Latest"] = dtSource;
        Session["Ses_rptFileName_RawData_Latest"] = rptFileName;
        if (dsRawData.Tables["Table"] == null || dsRawData.Tables["Table"].Rows.Count == 0)
        {
            blnCheckDataExits = false;
            MessagewithClose(rm.GetString("Alert_Thereisnorecord", ci));
            return;
        }
    }
    /// <summary>
    /// Summary Report
    /// </summary>
    public void LoadSummaryReport()
    {
        DataSet dsHeader = new DataSet();
        DataTable dt = new DataTable();
        if (Convert.ToInt16(ParentLevelid) != 0)
        {
            dt = rptEmp.getHeader(Convert.ToInt16(ParentLevelid));
            Session["Ses_rptHeader_Summary"] = dt;
        }
        else
        {
            Session["Ses_rptHeader_Summary"] = dt;
        }
        DataSet dsSummaryReport = new DataSet();
        if (Request.QueryString["ScheduleId"] != null)
        {
            dsSummaryReport = rptEmp.SelectReportData(Filters, ReportName, ReportType);
            rptFileName = Server.MapPath(rm.GetString("SummaryReport", ci));
            DataTable dtShift = new DataTable();
            dtShift = dsSummaryReport.Tables[1];
            Session["Ses_dtSource_SummaryShift"] = dtShift;
        }
        else
        {
            if (ReportType == "SummaryReport")
            {
                dsSummaryReport = rptEmp.SelectSummaryReport(dtFrom, Convert.ToString(Session["UserGroupName"]), Convert.ToInt16(ParentLevelid), shft, 1, Convert.ToInt32(strEmpAutoId));
                rptFileName = Server.MapPath(rm.GetString("SummaryReport", ci));
                DataTable dtShift = new DataTable();
                dtShift = dsSummaryReport.Tables[1];
                Session["Ses_dtSource_SummaryShift"] = dtShift;
            }
            else if (ReportType == "DetailsReport")
            {
                dsSummaryReport = rptEmp.SelectDetailsReport(dtFrom, Convert.ToString(Session["UserGroupName"]), Convert.ToInt16(ParentLevelid), shft, Convert.ToInt32(strEmpAutoId));
                rptFileName = Server.MapPath(rm.GetString("DetailsReport", ci));
            }
        }
        if (dsSummaryReport.Tables[0].Rows.Count <= 0)
        {
            blnCheckDataExits = false;
            MessagewithClose(rm.GetString("Alert_Thereisnorecord", ci));
            return;
        }
        DataTable dtHdr1 = GetReportHeader();
        dtHdr = dtHdr1;
        dtSource = dsSummaryReport.Tables[0];
        Session["Ses_dtHdr_Summary"] = dtHdr;
        Session["Ses_dtSource_Summary"] = dtSource;
        Session["Ses_rptFileName_Summary"] = rptFileName;
    }
    /// <summary>
    /// Report loading
    /// </summary>
    /// <param name="strReportName"></param>
    public void LoadReport(string strReportName)
    {
        DataTable dtMonthlyAttendanceData2 = new DataTable();
        //if (Convert.ToString(Session["Session_ActiveLanguage"]) != "Resources.Resource_AR")
        //{
        if (strReportName != "Leave" && strReportName != "UnPlanedLeaveReport" && strReportName != "DeviationWorkHours")
        {
            ParameterFields pfFields = new ParameterFields();
            ParameterField pfField = new ParameterField();
            ParameterDiscreteValue dis = new ParameterDiscreteValue();
            pfField.Name = "DtFormat";
            dis.Value = Convert.ToString(Session["MDateFormat"]);
            pfField.CurrentValues.Add(dis);
            pfFields.Add(pfField);
            //Below code is used for TimeFormat changes in Reports
            ParameterField pfTimeFormat = new ParameterField();
            ParameterDiscreteValue disTimeFormat = new ParameterDiscreteValue();
            pfTimeFormat.Name = "TimeFormat";
            disTimeFormat.Value = Convert.ToString(Session["MTimeFormat"]);
            pfTimeFormat.CurrentValues.Add(disTimeFormat);
            pfFields.Add(pfTimeFormat);
            rptViewer.ParameterFieldInfo = pfFields;
        }
        //}
        DataTable dt7 = new DataTable();
        if (strReportName == "EmployeeInOut")
        {
            dt7 = Session["sessTable3"] as DataTable;
            if (strReportType != "Summary")
            {
                if (Convert.ToString(Session["strReportType"]) != string.Empty)
                {
                    ParameterFields pfFields = new ParameterFields();
                    ParameterField pfField = new ParameterField();
                    ParameterDiscreteValue dis = new ParameterDiscreteValue();
                    pfField.Name = "DtFormat";
                    dis.Value = Convert.ToString(Session["MDateFormat"]);
                    pfField.CurrentValues.Add(dis);
                    pfFields.Add(pfField);
                    ParameterField pfFieldFrodate = new ParameterField();
                    ParameterDiscreteValue disFromDate = new ParameterDiscreteValue();
                    pfFieldFrodate.Name = "FromDate";
                    if (dtHdr != null)
                    {
                        disFromDate.Value = dtHdr.Rows[0]["FromDate"];
                    }
                    pfFieldFrodate.CurrentValues.Add(disFromDate);
                    pfFields.Add(pfFieldFrodate);
                    //todate
                    ParameterField pfFieldToDate = new ParameterField();
                    ParameterDiscreteValue disToDate = new ParameterDiscreteValue();
                    pfFieldToDate.Name = "ToDate";
                    if (dtHdr != null)
                    {
                        disToDate.Value = dtHdr.Rows[0]["ToDate"];
                    }
                    pfFieldToDate.CurrentValues.Add(disToDate);
                    pfFields.Add(pfFieldToDate);
                    ParameterField pfDisplay = new ParameterField();
                    ParameterDiscreteValue disDisplay = new ParameterDiscreteValue();
                    pfDisplay.Name = "Display";
                    disDisplay.Value = Convert.ToString(Session["strReportType"]);
                    pfDisplay.CurrentValues.Add(disDisplay);
                    pfFields.Add(pfDisplay);
                    rptViewer.ParameterFieldInfo = pfFields;
                }
            }
            dtSource = Session["SessTable2"] as DataTable;
        }
        switch (strReportName)
        {
            case "NearestShift":
                if (Session["Ses_rptFileName_NearestShift"] != null)
                {
                    rptFileName = Convert.ToString(Session["Ses_rptFileName_NearestShift"]);
                }
                if (Session["Ses_dtHdr_NearestShift"] != null)
                {
                    dtHdr = (DataTable)Session["Ses_dtHdr_NearestShift"];
                }
                if (Session["Ses_dtSource_NearestShift"] != null)
                {
                    dtSource = (DataTable)Session["Ses_dtSource_NearestShift"];
                }
                if (Session["Ses_rptHeader_NearestShift"] != null)
                {
                    rptHeader = (DataTable)Session["Ses_rptHeader_NearestShift"];
                }
                break;
            case "DailyDeviation":
                if (Session["Ses_rptFileName_DailyDeviation"] != null)
                {
                    rptFileName = Convert.ToString(Session["Ses_rptFileName_DailyDeviation"]);
                }
                if (Session["Ses_dtHdr_DailyDeviation"] != null)
                {
                    dtHdr = (DataTable)Session["Ses_dtHdr_DailyDeviation"];
                }
                if (Session["Ses_dtSource_DailyDeviation"] != null)
                {
                    dtSource = (DataTable)Session["Ses_dtSource_DailyDeviation"];
                }
                if (Session["Ses_rptHeader_DailyDeviation"] != null)
                {
                    rptHeader = (DataTable)Session["Ses_rptHeader_DailyDeviation"];
                }
                break;
            case "DeviationWorkHours":
                if (Session["Ses_rptFileName_Deviation"] != null)
                {
                    rptFileName = Convert.ToString(Session["Ses_rptFileName_Deviation"]);
                }
                if (Session["Ses_dtHdr_Deviation"] != null)
                {
                    dtHdr = (DataTable)Session["Ses_dtHdr_Deviation"];
                }
                if (Session["Ses_dtSource_Deviation"] != null)
                {
                    dtSource = (DataTable)Session["Ses_dtSource_Deviation"];
                }
                if (Session["Ses_rptHeader_Deviation"] != null)
                {
                    rptHeader = (DataTable)Session["Ses_rptHeader_Deviation"];
                }
                break;
            case "CountfactorWorkingdays":
                if (Session["Ses_rptFileName_CountfactorWorkingdays"] != null)
                {
                    rptFileName = Convert.ToString(Session["Ses_rptFileName_CountfactorWorkingdays"]);
                }
                if (Session["Ses_dtHdr_CountfactorWorkingdays"] != null)
                {
                    dtHdr = (DataTable)Session["Ses_dtHdr_CountfactorWorkingdays"];
                }
                if (Session["Ses_dtSource_CountfactorWorkingdays"] != null)
                {
                    dtSource = (DataTable)Session["Ses_dtSource_CountfactorWorkingdays"];
                }
                if (Session["Ses_rptHeader_CountfactorWorkingdays"] != null)
                {
                    rptHeader = (DataTable)Session["Ses_rptHeader_CountfactorWorkingdays"];
                }
                break;
            case "GeneralMonthlyAttendance":
                if (Session["Ses_rptFileName_GeneralMonthlyAttendance"] != null)
                {
                    rptFileName = Convert.ToString(Session["Ses_rptFileName_GeneralMonthlyAttendance"]);
                }
                if (Session["Ses_dtHdr_GeneralMonthlyAttendance"] != null)
                {
                    dtHdr = (DataTable)Session["Ses_dtHdr_GeneralMonthlyAttendance"];
                }
                if (Session["Ses_dtSource_GeneralMonthlyAttendance"] != null)
                {
                    dtSource = (DataTable)Session["Ses_dtSource_GeneralMonthlyAttendance"];
                }
                if (Session["Ses_rptHeader_GeneralMonthlyAttendance"] != null)
                {
                    rptHeader = (DataTable)Session["Ses_rptHeader_GeneralMonthlyAttendance"];
                }
                break;
            case "WeeklyWorkHours_Angler":
                if (Session["Ses_rptFileName_Cumulative"] != null)
                {
                    rptFileName = Convert.ToString(Session["Ses_rptFileName_Cumulative"]);
                }
                if (Session["Ses_dtHdr_Cumulative"] != null)
                {
                    dtHdr = (DataTable)Session["Ses_dtHdr_Cumulative"];
                }
                if (Session["Ses_dtSource_Cumulative"] != null)
                {
                    dtSource = (DataTable)Session["Ses_dtSource_Cumulative"];
                }
                if (Session["Ses_rptHeader_Cumulative"] != null)
                {
                    rptHeader = (DataTable)Session["Ses_rptHeader_Cumulative"];
                }
                break;
            case "Payslip":

                if (Session["Ses_rptFileName_Payslip"] != null)
                {
                    rptFileName = Convert.ToString(Session["Ses_rptFileName_Payslip"]);

                }
                if (Session["Ses_drHdr_Payaslip"] != null)
                {
                    dtHdr = (DataTable)Session["Ses_dtHdr_PaySlip"];
                }
                if (Session["Ses_dtSource_Payslip"] != null)
                {
                    dtSource = (DataTable)Session["Ses_dtSource_Payslip"];
                }
                if (Session["Ses_rptHeader_Payslip"] != null)
                {
                    rptHeader = (DataTable)Session["Ses_rptHeader_Payslip"];
                }
                break;

            case "EmployeeInOut":
                if (Session["Ses_rptFileName_EmployeeInOut"] != null)
                {
                    rptFileName = Convert.ToString(Session["Ses_rptFileName_EmployeeInOut"]);
                }
                if (Session["Ses_dtHdr_EmployeeInOut"] != null)
                {
                    dtHdr = (DataTable)Session["Ses_dtHdr_EmployeeInOut"];
                }
                if (Session["Ses_dtSource_EmployeeInOut"] != null)
                {
                    dtSource = (DataTable)Session["Ses_dtSource_EmployeeInOut"];
                }
                if (Session["Ses_rptHeader_EmployeeInOut"] != null)
                {
                    rptHeader = (DataTable)Session["Ses_rptHeader_EmployeeInOut"];
                }
                break;
            case "LessHoursWorked":
                if (Session["Ses_rptFileName_LessHoursWorked"] != null)
                {
                    rptFileName = Convert.ToString(Session["Ses_rptFileName_LessHoursWorked"]);
                }
                if (Session["Ses_dtHdr_LessHoursWorked"] != null)
                {
                    dtHdr = (DataTable)Session["Ses_dtHdr_LessHoursWorked"];
                }
                if (Session["Ses_dtSource_LessHoursWorked"] != null)
                {
                    dtSource = (DataTable)Session["Ses_dtSource_LessHoursWorked"];
                }
                if (Session["Ses_rptHeader_LessHoursWorked"] != null)
                {
                    rptHeader = (DataTable)Session["Ses_rptHeader_LessHoursWorked"];
                }
                break;
            case "EarlyEntry":
                if (Session["Ses_rptFileName_EarlyEntry"] != null)
                {
                    rptFileName = Convert.ToString(Session["Ses_rptFileName_EarlyEntry"]);
                }
                if (Session["Ses_dtHdr_EarlyEntry"] != null)
                {
                    dtHdr = (DataTable)Session["Ses_dtHdr_EarlyEntry"];
                }
                if (Session["Ses_dtSource_EarlyEntry"] != null)
                {
                    dtSource = (DataTable)Session["Ses_dtSource_EarlyEntry"];
                }
                if (Session["Ses_rptHeader_EarlyEntry"] != null)
                {
                    rptHeader = (DataTable)Session["Ses_rptHeader_EarlyEntry"];
                }
                break;
            case "ForPayroll":
                if (Session["Ses_rptFileName_WorkedDaysNew"] != null)
                {
                    rptFileName = Convert.ToString(Session["Ses_rptFileName_WorkedDaysNew"]);
                }
                if (Session["Ses_dtHdr_WorkedDaysNew"] != null)
                {
                    dtHdr = (DataTable)Session["Ses_dtHdr_WorkedDaysNew"];
                }
                if (Session["Ses_dtSource_WorkedDaysNew"] != null)
                {
                    dtSource = (DataTable)Session["Ses_dtSource_WorkedDaysNew"];
                }
                if (Session["Ses_rptHeader_WorkedDaysNew"] != null)
                {
                    rptHeader = (DataTable)Session["Ses_rptHeader_WorkedDaysNew"];
                }
                break;
            case "InOutReport":
                if (Session["Ses_rptFileName_InOutReport"] != null)
                {
                    rptFileName = Convert.ToString(Session["Ses_rptFileName_InOutReport"]);
                }
                if (Session["Ses_dtHdr_InOutReport"] != null)
                {
                    dtHdr = (DataTable)Session["Ses_dtHdr_InOutReport"];
                }
                if (Session["Ses_dtSource_InOutReport"] != null)
                {
                    dtSource = (DataTable)Session["Ses_dtSource_InOutReport"];
                }
                if (Session["Ses_rptHeader_InOutReport"] != null)
                {
                    rptHeader = (DataTable)Session["Ses_rptHeader_InOutReport"];
                }
                break;
            case "EmployeeHistory":
                if (Session["Ses_rptFileName_EmployeeHistory"] != null)
                {
                    rptFileName = Convert.ToString(Session["Ses_rptFileName_EmployeeHistory"]);
                }
                if (Session["Ses_dtHdr_EmployeeHistory"] != null)
                {
                    dtHdr = (DataTable)Session["Ses_dtHdr_EmployeeHistory"];
                }
                if (Session["Ses_dtSource_EmployeeHistory"] != null)
                {
                    dtSource = (DataTable)Session["Ses_dtSource_EmployeeHistory"];
                }
                if (Session["Ses_rptHeader_EmployeeHistory"] != null)
                {
                    rptHeader = (DataTable)Session["Ses_rptHeader_EmployeeHistory"];
                }
                break;
            case "AllSwipes":
                if (Session["Ses_rptFileName_AllSwipes"] != null)
                {
                    rptFileName = Convert.ToString(Session["Ses_rptFileName_AllSwipes"]);
                }
                if (Session["Ses_dtHdr_AllSwipes"] != null)
                {
                    dtHdr = (DataTable)Session["Ses_dtHdr_AllSwipes"];
                }
                if (Session["Ses_dtSource_AllSwipes"] != null)
                {
                    dtSource = (DataTable)Session["Ses_dtSource_AllSwipes"];
                }
                if (Session["Ses_rptHeader_AllSwipes"] != null)
                {
                    rptHeader = (DataTable)Session["Ses_rptHeader_AllSwipes"];
                }
                break;
            case "MatchedAllSwipes":
                if (Session["Ses_rptFileName_MatchedAllSwipes"] != null)
                {
                    rptFileName = Convert.ToString(Session["Ses_rptFileName_MatchedAllSwipes"]);
                }
                if (Session["Ses_dtHdr_MatchedAllSwipes"] != null)
                {
                    dtHdr = (DataTable)Session["Ses_dtHdr_MatchedAllSwipes"];
                }
                if (Session["Ses_dtSource_MatchedAllSwipes"] != null)
                {
                    dtSource = (DataTable)Session["Ses_dtSource_MatchedAllSwipes"];
                }
                if (Session["Ses_rptHeader_MatchedAllSwipes"] != null)
                {
                    rptHeader = (DataTable)Session["Ses_rptHeader_MatchedAllSwipes"];
                }
                break;
            case "Absentees":
                if (Session["Ses_rptFileName_Absentees"] != null)
                {
                    rptFileName = Convert.ToString(Session["Ses_rptFileName_Absentees"]);
                }
                if (Session["Ses_dtHdr_Absentees"] != null)
                {
                    dtHdr = (DataTable)Session["Ses_dtHdr_Absentees"];
                }
                if (Session["Ses_dtSource_Absentees"] != null)
                {
                    dtSource = (DataTable)Session["Ses_dtSource_Absentees"];
                }
                if (Session["Ses_rptHeader_Absentees"] != null)
                {
                    rptHeader = (DataTable)Session["Ses_rptHeader_Absentees"];
                }
                break;
            case "LateEntry":
                if (Session["Ses_rptFileName_LateEntry"] != null)
                {
                    rptFileName = Convert.ToString(Session["Ses_rptFileName_LateEntry"]);
                }
                if (Session["Ses_dtHdr_LateEntry"] != null)
                {
                    dtHdr = (DataTable)Session["Ses_dtHdr_LateEntry"];
                }
                if (Session["Ses_dtSource_LateEntry"] != null)
                {
                    dtSource = (DataTable)Session["Ses_dtSource_LateEntry"];
                }
                if (Session["Ses_rptHeader_LateEntry"] != null)
                {
                    rptHeader = (DataTable)Session["Ses_rptHeader_LateEntry"];
                }
                break;
            case "Exception":
                if (Session["Ses_rptFileName_Exception"] != null)
                {
                    rptFileName = Convert.ToString(Session["Ses_rptFileName_Exception"]);
                }
                if (Session["Ses_dtHdr_Exception"] != null)
                {
                    dtHdr = (DataTable)Session["Ses_dtHdr_Exception"];
                }
                if (Session["Ses_dtSource_Exception"] != null)
                {
                    dtSource = (DataTable)Session["Ses_dtSource_Exception"];
                }
                if (Session["Ses_rptHeader_Exception"] != null)
                {
                    rptHeader = (DataTable)Session["Ses_rptHeader_Exception"];
                }
                break;
            case "EarlyExit":
                if (Session["Ses_rptFileName_EarlyExit"] != null)
                {
                    rptFileName = Convert.ToString(Session["Ses_rptFileName_EarlyExit"]);
                }
                if (Session["Ses_dtHdr_EarlyExit"] != null)
                {
                    dtHdr = (DataTable)Session["Ses_dtHdr_EarlyExit"];
                }
                if (Session["Ses_dtSource_EarlyExit"] != null)
                {
                    dtSource = (DataTable)Session["Ses_dtSource_EarlyExit"];
                }
                if (Session["Ses_rptHeader_EarlyExit"] != null)
                {
                    rptHeader = (DataTable)Session["Ses_rptHeader_EarlyExit"];
                }
                break;
            case "LateExit":
                if (Session["Ses_rptFileName_LateExit"] != null)
                {
                    rptFileName = Convert.ToString(Session["Ses_rptFileName_LateExit"]);
                }
                if (Session["Ses_dtHdr_LateExit"] != null)
                {
                    dtHdr = (DataTable)Session["Ses_dtHdr_LateExit"];
                }
                if (Session["Ses_dtSource_LateExit"] != null)
                {
                    dtSource = (DataTable)Session["Ses_dtSource_LateExit"];
                }
                if (Session["Ses_rptHeader_LateExit"] != null)
                {
                    rptHeader = (DataTable)Session["Ses_rptHeader_LateExit"];
                }
                break;
            case "OverTime":
                if (Session["Ses_rptFileName_OverTimeAmount"] != null)
                {
                    rptFileName = Convert.ToString(Session["Ses_rptFileName_OverTimeAmount"]);
                }
                if (Session["Ses_dtHdr_OverTimewithAmount"] != null)
                {
                    dtHdr = (DataTable)Session["Ses_dtHdr_OverTimewithAmount"];
                }
                if (Session["Ses_dtSource_OverTimewithAmount"] != null)
                {
                    dtSource = (DataTable)Session["Ses_dtSource_OverTimewithAmount"];
                }
                if (Session["Ses_rptHeader_OverTime"] != null)
                {
                    rptHeader = (DataTable)Session["Ses_rptHeader_OverTime"];
                }
                break;
            case "OverTimewithAmount":
                if (Session["Ses_rptFileName_OverTimewithAmount"] != null)
                {
                    rptFileName = Convert.ToString(Session["Ses_rptFileName_OverTimewithAmount"]);
                }
                if (Session["Ses_dtHdr_OverTimewithAmount"] != null)
                {
                    dtHdr = (DataTable)Session["Ses_dtHdr_OverTimewithAmount"];
                }
                if (Session["Ses_dtSource_OverTimewithAmount"] != null)
                {
                    dtSource = (DataTable)Session["Ses_dtSource_OverTimewithAmount"];
                }
                if (Session["Ses_rptHeader_OverTimewithAmount"] != null)
                {
                    rptHeader = (DataTable)Session["Ses_rptHeader_OverTimewithAmount"];
                }
                break;

            case "Leave":
                if (Session["Ses_rptFileName_Leave"] != null)
                {
                    rptFileName = Convert.ToString(Session["Ses_rptFileName_Leave"]);
                }
                if (Session["Ses_dtHdr_Leave"] != null)
                {
                    dtHdr = (DataTable)Session["Ses_dtHdr_Leave"];
                }
                if (Session["Ses_dtSource_Leave"] != null)
                {
                    dtSource = (DataTable)Session["Ses_dtSource_Leave"];
                }
                if (Session["Ses_rptHeader_Leave"] != null)
                {
                    rptHeader = (DataTable)Session["Ses_rptHeader_Leave"];
                }
                break;
            case "DetailedAttendance":
                if (Session["Ses_rptFileName_DetailedAttendance"] != null)
                {
                    rptFileName = Convert.ToString(Session["Ses_rptFileName_DetailedAttendance"]);
                }
                if (Session["Ses_dtHdr_DetailedAttendance"] != null)
                {
                    dtHdr = (DataTable)Session["Ses_dtHdr_DetailedAttendance"];
                }
                if (Session["Ses_dtSource_DetailedAttendance"] != null)
                {
                    dtSource = (DataTable)Session["Ses_dtSource_DetailedAttendance"];
                }
                if (Session["Ses_rptHeader_DetailedAttendance"] != null)
                {
                    rptHeader = (DataTable)Session["Ses_rptHeader_DetailedAttendance"];
                }
                if (Session["Ses_rptHeaderLabels_DetailedAttendance"] != null)
                {
                    rptHeaderLabels = (DataTable)Session["Ses_rptHeaderLabels_DetailedAttendance"];
                }
                break;
            case "MonthlyAttendance":
                if (Session["Ses_rptFileName_MonthlyAttendance"] != null)
                {
                    rptFileName = Convert.ToString(Session["Ses_rptFileName_MonthlyAttendance"]);
                }
                if (Session["Ses_dtHdr_MonthlyAttendance"] != null)
                {
                    dtHdr = (DataTable)Session["Ses_dtHdr_MonthlyAttendance"];
                }
                if (Session["Ses_dtSource_MonthlyAttendance"] != null)
                {
                    dtSource = (DataTable)Session["Ses_dtSource_MonthlyAttendance"];
                }
                if (Session["Ses_dtSource1_MonthlyAttendance"] != null)
                {
                    dtSource1 = (DataTable)Session["Ses_dtSource1_MonthlyAttendance"];
                }
                if (Session["Ses_rptHeader_MonthlyAttendance"] != null)
                {
                    rptHeader = (DataTable)Session["Ses_rptHeader_MonthlyAttendance"];
                }
                break;
            case "ContractorAttendanceReport":
                if (Session["Ses_rptFileName_GeneralContractorAttendance"] != null)
                {
                    rptFileName = Convert.ToString(Session["Ses_rptFileName_GeneralContractorAttendance"]);

                }
                if (Session["Ses_dtHdr_GeneralContractorAttendance"] != null)
                {
                    dtHdr = (DataTable)Session["Ses_dtHdr_GeneralContractorAttendance"];
                }
                if (Session["Ses_dtSource_GeneralContractorAttendance"] != null)
                {
                    dtSource = (DataTable)Session["Ses_dtSource_GeneralContractorAttendance"];
                }
                if (Session["Ses_dtSource1_ContractorAttendance"] != null)
                {
                    dtSource1 = (DataTable)Session["Ses_dtSource1_ContractorAttendance"];
                }
                if (Session["Ses_rptHeader_GeneralContractorAttendance"] != null)
                {
                    rptHeader = (DataTable)Session["Ses_rptHeader_GeneralContractorAttendance"];
                }
                break;
            case "MonthlyAttendanceDetail":
                if (Session["Ses_rptFileName_MonthlyAttendanceDetail"] != null)
                {
                    rptFileName = Convert.ToString(Session["Ses_rptFileName_MonthlyAttendanceDetail"]);
                }
                if (Session["Ses_dtHdr_MonthlyAttendanceDetail"] != null)
                {
                    dtHdr = (DataTable)Session["Ses_dtHdr_MonthlyAttendanceDetail"];
                }
                if (Session["Ses_dtSource_MonthlyAttendanceDetail"] != null)
                {
                    dtSource = (DataTable)Session["Ses_dtSource_MonthlyAttendanceDetail"];
                }
                if (Session["Ses_rptHeader_MonthlyAttendanceDetail"] != null)
                {
                    rptHeader = (DataTable)Session["Ses_rptHeader_MonthlyAttendanceDetail"];
                }
                if (Session["Ses_dtSource_MonthlyAttendanceDetailData2"] != null)
                {
                    dtMonthlyAttendanceData2 = (DataTable)Session["Ses_dtSource_MonthlyAttendanceDetailData2"];
                }
                break;
            case "TotalDays":
                if (Session["Ses_rptFileName_TotalDays"] != null)
                {
                    rptFileName = Convert.ToString(Session["Ses_rptFileName_TotalDays"]);
                }
                if (Session["Ses_dtHdr_TotalDays"] != null)
                {
                    dtHdr = (DataTable)Session["Ses_dtHdr_TotalDays"];
                }
                if (Session["Ses_dtSource_TotalDays"] != null)
                {
                    dtSource = (DataTable)Session["Ses_dtSource_TotalDays"];
                }
                if (Session["Ses_rptHeader_TotalDays"] != null)
                {
                    rptHeader = (DataTable)Session["Ses_rptHeader_TotalDays"];
                }
                break;
            case "Punctuality":
                if (Session["Ses_rptFileName_Punctuality"] != null)
                {
                    rptFileName = Convert.ToString(Session["Ses_rptFileName_Punctuality"]);
                }
                if (Session["Ses_dtHdr_Punctuality"] != null)
                {
                    dtHdr = (DataTable)Session["Ses_dtHdr_Punctuality"];
                }
                if (Session["Ses_dtSource_Punctuality"] != null)
                {
                    dtSource = (DataTable)Session["Ses_dtSource_Punctuality"];
                }
                if (Session["Ses_rptHeader_Punctuality"] != null)
                {
                    rptHeader = (DataTable)Session["Ses_rptHeader_Punctuality"];
                }
                break;
            case "Discrepancy":
                if (Session["Ses_rptFileName_Discrepancy"] != null)
                {
                    rptFileName = Convert.ToString(Session["Ses_rptFileName_Discrepancy"]);
                }
                if (Session["Ses_dtHdr_Discrepancy"] != null)
                {
                    dtHdr = (DataTable)Session["Ses_dtHdr_Discrepancy"];
                }
                if (Session["Ses_dtSource_Discrepancy"] != null)
                {
                    dtSource = (DataTable)Session["Ses_dtSource_Discrepancy"];
                }
                if (Session["Ses_rptHeader_Discrepancy"] != null)
                {
                    rptHeader = (DataTable)Session["Ses_rptHeader_Discrepancy"];
                }
                break;
            case "Shift":
                if (Session["ses_rptFileName_Shift"] != null)
                {
                    rptFileName = Convert.ToString(Session["ses_rptFileName_Shift"]);
                }
                if (Session["Ses_dtHdr_Shift"] != null)
                {
                    dtHdr = (DataTable)Session["Ses_dtHdr_Shift"];
                }
                if (Session["Ses_dtSource_Shift"] != null)
                {
                    dtSource = (DataTable)Session["Ses_dtSource_Shift"];
                }
                if (Session["Ses_rptHeader_Shift"] != null)
                {
                    rptHeader = (DataTable)Session["Ses_rptHeader_Shift"];
                }
                break;
            case "ShiftWise":
                if (Session["ses_rptFileName_Shiftwise"] != null)
                {
                    rptFileName = Convert.ToString(Session["ses_rptFileName_Shiftwise"]);
                }
                if (Session["Ses_dtHdr_Shiftwise"] != null)
                {
                    dtHdr = (DataTable)Session["Ses_dtHdr_Shiftwise"];
                }
                if (Session["Ses_dtSource_Shiftwise"] != null)
                {
                    dtSource = (DataTable)Session["Ses_dtSource_Shiftwise"];
                }
                if (Session["Ses_rptHeader_Shiftwise"] != null)
                {
                    rptHeader = (DataTable)Session["Ses_rptHeader_Shiftwise"];
                }
                break;
            case "EmployeeShiftAllocation":
                if (Session["Ses_rptFileName_EmployeeShiftAllocation"] != null)
                {
                    rptFileName = Convert.ToString(Session["Ses_rptFileName_EmployeeShiftAllocation"]);
                }
                if (Session["Ses_dtHdr_EmployeeShiftAllocation"] != null)
                {
                    dtHdr = (DataTable)Session["Ses_dtHdr_EmployeeShiftAllocation"];
                }
                if (Session["Ses_dtSource_EmployeeShiftAllocation"] != null)
                {
                    dtSource = (DataTable)Session["Ses_dtSource_EmployeeShiftAllocation"];
                }
                if (Session["Ses_rptHeader_EmployeeShiftAllocation"] != null)
                {
                    rptHeader = (DataTable)Session["Ses_rptHeader_EmployeeShiftAllocation"];
                }
                if (Convert.ToString(Session["packageID"]) != "")
                    if (Convert.ToString(Session["packageID"]) == "158")
                    {
                        //Hotel Surguru
                        if (Session["Ses_dtSource2_EmployeeShiftAllocationtbl2"] != null)
                        {
                            dtSourceShift = (DataTable)Session["Ses_dtSource2_EmployeeShiftAllocationtbl2"];
                        }
                    }
                break;
            case "DailyAttendance":
                if (Session["Ses_rptFileName_DailyAttendance"] != null)
                {
                    rptFileName = Convert.ToString(Session["Ses_rptFileName_DailyAttendance"]);
                }
                if (Session["Ses_dtHdr_DailyAttendance"] != null)
                {
                    dtHdr = (DataTable)Session["Ses_dtHdr_DailyAttendance"];
                }
                if (Session["Ses_dtSource_DailyAttendance"] != null)
                {
                    dtSource = (DataTable)Session["Ses_dtSource_DailyAttendance"];
                }
                if (Session["Ses_rptHeader_DailyAttendance"] != null)
                {
                    rptHeader = (DataTable)Session["Ses_rptHeader_DailyAttendance"];
                }
                break;
            case "EmployeeDetails":
                if (Session["Ses_rptFileName_EmployeeDetails"] != null)
                {
                    rptFileName = Convert.ToString(Session["Ses_rptFileName_EmployeeDetails"]);
                }
                if (Session["Ses_dtHdr_EmployeeDetails"] != null)
                {
                    dtHdr = (DataTable)Session["Ses_dtHdr_EmployeeDetails"];
                }
                if (Session["Ses_dtSource_EmployeeDetails"] != null)
                {
                    dtSource = (DataTable)Session["Ses_dtSource_EmployeeDetails"];
                }
                if (Session["Ses_rptHeader_EmployeeDetails"] != null)
                {
                    rptHeader = (DataTable)Session["Ses_rptHeader_EmployeeDetails"];
                }
                break;
            case "DocumentExpiry":
                if (Session["Ses_rptFileName_DocumentExpiry"] != null)
                {
                    rptFileName = Convert.ToString(Session["Ses_rptFileName_DocumentExpiry"]);
                }
                if (Session["Ses_dtHdr_DocumentExpiry"] != null)
                {
                    dtHdr = (DataTable)Session["Ses_dtHdr_DocumentExpiry"];
                }
                if (Session["Ses_dtSource_DocumentExpiry"] != null)
                {
                    dtSource = (DataTable)Session["Ses_dtSource_DocumentExpiry"];
                }
                if (Session["Ses_rptHeader_DocumentExpiry"] != null)
                {
                    rptHeader = (DataTable)Session["Ses_rptHeader_DocumentExpiry"];
                }
                break;
            case "AuditTrail":
                if (Session["Ses_rptFileName_AuditTrail"] != null)
                {
                    rptFileName = Convert.ToString(Session["Ses_rptFileName_AuditTrail"]);
                }
                if (Session["Ses_dtHdr_AuditTrail"] != null)
                {
                    dtHdr = (DataTable)Session["Ses_dtHdr_AuditTrail"];
                }
                if (Session["Ses_dtSource_AuditTrail"] != null)
                {
                    dtSource = (DataTable)Session["Ses_dtSource_AuditTrail"];
                }
                if (Session["Ses_rptHeader_AuditTrail"] != null)
                {
                    rptHeader = (DataTable)Session["Ses_rptHeader_AuditTrail"];
                }
                break;
            case "MonthClosure":
                if (Session["Ses_rptFileName_MonthClosure"] != null)
                {
                    rptFileName = Convert.ToString(Session["Ses_rptFileName_MonthClosure"]);
                }
                if (Session["Ses_dtHdr_MonthClosure"] != null)
                {
                    dtHdr = (DataTable)Session["Ses_dtHdr_MonthClosure"];
                }
                if (Session["Ses_dtSource_MonthClosure"] != null)
                {
                    dtSource = (DataTable)Session["Ses_dtSource_MonthClosure"];
                }
                if (Session["Ses_rptHeader_MonthClosure"] != null)
                {
                    rptHeader = (DataTable)Session["Ses_rptHeader_MonthClosure"];
                }
                break;
            case "YearClosure":
                if (Session["Ses_rptFileName_YearClosure"] != null)
                {
                    rptFileName = Convert.ToString(Session["Ses_rptFileName_YearClosure"]);
                }
                if (Session["Ses_dtHdr_YearClosure"] != null)
                {
                    dtHdr = (DataTable)Session["Ses_dtHdr_YearClosure"];
                }
                if (Session["Ses_dtSource_YearClosure"] != null)
                {
                    dtSource = (DataTable)Session["Ses_dtSource_YearClosure"];
                }
                if (Session["Ses_rptHeader_YearClosure"] != null)
                {
                    rptHeader = (DataTable)Session["Ses_rptHeader_YearClosure"];
                }
                break;
            case "Permission":
                if (Session["Ses_rptFileName_Permission"] != null)
                {
                    rptFileName = Convert.ToString(Session["Ses_rptFileName_Permission"]);
                }
                if (Session["Ses_dtHdr_Permission"] != null)
                {
                    dtHdr = (DataTable)Session["Ses_dtHdr_Permission"];
                }
                if (Session["Ses_dtSource_Permission"] != null)
                {
                    dtSource = (DataTable)Session["Ses_dtSource_Permission"];
                }
                if (Session["Ses_rptHeader_Permission"] != null)
                {
                    rptHeader = (DataTable)Session["Ses_rptHeader_Permission"];
                }
                break;
            case "ManualTimeEntry":
                if (Session["Ses_rptFileName_ManualTimeEntry"] != null)
                {
                    rptFileName = Convert.ToString(Session["Ses_rptFileName_ManualTimeEntry"]);
                }
                if (Session["Ses_dtHdr_ManualTimeEntry"] != null)
                {
                    dtHdr = (DataTable)Session["Ses_dtHdr_ManualTimeEntry"];
                }
                if (Session["Ses_dtSource_ManualTimeEntry"] != null)
                {
                    dtSource = (DataTable)Session["Ses_dtSource_ManualTimeEntry"];
                }
                if (Session["Ses_rptHeader_ManualTimeEntry"] != null)
                {
                    rptHeader = (DataTable)Session["Ses_rptHeader_ManualTimeEntry"];
                }
                break;
            case "OnDutyEntry":
                if (Session["Ses_rptFileName_OnDutyEntry"] != null)
                {
                    rptFileName = Convert.ToString(Session["Ses_rptFileName_OnDutyEntry"]);
                }
                if (Session["Ses_dtHdr_OnDutyEntry"] != null)
                {
                    dtHdr = (DataTable)Session["Ses_dtHdr_OnDutyEntry"];
                }
                if (Session["Ses_dtSource_OnDutyEntry"] != null)
                {
                    dtSource = (DataTable)Session["Ses_dtSource_OnDutyEntry"];
                }
                if (Session["Ses_rptHeader_OnDutyEntry"] != null)
                {
                    rptHeader = (DataTable)Session["Ses_rptHeader_OnDutyEntry"];
                }
                break;
            case "ShiftNotAllocated":
                if (Session["Ses_rptFileName_ShiftNotAllocated"] != null)
                {
                    rptFileName = Convert.ToString(Session["Ses_rptFileName_ShiftNotAllocated"]);
                }
                if (Session["Ses_dtHdr_ShiftNotAllocated"] != null)
                {
                    dtHdr = (DataTable)Session["Ses_dtHdr_ShiftNotAllocated"];
                }
                if (Session["Ses_dtSource_ShiftNotAllocated"] != null)
                {
                    dtSource = (DataTable)Session["Ses_dtSource_ShiftNotAllocated"];
                }
                if (Session["Ses_rptHeader_ShiftNotAllocated"] != null)
                {
                    rptHeader = (DataTable)Session["Ses_rptHeader_ShiftNotAllocated"];
                }
                break;
            case "LeavePolicyNotAllocated":
                if (Session["Ses_rptFileName_LeavePolicyNotAllocated"] != null)
                {
                    rptFileName = Convert.ToString(Session["Ses_rptFileName_LeavePolicyNotAllocated"]);
                }
                if (Session["Ses_dtHdr_LeavePolicyNotAllocated"] != null)
                {
                    dtHdr = (DataTable)Session["Ses_dtHdr_LeavePolicyNotAllocated"];
                }
                if (Session["Ses_dtSource_LeavePolicyNotAllocated"] != null)
                {
                    dtSource = (DataTable)Session["Ses_dtSource_LeavePolicyNotAllocated"];
                }
                if (Session["Ses_rptHeader_LeavePolicyNotAllocated"] != null)
                {
                    rptHeader = (DataTable)Session["Ses_rptHeader_LeavePolicyNotAllocated"];
                }
                break;
            case "SummaryReport":
                if (Session["Ses_rptFileName_Summary"] != null)
                {
                    rptFileName = Convert.ToString(Session["Ses_rptFileName_Summary"]);
                }
                if (Session["Ses_dtHdr_Summary"] != null)
                {
                    dtHdr = (DataTable)Session["Ses_dtHdr_Summary"];
                }
                if (Session["Ses_dtSource_Summary"] != null)
                {
                    dtSource = (DataTable)Session["Ses_dtSource_Summary"];
                }
                if (Session["Ses_rptHeader_Summary"] != null)
                {
                    rptHeader = (DataTable)Session["Ses_rptHeader_Summary"];
                }
                break;
            case "RawData":
                if (Session["Ses_rptFileName_RawData"] != null)
                {
                    rptFileName = Convert.ToString(Session["Ses_rptFileName_RawData"]);
                }
                if (Session["Ses_dtHdr_RawData"] != null)
                {
                    dtHdr = (DataTable)Session["Ses_dtHdr_RawData"];
                }
                if (Session["Ses_dtSource_RawData"] != null)
                {
                    dtSource = (DataTable)Session["Ses_dtSource_RawData"];
                }
                if (Session["Ses_rptHeader_RawData"] != null)
                {
                    rptHeader = (DataTable)Session["Ses_rptHeader_RawData"];
                }
                break;
            case "RawData_Latest":
                if (Session["Ses_rptFileName_RawData_Latest"] != null)
                {
                    rptFileName = Convert.ToString(Session["Ses_rptFileName_RawData_Latest"]);
                }
                if (Session["Ses_dtHdr_RawData_Latest"] != null)
                {
                    dtHdr = (DataTable)Session["Ses_dtHdr_RawData_Latest"];
                }
                if (Session["Ses_dtSource_RawData_Latest"] != null)
                {
                    dtSource = (DataTable)Session["Ses_dtSource_RawData_Latest"];
                }
                if (Session["Ses_rptHeader_RawData_Latest"] != null)
                {
                    rptHeader = (DataTable)Session["Ses_rptHeader_RawData_Latest"];
                }
                break;
            case "WeeklyWorkHours":
                if (Session["Ses_rptFileName_Cumulative"] != null)
                {
                    rptFileName = Convert.ToString(Session["Ses_rptFileName_Cumulative"]);
                }
                if (Session["Ses_dtHdr_Cumulative"] != null)
                {
                    dtHdr = (DataTable)Session["Ses_dtHdr_Cumulative"];
                }
                if (Session["Ses_dtSource_Cumulative"] != null)
                {
                    dtSource = (DataTable)Session["Ses_dtSource_Cumulative"];
                }
                if (Session["Ses_dtSourceDetails_Cumulative"] != null)
                {
                    dtSourceDetails = (DataTable)Session["Ses_dtSourceDetails_Cumulative"];
                }
                if (Session["Ses_rptHeader_Cumulative"] != null)
                {
                    rptHeader = (DataTable)Session["Ses_rptHeader_Cumulative"];
                }
                break;
            case "TimeSheet":
                if (Session["Ses_rptFileName_TimeSheet"] != null)
                {
                    rptFileName = Convert.ToString(Session["Ses_rptFileName_TimeSheet"]);
                }
                if (Session["Ses_dtHdr_TimeSheet"] != null)
                {
                    dtHdr = (DataTable)Session["Ses_dtHdr_TimeSheet"];
                }
                if (Session["Ses_dtSource_TimeSheet"] != null)
                {
                    dtSource = (DataTable)Session["Ses_dtSource_TimeSheet"];
                }
                //if (Session["Ses_dtSourceDetails_TimeSheet"] != null)
                //{
                //    dtSourceDetails = (DataTable)Session["Ses_dtSourceDetails_TimeSheet"];
                //}
                if (Session["Ses_rptHeader_TimeSheet"] != null)
                {
                    rptHeader = (DataTable)Session["Ses_rptHeader_TimeSheet"];
                }
                break;
            case "LeaveAnalysis":
                if (Session["Ses_rptFileName_LeaveAnalysis"] != null)
                {
                    rptFileName = Convert.ToString(Session["Ses_rptFileName_LeaveAnalysis"]);
                }
                if (Session["Ses_dtHdr_LeaveAnalysis"] != null)
                {
                    dtHdr = (DataTable)Session["Ses_dtHdr_LeaveAnalysis"];
                }
                if (Session["Ses_dtSource_LeaveAnalysis"] != null)
                {
                    dtSource = (DataTable)Session["Ses_dtSource_LeaveAnalysis"];
                }
                if (Session["Ses_rptHeader_LeaveAnalysis"] != null)
                {
                    rptHeader = (DataTable)Session["Ses_rptHeader_LeaveAnalysis"];
                }
                break;
            case "DailyWagesPenalty":
                if (Session["Ses_rptFileName_DailyWages_Sohit"] != null)
                    rptFileName = Convert.ToString(Session["Ses_rptFileName_DailyWages_Sohit"]);
                if (Session["Ses_dtHdr_DailyWages_Sohit"] != null)
                    dtHdr = (DataTable)Session["Ses_dtHdr_DailyWages_Sohit"];
                if (Session["Ses_dtSource_DailyWages_Sohit"] != null)
                    dtSource = (DataTable)Session["Ses_dtSource_DailyWages_Sohit"];
                if (Session["Ses_rptHeader_DailyWages_Sohit"] != null)
                    rptHeader = (DataTable)Session["Ses_rptHeader_DailyWages_Sohit"];
                break;
            case "PayrollDetail":
                if (Session["Ses_rptFileName_Payroll_Sohit"] != null)
                    rptFileName = Convert.ToString(Session["Ses_rptFileName_Payroll_Sohit"]);
                if (Session["Ses_dtHdr_Payroll_Sohit"] != null)
                    dtHdr = (DataTable)Session["Ses_dtHdr_Payroll_Sohit"];
                if (Session["Ses_dtSource_Payroll_Sohit"] != null)
                    dtSource = (DataTable)Session["Ses_dtSource_Payroll_Sohit"];
                if (Session["Ses_rptHeader_Payroll_Sohit"] != null)
                    rptHeader = (DataTable)Session["Ses_rptHeader_Payroll_Sohit"];
                break;
            case "CanteenReport":
                if (Session["Ses_rptFileName_CanteenReport"] != null)
                    rptFileName = Convert.ToString(Session["Ses_rptFileName_CanteenReport"]);
                if (Session["Ses_dtHdr_CanteenReport"] != null)
                    dtHdr = (DataTable)Session["Ses_dtHdr_CanteenReport"];
                if (Session["Ses_dtSource_CanteenReport"] != null)
                    dtSource = (DataTable)Session["Ses_dtSource_CanteenReport"];
                if (Session["Ses_rptHeader_CanteenReport"] != null)
                    rptHeader = (DataTable)Session["Ses_rptHeader_CanteenReport"];
                break;
            case "Blocking 240Days":
                if (Session["Ses_rptFileName_Blocking_240Days"] != null)
                {
                    rptFileName = Convert.ToString(Session["Ses_rptFileName_Blocking_240Days"]);
                }
                if (Session["Ses_dtHdr_Blocking 240Days"] != null)
                {
                    dtHdr = (DataTable)Session["Ses_dtHdr_Blocking_240Days"];
                }
                if (Session["Ses_dtSource_Blocking_240Days"] != null)
                {
                    dtSource = (DataTable)Session["Ses_dtSource_Blocking_240Days"];
                }
                if (Session["Ses_rptHeader_Blocking_240Days"] != null)
                {
                    rptHeader = (DataTable)Session["Ses_rptHeader_Blocking_240Days"];
                }
                break;
            case "ContinuosWorking":
                if (Session["Ses_rptFileName_ContinuosWorking"] != null)
                {
                    rptFileName = Convert.ToString(Session["Ses_rptFileName_ContinuosWorking"]);
                }
                if (Session["Ses_dtHdr_ContinuosWorking"] != null)
                {
                    dtHdr = (DataTable)Session["Ses_dtHdr_ContinuosWorking"];
                }
                if (Session["Ses_dtSource_ContinuosWorking"] != null)
                {
                    dtSource = (DataTable)Session["Ses_dtSource_ContinuosWorking"];
                }
                if (Session["Ses_rptHeader_ContinuosWorking"] != null)
                {
                    rptHeader = (DataTable)Session["Ses_rptHeader_ContinuosWorking"];
                }
                break;

        }
        int payrollConfig = 0;
        payrollConfig = objCommon.CheckPageExistsInLicense(185);
        /*Below parameter is used for Angler*/
        if (payrollConfig == 1)
        {
            if (strReportName == "DetailedAttendance")
            {
                rptDoc.Load(rptFileName);
                rptDoc.Database.Tables["table_1"].SetDataSource(rptHeader);
                rptDoc.Database.Tables["Header"].SetDataSource(dtHdr);
                rptDoc.Database.Tables["Table"].SetDataSource(dtSource);
                rptViewer.ReportSource = rptDoc;
                rptViewer.DataBind();
                rptDoc.Clone();
                return;
            }
        }
        if (strReportName == "CountfactorWorkingdays")
        {
            rptDoc.Load(rptFileName);
            rptDoc.Database.Tables["Table"].SetDataSource(rptHeader);
            rptDoc.Database.Tables["dt_TotalWorkingDays"].SetDataSource(dtSource);
            rptDoc.Database.Tables["dt_Header"].SetDataSource(dtHdr);
            rptDoc.SetParameterValue("UTCDateTime", Convert.ToString(Session["EmployeeCountryGetDateTime"]));
            rptViewer.ReportSource = rptDoc;
            rptViewer.DataBind();
            rptDoc.Clone();
            return;
        }
        else if (strReportName == "MonthlyAttendance" || strReportName == "ContractorAttendanceReport")
        {
            rptDoc.Load(rptFileName);
            rptDoc.Database.Tables["Table_1"].SetDataSource(rptHeader);
            rptDoc.Database.Tables["Table"].SetDataSource(dtSource);
            rptDoc.Database.Tables["Header"].SetDataSource(dtHdr);
            if (dtSource1 != null)
            {
                rptDoc.Database.Tables["Table1"].SetDataSource(dtSource1);
            }
            rptDoc.SetParameterValue("DtFormat", Convert.ToString(Session["MDateFormat"]));
            rptDoc.SetParameterValue("TimeFormat", Convert.ToString(Session["MTimeFormat"]));
            if (isPresent != "1")
            {
                rptDoc.SetParameterValue("UTCDateTime", Convert.ToString(Session["EmployeeCountryGetDateTime"]));
            }
            rptViewer.ReportSource = rptDoc;
            rptViewer.DataBind();
            rptDoc.Clone();
            return;
        }
        else if (strReportName== "ContinuosWorking")
        {
            rptDoc.Load(rptFileName);
            rptDoc.Database.Tables["Table_1"].SetDataSource(rptHeader);
            rptDoc.Database.Tables["Table"].SetDataSource(dtSource);
            rptDoc.Database.Tables["Header"].SetDataSource(dtHdr);
            rptDoc.SetParameterValue("DtFormat", Convert.ToString(Session["MDateFormat"]));
            rptDoc.SetParameterValue("TimeFormat", Convert.ToString(Session["MTimeFormat"]));
            //rptDoc.SetParameterValue("UTCDateTime", Convert.ToString(Session["EmployeeCountryGetDateTime"]));
            rptDoc.SetParameterValue("ReportType", Convert.ToString(Normal));

            rptViewer.ReportSource = rptDoc;
            rptViewer.DataBind();
            rptDoc.Clone();
            return;
        }
        else if (strReportName == "WeeklyWorkHours")
        {
            rptDoc.Load(rptFileName);
            rptDoc.Database.Tables["Table_1"].SetDataSource(rptHeader);
            rptDoc.Database.Tables["Weekly_Work_Hours"].SetDataSource(dtSource);
            rptDoc.Database.Tables["dt_Header"].SetDataSource(dtHdr);
            rptDoc.Database.Tables["WeekDayDetails"].SetDataSource(dtSourceDetails);
            if (Convert.ToString(Session["Report_Type"]) == "DetailedReport")
            {
                rptDoc.SetParameterValue("DtFormat", Convert.ToString(Session["MDateFormat"]), "WeekDayDetails");
                rptDoc.SetParameterValue("TimeFormat", Convert.ToString(Session["MTimeFormat"]), "WeekDayDetails");
                rptDoc.SetParameterValue("UTCDateTime", Convert.ToString(Session["EmployeeCountryGetDateTime"]));
            }
            else
            {
                rptDoc.SetParameterValue("UTCDateTime", Convert.ToString(Session["EmployeeCountryGetDateTime"]));
            }
            rptViewer.ReportSource = rptDoc;
            rptViewer.DataBind();
            rptDoc.Clone();
            return;
        }
        else if (strReportName == "TimeSheet")
        {
            rptDoc.Load(rptFileName);
            rptDoc.Database.Tables["Table_1"].SetDataSource(rptHeader);
            rptDoc.Database.Tables["TimeSheet"].SetDataSource(dtSource);
            rptDoc.Database.Tables["dt_Header"].SetDataSource(dtHdr);
            rptViewer.ReportSource = rptDoc;
            rptViewer.DataBind();
            rptDoc.Clone();
            return;
        }
        else if (strReportName == "RawData")
        {
            rptDoc.Load(rptFileName);
            rptDoc.Database.Tables["Table_1"].SetDataSource(rptHeader);
            rptDoc.Database.Tables["RawData"].SetDataSource(dtSource);
            rptDoc.Database.Tables["dt_Header"].SetDataSource(dtHdr);
            rptDoc.SetParameterValue("UTCDateTime", Convert.ToString(Session["EmployeeCountryGetDateTime"]));
            rptViewer.ReportSource = rptDoc;
            rptViewer.DataBind();
            rptDoc.Clone();
            return;
        }
        else if (strReportName == "Exception")
        {
            rptDoc.Load(rptFileName);
            rptDoc.Database.Tables["Table_1"].SetDataSource(rptHeader);
            rptDoc.Database.Tables["Exception"].SetDataSource(dtSource);
            rptDoc.Database.Tables["dt_Header"].SetDataSource(dtHdr);
            rptDoc.SetParameterValue("UTCDateTime", Convert.ToString(Session["EmployeeCountryGetDateTime"]));
            rptViewer.ReportSource = rptDoc;
            rptViewer.DataBind();
            rptDoc.Clone();
            return;
        }
        else if (strReportName == "RawData_Latest")
        {
            rptDoc.Load(rptFileName);
            rptDoc.Database.Tables["Table_1"].SetDataSource(rptHeader);
            rptDoc.Database.Tables["RawData"].SetDataSource(dtSource);
            rptDoc.Database.Tables["dt_Header"].SetDataSource(dtHdr);
            rptDoc.SetParameterValue("DtFormat", Convert.ToString(Session["MDateFormat"]));
            rptDoc.SetParameterValue("TimeFormat", Convert.ToString(Session["MTimeFormat"]));
            rptDoc.SetParameterValue("UTCDateTime", Convert.ToString(Session["EmployeeCountryGetDateTime"]));
            rptViewer.ReportSource = rptDoc;
            rptViewer.ID = strReportName;
            rptViewer.DataBind();
            rptDoc.Clone();
            return;
        }

        else if (strReportName == "Payslip")
        {
            rptDoc.Load(rptFileName);
            rptDoc.Database.Tables["Header"].SetDataSource(dtHdr);
            rptDoc.Database.Tables["Table"].SetDataSource(dtSource);
            rptDoc.Database.Tables["Table_1"].SetDataSource(rptHeader);
            rptViewer.ID = strReportName;
            rptViewer.DataBind();
            rptDoc.Clone();

        }

        rptDoc.Load(rptFileName);

        if (rptFileName.Contains("EmployeeShiftAllocation"))
        {
            if (Convert.ToString(Session["packageID"]) != "")
                if (Convert.ToString(Session["packageID"]) == "158")
                {//Hotel Surguru
                    rptDoc.Load(rptFileName);
                    rptDoc.Database.Tables["Table1"].SetDataSource(dtSourceShift);
                }
        }
        rptDoc.Database.Tables["Header"].SetDataSource(dtHdr);
        if (ReportName != "WeeklyWorkHours_Angler")
        {
            rptDoc.Database.Tables["Table"].SetDataSource(dtSource);
        }
        else if (ReportName == "WeeklyWorkHours_Angler")
        {
            rptDoc.Database.Tables["Table"].SetDataSource(rptHeader);
            rptDoc.Database.Tables["Summary"].SetDataSource(dtSource);
            rptDoc.Database.Tables["Details"].SetDataSource(dtSourceDetails);
        }
        if (rptFileName.Contains("WeeklyWorkHours_Angler"))
        {
            rptDoc.Load(rptFileName);
            rptDoc.Database.Tables["Table"].SetDataSource(rptHeader);
            rptDoc.Database.Tables["Summary"].SetDataSource(dtSource);
            //   dtSourceDetails = dsEmp.Tables["Table"];
            dtSourceDetails = (DataTable)Session["Ses_rptFileName_CumulativeDetails"];
            rptDoc.Database.Tables["Details"].SetDataSource(dtSourceDetails);
            rptViewer.ReportSource = rptDoc; rptViewer.DataBind();
            rptDoc.Clone();
            return;
        }
        DataTable dtTemp = new DataTable();
        if (rptHeader == null)
        {
            rptHeader = dtTemp;
        }
        if (dtMonthlyAttendanceData2 != null)
        {
            if (dtMonthlyAttendanceData2.Rows.Count > 0)
            {
                rptDoc.Database.Tables["Table1"].SetDataSource(dtMonthlyAttendanceData2);
            }
        }
        if (strReportName == "EmployeeInOut")
            rptDoc.Database.Tables["Table1"].SetDataSource(dt7);
        if (ReportName != "WeeklyWorkHours_Angler")
            rptDoc.Database.Tables["Table_1"].SetDataSource(rptHeader);
        else
            rptDoc.Database.Tables["Table"].SetDataSource(rptHeader);
        if (rptFileName.IndexOf("SummaryReport.rpt") > 0 || rptFileName.IndexOf("SummaryReport_AR.rpt") > 0)
        {
            DataTable dtSummaryShift = new DataTable();
            dtSummaryShift = (DataTable)Session["Ses_dtSource_SummaryShift"];
            rptDoc.Database.Tables["Table1"].SetDataSource(dtSummaryShift);
        }
        if (rptFileName.IndexOf("CopyMovementsEntry.rpt") > 0)
            rptDoc.Database.Tables["MovShiftNotAllocated"].SetDataSource(dtMovShiftNotAllocated);
        if (rptFileName.IndexOf("detailedAttendance.rpt") > 0)
            rptDoc.Database.Tables["HeaderLabels"].SetDataSource(rptHeaderLabels);
        if (rptFileName.IndexOf("detailedAttendance_AR.rpt") > 0)
            rptDoc.Database.Tables["HeaderLabels"].SetDataSource(rptHeaderLabels);
        if ((rptFileName.Contains("Rptleave.rpt")) || (rptFileName.Contains("RptUnPlanedleave.rpt")))
        {
            rptDoc.Database.Tables["MonthName"].SetDataSource(Session["Session_dtMonthName"]);
            ParameterFields pfFields = new ParameterFields();
            ParameterField pfField = new ParameterField();
            ParameterDiscreteValue dis = new ParameterDiscreteValue();
            pfField.Name = "IntimationType";
            dis.Value = (chkunplan == 0);
            pfField.CurrentValues.Add(dis);
            rptViewer.ParameterFieldInfo.Add(pfField);
        }

        //******************Fist Code ********** Reprot partamter***********
        //if (strReportName != "DailyWagesPenalty")
        //{
        //    rptDoc.SetParameterValue("DtFormat", Convert.ToString(Session["MDateFormat"]));
        //    rptDoc.SetParameterValue("TimeFormat", Convert.ToString(Session["MTimeFormat"]));
        //}

        //******************Second Code ********** Reprot partamter Add UTC Datetime***********
        //if (strReportName != "DailyWagesPenalty")
        //{

        //        String ccc = Convert.ToString(Session["EmployeeCountryGetDateTime"]);
        //        rptDoc.SetParameterValue("DtFormat", Convert.ToString(Session["MDateFormat"]));
        //        rptDoc.SetParameterValue("TimeFormat", Convert.ToString(Session["MTimeFormat"]));
        //        rptDoc.SetParameterValue("UTCDateTime", Convert.ToString(Session["EmployeeCountryGetDateTime"]));  
        //}



        //******************3rd Code ********** Reprot partamter Add UTC Datetime***********
        if (strReportName != "EmployeeInOut" && strReportName != "DailyWagesPenalty")
        {
            String ccc = Convert.ToString(Session["EmployeeCountryGetDateTime"]);
            rptDoc.SetParameterValue("DtFormat", Convert.ToString(Session["MDateFormat"]));
            rptDoc.SetParameterValue("TimeFormat", Convert.ToString(Session["MTimeFormat"]));
            rptDoc.SetParameterValue("UTCDateTime", Convert.ToString(DateTime.Now.ToString()));

        }

        //******************4th Code *****Hariharan J**//01-03-2024//
        //*** Reprot partamter Add UTC Datetime Muster Roll Detail Report paramter only***********

        if (strReportName == "EmployeeInOut")
        {
            if (strReportType == "Details")
            {
                rptDoc.SetParameterValue("FromDate", Convert.ToString(dtFrom));
                rptDoc.SetParameterValue("ToDate", Convert.ToString(dtTo));
                rptDoc.SetParameterValue("Display", Convert.ToString(Session["strReportType"]));
                rptDoc.SetParameterValue("DtFormat", Convert.ToString(Session["MDateFormat"]));
                rptDoc.SetParameterValue("TimeFormat", Convert.ToString(Session["MTimeFormat"]));
                //rptDoc.SetParameterValue("UTCDateTime", Convert.ToString(Session["EmployeeCountryGetDateTime"]));
            }
            else
            {
                rptDoc.SetParameterValue("DtFormat", Convert.ToString(Session["MDateFormat"]));
                rptDoc.SetParameterValue("UTCDateTime", Convert.ToString(Session["EmployeeCountryGetDateTime"]));
                rptDoc.SetParameterValue("TimeFormat", Convert.ToString(Session["MTimeFormat"]));
            }

            //rptDoc.SetParameterValue("FromDate", Convert.ToString(dtFrom));
            /// rptDoc.SetParameterValue("ToDate", Convert.ToString(dtTo));

            //rptDoc.SetParameterValue("Display", Convert.ToString(Session["strReportType"]));

        }

        rptViewer.ReportSource = rptDoc;
        rptViewer.ID = strReportName;
        rptViewer.DataBind();
        rptDoc.Clone();
    }
    private DataTable TempShiftAllocation(string dtFrom, string dtTo, string employeeName, string levelId, string EmployeeId, int employeeCategory, int employeeType, string userGroupName, string gradeLevel, string strSwipeCard, int ParentId, int DesignationId, string Gender)
    {
        DataTable dtSift = new DataTable();
        try
        {
            // Get Data from Temporary Shift Allocation
            DataSet dsTempShiftAllocation = new DataSet();
            //Fill Data to Dataset dsTempShiftAllocation
            dsTempShiftAllocation = rptEmp.SelectTempShiftAllocationReport(dtFrom, dtTo, employeeName, levelId, EmployeeId, employeeCategory, employeeType, Convert.ToString(Session["UserGroupName"]), gradeLevel, strSwipeCard, ParentId, DesignationId, Gender, 1, Convert.ToInt64(strEmpAutoId));
            //Check the Empty table 
            if (dsTempShiftAllocation.Tables["Table"] == null || dsTempShiftAllocation.Tables["Table"].Rows.Count == 0)
            {
                dtSift = null;
            }
            else
            {
                int fromDay = DateTime.Parse(dtFrom).Day;
                int fromMonth = DateTime.Parse(dtFrom).Month;
                int fromYear = DateTime.Parse(dtFrom).Year;
                int toDay = DateTime.Parse(dtTo).Day;
                int toMonth = DateTime.Parse(dtTo).Month;
                int toYear = DateTime.Parse(dtTo).Year;
                int j = 0;
                DataTable dtShiftShortName = new DataTable();
                dtShiftShortName = rptEmp.GetShiftShortNameWithOutTime();
                for (int k = 0; k <= dsTempShiftAllocation.Tables[0].Columns.Count - 5; k++)
                {
                    if (k == 0)
                    {
                        dtSift.Columns.Add("Employee Name");
                    }
                    else if (k == 1)
                    {
                        dtSift.Columns.Add("Employee Id");
                    }
                    else if (k == 2)
                    {
                        dtSift.Columns.Add("Year");
                    }
                    else if (k == 3)
                    {
                        dtSift.Columns.Add("Month");
                    }
                    else if (k == dsTempShiftAllocation.Tables[0].Columns.Count - 5)
                    {
                        dtSift.Columns.Add("Gender");
                    }
                    else
                    {
                        dtSift.Columns.Add(Convert.ToString((k - 3)));
                    }
                }
                foreach (DataRow dr in dsTempShiftAllocation.Tables[0].Rows)
                {
                    j = j + 1;
                    dtSift.Rows.Add();
                    for (int i = 0; i <= dsTempShiftAllocation.Tables[0].Columns.Count - 5; i++)
                    {
                        if (i == 4 && Convert.ToInt32(dr["Month"]) == fromMonth)
                        {
                            if (Convert.ToInt32(dr["Year"]) != fromYear)
                            {
                            }
                            else
                            {
                                i = fromDay + 3;
                            }
                        }
                        if (i > 3 && i < dsTempShiftAllocation.Tables[0].Columns.Count - 5)
                        {
                            foreach (DataRow dRow in dtShiftShortName.Rows)
                            {
                                if (Convert.ToString(dr[i]) == Convert.ToString(dRow["Shift_Id"]))
                                {
                                    dtSift.Rows[j - 1][i] = dRow["Shift_ShortName"];
                                }
                                else if (Convert.ToString(dr[i]) == "-1")
                                {
                                    dtSift.Rows[j - 1][i] = rm.GetString("lbl_Off", ci);
                                }
                            }
                        }
                        else if (i == 3)
                        {
                            DateTimeFormatInfo dtfi = new CultureInfo("en-US", true).DateTimeFormat;
                            string temp = dtfi.GetMonthName(Convert.ToInt32(dr[i]));
                            dtSift.Rows[j - 1][i] = temp;
                        }
                        else if (i == dsTempShiftAllocation.Tables[0].Columns.Count - 5)
                        {
                            dtSift.Rows[j - 1][i] = dr["Gender"];
                        }
                        else
                        {
                            dtSift.Rows[j - 1][i] = dr[i];
                        }
                        if (toDay + 3 == i && Convert.ToInt32(dr["Month"]) == toMonth && Convert.ToInt32(dr["Year"]) == toYear)
                        {
                            i = dsTempShiftAllocation.Tables[0].Columns.Count - 6;
                        }
                    }
                }
            }
        }
        catch (Exception ex)
        {
            Response.Write(ex.Message);
        }
        return dtSift;
    }
    /// <summary>
    /// Monthly Attendance Report
    /// </summary>
    public void LoadGeneralMonthlyAttendanceReport()
    {
        if (Request.QueryString["ScheduleId"] != null)
        {
            dsEmp = rptEmp.SelectReportData(Filters, ReportName, ReportType);
        }
        else
        {
            dsEmp = rptEmp.SelectGeneralMonthlyAttendanceReport(dtFrom, dtTo, employeeName, Level, empId, EmployeeCategory, EmployeeType, Convert.ToString(Session["UserGroupName"]), GradeLevel, strSwipeCard, Convert.ToInt16(ParentLevelid), Convert.ToInt32(Designation), Gender, shft, Convert.ToInt32(strEmpAutoId));
        }

        //Check the Empty table 
        if (dsEmp.Tables["Table"] == null || dsEmp.Tables["Table"].Rows.Count == 0)
        {
            blnCheckDataExits = false;
            MessagewithClose(rm.GetString("Alert_Thereisnorecord", ci));
            return;
        }
        DataSet dsHeader = new DataSet();
        DataTable dt = new DataTable();
        if (Convert.ToInt16(ParentLevelid) != 0)
        {
            dt = rptEmp.getHeader(Convert.ToInt16(ParentLevelid));
            Session["Ses_rptHeader_GeneralMonthlyAttendance"] = dt;
        }
        else
        {
            Session["Ses_rptHeader_GeneralMonthlyAttendance"] = dt;
        }
        DataTable dtHdr1 = GetReportHeader();
        dtHdr = dtHdr1;
        dtSource = dsEmp.Tables[0];
        rptFileName = Server.MapPath(rm.GetString("rptGeneralMonthlyAttendance", ci));
        Session["Ses_dtHdr_GeneralMonthlyAttendance"] = dtHdr;
        Session["Ses_dtSource_GeneralMonthlyAttendance"] = dtSource;
        Session["Ses_rptFileName_GeneralMonthlyAttendance"] = rptFileName;
    }
    /// <summary>
    /// Angler Specific Report - ARMIS & Cumulative Work Hours Deviation Report
    /// </summary>


    public void LoadPayslip()
    {
        if (Request.QueryString["ScheduleId"] != null)
        {
            dsEmp = rptEmp.SelectReportData(Filters, ReportName, ReportType);

        }
        else
        {
            dsEmp = rptEmp.SelectPayslipReport(dtFrom, dtTo, employeeName, Level, empId, EmployeeCategory, EmployeeType, Convert.ToString(Session["UserGroupName"]), GradeLevel, strSwipeCard, Convert.ToInt16(ParentLevelid), Convert.ToInt32(Designation), Gender, shft, Convert.ToInt32(strEmpAutoId));

            if (dsEmp.Tables["Table"] == null || dsEmp.Tables["Table"].Rows.Count == 0)
            {
                blnCheckDataExits = false;
                MessagewithClose(rm.GetString("Alert_Thereisnorecord", ci));
                return;
            }
            DataSet dsHeader = new DataSet();
            DataTable dt = new DataTable();
            if (Convert.ToInt16(ParentLevelid) != 0)
            {
                dt = rptEmp.getHeader(Convert.ToInt16(ParentLevelid));
                Session["Ses_rptHeader_Payslip"] = dt;
            }
            else
            {
                Session["Ses_rptHeader_Payslip"] = dt;
            }
            DataTable dtHdr1 = GetReportHeader();
            dtHdr = dtHdr1;
            dtSource = dsEmp.Tables[1];
            rptFileName = Server.MapPath(rm.GetString("rptPayslip", ci));
            Session["Ses_dtHdr_Payslip"] = dtHdr;
            //dtHdr.WriteXmlSchema(@"C:\PaySlipReportHeader.xml");
            Session["Ses_dtSource_Payslip"] = dtSource;
            //dsEmp.Tables[1].WriteXmlSchema(@"C:\PaySlipReportData.xml");
            Session["Ses_rptFileName_Payslip"] = rptFileName;
            //dt.WriteXmlSchema(@"C:\PaySlipReportLogo.xml");

        }
    }
    public void NearestShiftDetails()
    {
        DataTable dtHdr1 = new DataTable();
        dtHdr1 = hdrTable.CreateHeader();
        dtHdr1.TableName = "Header";
        DataRow drHdr = dtHdr1.NewRow();
        drHdr["Link"] = 1;
        drHdr["Hdr1"] = "";
        drHdr["Hdr2"] = "";
        drHdr["Address1"] = "";
        drHdr["Address2"] = "";
        drHdr["ReportName"] = "Nearest Shift Report";
        dtDate = rptEmp.GetDateMonth(dtFrom, dtTo);
        if (dtDate.Rows.Count > 0)
        {
            drHdr["FromDate"] = dtDate.Rows[0][0];
            drHdr["ToDate"] = dtDate.Rows[0][1];
        }
        else
        {
            drHdr["ToDate"] = "";
            drHdr["FromDate"] = "";
        }
        dtHdr1.Rows.Add(drHdr);
        if (Convert.ToString(Session["NearestShiftDetails"]) != string.Empty)
        {
            dsEmp = (DataSet)Session["NearestShiftDetails"];
        }
        else
        {
            blnCheckDataExits = false;
            MessagewithClose(rm.GetString("Alert_Thereisnorecord", ci));
            return;
        }
        DataTable dt = new DataTable();
        if (Convert.ToInt16(ParentLevelid) != 0)
        {
            dt = rptEmp.getHeader(Convert.ToInt16(ParentLevelid));
            Session["Ses_rptHeader_NearestShift"] = dt;
        }
        else
        {
            Session["Ses_rptHeader_NearestShift"] = dt;
        }
        rptFileName = Server.MapPath(rm.GetString("NearestShiftReport", ci));
        dtHdr = dtHdr1;
        Session["Ses_rptFileName_NearestShift"] = rptFileName;
        Session["Ses_dtHdr_NearestShift"] = dtHdr;
        Session["Ses_dtSource_NearestShift"] = dsEmp.Tables[0];
    }
    public void LoadDailyWagesPenalty()
    {
        int isDetailed = 0;
        if (Request.QueryString["isDetailed"] != null)
        {
            isDetailed = Convert.ToInt16(Request.QueryString["isDetailed"]);
        }
        if (Convert.ToString(Session["DailyWagesPenalty"]) != "")
            dsEmp = (DataSet)Session["DailyWagesPenalty"];
        else
            dsEmp = rptEmp.GetDailyWagesDetails(dtFrom, dtTo, employeeName, Level, empId, EmployeeCategory, EmployeeType, Convert.ToString(Session["UserGroupName"]), GradeLevel, Convert.ToInt16(ParentLevelid), Convert.ToInt32(Designation), Gender, shft, Convert.ToInt64(strEmpAutoId), isDetailed);
        //Check the Empty table 
        if (dsEmp.Tables["Table"] == null || dsEmp.Tables["Table"].Rows.Count == 0)
        {
            blnCheckDataExits = false;
            MessagewithClose(rm.GetString("Alert_Thereisnorecord", ci));
            return;
        }
        DataSet dsHeader = new DataSet();
        DataTable dt = new DataTable();
        if (Convert.ToInt16(ParentLevelid) != 0)
        {
            dt = rptEmp.getHeader(Convert.ToInt16(ParentLevelid));
            Session["Ses_rptHeader_DailyWages_Sohit"] = dt;
        }
        else
        {
            Session["Ses_rptHeader_DailyWages_Sohit"] = dt;
        }
        DataTable dtHdr1 = GetReportHeader();
        dtHdr = dtHdr1;
        DataTable dtsource = new DataTable();
        dtsource = dsEmp.Tables[0];
        if (isDetailed == 1)
        {
            rptFileName = Getreportpath(rm.GetString("RptDailyWagesSohit_Summary", ci));
        }
        else
        {
            rptFileName = Getreportpath(rm.GetString("RptDailyWagesSohit_Detailed", ci));
        }
        if (!File.Exists(rptFileName))
        {
            blnCheckDataExits = false;
            MessagewithClose("Report file is missing");
            return;
        }
        Session["Ses_dtSource_DailyWages_Sohit"] = dtsource;
        Session["Ses_dtHdr_DailyWages_Sohit"] = dtHdr;
        Session["Ses_rptFileName_DailyWages_Sohit"] = rptFileName;
        //dtsource.WriteXmlSchema("E:\\DataSourceofDailyDeductionSummary.xml");
    }
    public void LoadPayrollDetails()
    {
        if (Convert.ToString(Session["PayrollDetails_Sohit"]) != "")
            dsEmp = (DataSet)Session["PayrollDetails_Sohit"];
        else
            dsEmp = rptEmp.GetPayrollDetails(dtFrom, dtTo, employeeName, empId, EmployeeCategory, EmployeeType, Convert.ToString(Session["UserGroupName"]), GradeLevel, Convert.ToInt16(ParentLevelid), Convert.ToInt32(Designation), Gender, Convert.ToInt64(strEmpAutoId));
        //Check the Empty table 
        if (dsEmp.Tables["Table"] == null || dsEmp.Tables["Table"].Rows.Count == 0)
        {
            blnCheckDataExits = false;
            MessagewithClose(rm.GetString("Alert_Thereisnorecord", ci));
            return;
        }
        DataSet dsHeader = new DataSet();
        DataTable dt = new DataTable();
        if (Convert.ToInt16(ParentLevelid) != 0)
        {
            dt = rptEmp.getHeader(Convert.ToInt16(ParentLevelid));
            Session["Ses_rptHeader_Payroll_Sohit"] = dt;
        }
        else
        {
            Session["Ses_rptHeader_Payroll_Sohit"] = dt;
        }
        DataTable dtHdr1 = GetReportHeader();
        dtHdr = dtHdr1;
        rptFileName = Getreportpath(rm.GetString("RptPayroll_Sohit", ci));
        if (!File.Exists(rptFileName))
        {
            blnCheckDataExits = false;
            MessagewithClose("Report file is missing");
            return;
        }
        Session["Ses_dtHdr_Payroll_Sohit"] = dtHdr;
        Session["Ses_rptFileName_Payroll_Sohit"] = rptFileName;
        Session["Ses_dtSource_Payroll_Sohit"] = dsEmp.Tables[0];
    }
    /// <summary>
    /// Angler Specific Report - ARMIS & Cumulative Work Hours Deviation Report
    /// </summary>
    public void LoadDeviationWorkHours()
    {
        //Create the datatable ,that holds the header information
        int iReportType = Request.QueryString["ReportType"] == null ? 1 : Convert.ToInt32(Request.QueryString["ReportType"]);
        DataTable dtHdr1 = new DataTable();
        dtHdr1 = hdrTable.CreateHeader();
        dtHdr1.TableName = "Header";
        //Add the Header information
        DataRow drHdr = dtHdr1.NewRow();
        drHdr["Link"] = 1;
        drHdr["Hdr1"] = "";
        drHdr["Hdr2"] = "";
        drHdr["Address1"] = "";
        drHdr["Address2"] = "";
        drHdr["ReportName"] = "ARMIS And Cumulative Work Hours Deviation Report";
        if (dtFrom != "")
        {
            DateTime tmpFrom = DateTime.Parse(dtFrom);
            drHdr["FromDate"] = tmpFrom.ToString("dd-MMM-yyyy");
        }
        else
            drHdr["FromDate"] = "";
        if (dtTo != "")
        {
            DateTime tmpTo = DateTime.Parse(dtTo);
            drHdr["ToDate"] = tmpTo.ToString("dd-MMM-yyyy");
        }
        else
            drHdr["ToDate"] = "";
        dtHdr1.Rows.Add(drHdr);
        dsEmp = rptEmp.SelectMonthlyDeviationHrs(empId, Level, dtFrom, dtTo, empName, EmployeeCategory, EmployeeType, Session["UserGroupName"].ToString(), Convert.ToString(Session["GradeLevel"]), strSwipeCard, Convert.ToInt32(strEmpAutoId), iReportType, Convert.ToInt16(ParentLevelid));
        if (dsEmp.Tables[0].Rows.Count <= 0)
        {
            blnCheckDataExits = false;
            MessagewithClose(rm.GetString("Alert_Thereisnorecord", ci));
            return;
        }
        //Report Header
        int orgID = Convert.ToInt32(ParentLevelid);
        if (orgID == 0)
        {
            //orgID = 1;
            DataSet dsOrgid = new DataSet();
            dsOrgid = rptEmp.getMinLevel();
            if (dsOrgid.Tables[0].Rows.Count > 0)
            {
                if (dsOrgid.Tables[0].Rows[0]["minID"] != DBNull.Value)
                {
                    orgID = Convert.ToInt16(dsOrgid.Tables[0].Rows[0]["minID"]);
                }
            }
        }
        int lid = 0;
        org_levelsEventData getOrg = new org_levelsEventData();
        getOrg.GetOrgParentLevels_FromID(orgID);
        DataSet ds_getOrg = new DataSet();
        ds_getOrg = getOrg.GetOrgParentLevels();
        if (ds_getOrg.Tables[0].Rows.Count > 0)
        {
            lid = Convert.ToInt16(ds_getOrg.Tables[0].Rows[0]["levelID"]);
        }
        DataTable dtRptHeader = new DataTable();
        dtRptHeader = rptEmp.getHeader(lid);
        rptHeader = dtRptHeader;
        //End of Report Header        
        //Set the session variable that holds the report table and report header table
        dtHdr = dtHdr1;
        dtSource = dsEmp.Tables["Table"].Copy();
        rptFileName = Server.MapPath(rm.GetString("DeviationWorkHours", ci));
        dtHdr = dtHdr1;
        Session["Ses_rptFileName_Deviation"] = rptFileName;
        Session["Ses_dtHdr_Deviation"] = dtHdr;
        Session["Ses_dtSource_Deviation"] = dtSource;
        Session["Ses_rptHeader_Deviation"] = rptHeader;
    }
    /// <summary>
    /// Angler Specific Report -  Daily Deviation Report
    /// </summary>
    public void LoadDailyDeviationReport()
    {
        //Create the datatable ,that holds the header information
        DataTable dtHdr1 = new DataTable();
        dtHdr1 = hdrTable.CreateHeader();
        dtHdr1.TableName = "Header";
        //Add the Header information
        DataRow drHdr = dtHdr1.NewRow();
        drHdr["Link"] = 1;
        drHdr["Hdr1"] = "Neuland Laboratories Limited";
        drHdr["Hdr2"] = "NEULAND";
        drHdr["Address1"] = "HeadOffice";
        drHdr["Address2"] = "Hyderabad";
        drHdr["ReportName"] = "Daily Minimum Work Hours Deviation Report";
        if (dtFrom != "")
        {
            DateTime tmpFrom = DateTime.Parse(dtFrom);
            drHdr["FromDate"] = tmpFrom.ToString(Convert.ToString(Session["MDateFormat"]));
        }
        else
            drHdr["FromDate"] = "";
        if (dtTo != "")
        {
            DateTime tmpTo = DateTime.Parse(dtTo);
            drHdr["ToDate"] = tmpTo.ToString(Convert.ToString(Session["MDateFormat"]));
        }
        else
            drHdr["ToDate"] = "";
        dtHdr1.Rows.Add(drHdr);
        if (Session["dsDailyDeviation"] == null)
        {
            dsEmp = rptEmp.SelectDailyDeviationReport(dtFrom, dtTo, employeeName, Level, empId, EmployeeCategory, EmployeeType, UserGroupName, GradeLevel, strSwipeCard, Convert.ToInt16(strEmpAutoId), Convert.ToInt16(ParentLevelid), Designation, Gender, 0);
        }
        else
        {
            if (Session["dsDailyDeviation"] != null)
            {
                dsEmp = (DataSet)Session["dsDailyDeviation"];
            }
            else
            {
                blnCheckDataExits = false;
                MessagewithClose(rm.GetString("Alert_Thereisnorecord", ci));
                return;
            }
        }
        //Report Header
        int orgID = Convert.ToInt16(ParentLevelid);
        if (orgID == 0)
        {
            //orgID = 1;
            DataSet dsOrgid = new DataSet();
            dsOrgid = rptEmp.getMinLevel();
            if (dsOrgid.Tables[0].Rows.Count > 0)
            {
                if (dsOrgid.Tables[0].Rows[0]["minID"] != DBNull.Value)
                {
                    orgID = Convert.ToInt16(dsOrgid.Tables[0].Rows[0]["minID"]);
                }
            }
        }
        int lid = 0;
        org_levelsEventData getOrg = new org_levelsEventData();
        getOrg.GetOrgParentLevels_FromID(orgID);
        DataSet ds_getOrg = new DataSet();
        ds_getOrg = getOrg.GetOrgParentLevels();
        if (ds_getOrg.Tables[0].Rows.Count > 0)
        {
            lid = Convert.ToInt16(ds_getOrg.Tables[0].Rows[0]["levelID"]);
        }
        DataSet dsHeader = new DataSet();
        DataTable dt = new DataTable();
        if (Convert.ToInt16(ParentLevelid) != 0)
        {
            dt = rptEmp.getHeader(Convert.ToInt16(ParentLevelid));
            Session["reportHeader"] = dt;
        }
        else
        {
            Session["reportHeader"] = dt;
        }
        DataTable dtRptHeader = new DataTable();
        dtRptHeader = dt;
        rptHeader = dtRptHeader;
        //End of Report Header
        DataTable dtDailyDeviation = new DataTable();
        dtDailyDeviation = dsEmp.Tables["Table"].Copy();
        //Add the link column
        DataColumn dcLink = new DataColumn("Link", Type.GetType("System.Int32"));
        dtDailyDeviation.Columns.Add(dcLink);
        for (int i = 0; i < dtDailyDeviation.Rows.Count; i++)
        {
            dtDailyDeviation.Rows[i]["Link"] = 1;
        }
        //WRITE XML SCHEMA TO DISK - THIS IS ONLY REQUIRED DURING DEVELOPMENT TO BUILD THE REPORT
        //Check the Empty table
        if (dtDailyDeviation.Rows.Count == 0)
        {
            blnCheckDataExits = false;
            MessagewithClose(rm.GetString("Alert_Thereisnorecord", ci));
            return;
        }
        //Set the session variable that holds the report table and report header table
        dtHdr = dtHdr1;
        dtSource = dtDailyDeviation;
        rptFileName = Server.MapPath(rm.GetString("rptDailyDeviation", ci));
        Session["Ses_rptFileName_DailyDeviation"] = rptFileName;
        Session["Ses_dtHdr_DailyDeviation"] = dtHdr;
        Session["Ses_dtSource_DailyDeviation"] = dtSource;
        Session["Ses_rptHeader_DailyDeviation"] = rptHeader;
    }
    /// <summary>
    /// Angler Specific Report -  LeaveAnalysis Report
    /// </summary>
    public void LoadLeaveAnalysisReport()
    {
        //for header ie. Logo,levelname,city
        //dt_LogoHeader table in the workingdays dataset
        //Table2
        DataTable dt = new DataTable();
        if (Convert.ToInt16(ParentLevelid) != 0)
        {
            dt = rptEmp.getHeader(Convert.ToInt16(ParentLevelid));
            //DataTable dtImages = getDTImage();
            //dt = LoadImages(dtImages, dt);
            Session["Ses_rptHeader_LeaveAnalysis"] = dt;
        }
        else
        {
            // DataTable dtImages = getDTImage();
            // dt = LoadImages(dtImages, dt);
            Session["Ses_rptHeader_LeaveAnalysis"] = dt;
        }
        // Create the datatable ,that holds the header information
        DataTable dtHdr1 = new DataTable();
        dtHdr1 = hdrTable.CreateHeader();
        dtHdr1.TableName = "Header";
        //Add the Header information
        DataRow drHdr = dtHdr1.NewRow();
        drHdr["Link"] = 1;
        drHdr["Hdr1"] = "";
        drHdr["Hdr2"] = "";
        drHdr["Address1"] = "";
        drHdr["Address2"] = Convert.ToString(Session["Remarks"]);
        drHdr["ReportName"] = "Leave Analysis Report";
        if (dtFrom != "")
        {
            DateTime tmpFrom = DateTime.Parse(dtFrom);
            drHdr["FromDate"] = tmpFrom.ToString("dd-MMM-yyyy");
        }
        else
            drHdr["FromDate"] = "";
        if (dtTo != "")
        {
            DateTime tmpTo = DateTime.Parse(dtTo);
            drHdr["ToDate"] = tmpTo.ToString("dd-MMM-yyyy");
        }
        else
            drHdr["ToDate"] = "";
        dtHdr1.Rows.Add(drHdr);
        //string dtFrom = string.Empty, dtTo = string.Empty;
        //if (txtFromDate.Text != string.Empty)
        //    dtFrom = strFromdate;
        //if (txtToDate.Text != string.Empty)
        //    dtTo = strTodate;
        //string strEmpName = string.Empty, strEmpId = string.Empty;
        //string strEmployeeName = string.Empty;
        //string strLevel = string.Empty;
        //if (intIndividualUser >= 1)
        //{
        //    strEmpName = string.Empty;
        //    strLevel = string.Empty;
        //    strEmpId = Convert.ToString(Session["EmployeeCodeId"]);
        //}
        //else
        //{
        //    strEmpName = txtEmployeeName.Text.ToString();
        //    strEmpId = txtEmployeeId.Text.ToString().Trim();
        //    strEmployeeName = this.txtEmployeeName.Text.Replace("'", "''");
        //    strLevel = rptcommon.getNodes(Convert.ToInt16(Session["parentLevelId"]), Convert.ToString(Session["LevelRights"]));
        //}
        //Get the Report source from the Server and load this into the report table
        DataSet dsLeaveAnalysis = new DataSet();
        //dsEmp = rptEmp.SelectLeave(, shft, , , LeaveType, Status, EmployeeCategory, EmployeeType, , , strSwipeCard);
        dsLeaveAnalysis = rptEmp.SelectLeaveAnalysis(dtFrom, dtTo, empId, employeeName, Level, UserGroupName, GradeLevel, strLeavePlanned, strLeaveWI, strLeaveWOI, Convert.ToInt64(strEmpAutoId));
        foreach (DataRow drLeaveAnalysis in dsLeaveAnalysis.Tables[0].Rows)
        {
            string[] strPermiDate;
            string[] strLeaveDate;
            string[] strAbsentDate;
            string strPermissionDates = string.Empty;
            string strLeaveDates = string.Empty;
            string strAbsentDates = string.Empty;
            if (drLeaveAnalysis["PermiDate"] != DBNull.Value)
            {
                strPermiDate = drLeaveAnalysis["PermiDate"].ToString().Split(',');
                for (int iLoop = 0; iLoop < strPermiDate.Length; iLoop++)
                {
                    string strDate = (strPermiDate[iLoop].Trim().Substring(0, 2) + strPermiDate[iLoop].Trim().Substring(11));
                    if (strPermissionDates == string.Empty)
                    {
                        strPermissionDates = strDate;
                        drLeaveAnalysis["PermiDate"] = strPermissionDates;
                    }
                    else
                    {
                        strPermissionDates = strPermissionDates + ", " + strDate;
                        drLeaveAnalysis["PermiDate"] = strPermissionDates;
                    }
                }
            }
            if (drLeaveAnalysis["LeaveDate"] != DBNull.Value)
            {
                strLeaveDate = drLeaveAnalysis["LeaveDate"].ToString().Split(',');
                for (int iLoop = 0; iLoop < strLeaveDate.Length; iLoop++)
                {
                    string strDate = string.Empty;
                    if (strLeaveDate[iLoop] != string.Empty)
                    {
                        if (strLeaveDate[iLoop].Length > 20)
                        {
                            string strDateFrom = (strLeaveDate[iLoop].Trim().Substring(0, 2));
                            string strDateTo = (strLeaveDate[iLoop].Trim().Substring(14, 2) + strLeaveDate[iLoop].Trim().Substring(25));
                            strDate = strDateFrom + "-" + strDateTo;
                        }
                        else
                        {
                            strDate = (strLeaveDate[iLoop].Trim().Substring(0, 2) + strLeaveDate[iLoop].Trim().Substring(11));
                        }
                    }
                    if (strLeaveDates == string.Empty)
                    {
                        strLeaveDates = strDate;
                        drLeaveAnalysis["LeaveDate"] = strLeaveDates;
                    }
                    else
                    {
                        strLeaveDates = strLeaveDates + ", " + strDate;
                        drLeaveAnalysis["LeaveDate"] = strLeaveDates;
                    }
                }
            }
            if (drLeaveAnalysis["AbsentDate"] != DBNull.Value)
            {
                strAbsentDate = drLeaveAnalysis["AbsentDate"].ToString().Split(',');
                if (strAbsentDate.Length > 12)
                {
                    drLeaveAnalysis["AbsentDate"] = "Absent Occurences : " + strAbsentDate.Length;
                }
                //for (int iLoop = 0; iLoop < strAbsentDate.Length; iLoop++)
                //{
                //    int intIndex = strAbsentDate[iLoop].ToString().IndexOf("(", 0);
                //    if (intIndex != -1)
                //    {
                //        //strAbsentDate = strAbsentDate.ToString().Replace(strAbsentDate.ToString().Substring(1,intIndex), strDate);
                //        string strDate = SuffixedDate(strAbsentDate[iLoop].ToString().Trim().Substring(0, intIndex));
                //        strDate = strAbsentDate[iLoop].ToString().Replace(strAbsentDate[iLoop].ToString().Trim().Substring(0, intIndex), strDate);
                //        if (strAbsentDates == string.Empty)
                //        {
                //            strAbsentDates = strDate.ToString();
                //            drLeaveAnalysis["AbsentDate"] = strAbsentDates;
                //        }
                //        else
                //        {
                //            strAbsentDates = strAbsentDates + ", " + strDate;
                //            drLeaveAnalysis["AbsentDate"] = strAbsentDates;
                //        }
                //    }
                //}
            }
        }
        //DataTable dtNew = new DataTable();
        //dtNew = dtHeaderLabel.Copy();
        //Session["HeaderLabels"] = dtHeaderLabel;
        //Report Header
        int orgID = Convert.ToInt16(ParentLevelid);
        if (orgID == 0)
        {
            //orgID = 1;
            DataSet dsOrgid = new DataSet();
            dsOrgid = rptEmp.getMinLevel();
            if (dsOrgid.Tables[0].Rows.Count > 0)
            {
                if (dsOrgid.Tables[0].Rows[0]["minID"] != DBNull.Value)
                {
                    orgID = Convert.ToInt16(dsOrgid.Tables[0].Rows[0]["minID"]);
                }
            }
        }
        int lid = 0;
        org_levelsEventData getOrg = new org_levelsEventData();
        getOrg.GetOrgParentLevels_FromID(orgID);
        DataSet ds_getOrg = new DataSet();
        ds_getOrg = getOrg.GetOrgParentLevels();
        if (ds_getOrg.Tables[0].Rows.Count > 0)
        {
            lid = Convert.ToInt16(ds_getOrg.Tables[0].Rows[0]["levelID"]);
        }
        //DataSet dsHeader = new DataSet();
        //dsHeader = rptEmp.getHeader(lid);
        //if (dsHeader.Tables[0].Rows.Count > 0)
        //{
        //    DataTable dtRptHeader = new DataTassble();
        //    dtRptHeader = dsHeader.Tables[0].Copy();
        //    rptHeader = dtRptHeader;
        //}
        //End of Report Header
        DataTable dtLeaveAnalysis = new DataTable();
        dtLeaveAnalysis = dsLeaveAnalysis.Tables["Table"].Copy();
        // Add the link column
        DataColumn dcLink = new DataColumn("Link", Type.GetType("System.Int32"));
        dtLeaveAnalysis.Columns.Add(dcLink);
        for (int i = 0; i < dtLeaveAnalysis.Rows.Count; i++)
        {
            dtLeaveAnalysis.Rows[i]["Link"] = 1;
        }
        //WRITE XML SCHEMA TO DISK - THIS IS ONLY REQUIRED DURING DEVELOPMENT TO BUILD THE REPORT
        //return;
        //Set the session variable that holds the report table and report header table
        //Session["Ses_dtHdr_AllSwipes"] = dtHdr;
        //Session["Ses_dtSource_AllSwipes"] = dtSource;
        //Session["Ses_rptFileName_AllSwipes"] = rptFileName;
        Session["Ses_dtHdr_LeaveAnalysis"] = dtHdr1;
        Session["Ses_dtSource_LeaveAnalysis"] = dtLeaveAnalysis;
        //if (Normal == "True")
        //{
        //    rptFileName = Server.MapPath(rm.GetString("leaveReport", ci));
        //}
        //else
        //{
        //    rptFileName = Server.MapPath(rm.GetString("rptLeaveGraph", ci));
        //}
        if (strLeavePlanned == string.Empty && strLeaveWI == string.Empty && strLeaveWOI == string.Empty)
        {
            Session["Ses_rptFileName_LeaveAnalysis"] = Server.MapPath("LeaveAnalysis.rpt");
        }
        else
        {
            Session["Ses_rptFileName_LeaveAnalysis"] = Server.MapPath("LeaveAnalysis_WI.rpt");
        }
    }
    /// <summary>
    /// Summary Report
    /// </summary>
    public void LoadInPunchDeviationHrs()
    {
        //Create the datatable ,that holds the header information
        DataTable dtHdr1 = new DataTable();
        dtHdr1 = hdrTable.CreateHeader();
        dtHdr1.TableName = "Header";
        //Add the Header information
        DataRow drHdr = dtHdr1.NewRow();
        drHdr["Link"] = 1;
        drHdr["Hdr1"] = "";
        drHdr["Hdr2"] = "";
        drHdr["Address1"] = "";
        drHdr["Address2"] = "";
        drHdr["ReportName"] = "In Punch Deviation Hours Report";
        if (dtFrom != "")
        {
            DateTime tmpFrom = DateTime.Parse(dtFrom);



            drHdr["FromDate"] = tmpFrom.ToString(Convert.ToString(Session["MDateFormat"]));
        }
        else
            drHdr["FromDate"] = "";
        if (dtTo != "")
        {
            DateTime tmpTo = DateTime.Parse(dtTo);
            drHdr["ToDate"] = tmpTo.ToString(Convert.ToString(Session["MDateFormat"]));
        }
        else
            drHdr["ToDate"] = "";
        dtHdr1.Rows.Add(drHdr);
        DataSet dsHeader = new DataSet();
        DataTable dt = new DataTable();
        if (Convert.ToInt16(ParentLevelid) != 0)
        {
            dt = rptEmp.getHeader(Convert.ToInt16(ParentLevelid));
            Session["Ses_rptHeader_InPunchDeviationHrs"] = dt;
        }
        else
        {
            Session["Ses_rptHeader_InPunchDeviationHrs"] = dt;
        }
        DataSet dstInDeviationHrs = rptEmp.GetFirstInPunchDifference(empId, Level, dtFrom, dtTo, employeeName, EmployeeCategory, EmployeeType, Convert.ToString(Session["UserGroupName"]), GradeLevel, Convert.ToInt32(strEmpAutoId), strMaxDeviationHrs, strPunchType.Replace(":", "'"), Convert.ToInt16(ParentLevelid));
        //DataSet dstInDeviationHrs = rptEmp.GetFirstInPunchDifference(empId, "107,108,109,110,111,112,113,114,115,123", dtFrom, dtTo, employeeName, EmployeeCategory, EmployeeType, Convert.ToString(Session["UserGroupName"]), GradeLevel, Convert.ToInt32(strEmpAutoId), strMaxDeviationHrs, strPunchType.Replace(":", "'"));
        if (dstInDeviationHrs.Tables[0].Rows.Count <= 0)
        {
            blnCheckDataExits = false;
            MessagewithClose(rm.GetString("Alert_Thereisnorecord", ci));
            return;
        }
        dtHdr = dtHdr1;
        dtSource = dstInDeviationHrs.Tables[0];
        rptFileName = Server.MapPath(rm.GetString("InPunchDeviationHrsReport", ci));
        Session["Ses_dtHdr_InPunchDeviationHrs"] = dtHdr;
        Session["Ses_dtSource_InPunchDeviationHrs"] = dtSource;
        Session["Ses_rptFileName_InPunchDeviationHrs"] = rptFileName;
    }
    #endregion
    #region Not Used
    public void LoadEmployeeInOutReport()
    {
        string employeeCategory = string.Empty, employeeType = string.Empty;
        int iWorkingDays = 0;
        DataSet dsTot = new DataSet();
        dsTot = rptEmp.SelectTotalWorkingDays(Convert.ToString(Request.QueryString["dtMonth"]), Convert.ToString(Request.QueryString["dtYear"]));
        if (dsTot != null && dsTot.Tables.Count > 0 && dsTot.Tables[0].Rows.Count > 0 && dsTot.Tables[0].Rows[0]["TotalWokingDays"] != DBNull.Value)
        {
            iWorkingDays = Convert.ToInt32(dsTot.Tables[0].Rows[0]["TotalWokingDays"]);
        }
        DataTable dtRptHeader = new DataTable();
        string dtFrom = "", dtTo = "";
        string empName = "", empId = "";
        empName = Convert.ToString(Request.QueryString["EmpName"]);
        empId = Convert.ToString(Request.QueryString["empid"]);
        if (Convert.ToString(Request.QueryString["EmpCategory"]) != "-Select-" && Convert.ToString(Request.QueryString["EmpCategory"]) != "")
        {
            employeeCategory = Convert.ToString(Request.QueryString["EmpCategory"]);
        }
        else
        {
            employeeCategory = string.Empty;
        }
        if (Convert.ToString(Request.QueryString["EmpType"]) != "-Select-" && Convert.ToString(Request.QueryString["EmpType"]) != "")
        {
            employeeType = Convert.ToString(Request.QueryString["EmpType"]);
        }
        else
        {
            employeeType = string.Empty;
        }
        DataSet dsForm25 = new DataSet();
        int shft = 1;
        string employeeName = Convert.ToString(Request.QueryString["EmpName"]).Replace("'", "''");
        string SelectedMonth = Convert.ToString(Request.QueryString["dtMonth"]);
        string SelectedYear = Convert.ToString(Request.QueryString["dtYear"]);
        int orgID = Convert.ToInt16(Request.QueryString["ParentLevelId"]);
        Session["parentLevelId"] = null;
        if (orgID == 0)
        {
            DataSet dsOrgid = new DataSet();
            dsOrgid = rptEmp.getMinLevel();
            if (dsOrgid.Tables[0].Rows.Count > 0)
            {
                if (dsOrgid.Tables[0].Rows[0]["minID"] != DBNull.Value)
                {
                    orgID = Convert.ToInt16(dsOrgid.Tables[0].Rows[0]["minID"]);
                }
            }
        }
        int lid = 0;
        org_levelsEventData getOrg = new org_levelsEventData();
        getOrg.GetOrgParentLevels_FromID(orgID);
        DataSet ds_getOrg = new DataSet();
        ds_getOrg = getOrg.GetOrgParentLevels();
        if (ds_getOrg.Tables[0].Rows.Count > 0)
        {
            lid = Convert.ToInt16(ds_getOrg.Tables[0].Rows[0]["levelID"]);
        }
        DataSet dsHeader = new DataSet();
        DataTable dt = new DataTable();
        if (Convert.ToInt16(ParentLevelid) != 0)
        {
            dt = rptEmp.getHeader(lid);
            Session["reportHeader"] = dt;
        }
        else
        {
            Session["reportHeader"] = dt;
        }
        Session["parentLevelId"] = null;
        DataTable NewDT = new DataTable();
        string EmpID = "";
        DataColumn DC1 = new DataColumn();
        DC1.ColumnName = "Name";
        NewDT.Columns.Add(DC1);
        DataColumn DC2 = new DataColumn();
        DC2.ColumnName = "FatherName";
        NewDT.Columns.Add(DC2);
        DataColumn DC3 = new DataColumn();
        DC3.ColumnName = "Designation";
        NewDT.Columns.Add(DC3);
        DataColumn DC9 = new DataColumn();
        DC9.ColumnName = "Employee_Code_Id";
        NewDT.Columns.Add(DC9);
        DataColumn DC4 = new DataColumn();
        DC4.ColumnName = "Present";
        NewDT.Columns.Add(DC4);
        DataColumn DC5 = new DataColumn();
        DC5.ColumnName = "Absent";
        NewDT.Columns.Add(DC5);
        DataColumn DC6 = new DataColumn();
        DC6.ColumnName = "Leave";
        NewDT.Columns.Add(DC6);
        DataColumn dcHoliday = new DataColumn();
        dcHoliday.ColumnName = "Holiday";
        NewDT.Columns.Add(dcHoliday);
        DataColumn dcOT = new DataColumn();
        dcOT.ColumnName = "TotalOT";
        NewDT.Columns.Add(dcOT);
        for (int j = 1; j <= 31; j++)
        {
            DataColumn DC = new DataColumn();
            DC.ColumnName = "Day" + j;
            NewDT.Columns.Add(DC);
        }
        DataSet dsEmp = new DataSet();
        dsEmp = rptEmp.SelectInOutEmployee(SelectedMonth, SelectedYear, empId, employeeName, Level, employeeCategory, employeeType, Convert.ToString(Session["UserGroupName"]), Convert.ToString(Session["GradeLevel"]), strSwipeCard);
        {
            if (dsEmp.Tables[0].Rows.Count > 0)
            {
                for (int emp = 0; emp < dsEmp.Tables[0].Rows.Count; emp++)
                {
                    DataSet dsReport = new DataSet();
                    DataRow DR = NewDT.NewRow();
                    dsReport = rptEmp.SelectInOut(SelectedMonth, SelectedYear, Convert.ToString(dsEmp.Tables[0].Rows[emp]["Employee_code_id"]), employeeName, Level, employeeCategory, employeeType);
                    if (dsReport.Tables.Count > 0)
                    {
                        if (dsReport.Tables[1] != null)
                        {
                            if (dsReport.Tables[1].Rows.Count > 0)
                            {
                                if (dsReport.Tables[1].Rows[0]["Present"] != DBNull.Value)
                                {
                                    DR["Present"] = Convert.ToString(dsReport.Tables[1].Rows[0]["Present"]);
                                }
                                else
                                {
                                    DR["Present"] = 0;
                                }
                                if (dsReport.Tables[1].Rows[0]["Absent"] != DBNull.Value)
                                {
                                    DR["Absent"] = Convert.ToString(dsReport.Tables[1].Rows[0]["Absent"]);
                                }
                                else
                                {
                                    DR["Absent"] = 0;
                                }
                                if (dsReport.Tables[1].Rows[0]["Leave"] != DBNull.Value)
                                {
                                    DR["Leave"] = Convert.ToString(dsReport.Tables[1].Rows[0]["Leave"]);
                                }
                                else
                                {
                                    DR["Leave"] = 0;
                                }
                                if (dsReport.Tables[1].Rows[0]["Holiday"] != DBNull.Value)
                                {
                                    DR["Holiday"] = Convert.ToString(dsReport.Tables[1].Rows[0]["Holiday"]);
                                }
                                else
                                {
                                    DR["Holiday"] = 0;
                                }
                                if (dsReport.Tables[1].Rows[0]["TotalOT"] != DBNull.Value)
                                {
                                    DR["TotalOT"] = Convert.ToString(dsReport.Tables[1].Rows[0]["TotalOT"]);
                                }
                                else
                                {
                                    DR["TotalOT"] = 0;
                                }
                            }
                        }
                        if (dsReport.Tables[0].Rows.Count > 0)
                        {
                            int i = 0;
                            DR["Name"] = Convert.ToString(dsReport.Tables[0].Rows[0]["EmpName"]);
                            DR["FatherName"] = Convert.ToString(dsReport.Tables[0].Rows[0]["Father_Name"]);
                            DR["Designation"] = Convert.ToString(dsReport.Tables[0].Rows[0]["Designation"]);
                            DR["Employee_Code_Id"] = Convert.ToString(dsReport.Tables[0].Rows[0]["Employee_Code_Id"]);
                            DateTime dtDateTimeDate = Convert.ToDateTime(dsReport.Tables[0].Rows[0]["date"]);
                            DateTime dtDateTimeFirst = dtDateTimeDate.AddDays((-1) * (dtDateTimeDate.Day - 1));
                            DateTime dtDateTimeLast = dtDateTimeFirst.AddMonths(1).AddDays(-1);
                            for (DateTime dtDateTimeNext = dtDateTimeFirst; dtDateTimeNext <= dtDateTimeLast;)
                            {
                                dsReport.Tables[0].DefaultView.RowFilter = "date='" + dtDateTimeNext + "'";
                                if (dsReport.Tables[0].DefaultView.Count == 0)
                                {
                                    DataRow dRow = dsReport.Tables[0].NewRow();
                                    dRow["Date"] = dtDateTimeNext;
                                    dRow["Attendance"] = "";
                                    dsReport.Tables[0].Rows.Add(dRow);
                                }
                                dtDateTimeNext = dtDateTimeNext.AddDays(1);
                            }
                            dsReport.Tables[0].DefaultView.RowFilter = "1=1";
                            DataView dView = new DataView();
                            dView = (DataView)dsReport.Tables[0].DefaultView;
                            dView.Sort = "date";
                            dsReport.Tables.Remove("Table");
                            dsReport.Tables.Add(dView.ToTable());
                            for (int j = 1; j <= 31; j++)
                            {
                                i = i + 1;
                                if (j <= dsReport.Tables["Table"].Rows.Count)
                                {
                                    DR["Day" + j] = Convert.ToString(dsReport.Tables["Table"].Rows[j - 1]["Attendance"]).Trim();
                                }
                                else
                                {
                                    DR["Day" + j] = "";
                                }
                            }
                            NewDT.Rows.Add(DR);
                        }
                    }
                }
            }
        }
        if (NewDT.Rows.Count == 0)
        {
            blnCheckDataExits = false;
            MessagewithClose(rm.GetString("Alert_Thereisnorecord", ci));
            return;
        }
        DataColumn dcLink = new DataColumn("Link", Type.GetType("System.Int32"));
        NewDT.Columns.Add(dcLink);
        for (int i = 0; i < NewDT.Rows.Count; i++)
        {
            NewDT.Rows[i]["Link"] = 1;
        }
        NewDT.TableName = "Table";
        rptFileName = Server.MapPath("EmployeeInOut.rpt");
        DataTable dtHdr1 = GetReportHeader();
        dtHdr = dtHdr1;
        dtSource = NewDT;
        rptHeader = dtRptHeader;
    }
    protected void btnFirst_Click(object sender, EventArgs e)
    {
        //CrystalDecisions.Web.ViewInfo vi = rptViewer.ViewInfo;
        rptViewer.ShowFirstPage();
        //if (vi.LastPageNumber == vi.PageNumber)
        //{
        //    btnNext.Enabled = false;
        //    btnLast.Enabled = false;
        //    btnFirst.Enabled = false;
        //    btnPrevious.Enabled = false;
        //}
        //else if (vi.LastPageNumber > 1)
        //{
        //    btnNext.Enabled = true;
        //    btnLast.Enabled = true;
        //    btnFirst.Enabled = false;
        //    btnPrevious.Enabled = false;
        //}
        //else
        //{
        //    btnNext.Enabled = false;
        //    btnLast.Enabled = false;
        //    btnFirst.Enabled = true;
        //    btnPrevious.Enabled = true;
        //}
        //lbltotal.Text = Convert.ToString(vi.PageNumber) + "/" + Convert.ToString(vi.LastPageNumber);
    }
    protected void btnPrevious_Click(object sender, EventArgs e)
    {
        //CrystalDecisions.Web.ViewInfo vi = rptViewer.ViewInfo;
        rptViewer.ShowPreviousPage();
        //if (vi.LastPageNumber == vi.PageNumber)
        //{
        //    btnNext.Enabled = false;
        //    btnLast.Enabled = false;
        //    btnFirst.Enabled = true;
        //    btnPrevious.Enabled = true;
        //}
        //else
        //{
        //    btnNext.Enabled = true;
        //    btnLast.Enabled = true;
        //    btnFirst.Enabled = true;
        //    btnPrevious.Enabled = true;
        //    btnNext.ImageUrl = "../aspnet_client/system_web/2_0_50727/CrystalReportWebFormViewer3/Images/ToolBar/Next.gif";
        //    btnLast.ImageUrl = "../aspnet_client/system_web/2_0_50727/CrystalReportWebFormViewer3/Images/ToolBar/Last.gif";
        //}
        //lbltotal.Text = Convert.ToString(vi.PageNumber) + "/" + Convert.ToString(vi.LastPageNumber);
    }
    protected void btnNext_Click(object sender, EventArgs e)
    {
        //CrystalDecisions.Web.ViewInfo vi = rptViewer.ViewInfo;
        rptViewer.ShowNextPage();
        //if (vi.LastPageNumber == vi.PageNumber)
        //{
        //    btnNext.Enabled = false;
        //    btnLast.Enabled = false;
        //    btnFirst.Enabled = true;
        //    btnPrevious.Enabled = true;
        //    btnNext.ImageUrl = "../aspnet_client/system_web/2_0_50727/CrystalReportWebFormViewer3/Images/ToolBar/Nextd.gif";
        //    btnLast.ImageUrl = "../aspnet_client/system_web/2_0_50727/CrystalReportWebFormViewer3/Images/ToolBar/Lastd.gif";
        //}
        //else
        //{
        //    btnNext.Enabled = true;
        //    btnLast.Enabled = true;
        //    btnFirst.Enabled = true;
        //    btnPrevious.Enabled = true;
        //}
        //lbltotal.Text = Convert.ToString(vi.PageNumber) + "/" + Convert.ToString(vi.LastPageNumber);
    }
    protected void btnLast_Click(object sender, EventArgs e)
    {
        //CrystalDecisions.Web.ViewInfo vi = rptViewer.ViewInfo;
        rptViewer.ShowLastPage();
        //if (vi.LastPageNumber == vi.PageNumber)
        //{
        //    btnNext.ImageUrl = "../aspnet_client/system_web/2_0_50727/CrystalReportWebFormViewer3/Images/ToolBar/Nextd.gif";
        //    btnLast.ImageUrl = "../aspnet_client/system_web/2_0_50727/CrystalReportWebFormViewer3/Images/ToolBar/Lastd.gif";
        //    btnNext.Enabled = false;
        //    btnLast.Enabled = false;
        //    btnFirst.Enabled = true;
        //    btnPrevious.Enabled = true;
        //}
        //lbltotal.Text = Convert.ToString(vi.PageNumber) + "/" + Convert.ToString(vi.LastPageNumber);
    }
    protected void rptViewer_Init(object sender, EventArgs e)
    {
        //if (!IsPostBack)
        //{
        //    CrystalDecisions.Web.ViewInfo vi = rptViewer.ViewInfo;
        //    int lastnumber = vi.LastPageNumber;
        //    btnFirst.Enabled = false;
        //    btnPrevious.Enabled = false;
        //    btnFirst.ImageUrl = "../aspnet_client/system_web/2_0_50727/CrystalReportWebFormViewer3/Images/ToolBar/Firstd.gif";
        //    btnPrevious.ImageUrl = "../aspnet_client/system_web/2_0_50727/CrystalReportWebFormViewer3/Images/ToolBar/Prevd.gif";
        //}
    }
    protected void rptViewer_Navigate(object source, CrystalDecisions.Web.NavigateEventArgs e)
    {
    }
    protected void Page_UnLoad(object sender, EventArgs e)
    {
        //To avoiding below issue, i have added this below if loop in unload evenit on 18-01-2016 05.47 pm
        //Crystal Reports: The maximum report processing jobs limit configured by your system administrator has been reached.
        if (rptDoc != null)
        {
            rptDoc.Close();
            rptDoc.Clone();
            rptDoc.Dispose();
            rptDoc = null;
        }
    }
    #endregion
}