#region Name Spaces
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Globalization;
using System.Threading;
using System.Reflection;
using System.Resources;
using NPOI.HSSF.UserModel;
using NPOI.SS.UserModel;
using NPOI.HSSF.Util;
using NPOI.SS.Util;
using System.IO;
#endregion
public partial class Reports_TA_UI_Report_DeviatedWorkHours : Base.BasePage
{
    #region Variable Declaration
    Cls_CheckUser objCheckUser = new Cls_CheckUser();
    DataSet ds_Checkuser = new DataSet();
    HeaderInformation hdrTable = new HeaderInformation();
    GetReports rptEmp = new GetReports();
    Rpt_Common rptcommon = new Rpt_Common();
    EmployeeEventData objEmployee = new EmployeeEventData();
    cls_Common objCommon = new cls_Common();
    ResourceManager rm;
    CultureInfo ci;
    string dtFrom = "", dtTo = "", EmployeeId = "", gstrDateFormat, strFromdate, strTodate;
    int intIndividualUser = 0;
    string gStrLevel = string.Empty, ParenetLevelid = string.Empty;
    #endregion
    #region Page Load
    protected override void Page_Load(object sender, EventArgs e)
    {
        // session checking
        base.Page_Load(sender, e);
        if (!Page.IsPostBack)
        {
            Hidden1.Value = Convert.ToString(Session["IDateFormat"]);
            base.CheckPages(0);
            objCommon.menu("Attendance Reports", "161");
        }
        //get the culture info to set the language        
        string source_Language;
        source_Language = Convert.ToString(Session["Session_ActiveLanguage"]);
        rm = new ResourceManager(source_Language, System.Reflection.Assembly.Load("App_GlobalResources"));
        ci = Thread.CurrentThread.CurrentCulture;
        site.SiteMapProvider = Convert.ToString(Session["SiteMapProvider"]);
        LoadStrings(ci);
        //Set UserRights
        UserRights();
        if (!IsPostBack)
        {
            // Bindings the employee category and type.
            BindingEmployeeCategoryandType();
            //txtFromDate.Text = Session["SearchFromDate"].ToString();
            //txtFromDate.Text = (Convert.ToDateTime(objCommon.CurrentMonthStartDate())).ToString(Session["MDateFormat"].ToString());
            string strDayName = Convert.ToString(DateTime.Now.Date.DayOfWeek).ToLower();
            double iFromDate = strDayName.Contains("monday") ? 0 : strDayName.Contains("tuesday") ? -1 : strDayName.Contains("wednesday") ? -2 : strDayName.Contains("thursday") ? -3 : strDayName.Contains("friday") ? -4 : -5;
            txtFromDate.Text = System.DateTime.Now.Date.AddDays(iFromDate).ToString(Convert.ToString(Session["MDateFormat"]));
            txtToDate.Text = System.DateTime.Now.Date.AddDays(iFromDate + 5).ToString(Convert.ToString(Session["MDateFormat"]));
            //txtToDate.Text = (Convert.ToDateTime(System.DateTime.Now.ToShortDateString())).ToString(Session["MDateFormat"].ToString());
            fillShift();
        }
        //Check whether the employee is Individual User
        intIndividualUser = objCheckUser.CheckIndividualUser(Convert.ToString(Session["UserGroupName"]));
        if (intIndividualUser >= 1)
        {
            PlaceHolderLateEntry.Controls.Clear();
            divEmployeeDetails.Visible = false;
            lblEmpSwipe.Visible = false;
            txtSwipeCard.Visible = false;
        }
        ////Convert date time to MM/dd/YYYY format
        gstrDateFormat = Convert.ToString(Session["MDateFormat"]);
        strFromdate = txtFromDate.Text;
        strFromdate = objCommon.DateConvertion(gstrDateFormat, strFromdate);
        strTodate = txtToDate.Text;
        strTodate = objCommon.DateConvertion(gstrDateFormat, strTodate);
    }
    #endregion
    #region Button Event
    /// <summary>
    /// Load Late Entry report
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void btn_View_Click(object sender, EventArgs e)
    {
        int EmpCategory = 0, EmpType = 0;
        string Level = string.Empty, EmpName = string.Empty, EmpId = string.Empty, SwipeCard = string.Empty;
        try
        {
            if (Page.IsValid == true)
            {
                // set employee category and type
                if (Convert.ToInt32(ddlEmpCatagory.SelectedValue) != 0)
                    EmpCategory = Convert.ToInt32(ddlEmpCatagory.SelectedValue);
                if (Convert.ToInt32(ddlEmpType.SelectedValue) != 0)
                    EmpType = Convert.ToInt32(ddlEmpType.SelectedValue);
                if (txtFromDate.Text != "")
                    dtFrom = strFromdate;
                if (txtToDate.Text != "")
                    dtTo = strTodate;
                //Get the Report source from the Server and load this into the report table\
                DataSet dsWeeklyHrs = new DataSet();
                //shft = Convert.ToInt16(this.ddlShift.SelectedValue);
                if (intIndividualUser >= 1)
                {
                    EmpId = Convert.ToString(Session["EmployeeCodeId"]);
                    EmployeeId = Convert.ToString(Session["EmployeeCodeId"]);
                }
                else
                {
                    EmpId = Convert.ToString(txtEmployeeId.Text.Trim());
                    EmployeeId = Convert.ToString(txtEmployeeId.Text.Trim());
                    EmpName = txtEmployeeName.Text.Replace("'", "''").Replace(' ', '%');
                    SwipeCard = Convert.ToString(txtSwipeCard.Text.Trim()).Replace("'", "''");
                    Level = rptcommon.getNodes(Convert.ToInt16(Session["parentLevelId"]), Convert.ToString(Session["LevelRights"]));
                    gStrLevel = Level;
                }
                Session["LateInsLevel"] = Level;
                string strEmpAutoId = string.Empty;
                if (Session["ReportsBasedOn"] != null)
                {
                    if (Convert.ToString(Session["ReportsBasedOn"]) == "False")
                    {
                        strEmpAutoId = "0";
                    }
                    else
                    {
                        strEmpAutoId = Convert.ToString(Session["EmpAutoID"]);
                    }
                }
                int iReportType = rbtnDeviation.Checked ? 1 : 0;
                //dsWeeklyHrs = rptEmp.SelectMonthlyDeviationHrs(EmployeeId, Level, dtFrom, dtTo, EmpName, EmpCategory, EmpType, Session["UserGroupName"].ToString(), Convert.ToString(Session["GradeLevel"]), SwipeCard, Convert.ToInt32(strEmpAutoId), iReportType);
                ////Check the Empty table
                //if (dsWeeklyHrs.Tables["Table"].Rows.Count == 0)
                //{
                //    string strMsg;
                //    strMsg = "<script language='javascript'>";
                //    strMsg = strMsg + "alert('There is no record ');";
                //    strMsg = strMsg + "</script>";
                //    Page.RegisterStartupScript("Display Message", strMsg);
                //    return;
                //}
                //Session["ReportDetails"] = dsWeeklyHrs;
                //Redirect the page to the report viewer
                string strReportName = "DeviationWorkHours";
                string strEmpCategory = Convert.ToString(EmpCategory);
                string strEmpType = Convert.ToString(EmpType);
                string strScript = "";
                strScript = strScript + "<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Transitional//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'>";
                strScript = strScript + "<meta http-equiv='X-UA-Compatible' content='IE=document.documentMode;' />";
                strScript = strScript + "<script language='javascript'>";
                //strScript = strScript + "window.open('TA_UI_Report_ReportViewer.aspx?ReportName=" + strReportName + "&dtFrom=" + Cryptographys.Cryptography.Encrypt(dtFrom, "AnglerReports") + "&dtTo=" + Cryptographys.Cryptography.Encrypt(dtTo, "AnglerReports") + "&empid=" + Cryptographys.Cryptography.Encrypt(EmpId, "AnglerReports") + "&EmpName=" + Cryptographys.Cryptography.Encrypt(EmpName, "AnglerReports") + "&Level=" + Cryptographys.Cryptography.Encrypt(Level, "AnglerReports") + "&EmpCategory=" + strEmpCategory + "&EmpType=" + strEmpType + "&ParentLevelId=" + Cryptographys.Cryptography.Encrypt(Convert.ToInt16(Session["parentLevelId"]).ToString(), "AnglerReports") + "&SwipeCard=" + Cryptographys.Cryptography.Encrypt(SwipeCard, "AnglerReports") + "&ReportType=" + Cryptographys.Cryptography.Encrypt(iReportType.ToString(), "AnglerReports") + "','','left=10px, top=60px, width=1000px, height=600px, scrollbars=yes, status=no, resizable=yes');";
                strScript = strScript + "window.open('TA_UI_Report_ReportViewer.aspx?ReportName=" + strReportName + "&dtFrom=" + dtFrom + "&dtTo=" + dtTo + "&empid=" + EmpId + "&EmpName=" + EmpName + "&Level=" + Level + "&EmpCategory=" + strEmpCategory + "&EmpType=" + strEmpType + "&ParentLevelId=" + Convert.ToInt16(Session["parentLevelId"]) + "&SwipeCard=" + SwipeCard + "&ReportType=" + Convert.ToString(iReportType) + "','','left=10px, top=60px, width=1000px, height=600px, scrollbars=yes, status=no, resizable=yes');";
                strScript = strScript + "</script>";
                Response.Write(strScript);
            }
        }
        catch (Exception ex)
        {
            Response.Write(ex.ToString());
        }
    }
    protected void btn_Export_Click(object sender, EventArgs e)
    {
        int EmpCategory = 0, EmpType = 0;
        string Level = string.Empty, EmpName = string.Empty, EmpId = string.Empty, SwipeCard = string.Empty;
        try
        {
            DataSet dsEmp = new DataSet();
            if (Page.IsValid == true)
            {
                // set employee category and type
                if (Convert.ToInt32(ddlEmpCatagory.SelectedValue) != 0)
                    EmpCategory = Convert.ToInt32(ddlEmpCatagory.SelectedValue);
                if (Convert.ToInt32(ddlEmpType.SelectedValue) != 0)
                    EmpType = Convert.ToInt32(ddlEmpType.SelectedValue);
                if (txtFromDate.Text != "")
                    dtFrom = strFromdate;
                if (txtToDate.Text != "")
                    dtTo = strTodate;
                //Get the Report source from the Server and load this into the report table\
                DataSet dsWeeklyHrs = new DataSet();
                if (intIndividualUser >= 1)
                {
                    EmpId = Convert.ToString(Session["EmployeeCodeId"]);
                    EmployeeId = Convert.ToString(Session["EmployeeCodeId"]);
                }
                else
                {
                    EmpId = Convert.ToString(txtEmployeeId.Text.Trim());
                    EmployeeId = Convert.ToString(txtEmployeeId.Text.Trim());
                    EmpName = txtEmployeeName.Text.Replace("'", "''").Replace(' ', '%');
                    SwipeCard = Convert.ToString(txtSwipeCard.Text.Trim()).Replace("'", "''");
                    Level = rptcommon.getNodes(Convert.ToInt16(Session["parentLevelId"]), Convert.ToString(Session["LevelRights"]));
                    gStrLevel = Level;
                }
                Session["LateInsLevel"] = Level;
                string strEmpAutoId = string.Empty;
                if (Session["ReportsBasedOn"] != null)
                {
                    if (Convert.ToString(Session["ReportsBasedOn"]) == "False")
                    {
                        strEmpAutoId = "0";
                    }
                    else
                    {
                        strEmpAutoId = Convert.ToString(Session["EmpAutoID"]);
                    }
                }
                int iReportType = rbtnDeviation.Checked ? 1 : 0;
                string strEmpCategory = Convert.ToString(EmpCategory);
                string strEmpType = Convert.ToString(EmpType);
                dsEmp = rptEmp.SelectMonthlyDeviationHrs(EmpId, Level, dtFrom, dtTo, EmpName, EmpCategory, EmpType, Convert.ToString(Session["UserGroupName"]), Convert.ToString(Session["GradeLevel"]), SwipeCard, Convert.ToInt32(strEmpAutoId), iReportType, Convert.ToInt16(Session["parentLevelId"]));
                if (dsEmp.Tables["Table"] == null || dsEmp.Tables["Table"].Rows.Count == 0)
                {
                    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;
                }
                else
                {
                    HSSFWorkbook workbook = new HSSFWorkbook();
                    ISheet sheet = workbook.CreateSheet("ARMIS_Cumulative_WorkHrs_Deviation_Report");
                    sheet.IsPrintGridlines = true;
                    sheet.VerticallyCenter = true;
                    int rowIndex = 0;
                    NPOI.SS.UserModel.IRow row = sheet.CreateRow(rowIndex);
                    HSSFFont hFont = (HSSFFont)workbook.CreateFont();
                    hFont.Boldweight = (short)FontBoldWeight.Bold;
                    hFont.Color = HSSFColor.Maroon.Index;
                    HSSFCellStyle hStyle = (HSSFCellStyle)workbook.CreateCellStyle();
                    hStyle.BorderTop = NPOI.SS.UserModel.BorderStyle.Thin;
                    hStyle.BorderBottom = NPOI.SS.UserModel.BorderStyle.Thin;
                    hStyle.BorderLeft = NPOI.SS.UserModel.BorderStyle.Thin;
                    hStyle.BorderRight = NPOI.SS.UserModel.BorderStyle.Thin;
                    hStyle.SetFont(hFont);
                    row.CreateCell(0).SetCellValue("Sl.No");
                    row.CreateCell(1).SetCellValue("Emp.No");
                    row.CreateCell(2).SetCellValue("Employee Name");
                    row.CreateCell(3).SetCellValue("Employee Category");
                    row.CreateCell(4).SetCellValue("Target Hours");
                    row.CreateCell(5).SetCellValue("TimeCheck Actual Hours");
                    row.CreateCell(6).SetCellValue("ARMIS Actual Hours");
                    row.CreateCell(7).SetCellValue("Leave Hours");
                    row.CreateCell(8).SetCellValue("Deviation Hours");
                    row.CreateCell(9).SetCellValue("Target Hours");
                    row.CreateCell(10).SetCellValue("TimeCheck Actual Hours");
                    row.CreateCell(11).SetCellValue("ARMIS Actual Hours");
                    row.CreateCell(12).SetCellValue("Leave Hours");
                    row.CreateCell(13).SetCellValue("Deviation Hours");
                    row.CreateCell(14).SetCellValue("Target Hours");
                    row.CreateCell(15).SetCellValue("TimeCheck Actual Hours");
                    row.CreateCell(16).SetCellValue("ARMIS Actual Hours");
                    row.CreateCell(17).SetCellValue("Leave Hours");
                    row.CreateCell(18).SetCellValue("Deviation Hours");
                    row.CreateCell(19).SetCellValue("Target Hours");
                    row.CreateCell(20).SetCellValue("TimeCheck Actual Hours");
                    row.CreateCell(21).SetCellValue("ARMIS Actual Hours");
                    row.CreateCell(22).SetCellValue("Leave Hours");
                    row.CreateCell(23).SetCellValue("Deviation Hours");
                    row.CreateCell(24).SetCellValue("Target Hours");
                    row.CreateCell(25).SetCellValue("TimeCheck Actual Hours");
                    row.CreateCell(26).SetCellValue("ARMIS Actual Hours");
                    row.CreateCell(27).SetCellValue("Leave Hours");
                    row.CreateCell(28).SetCellValue("Deviation Hours");
                    //row.RowStyle = hStyle;
                    for (int i = 0; i <= 28; i++)
                    {
                        row.GetCell(i).CellStyle = hStyle;
                    }
                    rowIndex++;
                    int slno = 1;
                    foreach (DataRow DR in dsEmp.Tables[0].Rows)
                    {
                        row = sheet.CreateRow(rowIndex);
                        row.Height = 300;
                        DataColumnCollection columns = dsEmp.Tables[0].Columns;
                        row.CreateCell(0).SetCellValue(Convert.ToInt32(slno));
                        row.CreateCell(1).SetCellValue(Convert.ToString(DR["Employee_Code_ID"]));
                        row.CreateCell(2).SetCellValue(Convert.ToString(DR["EmployeeName"]));
                        row.CreateCell(3).SetCellValue(Convert.ToString(DR["CategoryName"]));
                        row.CreateCell(4).SetCellValue(Convert.ToString(DR["TargetWorkHours_Week1"]));
                        row.CreateCell(5).SetCellValue(Convert.ToString(DR["ActualWorkHours_Week1"]));
                        row.CreateCell(6).SetCellValue(Convert.ToString(DR["ArmisWorkHours_Week1"]));
                        row.CreateCell(7).SetCellValue(Convert.ToString(DR["Leave_Permision_Week1"]));
                        row.CreateCell(8).SetCellValue(Convert.ToString(DR["DeviationHours_Week1"]));
                        if (columns.Contains("TargetWorkHours_Week2"))
                        {
                            row.CreateCell(9).SetCellValue(Convert.ToString(DR["TargetWorkHours_Week2"]));
                        }
                        else
                        {
                            row.CreateCell(9).SetCellValue(Convert.ToString(""));
                        }
                        if (columns.Contains(Convert.ToString("ActualWorkHours_Week2")))
                        {
                            row.CreateCell(10).SetCellValue(Convert.ToString(DR["ActualWorkHours_Week2"]));
                        }
                        else
                        {
                            row.CreateCell(10).SetCellValue(Convert.ToString(""));
                        }
                        if (columns.Contains(Convert.ToString("ArmisWorkHours_Week2")))
                        {
                            row.CreateCell(11).SetCellValue(Convert.ToString(DR["ArmisWorkHours_Week2"]));
                        }
                        else
                        {
                            row.CreateCell(11).SetCellValue(Convert.ToString(""));
                        }
                        if (columns.Contains(Convert.ToString("Leave_Permision_Week2")))
                        {
                            row.CreateCell(12).SetCellValue(Convert.ToString(DR["Leave_Permision_Week2"]));
                        }
                        else
                        {
                            row.CreateCell(12).SetCellValue(Convert.ToString(""));
                        }
                        if (columns.Contains(Convert.ToString("DeviationHours_Week2")))
                        {
                            row.CreateCell(13).SetCellValue(Convert.ToString(DR["DeviationHours_Week2"]));
                        }
                        else
                        {
                            row.CreateCell(13).SetCellValue(Convert.ToString(""));
                        }
                        if (columns.Contains(Convert.ToString("TargetWorkHours_Week3")))
                        {
                            row.CreateCell(14).SetCellValue(Convert.ToString(DR["TargetWorkHours_Week3"]));
                        }
                        else
                        {
                            row.CreateCell(14).SetCellValue(Convert.ToString(""));
                        }
                        if (columns.Contains(Convert.ToString("ActualWorkHours_Week3")))
                        {
                            row.CreateCell(15).SetCellValue(Convert.ToString(DR["ActualWorkHours_Week3"]));
                        }
                        else
                        {
                            row.CreateCell(15).SetCellValue(Convert.ToString(""));
                        }
                        if (columns.Contains(Convert.ToString("ArmisWorkHours_Week3")))
                        {
                            row.CreateCell(16).SetCellValue(Convert.ToString(DR["ArmisWorkHours_Week3"]));
                        }
                        else
                        {
                            row.CreateCell(16).SetCellValue(Convert.ToString(""));
                        }
                        if (columns.Contains(Convert.ToString("Leave_Permision_Week3")))
                        {
                            row.CreateCell(17).SetCellValue(Convert.ToString(DR["Leave_Permision_Week3"]));
                        }
                        else
                        {
                            row.CreateCell(17).SetCellValue(Convert.ToString(""));
                        }
                        if (columns.Contains(Convert.ToString("DeviationHours_Week3")))
                        {
                            row.CreateCell(18).SetCellValue(Convert.ToString(DR["DeviationHours_Week3"]));
                        }
                        else
                        {
                            row.CreateCell(18).SetCellValue(Convert.ToString(""));
                        }
                        if (columns.Contains(Convert.ToString("TargetWorkHours_Week4")))
                        {
                            row.CreateCell(19).SetCellValue(Convert.ToString(DR["TargetWorkHours_Week4"]));
                        }
                        else
                        {
                            row.CreateCell(19).SetCellValue(Convert.ToString(""));
                        }
                        if (columns.Contains(Convert.ToString("ActualWorkHours_Week4")))
                        {
                            row.CreateCell(20).SetCellValue(Convert.ToString(DR["ActualWorkHours_Week4"]));
                        }
                        else
                        {
                            row.CreateCell(20).SetCellValue(Convert.ToString(""));
                        }
                        if (columns.Contains(Convert.ToString("ArmisWorkHours_Week4")))
                        {
                            row.CreateCell(21).SetCellValue(Convert.ToString(DR["ArmisWorkHours_Week4"]));
                        }
                        else
                        {
                            row.CreateCell(21).SetCellValue(Convert.ToString(""));
                        }
                        if (columns.Contains(Convert.ToString("Leave_Permision_Week4")))
                        {
                            row.CreateCell(22).SetCellValue(Convert.ToString(DR["Leave_Permision_Week4"]));
                        }
                        else
                        {
                            row.CreateCell(22).SetCellValue(Convert.ToString(""));
                        }
                        if (columns.Contains(Convert.ToString("DeviationHours_Week4")))
                        {
                            row.CreateCell(23).SetCellValue(Convert.ToString(DR["DeviationHours_Week4"]));
                        }
                        else
                        {
                            row.CreateCell(23).SetCellValue(Convert.ToString(""));
                        }
                        if (columns.Contains(Convert.ToString("TargetWorkHours_Week5")))
                        {
                            row.CreateCell(24).SetCellValue(Convert.ToString(DR["TargetWorkHours_Week5"]));
                        }
                        else
                        {
                            row.CreateCell(24).SetCellValue(Convert.ToString(""));
                        }
                        if (columns.Contains(Convert.ToString("ActualWorkHours_Week5")))
                        {
                            row.CreateCell(25).SetCellValue(Convert.ToString(DR["ActualWorkHours_Week5"]));
                        }
                        else
                        {
                            row.CreateCell(25).SetCellValue(Convert.ToString(""));
                        }
                        if (columns.Contains(Convert.ToString("ArmisWorkHours_Week5")))
                        {
                            row.CreateCell(26).SetCellValue(Convert.ToString(DR["ArmisWorkHours_Week5"]));
                        }
                        else
                        {
                            row.CreateCell(26).SetCellValue(Convert.ToString(""));
                        }
                        if (columns.Contains(Convert.ToString("Leave_Permision_Week5")))
                        {
                            row.CreateCell(27).SetCellValue(Convert.ToString(DR["Leave_Permision_Week5"]));
                        }
                        else
                        {
                            row.CreateCell(27).SetCellValue(Convert.ToString(""));
                        }
                        if (columns.Contains(Convert.ToString("DeviationHours_Week5")))
                        {
                            row.CreateCell(28).SetCellValue(Convert.ToString(DR["DeviationHours_Week5"]));
                        }
                        else
                        {
                            row.CreateCell(28).SetCellValue(Convert.ToString(""));
                        }
                        rowIndex++;
                        slno += 1;
                    }
                    using (MemoryStream exportData = new MemoryStream())
                    {
                        workbook.Write(exportData);
                        string saveAsFileName = string.Format("ARMIS_Cumulative_WorkHrs_Deviation_Report-{0:d}.xls", DateTime.Now).Replace("/", "-");
                        Response.ContentType = "application/vnd.ms-excel";
                        Response.AddHeader("Content-Disposition", string.Format("attachment;filename={0}", saveAsFileName));
                        Response.Clear();
                        Response.BinaryWrite(exportData.GetBuffer());
                        Response.End();
                    }
                }
            }
        }
        catch (Exception ex)
        {
            Response.Write(ex.ToString());
        }
    }
    #endregion
    #region User Define Function
    /// <summary>
    /// Validate the FromDate
    /// </summary>
    /// <param name="s"></param>
    /// <param name="e"></param>
    public void ValidateFromDate(object s, ServerValidateEventArgs e)
    {
        e.IsValid = false;
        try
        {
            DateTime dtCurrentDate = Convert.ToDateTime(DateTime.Today.Date);
            DateTime dtFromDate = DateTime.Parse(strFromdate);
            TimeSpan diff = dtFromDate.Subtract(dtCurrentDate);
            int day = diff.Days;
            e.IsValid = (day <= 0) && (dtFromDate.ToLongDateString().Split(',')[0].Equals("Monday"));
            if (!e.IsValid)
                base.Message((day > 0) ? "Enter Valid From Date" : "Select Monday in From Date");
        }
        catch
        {
            base.Message("Enter Valid From Date");
        }
    }
    /// <summary>
    /// Validate the ToDate
    /// </summary>
    /// <param name="s"></param>
    /// <param name="e"></param>
    public void ValidateToDate(object s, ServerValidateEventArgs e)
    {
        e.IsValid = false;
        try
        {
            DateTime dtCurrentDate = Convert.ToDateTime(DateTime.Today.Date);
            DateTime dtToDate = DateTime.Parse(strTodate);
            TimeSpan diff = dtToDate.Subtract(dtCurrentDate);
            int day = diff.Days;
            //e.IsValid = (day <= 0) && (dtToDate.ToLongDateString().Split(',')[0].Equals("Saturday"));
            e.IsValid = (dtToDate.ToLongDateString().Split(',')[0].Equals("Saturday"));
            if (!e.IsValid)
                base.Message((day > 0) ? "Enter Valid To Date" : "Select Saturday in To Date");
        }
        catch
        {
            base.Message("Enter Valid To Date");
        }
    }
    /// <summary>
    /// Compare ToDate with FromDate
    /// </summary>
    /// <param name="s"></param>
    /// <param name="e"></param>
    public void CompareDate(object s, ServerValidateEventArgs e)
    {
        e.IsValid = false;
        try
        {
            DateTime dtToDate = DateTime.Parse(strTodate);
            DateTime dtFromDate = DateTime.Parse(strFromdate);
            TimeSpan diff = dtToDate.Subtract(dtFromDate);
            int day = diff.Days + 2;
            e.IsValid = (day / 7 <= 5);
            if (!e.IsValid)
                base.Message("Select any saturday with in the month duration");
        }
        catch
        {
            base.Message("Enter Valid Date");
        }
    }
    //Getting Information from resource file and display it in label
    /// <summary>
    /// Bindings the employee category and type.
    /// </summary>
    private void BindingEmployeeCategoryandType()
    {
        // employee category binding
        DataSet dsCategory = new DataSet();
        dsCategory = objEmployee.SelectCategoryDetailsEmployee("");
        if (dsCategory != null)
        {
            if (dsCategory.Tables[0].Rows.Count > 0)
            {
                ddlEmpCatagory.DataSource = dsCategory;
                ddlEmpCatagory.DataTextField = "CategoryName";
                ddlEmpCatagory.DataValueField = "CategoryId";
                ddlEmpCatagory.DataBind();
            }
            dsCategory.Dispose();
        }
        // employee type binding
        DataSet dsType = new DataSet();
        dsType = objEmployee.SelectTypeDetailsEmployee("");
        if (dsType != null)
        {
            if (dsType.Tables[0].Rows.Count > 0)
            {
                ddlEmpType.DataSource = dsType;
                ddlEmpType.DataTextField = "TypeName";
                ddlEmpType.DataValueField = "TypeId";
                ddlEmpType.DataBind();
            }
            dsType.Dispose();
        }
    }
    public void fillShift()
    {
        ShiftEvenData getShift = new ShiftEvenData();
        DataSet ds = new DataSet();
        string strusergroup = string.Empty;
        //ds = getShift.SelectShift(strusergroup, Convert.ToString(Session["LevelRights"]), 0);
        ds = getShift.SelectShift(Convert.ToString(Session["UserGroupName"]), Convert.ToString(Session["LevelRights"]), 0);
        if (ds.Tables[0].Rows.Count > 0)
        {
            this.ddlShift.DataSource = ds;
            this.ddlShift.DataTextField = "Shift_Name";
            this.ddlShift.DataValueField = "Shift_Id";
            this.ddlShift.DataBind();
        }
        ListItem lstItem = new ListItem();
        lstItem.Value = "0";
        lstItem.Text = "All";
        ddlShift.Items.Insert(0, lstItem);
    }
    private void LoadStrings(CultureInfo ci)
    {
        btn_View.Text = "&nbsp;&nbsp;" + rm.GetString("btn_View", ci);
        lblWeeklyWorkHours.Text = "Streamline & Cumulative Work Hours Deviation Report";
        lblShift.Text = rm.GetString("Menu_Reports_Shift", ci);
        lblEmployeeName.Text = rm.GetString("email_EmployeeName", ci);
        lblEmployeeId.Text = rm.GetString("email_EmployeeId", ci);
        lblEmpCategory.Text = rm.GetString("Master_Category", ci);
        lblEmpType.Text = rm.GetString("Master_Type", ci);
        lblTimePeriod.Text = rm.GetString("Reports_TimePeriod", ci);
        lblFrom.Text = rm.GetString("email_FromDate", ci);
        lblTo.Text = rm.GetString("email_ToDate", ci);
        lblEmpSwipe.Text = rm.GetString("TerminalDataType_Card_No", ci);
    }
    private void UserRights()
    {
        ds_Checkuser = objCheckUser.checkRights(161, Convert.ToInt32(Session["userGroup_Id"]), "viewPrv");
        if (ds_Checkuser.Tables[0].Rows.Count > 0)
        {
            if (ds_Checkuser.Tables[0].Rows[0]["viewPrv"] == DBNull.Value || Convert.ToInt32(ds_Checkuser.Tables[0].Rows[0]["viewPrv"]) == 1)
            {
                btn_View.Visible = true;
            }
            else
            {
                btn_View.Visible = false;
            }
        }
        else
        {
            Response.Redirect("ReportsLandingPage.aspx");
        }
    }
    #endregion
}