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 System.Text;
using System.IO;
public partial class Transactions_PopUp_EmployeeOTSanction : Base.BasePage
{
    #region Variable Declaraion
    ResourceManager rm;
    CultureInfo ci;
    cls_Common objCommon = new cls_Common();
    EmployeeEventData objEmployee = new EmployeeEventData();
    ShiftAllocationEvendata obj = new ShiftAllocationEvendata();
    YearSettingsEventData objYearSettingsEventData = new YearSettingsEventData();
    LeaveApplicationEventData objEmployeeEventData = new LeaveApplicationEventData();
    Rpt_Common rptcommon = new Rpt_Common();
    OTEventData objOT = new OTEventData();
    DataTable dtLeaveOTDetails = new DataTable();
    DataTable dtLeaveApplicationOTHrs = new DataTable();
    string strEmpFirstName, strEmpLastName;
    DataSet dsEmployeeDetails = new DataSet();
    string strEmailIdSanctioningAuthority, strEmailIdReportingTo, strEmployeeCodeId, strEmployeeName, strlevelName, strEmailID;
    Email_Triggering ObjEmailTrigger = new Email_Triggering();
    bool blnCheckEmail = true;
    int intCount;
    DataView dv;
    int loginEmployeeId;
    DataSet ds = new DataSet();
    bool checkRecordExists;
    string OTStatus;
    bool CheckGrid = false;
    DataSet dsOtEmployee = new DataSet();
    int intOTHrs, intWOFOTHrs, intHDOTFrs;
    int intUpOTHrs, intUpWOFOTHrs, intUpHDOTFrs;

    int intSpecOTHrs1, intWOFSpecOTHrs1, intHDSpecOTFrs1;
    int intSpecOTHrs2, intWOFSpecOTHrs2, intHDSpecOTFrs2;

    int intUpSpecOTHrs1, intUpWOFSpecOTHrs1, intUpHDSpecOTFrs1;
    int intUpSpecOTHrs2, intUpWOFSpecOTHrs2, intUpHDSpecOTFrs2;
    int iEmployeeID;
    #endregion
    #region Page Load Event
    protected override void Page_Load(object sender, EventArgs e)
    {
        // session checking and reset date format
        base.Page_Load(sender, e);
        //if Standar Edition set the visibility to false
        int otApprovalExists = 0;
        otApprovalExists = objCommon.CheckPageExistsInLicense(97);
        //if (Session["Edition"].ToString() == "1")
        if (otApprovalExists == 0)
        {
            string strScripts = "";
            strScripts = strScripts + "<script language='javascript'>";
            strScripts = strScripts + "parent.$('#myModal').modal('hide');</script>";
            Page.RegisterStartupScript("AlertManualApproval", strScripts);
            return;
        }
        if (Session["Session_ActiveLanguage"] == null)
        {
            string str = "<script language=\"javascript\">";
            //str = str + "opener.focus();";
            //str = str + "alert(opener.location+'?fl=1&sid=';";
            str = str + "window.top.location.href = window.top.location.href + '?fl=1&sid=" + Session.SessionID + "';";
            str = str + "parent.$('#myModal').modal('hide');";
            str = str + "</script>";
            Response.Write(str);
        }
        else
        {
            string source_Language;
            loginEmployeeId = Int32.Parse(Session["EmpAutoID"].ToString());
            source_Language = Convert.ToString(Session["Session_ActiveLanguage"]);
            rm = new ResourceManager(source_Language, System.Reflection.Assembly.Load("App_GlobalResources"));
            ci = Thread.CurrentThread.CurrentCulture;
            aspnetForm.Attributes.CssStyle.Add("Direction", rm.GetString("Direction", ci));
            LoadStrings(ci);
            loadcss();
            string strSetAlert = "";
            strSetAlert = strSetAlert + "<script language='javascript'>";
            strSetAlert = strSetAlert + "SetAlertMessages_DeleteRestore('" + rm.GetString("Alert_ConfirmDelete") + "','" + rm.GetString("Alert_SelectItemsToDelete") + "','" + rm.GetString("Alert_ConfirmDeletePermanent") + "','" + rm.GetString("Alert_Areyousuretorestore") + "','" + rm.GetString("Alert_SelectItemsToRestore") + "','" + rm.GetString("Alert_SelectItemToForwarded") + "','" + rm.GetString("Alert_SelectItemToApproved") + "','" + rm.GetString("Alert_SelectItemToForwarded") + "','" + rm.GetString("Alert_SelectItemToApproved") + "');";
            strSetAlert = strSetAlert + "</script>";
            Page.RegisterStartupScript("SetAlertMessages", strSetAlert);
        }
        if (!IsPostBack)
        {
            //Checking Approval Settings
            int intCompanyId;
            string strStatus = string.Empty;
            string strModule = string.Empty;
            string strScript = "";
            strScript = strScript + "<script language='javascript'>";
            bool blnParentExists = true;
            strModule = "OTApproval";
            if (Session["parentLevelId"] == null)
            {
                blnParentExists = false;
            }
            else if (Convert.ToInt32(Session["parentLevelId"]) == 0)
            {
                blnParentExists = false;
            }
            if (blnParentExists == false)
            {
                //strStatus = "Select a company";
                strStatus = rm.GetString("Alert_SelectCompany", ci);
                Div1.Visible = false;
                strScript = strScript + "alert('" + strStatus + "');parent.$('#myModal').modal('hide');";
                strScript = strScript + "</script>";
                Page.RegisterStartupScript("AlertManualApproval", strScript);
                return;
            }
            intCompanyId = getParentCompany(Convert.ToInt32(Session["parentLevelId"]));
            strStatus = GetApprovalStatus(intCompanyId, strModule);
            if (strStatus == "ApprovalNotRequired")
            {
                //lblApprovalStatus.Text = "Approval Not Required for this company";
                //strStatus = "Approval Not Required for this company";
                strStatus = rm.GetString("Alert_ApprovalNotRequiredforthiscompany", ci);
                Div1.Visible = false;
                strScript = strScript + "alert('" + strStatus + "');parent.$('#myModal').modal('hide');";
                strScript = strScript + "</script>";
                Page.RegisterStartupScript("AlertManualApproval", strScript);
                return;
            }
            else if (strStatus == "NotDefined")
            {
                //lblApprovalStatus.Text = "Approval Settings not defined for this company";
                //strStatus = "Approval Settings not defined for this company";
                strStatus = rm.GetString("Alert_ApprovalSettingsnotdefinedforthiscompany", ci);
                Div1.Visible = false;
                strScript = strScript + "alert('" + strStatus + "');parent.$('#myModal').modal('hide');";
                strScript = strScript + "</script>";
                Page.RegisterStartupScript("AlertManualApproval", strScript);
                return;
            }
            //Approval Settings checking ends here
            OTEmployeeDetails();
            switch (OTStatus)
            {
                case "Pending":
                    btn_Pending.Visible = false;
                    break;
                case "Approved":
                    btn_Approved.Visible = false;
                    btn_Forwarded.Visible = false;
                    break;
                case "Forwarded":
                    btn_Forwarded.Visible = false;
                    break;
                case "Rejected":
                    btn_Reject.Visible = false;
                    break;
                default:
                    break;
            }
            Session["EmployeeIds"] = "";
        }
        checkRecordExists = true;
        //intCount = grv_EmployeeOTSanction.Rows.Count;
    }
    #endregion
    #region User Defined Functions
    public int getParentCompany(int iEmployeeLevelID)
    {
        //Select Company
        org_levelsEventData getOrg = new org_levelsEventData();
        getOrg.GetOrgParentLevels_FromID(iEmployeeLevelID);
        DataSet ds_getOrg = new DataSet();
        ds_getOrg = getOrg.GetOrgParentLevels();
        int iCompanyID = 0;
        if (ds_getOrg != null)
        {
            if (ds_getOrg.Tables[0].Rows.Count > 0)
            {
                iCompanyID = Convert.ToInt32(ds_getOrg.Tables[0].Rows[0]["LevelID"].ToString());
            }
        }
        return iCompanyID;
    }
    public string GetApprovalStatus(int intCompanyId, string strModule)
    {
        int approvalSettingsPageExists = 0;
        //Checking grade module is available or not and changed the id value from 110 to 228
        approvalSettingsPageExists = objCommon.CheckPageExistsInLicense(228);
        string strStatus = string.Empty;
        if (approvalSettingsPageExists == 1)
        {
            //Get Approval Settings Based on Company Id
            DataSet dsApprovalSettings = new DataSet();
            ShiftEvenData objShift = new ShiftEvenData();
            dsApprovalSettings = objShift.SelectApprovalSettings(intCompanyId);
            if (dsApprovalSettings != null)
            {
                if (dsApprovalSettings.Tables.Count > 0)
                {
                    if (dsApprovalSettings.Tables[0].Rows.Count > 0)
                    {
                        if (Convert.ToBoolean(dsApprovalSettings.Tables[0].Rows[0][strModule]) == false)
                            strStatus = "ApprovalNotRequired";
                        else
                            strStatus = "ApprovalRequired";
                    }
                    else
                        strStatus = "NotDefined";
                }
            }
        }
        else
            strStatus = "ApprovalRequired";
        return strStatus;
    }
    protected void OTEmployeeDetails()
    {
        DataSet dsYearSetting = new DataSet();
        string strFromdate, strTodate;
        dsYearSetting = objYearSettingsEventData.GetActiveYearSettings();
        if (dsYearSetting.Tables[0].Rows.Count <= 0)
            return;
        else
        {
            strFromdate = Convert.ToString(dsYearSetting.Tables[0].Rows[0]["FromDate"]);
            strTodate = Convert.ToString(dsYearSetting.Tables[0].Rows[0]["ToDate"]);
        }
        string EmployeeID = Convert.ToString(Request.QueryString["EmpId"]);
        string EmployeeName = Convert.ToString(Request.QueryString["EmpName"]);
        int EmployeeCategory = Convert.ToInt32(Request.QueryString["EmpCategory"].ToString());
        int EmployeeType = Convert.ToInt32(Request.QueryString["EmpType"].ToString());
        string gstrDateFormat = Convert.ToString(Session["MDateFormat"]);
        string Fromdate = Convert.ToString(Request.QueryString["FromDate"]);
        string Todate = Convert.ToString(Request.QueryString["ToDate"]);
        string SanctionType = Convert.ToString(Request.QueryString["SanctionType"]);
        string strSwipeCard = Convert.ToString(Request.QueryString["SwipeCard"]);
        OTStatus = Convert.ToString(Request.QueryString["Status"]);
        if (Fromdate == string.Empty)
        {
            Fromdate = strFromdate;
        }
        else
        {
            Fromdate = objCommon.DateConvertion(gstrDateFormat, Fromdate);
        }
        if (Todate == string.Empty)
        {
            Todate = strTodate;
        }
        else
        {
            Todate = objCommon.DateConvertion(gstrDateFormat, Todate);
        }
        string Level = rptcommon.getNodes(Convert.ToInt32(Session["parentLevelId"]), Convert.ToString(Session["LevelRights"]));
        dsOtEmployee = objOT.SelectOverTimeEmployee(Convert.ToInt32(Session["EmpAutoID"]), Fromdate, Todate, EmployeeID, EmployeeName, Level, EmployeeCategory, EmployeeType, Convert.ToString(Session["UserGroupName"]), Convert.ToString(Session["GradeLevel"]), OTStatus, strSwipeCard, Convert.ToInt32(Session["parentLevelId"]), SanctionType);
        Session["OTEmployee"] = dsOtEmployee;
        Session["TotalEmployees"] = dsOtEmployee.Tables[0].Rows.Count;
        int isRequestCompOff = 0;
        if (dsOtEmployee.Tables.Count > 0)
        {
            if (dsOtEmployee.Tables[0].Rows.Count > 0)
            {
                Session["isRequestCompOff"] = Convert.ToString(dsOtEmployee.Tables[0].Rows[0]["isRequestCompOff"]);
                if (Convert.ToInt32(Session["isRequestCompOff"]) == 1)
                {
                    grv_EmployeeOTSanction.Columns[7].Visible = false;
                    grv_EmployeeOTSanction.Columns[8].Visible = false;
                    grv_EmployeeOTSanction.Columns[9].Visible = false;
                    grv_EmployeeOTSanction.Columns[10].Visible = false;
                    grv_EmployeeOTSanction.Columns[11].Visible = false;

                    grv_EmployeeOTSanction.Columns[12].Visible = false;
                    grv_EmployeeOTSanction.Columns[13].Visible = false;
                    grv_EmployeeOTSanction.Columns[14].Visible = false;
                    grv_EmployeeOTSanction.Columns[15].Visible = false;

                    grv_EmployeeOTSanction.Columns[16].Visible = false;
                    grv_EmployeeOTSanction.Columns[17].Visible = false;
                    grv_EmployeeOTSanction.Columns[18].Visible = false;
                    grv_EmployeeOTSanction.Columns[19].Visible = false;

                    grv_EmployeeOTSanction.Columns[20].Visible = false;
                    grv_EmployeeOTSanction.Columns[21].Visible = false;
                    grv_EmployeeOTSanction.Columns[22].Visible = false;
                    grv_EmployeeOTSanction.Columns[23].Visible = false;

                    grv_EmployeeOTSanction.Columns[26].Visible = false;
                    lblle1.Visible = false;
                }
                grv_EmployeeOTSanction.DataSource = dsOtEmployee;
                //Check OT Mins for Comp Off Application Mapping 
                //Session["dtLeaveDetails"]= checkOTMins(dsOtEmployee);
                grv_EmployeeOTSanction.DataBind();
            }
            else
            {
                grv_EmployeeOTSanction.DataSource = dsOtEmployee;
                grv_EmployeeOTSanction.DataBind();
                btn_Approved.Visible = false;
                btn_Forwarded.Visible = false;
                btn_Pending.Visible = false;
                btn_Reject.Visible = false;
                checkRecordExists = false;
            }
        }
        else
        {
            checkRecordExists = false;
        }
        if (checkRecordExists == true)
        {
            CheckBox chkSelect = new CheckBox();
            chkSelect = (CheckBox)grv_EmployeeOTSanction.HeaderRow.Cells[0].FindControl("checkall");
            chkSelect.Checked = Convert.ToBoolean(Session["SelectAllStatus"]);
        }
    }
    public void OTEmployeeSorting_bind()
    {
        DataSet dsSort = new DataSet();
        dsSort = (DataSet)Session["OTEmployee"];
        if (ViewState["sort"] != null)
        {
            dv = new DataView(dsSort.Tables[0]);
            dv.Sort = ViewState["sort"].ToString() + " " + ViewState["sort_direction"].ToString();
        }
        else
        {
            dv = dsSort.Tables[0].DefaultView;
        }
        grv_EmployeeOTSanction.DataSource = dv; ;
        grv_EmployeeOTSanction.DataBind();
    }
    private void LoadStrings(CultureInfo ci)
    {
        btn_Pending.Text = "&nbsp;&nbsp;" + rm.GetString("btn_Pending", ci);
        btn_Approved.Text = "&nbsp;&nbsp;" + rm.GetString("btn_Approved", ci);
        btn_Forwarded.Text = "&nbsp;&nbsp;" + rm.GetString("btn_Forwarded", ci);
        btn_Reject.Text = "&nbsp;&nbsp;" + rm.GetString("btn_Reject", ci);
        if (Convert.ToString(Session["packageID"]) != "")
        {
            if (Convert.ToString(Session["packageID"]) != "156")
            {
                FieldData(ci);
            }
        }
        else
        {
            FieldData(ci);
        }
        lblle1.Text = rm.GetString("OT_Hours_Got_Modified", ci);
        lblheader.Text = Convert.ToString(Request.QueryString["SanctionType"]).Contains("OverTime") ? rm.GetString("lblOVerTimeApproval", ci) : rm.GetString("lblCompOffApproval", ci);
    }

    private void FieldData(CultureInfo ci)
    {
        grv_EmployeeOTSanction.Columns[5].HeaderText = rm.GetString("Reports_Date", ci);
        grv_EmployeeOTSanction.Columns[2].HeaderText = rm.GetString("email_EmployeeId", ci);
        grv_EmployeeOTSanction.Columns[3].HeaderText = rm.GetString("email_EmployeeName", ci);
        grv_EmployeeOTSanction.Columns[4].HeaderText = rm.GetString("LevelDetails_LevelName", ci);
        grv_EmployeeOTSanction.Columns[6].HeaderText = rm.GetString("OTSanction_HoursOt", ci);
        grv_EmployeeOTSanction.Columns[7].HeaderText = rm.GetString("Approved_OTSanction", ci);
        grv_EmployeeOTSanction.Columns[8].HeaderText = rm.GetString("OTSanction_WeeklyoffOt", ci);
        grv_EmployeeOTSanction.Columns[9].HeaderText = rm.GetString("Approved_WeeklyOffOT", ci);
        grv_EmployeeOTSanction.Columns[10].HeaderText = rm.GetString("OTSanction_HolidayOt", ci);
        grv_EmployeeOTSanction.Columns[11].HeaderText = rm.GetString("Approved_HolidayOT", ci);
        grv_EmployeeOTSanction.Columns[24].HeaderText = rm.GetString("email_Status", ci);
        if (lblheader.Text == "Comp Off Approval")
        {
            grv_EmployeeOTSanction.Columns[6].HeaderText = rm.GetString("lbl_ExtraWorkedHrs", ci);
            grv_EmployeeOTSanction.Columns[7].HeaderText = rm.GetString("lbl_ApprovedExtraWorkingHrs", ci);
            grv_EmployeeOTSanction.Columns[8].HeaderText = rm.GetString("lbl_WeeklyOffWorkedHrs", ci);
            grv_EmployeeOTSanction.Columns[9].HeaderText = rm.GetString("lbl_ApprovedWeeklyOffWorkedHrs", ci);
            grv_EmployeeOTSanction.Columns[10].HeaderText = rm.GetString("lbl_HolidayWorkedHrs", ci);
            grv_EmployeeOTSanction.Columns[11].HeaderText = rm.GetString("lbl_ApprovedWorkedHrs", ci);
        }
    }

    protected void UpdatedEmployeeOTStatus(string Status)
    {
        string strEmployeeCode = string.Empty;
        string strEmployeeName = string.Empty;
        DataSet ds = new DataSet();
        ds = (DataSet)Session["OTEmployee"];
        ds.Tables[0].Columns.Remove("Employee_Code_Id");
        ds.Tables[0].Columns.Remove("date");
        ds.Tables[0].Columns.Remove("shift_id");
        ds.Tables[0].Columns.Remove("HrsWork");
        ds.Tables[0].Columns.Remove("HrsOT");
        ds.Tables[0].Columns.Remove("OffOT");
        ds.Tables[0].Columns.Remove("HolOT");
        ds.Tables[0].Columns.Remove("Employee_FirstName");
        ds.Tables[0].Columns.Remove("Level Name");
        ds.Tables[0].Columns.Remove("OTMins");
        if (Status == "Forwarded")
        {
            ds.Tables[0].DefaultView.RowFilter = "OverTimeStatus='Pending' and OverTimeStatus<>'Rejected' and SelectedRecords=1";
        }
        if (Status == "Approved")
        {
            ds.Tables[0].DefaultView.RowFilter = "(OverTimeStatus='Forwarded' or OverTimeStatus='Pending') and OverTimeStatus<>'Rejected' and SelectedRecords=1";
        }
        if (Status == "Rejected")
        {
            ds.Tables[0].DefaultView.RowFilter = "OverTimeStatus<>'Approved'  and SelectedRecords=1";
        }
        ds.Tables[0].Columns.Remove("OverTimeStatus");
        DataTable dtOTStatus = ds.Tables[0].DefaultView.ToTable();
        dtOTStatus.Columns.Remove("SelectedRecords");
        dtOTStatus.Columns.Remove("isRequestCompOff");
        if (Convert.ToInt32(Session["isRequestCompOff"]) == 0)
        {
            dtOTStatus.Columns.Remove("ExtraTime_Id");
            ds.Tables[0].Columns.Remove("Employee_Id");
        }
        StringWriter strWriteXML = new StringWriter();
        string OtDate = "1/1/2011";
        dtOTStatus.TableName = "Table";
        dtOTStatus.WriteXml(strWriteXML);
        objOT.UpdateEmployeeOTStatus(strEmployeeCode, Status, OtDate, strWriteXML.ToString(), Convert.ToInt32(Session["isRequestCompOff"]));
        if (Convert.ToInt32(Session["isRequestCompOff"]) == 1)
        {
            foreach (DataRow DR in dtOTStatus.Rows)
            {
                SendMail(Convert.ToInt32(DR["ExtraTime_Id"]), Status);
            }
        }
    }
    public void SendMail(int CompOffID, string status)
    {
        try
        {
            ViewDetails(CompOffID);
            dsEmployeeDetails = objEmployeeEventData.GetEmployeeDetails(Convert.ToInt32(ViewState["iEmployeeID"]));
            if (dsEmployeeDetails.Tables.Count > 0)
            {
                if (dsEmployeeDetails.Tables[0].Rows.Count > 0)
                {
                    if (dsEmployeeDetails.Tables[0].Rows[0]["ReportingToEmailID"] != DBNull.Value)
                    {
                        strEmailIdReportingTo = Convert.ToString(dsEmployeeDetails.Tables[0].Rows[0]["ReportingToEmailID"]);
                    }
                    if (dsEmployeeDetails.Tables[0].Rows[0]["ApprovalAuthorityEmailID"] != DBNull.Value)
                    {
                        strEmailIdSanctioningAuthority = Convert.ToString(dsEmployeeDetails.Tables[0].Rows[0]["ApprovalAuthorityEmailID"]);
                    }
                    strEmpFirstName = Convert.ToString(dsEmployeeDetails.Tables[0].Rows[0]["Employee_FirstName"]);
                    strEmpLastName = Convert.ToString(dsEmployeeDetails.Tables[0].Rows[0]["Employee_LastName"]);
                    strEmployeeCodeId = Convert.ToString(dsEmployeeDetails.Tables[0].Rows[0]["Employee_Code_Id"]);
                    strEmployeeName = strEmpFirstName + " " + strEmpLastName;
                    strlevelName = Convert.ToString(dsEmployeeDetails.Tables[0].Rows[0]["levelName"]);
                    strEmailID = Convert.ToString(dsEmployeeDetails.Tables[0].Rows[0]["EmailId"]);
                    blnCheckEmail = ObjEmailTrigger.SendMailCompOff(strEmailID, strEmailIdReportingTo, strEmailIdSanctioningAuthority, strEmployeeCodeId, strEmployeeName, Convert.ToString(ViewState["strAppDate"]), Convert.ToString(ViewState["strComDate"]), Convert.ToString(ViewState["CompIntime"]), Convert.ToString(ViewState["CompOuttime"]), Convert.ToString(ViewState["CompType"]), Convert.ToString(ViewState["CompWorkedHrs"]), Convert.ToString(ViewState["CompReason"]), status, strlevelName, "Sanction");
                }
            }
        }
        catch (Exception ex)
        {
            Message(ex.ToString());
        }
    }
    public void ViewDetails(int CompoffID)
    {
        DataSet dsCompensation = new DataSet();
        dsCompensation = objEmployeeEventData.SelectCompensationDatabyid(CompoffID);
        iEmployeeID = Convert.ToInt32(dsCompensation.Tables[0].Rows[0]["E_Employee_Id"]);
        ViewState["iEmployeeID"] = iEmployeeID.ToString();
        ViewState["StatusOfApplication"] = dsCompensation.Tables[0].Rows[0]["Comp_Status"].ToString();
        ViewState["Emp_Code_ID"] = dsCompensation.Tables[0].Rows[0]["Employee_Id"].ToString();
        ViewState["strComDate"] = dsCompensation.Tables[0].Rows[0]["FromDate"].ToString();
        ViewState["strAppDate"] = dsCompensation.Tables[0].Rows[0]["ApplicationDate"].ToString();
        //ViewState["strComDate"] = objClassCommon.DateConvertion(gstrDateFormat, Convert.ToString(ViewState["strComDate"]));
        ViewState["CompType"] = dsCompensation.Tables[0].Rows[0]["DayWorked"].ToString();
        ViewState["CompIntime"] = dsCompensation.Tables[0].Rows[0]["InTime"].ToString();
        ViewState["CompOuttime"] = dsCompensation.Tables[0].Rows[0]["OutTime"].ToString();
        ViewState["CompWorkedHrs"] = dsCompensation.Tables[0].Rows[0]["WorkedHours"].ToString();
        ViewState["CompStatus"] = dsCompensation.Tables[0].Rows[0]["Comp_Status"].ToString();
        ViewState["CompReason"] = dsCompensation.Tables[0].Rows[0]["Reason"].ToString();
    }
    public void GetEmptyText(object sender, EventArgs e)
    {
        Label lblNoRecords = (Label)sender;
        lblNoRecords.Text = rm.GetString("Alert_Norecordsfound", ci);
    }
    #endregion
    #region Grid View Events
    protected void grv_CheckAll_CheckedChanged(object sender, EventArgs e)
    {
        grv_EmployeeOTSanction.EnableViewState = true;
        DataSet dsOTSanction = new DataSet();
        dsOTSanction = (DataSet)Session["OTEmployee"];
        foreach (DataRow dRowOTSanction in dsOTSanction.Tables[0].Rows)
        {
            if (((CheckBox)(sender)).Checked == true)
                dRowOTSanction["SelectedRecords"] = "1";
            else
            {
                dRowOTSanction["SelectedRecords"] = "0";
            }
        }
        Session["OTEmployee"] = dsOTSanction;
        grv_EmployeeOTSanction.DataSource = dsOTSanction;
        grv_EmployeeOTSanction.DataBind();
        CheckBox chkSelect = new CheckBox();
        chkSelect = (CheckBox)grv_EmployeeOTSanction.HeaderRow.Cells[0].FindControl("checkall");
        if (((CheckBox)(sender)).Checked)
        {
            chkSelect.Checked = true;
        }
        else
        {
            chkSelect.Checked = false;
        }
        Session["SelectAllStatus"] = chkSelect.Checked;
    }
    protected void grv_OTSanction_PageIndexChanging(object sender, GridViewPageEventArgs e)
    {
        grv_EmployeeOTSanction.EnableViewState = true;
        grv_EmployeeOTSanction.PageIndex = e.NewPageIndex;
        grv_EmployeeOTSanction.DataSource = (DataSet)Session["OTEmployee"];
        grv_EmployeeOTSanction.DataBind();
        CheckBox chkSelect = new CheckBox();
        chkSelect = (CheckBox)grv_EmployeeOTSanction.HeaderRow.Cells[0].FindControl("checkall");
        chkSelect.Checked = Convert.ToBoolean(Session["SelectAllStatus"]);
    }
    protected void grv_Check_CheckedChanged(object sender, EventArgs e)
    {
        Label lblProcessRecId = new Label();
        lblProcessRecId.Text = ((Label)((CheckBox)(sender)).FindControl("lblProc_RecordId")).Text.ToString();
        DataSet dsOTSanction = new DataSet();
        dsOTSanction = (DataSet)Session["OTEmployee"];
        DataRow[] OTSanctionRow = dsOTSanction.Tables[0].Select("Process_Rec_ID = " + lblProcessRecId.Text);
        if (OTSanctionRow.Length > 0)
        {
            if (((CheckBox)(sender)).Checked == true)
            {
                OTSanctionRow[0]["SelectedRecords"] = "1";
            }
            else
            {
                OTSanctionRow[0]["SelectedRecords"] = "0";
            }
        }
        dsOTSanction.Tables[0].DefaultView.RowFilter = "SelectedRecords=0";
        int intSelectAllCount = dsOTSanction.Tables[0].DefaultView.ToTable().Rows.Count;
        CheckBox chkSelectAll = new CheckBox();
        chkSelectAll = (CheckBox)grv_EmployeeOTSanction.HeaderRow.Cells[0].FindControl("checkall");
        if (intSelectAllCount == 0)
        {
            chkSelectAll.Checked = true;
        }
        else
        {
            chkSelectAll.Checked = false;
        }
        Session["SelectAllStatus"] = chkSelectAll.Checked;
        Session["OTEmployee"] = dsOTSanction;
    }
    protected void grv_EmployeeOTSanction_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            Label lblStatus = (Label)e.Row.FindControl("lblOTStatus");
            Label lblHoursOT = (Label)e.Row.FindControl("lblHoursOT");
            Label lblWeekOffOT = (Label)e.Row.FindControl("lblWeeklyoffOT");
            Label lblHolidayOT = (Label)e.Row.FindControl("lblHolidayOT");
            Label lblHoursOT1 = (Label)e.Row.FindControl("lblHoursOT1");
            Label lblWeekOffOT1 = (Label)e.Row.FindControl("lblWeeklyoffOT1");
            Label lblHolidayOT1 = (Label)e.Row.FindControl("lblHoliday1");


            Label lblSPEC_NormOT1 = (Label)e.Row.FindControl("lblSPEC_NormOT1");
            Label lblModified_Spec_NormOTHrs1 = (Label)e.Row.FindControl("lblModified_Spec_NormOTHrs1");
            Label lblSPEC_NormOT2 = (Label)e.Row.FindControl("lblSPEC_NormOT2");
            Label lblModified_Spec_NormOTHrs2 = (Label)e.Row.FindControl("lblModified_Spec_NormOTHrs2");

            if (lblModified_Spec_NormOTHrs1 != null)
            {
                if (lblSPEC_NormOT1.Text == lblModified_Spec_NormOTHrs1.Text)
                    lblModified_Spec_NormOTHrs1.Style.Add("color", "#333");
                else
                    lblModified_Spec_NormOTHrs1.Style.Add("color", "#F00");
            }

            if (lblModified_Spec_NormOTHrs2 != null)
            {
                if (lblSPEC_NormOT2.Text == lblModified_Spec_NormOTHrs2.Text)
                    lblModified_Spec_NormOTHrs2.Style.Add("color", "#333");
                else
                    lblModified_Spec_NormOTHrs2.Style.Add("color", "#F00");
            }

            Label lblSPEC_OffOT1 = (Label)e.Row.FindControl("lblSPEC_OffOT1");
            Label lblModified_Spec_OffOTHrs1 = (Label)e.Row.FindControl("lblModified_Spec_OffOTHrs1");
            Label lblSPEC_OffOT2 = (Label)e.Row.FindControl("lblSPEC_OffOT2");
            Label lblModified_Spec_OffOTHrs2 = (Label)e.Row.FindControl("lblModified_Spec_OffOTHrs2");

            if (lblModified_Spec_OffOTHrs1 != null)
            {
                if (lblSPEC_OffOT1.Text == lblModified_Spec_OffOTHrs1.Text)
                    lblModified_Spec_OffOTHrs1.Style.Add("color", "#333");
                else
                    lblModified_Spec_OffOTHrs1.Style.Add("color", "#F00");
            }

            if (lblModified_Spec_OffOTHrs2 != null)
            {
                if (lblSPEC_OffOT2.Text == lblModified_Spec_OffOTHrs2.Text)
                    lblModified_Spec_OffOTHrs2.Style.Add("color", "#333");
                else
                    lblModified_Spec_OffOTHrs2.Style.Add("color", "#F00");
            }

            Label lblSPEC_HOLOT1 = (Label)e.Row.FindControl("lblSPEC_HOLOT1");
            Label lblModified_Spec_HolOTHrs1 = (Label)e.Row.FindControl("lblModified_Spec_HolOTHrs1");
            Label lblSPEC_HOLOT2 = (Label)e.Row.FindControl("lblSPEC_HOLOT2");
            Label lblModified_Spec_HolOTHrs2 = (Label)e.Row.FindControl("lblModified_Spec_HolOTHrs2");

            if (lblModified_Spec_HolOTHrs1 != null)
            {
                if (lblSPEC_HOLOT1.Text == lblModified_Spec_HolOTHrs1.Text)
                    lblModified_Spec_HolOTHrs1.Style.Add("color", "#333");
                else
                    lblModified_Spec_HolOTHrs1.Style.Add("color", "#F00");
            }
            if (lblModified_Spec_HolOTHrs2 != null)
            {
                if (lblSPEC_HOLOT2.Text == lblModified_Spec_HolOTHrs2.Text)
                    lblModified_Spec_HolOTHrs2.Style.Add("color", "#333");
                else
                    lblModified_Spec_HolOTHrs2.Style.Add("color", "#F00");
            }
            if (lblHoursOT1 != null)
            {
                if (lblHoursOT.Text == lblHoursOT1.Text)
                    lblHoursOT1.Style.Add("color", "#333");
                else
                    lblHoursOT1.Style.Add("color", "#F00");
            }
            if (lblWeekOffOT1 != null)
            {
                if (lblWeekOffOT.Text == lblWeekOffOT1.Text)
                    lblWeekOffOT1.Style.Add("color", "#333");
                else
                    lblWeekOffOT1.Style.Add("color", "#F00");
            }
            if (lblHolidayOT1 != null)
            {
                if (lblHolidayOT.Text == lblHolidayOT1.Text)
                    lblHolidayOT1.Style.Add("color", "#333");
                else
                    lblHolidayOT1.Style.Add("color", "#F00");
            }
            if (lblStatus != null)
            {
                switch (lblStatus.Text)
                {
                    case "Approved":
                        lblStatus.Text = rm.GetString("btn_Approved", ci);
                        break;
                    case "Forwarded":
                        lblStatus.Text = rm.GetString("btn_Forwarded", ci);
                        break;
                    case "Pending":
                        lblStatus.Text = rm.GetString("btn_Pending", ci);
                        break;
                    case "Rejected":
                        lblStatus.Text = rm.GetString("btn_Reject", ci);
                        break;
                }
            }
            Label lbl = (Label)e.Row.Cells[2].FindControl("lblOTDate");
            if (lbl != null)
                if (lbl.Text != "")
                    lbl.Text = (Convert.ToDateTime(lbl.Text.ToString())).ToString(Session["MDateFormat"].ToString());
        }
    }
    public void grv_OTSanctionSorting(object sender, GridViewSortEventArgs e)
    {
        ViewState["sort"] = e.SortExpression;
        ViewState["sort"] = e.SortExpression;
        if (ViewState["sort_direction"] == null)
        {
            ViewState["sort_direction"] = "Asc";
        }
        else if (ViewState["sort_direction"].ToString() == "Asc")
        {
            ViewState["sort_direction"] = "Desc";
        }
        else
        {
            ViewState["sort_direction"] = "Asc";
        }
        OTEmployeeSorting_bind();
    }

    protected void grv_EmployeeOTSanction_RowCancelingEdit(object sender, GridViewCancelEditEventArgs e)
    {
        grv_EmployeeOTSanction.EditIndex = -1;
        grv_EmployeeOTSanction.DataSource = (DataSet)Session["OTEmployee"];
        grv_EmployeeOTSanction.DataBind();
        ViewState["EditMode"] = "Fales";
    }
    protected void grv_EmployeeOTSanction_RowEditing(object sender, GridViewEditEventArgs e)
    {
        grv_EmployeeOTSanction.EditIndex = e.NewEditIndex;
        grv_EmployeeOTSanction.DataSource = (DataSet)Session["OTEmployee"];
        grv_EmployeeOTSanction.DataBind();
        TextBox txtOT = (TextBox)grv_EmployeeOTSanction.Rows[e.NewEditIndex].FindControl("txtHoursOT");
        TextBox txtWOOT = (TextBox)grv_EmployeeOTSanction.Rows[e.NewEditIndex].FindControl("txtWeeklyoffOT");
        TextBox txtHDOT = (TextBox)grv_EmployeeOTSanction.Rows[e.NewEditIndex].FindControl("txtHolidayOT");


        TextBox txtModified_Spec_NormOTHrs1 = (TextBox)grv_EmployeeOTSanction.Rows[e.NewEditIndex].FindControl("txtModified_Spec_NormOTHrs1");
        TextBox txtModified_Spec_NormOTHrs2 = (TextBox)grv_EmployeeOTSanction.Rows[e.NewEditIndex].FindControl("txtModified_Spec_NormOTHrs2");
        TextBox txtModified_Spec_OffOTHrs1 = (TextBox)grv_EmployeeOTSanction.Rows[e.NewEditIndex].FindControl("txtModified_Spec_OffOTHrs1");
        TextBox txtModified_Spec_OffOTHrs2 = (TextBox)grv_EmployeeOTSanction.Rows[e.NewEditIndex].FindControl("txtModified_Spec_OffOTHrs2");
        TextBox txtModified_Spec_HolOTHrs1 = (TextBox)grv_EmployeeOTSanction.Rows[e.NewEditIndex].FindControl("txtModified_Spec_HolOTHrs1");
        TextBox txtModified_Spec_HolOTHrs2 = (TextBox)grv_EmployeeOTSanction.Rows[e.NewEditIndex].FindControl("txtModified_Spec_HolOTHrs2");

        Label lblModified_Spec_NormOTHrs1 = (Label)grv_EmployeeOTSanction.Rows[e.NewEditIndex].FindControl("lblSPEC_NormOT1");
        Label lblModified_Spec_NormOTHrs2 = (Label)grv_EmployeeOTSanction.Rows[e.NewEditIndex].FindControl("lblSPEC_NormOT2");
        Label lblModified_Spec_OffOTHrs1 = (Label)grv_EmployeeOTSanction.Rows[e.NewEditIndex].FindControl("lblSPEC_OffOT1");
        Label lblModified_Spec_OffOTHrs2 = (Label)grv_EmployeeOTSanction.Rows[e.NewEditIndex].FindControl("lblSPEC_OffOT2");
        Label lblModified_Spec_HolOTHrs1 = (Label)grv_EmployeeOTSanction.Rows[e.NewEditIndex].FindControl("lblSPEC_HOLOT1");
        Label lblModified_Spec_HolOTHrs2 = (Label)grv_EmployeeOTSanction.Rows[e.NewEditIndex].FindControl("lblSPEC_HOLOT2");



        Label lblOT = (Label)grv_EmployeeOTSanction.Rows[e.NewEditIndex].FindControl("lblHoursOT");
        Label lblWOOT = (Label)grv_EmployeeOTSanction.Rows[e.NewEditIndex].FindControl("lblWeeklyoffOT");
        Label lblHDOT = (Label)grv_EmployeeOTSanction.Rows[e.NewEditIndex].FindControl("lblHolidayOT");
        Label lblStatus = (Label)grv_EmployeeOTSanction.Rows[e.NewEditIndex].FindControl("lblOTStatus");
        if (lblStatus.Text != "Approved")
        {
            //txtOT.Attributes.Add("onmouseover", "javascript:return DynamicDatePicker('" + Session["ITimeFormat"] + "','" + txtOT.ClientID + "')");
            //txtWOOT.Attributes.Add("onmouseover", "javascript:return DynamicDatePicker('" + Session["ITimeFormat"] + "','" + txtWOOT.ClientID + "')");
            //txtHDOT.Attributes.Add("onmouseover", "javascript:return DynamicDatePicker('" + Session["ITimeFormat"] + "','" + txtHDOT.ClientID + "')");
            if (txtOT.Text == "00:00" && lblOT.Text == "00:00")
            {
                txtOT.Enabled = false;
                txtOT.Style.Add("background-color", "#D3DBE7");
            }
            else
            {
                txtOT.Enabled = true;
                txtOT.Style.Add("background-color", "#FFF");
            }
            if (txtWOOT.Text == "00:00" && lblWOOT.Text == "00:00")
            {
                txtWOOT.Enabled = false;
                txtWOOT.Style.Add("background-color", "#D3DBE7");
            }
            else
            {
                txtWOOT.Enabled = true;
                txtWOOT.Style.Add("background-color", "#FFF");
            }
            if (txtHDOT.Text == "00:00" && lblHDOT.Text == "00:00")
            {
                txtHDOT.Enabled = false;
                txtHDOT.Style.Add("background-color", "#D3DBE7");
            }
            else
            {
                txtHDOT.Enabled = true;
                txtHDOT.Style.Add("background-color", "#FFF");
            }

            if (txtModified_Spec_NormOTHrs1.Text == "00:00" && lblModified_Spec_NormOTHrs1.Text == "00:00")
            {
                txtModified_Spec_NormOTHrs1.Enabled = false;
                txtModified_Spec_NormOTHrs1.Style.Add("background-color", "#D3DBE7");
            }
            else
            {
                txtModified_Spec_NormOTHrs1.Enabled = true;
                txtModified_Spec_NormOTHrs1.Style.Add("background-color", "#FFF");
            }
            if (txtModified_Spec_NormOTHrs2.Text == "00:00" && lblModified_Spec_NormOTHrs2.Text == "00:00")
            {
                txtModified_Spec_NormOTHrs2.Enabled = false;
                txtModified_Spec_NormOTHrs2.Style.Add("background-color", "#D3DBE7");
            }
            else
            {
                txtModified_Spec_NormOTHrs2.Enabled = true;
                txtModified_Spec_NormOTHrs2.Style.Add("background-color", "#FFF");
            }

            if (txtModified_Spec_OffOTHrs1.Text == "00:00" && lblModified_Spec_OffOTHrs1.Text == "00:00")
            {
                txtModified_Spec_OffOTHrs1.Enabled = false;
                txtModified_Spec_OffOTHrs1.Style.Add("background-color", "#D3DBE7");
            }
            else
            {
                txtModified_Spec_OffOTHrs1.Enabled = true;
                txtModified_Spec_OffOTHrs1.Style.Add("background-color", "#FFF");
            }
            if (txtModified_Spec_OffOTHrs2.Text == "00:00" && lblModified_Spec_OffOTHrs2.Text == "00:00")
            {
                txtModified_Spec_OffOTHrs2.Enabled = false;
                txtModified_Spec_OffOTHrs2.Style.Add("background-color", "#D3DBE7");
            }
            else
            {
                txtModified_Spec_OffOTHrs2.Enabled = true;
                txtModified_Spec_OffOTHrs2.Style.Add("background-color", "#FFF");
            }

            if (txtModified_Spec_HolOTHrs1.Text == "00:00" && lblModified_Spec_HolOTHrs1.Text == "00:00")
            {
                txtModified_Spec_HolOTHrs1.Enabled = false;
                txtModified_Spec_HolOTHrs1.Style.Add("background-color", "#D3DBE7");
            }
            else
            {
                txtModified_Spec_HolOTHrs1.Enabled = true;
                txtModified_Spec_HolOTHrs1.Style.Add("background-color", "#FFF");
            }
            if (txtModified_Spec_HolOTHrs2.Text == "00:00" && lblModified_Spec_HolOTHrs2.Text == "00:00")
            {
                txtModified_Spec_HolOTHrs2.Enabled = false;
                txtModified_Spec_HolOTHrs2.Style.Add("background-color", "#D3DBE7");
            }
            else
            {
                txtModified_Spec_HolOTHrs2.Enabled = true;
                txtModified_Spec_HolOTHrs2.Style.Add("background-color", "#FFF");
            }

        }
        else
        {
            string str = "<script language=\"javascript\">";
            //str = str + "alert('Select Any Record');";
            str = str + "alert('" + rm.GetString("OT_Approved", ci) + "');";
            str = str + "</script>";
            Page.RegisterStartupScript("alert", str);
            grv_EmployeeOTSanction.EditIndex = -1;
            grv_EmployeeOTSanction.DataSource = (DataSet)Session["OTEmployee"];
            grv_EmployeeOTSanction.DataBind();
            return;
        }
        ViewState["EditMode"] = "True";
    }
    protected void grv_EmployeeOTSanction_RowUpdating(object sender, GridViewUpdateEventArgs e)
    {
        int Pro_RecordID = Convert.ToInt32(((Label)grv_EmployeeOTSanction.Rows[e.RowIndex].FindControl("lblProc_RecordId")).Text);
        string UpOTHours = Convert.ToString(((TextBox)grv_EmployeeOTSanction.Rows[e.RowIndex].FindControl("txtHoursOT")).Text);
        string UpWOFOTHours = Convert.ToString(((TextBox)grv_EmployeeOTSanction.Rows[e.RowIndex].FindControl("txtWeeklyoffOT")).Text);
        string UpHDOTHours = Convert.ToString(((TextBox)grv_EmployeeOTSanction.Rows[e.RowIndex].FindControl("txtHolidayOT")).Text);
        string OTHours = Convert.ToString(((Label)grv_EmployeeOTSanction.Rows[e.RowIndex].FindControl("lblHoursOT")).Text);
        string WOFOTHours = Convert.ToString(((Label)grv_EmployeeOTSanction.Rows[e.RowIndex].FindControl("lblWeeklyoffOT")).Text);
        string HDOTHours = Convert.ToString(((Label)grv_EmployeeOTSanction.Rows[e.RowIndex].FindControl("lblHolidayOT")).Text);

        string upSpec_NormOTHrs1 = Convert.ToString(((TextBox)grv_EmployeeOTSanction.Rows[e.RowIndex].FindControl("txtModified_Spec_NormOTHrs1")).Text);
        string upSpec_NormOTHrs2 = Convert.ToString(((TextBox)grv_EmployeeOTSanction.Rows[e.RowIndex].FindControl("txtModified_Spec_NormOTHrs2")).Text);
        string upSpec_OffOTHrs1 = Convert.ToString(((TextBox)grv_EmployeeOTSanction.Rows[e.RowIndex].FindControl("txtModified_Spec_OffOTHrs1")).Text);
        string upSpec_OffOTHrs2 = Convert.ToString(((TextBox)grv_EmployeeOTSanction.Rows[e.RowIndex].FindControl("txtModified_Spec_OffOTHrs2")).Text);
        string upSpec_HolOTHrs1 = Convert.ToString(((TextBox)grv_EmployeeOTSanction.Rows[e.RowIndex].FindControl("txtModified_Spec_HolOTHrs1")).Text);
        string upSpec_HolOTHrs2 = Convert.ToString(((TextBox)grv_EmployeeOTSanction.Rows[e.RowIndex].FindControl("txtModified_Spec_HolOTHrs2")).Text);

        string Spec_NormOTHrs1 = Convert.ToString(((Label)grv_EmployeeOTSanction.Rows[e.RowIndex].FindControl("lblSPEC_NormOT1")).Text);
        string Spec_NormOTHrs2 = Convert.ToString(((Label)grv_EmployeeOTSanction.Rows[e.RowIndex].FindControl("lblSPEC_NormOT2")).Text);
        string Spec_OffOTHrs1 = Convert.ToString(((Label)grv_EmployeeOTSanction.Rows[e.RowIndex].FindControl("lblSPEC_OffOT1")).Text);
        string Spec_OffOTHrs2 = Convert.ToString(((Label)grv_EmployeeOTSanction.Rows[e.RowIndex].FindControl("lblSPEC_OffOT2")).Text);
        string Spec_HolOTHrs1 = Convert.ToString(((Label)grv_EmployeeOTSanction.Rows[e.RowIndex].FindControl("lblSPEC_HOLOT1")).Text);
        string Spec_HolOTHrs2 = Convert.ToString(((Label)grv_EmployeeOTSanction.Rows[e.RowIndex].FindControl("lblSPEC_HOLOT2")).Text);

        string[] str1;
        if (UpOTHours == "" || UpWOFOTHours == "" || UpHDOTHours == "" || upSpec_NormOTHrs1 == "" | upSpec_NormOTHrs2 == "" || upSpec_OffOTHrs1 == "" || upSpec_OffOTHrs2 == "" || upSpec_HolOTHrs1 == "" || upSpec_HolOTHrs2 == "")
        {
            string str = "<script language=\"javascript\">";
            str = str + "alert('Enter OT Hours');";
            str = str + "</script>";
            Page.RegisterStartupScript("alert", str);
            if (UpOTHours == "")
            {
                ((TextBox)grv_EmployeeOTSanction.Rows[e.RowIndex].FindControl("txtHoursOT")).Focus();
                return;
            }
            if (UpWOFOTHours == "")
            {
                ((TextBox)grv_EmployeeOTSanction.Rows[e.RowIndex].FindControl("txtWeeklyoffOT")).Focus();
                return;
            }
            if (UpHDOTHours == "")
            {
                ((TextBox)grv_EmployeeOTSanction.Rows[e.RowIndex].FindControl("txtHolidayOT")).Focus();
                return;
            }
            if (upSpec_NormOTHrs1 == "")
            {
                ((TextBox)grv_EmployeeOTSanction.Rows[e.RowIndex].FindControl("txtModified_Spec_NormOTHrs1")).Focus();
                return;
            }
            if (upSpec_NormOTHrs2 == "")
            {
                ((TextBox)grv_EmployeeOTSanction.Rows[e.RowIndex].FindControl("txtModified_Spec_NormOTHrs2")).Focus();
                return;
            }
            if (upSpec_OffOTHrs1 == "")
            {
                ((TextBox)grv_EmployeeOTSanction.Rows[e.RowIndex].FindControl("txtModified_Spec_OffOTHrs1")).Focus();
                return;
            }
            if (upSpec_OffOTHrs2 == "")
            {
                ((TextBox)grv_EmployeeOTSanction.Rows[e.RowIndex].FindControl("txtModified_Spec_OffOTHrs2")).Focus();
                return;
            }
            if (upSpec_HolOTHrs1 == "")
            {
                ((TextBox)grv_EmployeeOTSanction.Rows[e.RowIndex].FindControl("txtModified_Spec_HolOTHrs1")).Focus();
                return;
            }
            if (upSpec_HolOTHrs2 == "")
            {
                ((TextBox)grv_EmployeeOTSanction.Rows[e.RowIndex].FindControl("txtModified_Spec_HolOTHrs2")).Focus();
                return;
            }

        }
        // Get Modify OT Hours in integer format
        str1 = UpOTHours.Split(':');
        if (str1.Length == 2 && str1[0].Length == 2 && str1[1].Length == 2)
        {
            if (str1[0].Length == 2)
                intUpOTHrs = Convert.ToInt32(str1[0]) * 60;
            if (str1[1].Length == 2)
                intUpOTHrs = intUpOTHrs + Convert.ToInt32(str1[1]);
        }
        else
        {
            string str = "<script language=\"javascript\">";
            str = str + "alert('" + rm.GetString("Alert_OTHoursIncorrect", ci) + "');";
            str = str + "</script>";
            Page.RegisterStartupScript("alert", str);
            ((TextBox)grv_EmployeeOTSanction.Rows[e.RowIndex].FindControl("txtHoursOT")).Focus();
            return;
        }
        // Get OT Hours in integer format
        str1 = OTHours.Split(':');
        if (str1.Length == 2)
        {
            intOTHrs = Convert.ToInt32(str1[0]) * 60;
            intOTHrs = intOTHrs + Convert.ToInt32(str1[1]);
        }
        // Get Modify Week Off OT Hours in integer format
        str1 = UpWOFOTHours.Split(':');
        if (str1.Length == 2 && str1[0].Length == 2 && str1[1].Length == 2)
        {
            if (str1[0].Length == 2)
                intUpWOFOTHrs = Convert.ToInt32(str1[0]) * 60;
            if (str1[1].Length == 2)
                intUpWOFOTHrs = intUpWOFOTHrs + Convert.ToInt32(str1[1]);
        }
        else
        {
            string str = "<script language=\"javascript\">";
            str = str + "alert('" + rm.GetString("Alert_WOOTHoursIncorrect", ci) + "');";
            str = str + "</script>";
            Page.RegisterStartupScript("alert", str);
            ((TextBox)grv_EmployeeOTSanction.Rows[e.RowIndex].FindControl("txtWeeklyoffOT")).Focus();
            return;
        }
        // Get Week Off OT Hours in integer format
        str1 = WOFOTHours.Split(':');
        if (str1.Length == 2)
        {
            intWOFOTHrs = Convert.ToInt32(str1[0]) * 60;
            intWOFOTHrs = intWOFOTHrs + Convert.ToInt32(str1[1]);
        }
        // Get Modify Holiday OT Hours in integer format
        str1 = UpHDOTHours.Split(':');
        if (str1.Length == 2 && str1[0].Length == 2 && str1[1].Length == 2)
        {
            if (str1[0].Length == 2)
                intUpHDOTFrs = Convert.ToInt32(str1[0]) * 60;
            if (str1[1].Length == 2)
                intUpHDOTFrs = intUpHDOTFrs + Convert.ToInt32(str1[1]);
        }
        else
        {
            string str = "<script language=\"javascript\">";
            //str = str + "alert('Select Any Record');";
            str = str + "alert('" + rm.GetString("Alert_HDOTHoursIncorrect", ci) + "');";
            str = str + "</script>";
            Page.RegisterStartupScript("alert", str);
            ((TextBox)grv_EmployeeOTSanction.Rows[e.RowIndex].FindControl("txtHolidayOT")).Focus();
            return;
        }
        // Get Holiday OT Hours in integer format
        str1 = HDOTHours.Split(':');
        if (str1.Length == 2)
        {
            intHDOTFrs = Convert.ToInt32(str1[0]) * 60;
            intHDOTFrs = intHDOTFrs + Convert.ToInt32(str1[1]);
        }

        #region Special
        // Normal Days Specila Overtime 1 and 2
        str1 = upSpec_NormOTHrs1.Split(':');
        if (str1.Length == 2 && str1[0].Length == 2 && str1[1].Length == 2)
        {
            if (str1[0].Length == 2)
                intUpSpecOTHrs1 = Convert.ToInt32(str1[0]) * 60;
            if (str1[1].Length == 2)
                intUpSpecOTHrs1 = intUpSpecOTHrs1 + Convert.ToInt32(str1[1]);
        }
        else
        {
            string str = "<script language=\"javascript\">";
            str = str + "alert('Enter valid Overtime hours');";
            str = str + "</script>";
            Page.RegisterStartupScript("alert", str);
            ((TextBox)grv_EmployeeOTSanction.Rows[e.RowIndex].FindControl("txtModified_Spec_NormOTHrs1")).Focus();
            return;
        }
        // Get OT Hours in integer format
        str1 = Spec_NormOTHrs1.Split(':');
        if (str1.Length == 2)
        {
            intSpecOTHrs1 = Convert.ToInt32(str1[0]) * 60;
            intSpecOTHrs1 = intSpecOTHrs1 + Convert.ToInt32(str1[1]);
        }


        str1 = upSpec_NormOTHrs2.Split(':');
        if (str1.Length == 2 && str1[0].Length == 2 && str1[1].Length == 2)
        {
            if (str1[0].Length == 2)
                intUpSpecOTHrs2 = Convert.ToInt32(str1[0]) * 60;
            if (str1[1].Length == 2)
                intUpSpecOTHrs2 = intUpSpecOTHrs2 + Convert.ToInt32(str1[1]);
        }
        else
        {
            string str = "<script language=\"javascript\">";
            str = str + "alert('Enter valid Overtime hours');";
            str = str + "</script>";
            Page.RegisterStartupScript("alert", str);
            ((TextBox)grv_EmployeeOTSanction.Rows[e.RowIndex].FindControl("txtModified_Spec_NormOTHrs2")).Focus();
            return;
        }
        // Get OT Hours in integer format
        str1 = Spec_NormOTHrs2.Split(':');
        if (str1.Length == 2)
        {
            intSpecOTHrs2 = Convert.ToInt32(str1[0]) * 60;
            intSpecOTHrs2 = intSpecOTHrs2 + Convert.ToInt32(str1[1]);
        }



        // Weekly off Days Specila Overtime 1 and 2
        str1 = upSpec_OffOTHrs1.Split(':');
        if (str1.Length == 2 && str1[0].Length == 2 && str1[1].Length == 2)
        {
            if (str1[0].Length == 2)
                intUpWOFSpecOTHrs1 = Convert.ToInt32(str1[0]) * 60;
            if (str1[1].Length == 2)
                intUpWOFSpecOTHrs1 = intUpWOFSpecOTHrs1 + Convert.ToInt32(str1[1]);
        }
        else
        {
            string str = "<script language=\"javascript\">";
            str = str + "alert('Enter valid Overtime hours');";
            str = str + "</script>";
            Page.RegisterStartupScript("alert", str);
            ((TextBox)grv_EmployeeOTSanction.Rows[e.RowIndex].FindControl("txtModified_Spec_NormOTHrs1")).Focus();
            return;
        }
        // Get OT Hours in integer format
        str1 = Spec_OffOTHrs1.Split(':');
        if (str1.Length == 2)
        {
            intWOFSpecOTHrs1 = Convert.ToInt32(str1[0]) * 60;
            intWOFSpecOTHrs1 = intWOFSpecOTHrs1 + Convert.ToInt32(str1[1]);
        }


        str1 = upSpec_OffOTHrs2.Split(':');
        if (str1.Length == 2 && str1[0].Length == 2 && str1[1].Length == 2)
        {
            if (str1[0].Length == 2)
                intUpWOFSpecOTHrs2 = Convert.ToInt32(str1[0]) * 60;
            if (str1[1].Length == 2)
                intUpWOFSpecOTHrs2 = intUpWOFSpecOTHrs2 + Convert.ToInt32(str1[1]);
        }
        else
        {
            string str = "<script language=\"javascript\">";
            str = str + "alert('Enter valid Overtime hours');";
            str = str + "</script>";
            Page.RegisterStartupScript("alert", str);
            ((TextBox)grv_EmployeeOTSanction.Rows[e.RowIndex].FindControl("txtModified_Spec_NormOTHrs1")).Focus();
            return;
        }
        // Get OT Hours in integer format
        str1 = Spec_OffOTHrs2.Split(':');
        if (str1.Length == 2)
        {
            intWOFSpecOTHrs2 = Convert.ToInt32(str1[0]) * 60;
            intWOFSpecOTHrs2 = intWOFSpecOTHrs2 + Convert.ToInt32(str1[1]);
        }

        // Holiday Specila Overtime 1 and 2
        str1 = upSpec_HolOTHrs1.Split(':');
        if (str1.Length == 2 && str1[0].Length == 2 && str1[1].Length == 2)
        {
            if (str1[0].Length == 2)
                intUpHDSpecOTFrs1 = Convert.ToInt32(str1[0]) * 60;
            if (str1[1].Length == 2)
                intUpHDSpecOTFrs1 = intUpHDSpecOTFrs1 + Convert.ToInt32(str1[1]);
        }
        else
        {
            string str = "<script language=\"javascript\">";
            str = str + "alert('Enter valid Overtime hours');";
            str = str + "</script>";
            Page.RegisterStartupScript("alert", str);
            ((TextBox)grv_EmployeeOTSanction.Rows[e.RowIndex].FindControl("txtModified_Spec_NormOTHrs1")).Focus();
            return;
        }
        // Get OT Hours in integer format
        str1 = Spec_HolOTHrs1.Split(':');
        if (str1.Length == 2)
        {
            intHDSpecOTFrs1 = Convert.ToInt32(str1[0]) * 60;
            intHDSpecOTFrs1 = intHDSpecOTFrs1 + Convert.ToInt32(str1[1]);
        }

        str1 = upSpec_HolOTHrs2.Split(':');
        if (str1.Length == 2 && str1[0].Length == 2 && str1[1].Length == 2)
        {
            if (str1[0].Length == 2)
                intUpHDSpecOTFrs2 = Convert.ToInt32(str1[0]) * 60;
            if (str1[1].Length == 2)
                intUpHDSpecOTFrs2 = intUpHDSpecOTFrs2 + Convert.ToInt32(str1[1]);
        }
        else
        {
            string str = "<script language=\"javascript\">";
            str = str + "alert('Enter valid Overtime hours');";
            str = str + "</script>";
            Page.RegisterStartupScript("alert", str);
            ((TextBox)grv_EmployeeOTSanction.Rows[e.RowIndex].FindControl("txtModified_Spec_NormOTHrs1")).Focus();
            return;
        }
        // Get OT Hours in integer format
        str1 = Spec_HolOTHrs2.Split(':');
        if (str1.Length == 2)
        {
            intHDSpecOTFrs2 = Convert.ToInt32(str1[0]) * 60;
            intHDSpecOTFrs2 = intHDSpecOTFrs2 + Convert.ToInt32(str1[1]);
        }
        #endregion

        if (intOTHrs < intUpOTHrs)
        {
            string str = "<script language=\"javascript\">";
            //str = str + "alert('Select Any Record');";
            str = str + "alert('" + rm.GetString("Alert_OTHours", ci) + "');";
            str = str + "</script>";
            Page.RegisterStartupScript("alert", str);
            ((TextBox)grv_EmployeeOTSanction.Rows[e.RowIndex].FindControl("txtHoursOT")).Focus();
            return;
        }
        if (intWOFOTHrs < intUpWOFOTHrs)
        {
            string str = "<script language=\"javascript\">";
            //str = str + "alert('Select Any Record');";
            str = str + "alert('" + rm.GetString("Alert_WeekOffOTHours", ci) + "');";
            str = str + "</script>";
            Page.RegisterStartupScript("alert", str);
            ((TextBox)grv_EmployeeOTSanction.Rows[e.RowIndex].FindControl("txtWeeklyoffOT")).Focus();
            return;
        }
        if (intHDOTFrs < intUpHDOTFrs)
        {
            string str = "<script language=\"javascript\">";
            //str = str + "alert('Select Any Record');";
            str = str + "alert('" + rm.GetString("Alert_HolidayOTHours", ci) + "');";
            str = str + "</script>";
            Page.RegisterStartupScript("alert", str);
            ((TextBox)grv_EmployeeOTSanction.Rows[e.RowIndex].FindControl("txtHolidayOT")).Focus();
            return;
        }
        #region SpecialOverTime
        if (intSpecOTHrs1 < intUpSpecOTHrs1)
        {
            string str = "<script language=\"javascript\">";
            str = str + "alert('Enter valid Overtime');";
            str = str + "</script>";
            Page.RegisterStartupScript("alert", str);
            return;
        }
        if (intSpecOTHrs2 < intUpSpecOTHrs2)
        {
            string str = "<script language=\"javascript\">";
            str = str + "alert('Enter valid Overtime');";
            str = str + "</script>";
            Page.RegisterStartupScript("alert", str);
            return;
        }
        if (intWOFSpecOTHrs1 < intUpWOFSpecOTHrs1)
        {
            string str = "<script language=\"javascript\">";
            str = str + "alert('Enter valid Overtime');";
            str = str + "</script>";
            Page.RegisterStartupScript("alert", str);
            return;
        }
        if (intWOFSpecOTHrs2 < intUpWOFSpecOTHrs2)
        {
            string str = "<script language=\"javascript\">";
            str = str + "alert('Enter valid Overtime');";
            str = str + "</script>";
            Page.RegisterStartupScript("alert", str);
            return;
        }

        if (intHDSpecOTFrs1 < intUpHDSpecOTFrs1)
        {
            string str = "<script language=\"javascript\">";
            str = str + "alert('Enter valid Overtime');";
            str = str + "</script>";
            Page.RegisterStartupScript("alert", str);
            return;
        }
        if (intHDSpecOTFrs2 < intUpHDSpecOTFrs2)
        {
            string str = "<script language=\"javascript\">";
            str = str + "alert('Enter valid Overtime');";
            str = str + "</script>";
            Page.RegisterStartupScript("alert", str);
            return;
        }
        #endregion

        string strEmployee_code_id = Convert.ToString(((Label)grv_EmployeeOTSanction.Rows[e.RowIndex].FindControl("lblEmployeeCodeId")).Text);
        string strdate = Convert.ToString(((Label)grv_EmployeeOTSanction.Rows[e.RowIndex].FindControl("lblOTDate")).Text);
        if (strEmployee_code_id != "" && strdate != "")
            obj.UpdateOvertimeHours
                (
                    intOTHrs,
                    intWOFOTHrs,
                    intHDOTFrs,
                    OTHours,
                    WOFOTHours,
                    HDOTHours,
                    intUpOTHrs,
                    intUpWOFOTHrs,
                    intUpHDOTFrs,
                    UpOTHours,
                    UpWOFOTHours,
                    UpHDOTHours,
                    Pro_RecordID,
                    strEmployee_code_id,
                    strdate,
                    intUpSpecOTHrs1,
                    intUpSpecOTHrs2,
                    intUpWOFSpecOTHrs1,
                    intUpWOFSpecOTHrs2,
                    intUpHDSpecOTFrs1,
                    intUpHDSpecOTFrs2,
                    upSpec_NormOTHrs1,
                    upSpec_NormOTHrs2,
                    upSpec_OffOTHrs1,
                    upSpec_OffOTHrs2,
                    upSpec_HolOTHrs1,
                    upSpec_HolOTHrs2,
                    Convert.ToInt64(Session["EmpAutoID"])
                );
        OTEmployeeDetails();
        grv_EmployeeOTSanction.EditIndex = -1;
        grv_EmployeeOTSanction.DataSource = (DataSet)Session["OTEmployee"];
        grv_EmployeeOTSanction.DataBind();
        ViewState["EditMode"] = "Fales";
    }

    #endregion
    #region Button Events
    protected void btn_Approved_Click(object sender, EventArgs e)
    {
        if (Convert.ToString(ViewState["EditMode"]) == "True")
        {
            string str = "<script language=\"javascript\">";
            //str = str + "alert('Select Any Record');";
            str = str + "alert('" + rm.GetString("Alert_UpdatetheOThoursandthenproceedwithapprovals", ci) + "');";
            str = str + "</script>";
            Page.RegisterStartupScript("alert", str);
            return;
        }
        DataSet dsOTSanction = new DataSet();
        dsOTSanction = (DataSet)Session["OTEmployee"];
        dsOTSanction.Tables[0].DefaultView.RowFilter = "SelectedRecords=1";
        int intSelectAllCount = dsOTSanction.Tables[0].DefaultView.ToTable().Rows.Count;
        if (intSelectAllCount == 0)
        {
            string str = "<script language=\"javascript\">";
            //str = str + "alert('Select Any Record');";
            str = str + "alert('" + rm.GetString("Alert_SelectAnyRecord", ci) + "');";
            str = str + "</script>";
            Page.RegisterStartupScript("alert", str);
        }
        else
        {
            dsOTSanction.Tables[0].DefaultView.RowFilter = "(OverTimeStatus='Approved' or OverTimeStatus='Rejected') and SelectedRecords=1";
            int intSelectAllCount1 = dsOTSanction.Tables[0].DefaultView.ToTable().Rows.Count;
            if (intSelectAllCount1 != 0)
            {
                string str = "<script language=\"javascript\">";
                //str = str + "alert('Select Any Record');";
                str = str + "alert('" + rm.GetString("Aleart_OTApprovedStatus", ci) + "');";
                str = str + "</script>";
                Page.RegisterStartupScript("alert", str);
                return;
            }
            UpdatedEmployeeOTStatus("Approved");
            string str1 = "<script language=\"javascript\">";
            //str = str + "alert('Saved Successfully');";
            str1 = str1 + "alert('" + rm.GetString("Alert_SavedSuccessfully", ci) + "');";
            //str1 = str1 + "opener.focus();";
            //str = str + "alert(opener.location+'?fl=1&sid=';";
            str1 = str1 + "window.top.location.href = window.top.location.href + '?fl=1&sid=" + Session.SessionID + "';";
            str1 = str1 + "parent.$('#myModal').modal('hide');";
            str1 = str1 + "</script>";
            Page.RegisterStartupScript("alert", str1);
        }
    }
    protected void btn_Pending_Click(object sender, EventArgs e)
    {
        if (Convert.ToString(ViewState["EditMode"]) == "True")
        {
            string str = "<script language=\"javascript\">";
            //str = str + "alert('Select Any Record');";
            str = str + "alert('" + rm.GetString("Alert_UpdatetheOThoursandthenproceedwithapprovals", ci) + "');";
            str = str + "</script>";
            Page.RegisterStartupScript("alert", str);
            return;
        }
        DataSet dsOTSanction = new DataSet();
        dsOTSanction = (DataSet)Session["OTEmployee"];
        dsOTSanction.Tables[0].DefaultView.RowFilter = "SelectedRecords=1";
        int intSelectAllCount = dsOTSanction.Tables[0].DefaultView.ToTable().Rows.Count;
        if (intSelectAllCount == 0)
        {
            string str = "<script language=\"javascript\">";
            //str = str + "alert('Select Any Record');";
            str = str + "alert('" + rm.GetString("Alert_SelectAnyRecord", ci) + "');";
            str = str + "</script>";
            Page.RegisterStartupScript("alert", str);
        }
        else
        {
            UpdatedEmployeeOTStatus("Pending");
            string str = "<script language=\"javascript\">";
            //str = str + "alert('Saved Successfully');";
            str = str + "alert('" + rm.GetString("Alert_SavedSuccessfully", ci) + "');";
            //str = str + "opener.focus();";
            //str = str + "alert(opener.location+'?fl=1&sid=';";
            str = str + "window.top.location.href = window.top.location.href + '?fl=1&sid=" + Session.SessionID + "';";
            str = str + "parent.$('#myModal').modal('hide');";
            str = str + "</script>";
            Page.RegisterStartupScript("alert", str);
        }
    }
    protected void btn_Forwarded_Click(object sender, EventArgs e)
    {
        if (Convert.ToString(ViewState["EditMode"]) == "True")
        {
            string str = "<script language=\"javascript\">";
            //str = str + "alert('Select Any Record');";
            str = str + "alert('" + rm.GetString("Alert_UpdatetheOThoursandthenproceedwithapprovals", ci) + "');";
            str = str + "</script>";
            Page.RegisterStartupScript("alert", str);
            return;
        }
        DataSet dsOTSanction = new DataSet();
        dsOTSanction = (DataSet)Session["OTEmployee"];
        dsOTSanction.Tables[0].DefaultView.RowFilter = "SelectedRecords=1";
        int intSelectAllCount = dsOTSanction.Tables[0].DefaultView.ToTable().Rows.Count;
        if (intSelectAllCount == 0)
        {
            string str = "<script language=\"javascript\">";
            //str = str + "alert('Select Any Record');";
            str = str + "alert('" + rm.GetString("Alert_SelectAnyRecord", ci) + "');";
            str = str + "</script>";
            Page.RegisterStartupScript("alert", str);
        }
        else
            dsOTSanction.Tables[0].DefaultView.RowFilter = "(OverTimeStatus='Approved' or OverTimeStatus='Rejected') and SelectedRecords=1";
        int intSelectAllCount1 = dsOTSanction.Tables[0].DefaultView.ToTable().Rows.Count;
        if (intSelectAllCount1 != 0)
        {
            string str = "<script language=\"javascript\">";
            //str = str + "alert('Select Any Record');";
            str = str + "alert('" + rm.GetString("Aleart_OTApprovedStatus", ci) + "');";
            str = str + "</script>";
            Page.RegisterStartupScript("alert", str);
            return;
        }
        {
            UpdatedEmployeeOTStatus("Forwarded");
            string str1 = "<script language=\"javascript\">";
            //str = str + "alert('Saved Successfully');";
            str1 = str1 + "alert('" + rm.GetString("Alert_SavedSuccessfully", ci) + "');";
            //str1 = str1 + "opener.focus();";
            //str = str + "alert(opener.location+'?fl=1&sid=';";
            str1 = str1 + "window.top.location.href = window.top.location.href + '?fl=1&sid=" + Session.SessionID + "';";
            str1 = str1 + "parent.$('#myModal').modal('hide');";
            str1 = str1 + "</script>";
            Page.RegisterStartupScript("alert", str1);
        }
    }
    protected void btn_Reject_Click(object sender, EventArgs e)
    {
        if (Convert.ToString(ViewState["EditMode"]) == "True")
        {
            string str = "<script language=\"javascript\">";
            //str = str + "alert('Select Any Record');";
            str = str + "alert('" + rm.GetString("Alert_UpdatetheOThoursandthenproceedwithapprovals", ci) + "');";
            str = str + "</script>";
            Page.RegisterStartupScript("alert", str);
            return;
        }
        DataSet dsOTSanction = new DataSet();
        dsOTSanction = (DataSet)Session["OTEmployee"];
        dsOTSanction.Tables[0].DefaultView.RowFilter = "SelectedRecords=1";
        int intSelectAllCount = dsOTSanction.Tables[0].DefaultView.ToTable().Rows.Count;
        if (intSelectAllCount == 0)
        {
            string str = "<script language=\"javascript\">";
            str = str + "alert('" + rm.GetString("Alert_SelectAnyRecord", ci) + "');";
            str = str + "</script>";
            Page.RegisterStartupScript("alert", str);
        }
        else
        {
            dsOTSanction.Tables[0].DefaultView.RowFilter = "(OverTimeStatus='Approved' or OverTimeStatus='Rejected') and SelectedRecords=1";
            int intSelectAllCount1 = dsOTSanction.Tables[0].DefaultView.ToTable().Rows.Count;
            if (intSelectAllCount1 != 0)
            {
                string str = "<script language=\"javascript\">";
                //str = str + "alert('Select Any Record');";
                str = str + "alert('" + rm.GetString("Aleart_OTApprovedStatus", ci) + "');";
                str = str + "</script>";
                Page.RegisterStartupScript("alert", str);
                return;
            }
            UpdatedEmployeeOTStatus("Rejected");
            string str1 = "<script language=\"javascript\">";
            str1 = str1 + "alert('" + rm.GetString("Alert_SavedSuccessfully", ci) + "');";
            //str1 = str1 + "opener.focus();";
            //str = str + "alert(opener.location+'?fl=1&sid=';";
            str1 = str1 + "window.top.location.href = window.top.location.href + '?fl=1&sid=" + Session.SessionID + "';";
            str1 = str1 + "parent.$('#myModal').modal('hide');";
            str1 = str1 + "</script>";
            Page.RegisterStartupScript("alert", str1);
        }
    }
    #endregion
    #region Not Used
    public void CheckEmployeeId_CheckBox()
    {
        string strEmpId = "";
        strEmpId = (string)Session["EmployeeIds"];
        int intEmployeeIdsLength = strEmpId.Length;
        char[] Delimit = { ',' };
        string[] Empid = strEmpId.Split(Delimit);
        CheckBox deleteChkBxItem = new CheckBox();
        foreach (GridViewRow gr in grv_EmployeeOTSanction.Rows)
        {
            string empId = ((Label)gr.FindControl("lblProc_RecordId")).Text.ToString();
            foreach (string str in Empid)
            {
                if (str == empId)
                {
                    //HtmlInputCheckBox deleteChkBxItem = (HtmlInputCheckBox)gr.FindControl("deletethis");
                    deleteChkBxItem = (CheckBox)gr.Cells[0].FindControl("deletethis");
                    deleteChkBxItem.Checked = true;
                    int intLength = empId.Length;
                    //int intActualIndex = 0;
                    if (intEmployeeIdsLength > intLength)
                    {
                        //More than One Id Present in the list
                        int intIndex = strEmpId.IndexOf("," + str + ",");
                        if (intIndex != -1)
                        {
                            //Exist in between
                            strEmpId = strEmpId.Remove(intIndex, (intLength + 1));
                        }
                        else
                        {
                            //Exist as the first or last
                            if (strEmpId.IndexOf(str + ",") != -1 && strEmpId.IndexOf(str + ",") == 0)
                            {
                                //Exist as a first Id
                                strEmpId = strEmpId.Remove(0, (intLength + 1));
                            }
                            else if (strEmpId.IndexOf("," + str) != -1 && (strEmpId.IndexOf("," + str) + intLength + 1) == intEmployeeIdsLength)
                            {
                                //Exist as a Last Id
                                strEmpId = strEmpId.Substring(0, (intEmployeeIdsLength - (intLength + 1)));
                            }
                        }
                    }
                    else
                    {
                        //Only one Id in the list
                        strEmpId = strEmpId.Replace(empId, "");
                    }
                    intEmployeeIdsLength = strEmpId.Length;
                    Session["EmployeeIds"] = strEmpId;
                    goto D;
                }
            }
            D:;
        }
    }
    protected string GetEmployeeIdsInOtherPagesOfGrid()
    {
        DataSet ds = new DataSet();
        ds = (DataSet)Session["OTEmployee"];
        string strEmpId = string.Empty;
        //string ChkBoxIDs = string.Empty;
        StringBuilder ChkBoxIDs = new StringBuilder();
        foreach (DataRow dr in ds.Tables[0].Rows)
        {
            foreach (GridViewRow gr in grv_EmployeeOTSanction.Rows)
            {
                strEmpId = ((Label)gr.FindControl("lblProc_RecordId")).Text.ToString();
                //strEmpId = ((HiddenField)gr.FindControl("lblProcess_Rec_ID")).Value.ToString();
                CheckBox chkEnabled = (CheckBox)gr.FindControl("deletethis");
                if (chkEnabled.Enabled == false)
                {
                    goto A;
                }
                if (strEmpId == dr["Process_Rec_ID"].ToString())
                {
                    goto A;
                }
            }
            if (ChkBoxIDs.ToString() == "")
            {
                ChkBoxIDs.Append(dr["Process_Rec_ID"].ToString());
            }
            else
            {
                ChkBoxIDs.Append("," + dr["Process_Rec_ID"].ToString());
            }
            A:;
        }
        return ChkBoxIDs.ToString();
    }
    private DataTable checkOTMins(DataSet dsOtMinsEmployee)
    {
        DataColumn dcEmployeeId = new DataColumn("EmployeeCodeId");
        DataColumn dcOTHours = new DataColumn("OTHours");
        DataColumn dcOTMinsLeaveApplication = new DataColumn("OTMinsLeaveApplication");
        DataRow dRowOTDetails;
        dtLeaveOTDetails.Columns.Add(dcEmployeeId);
        dtLeaveOTDetails.Columns.Add(dcOTMinsLeaveApplication);
        dtLeaveOTDetails.Columns.Add(dcOTHours);
        string strEmployeeId = string.Empty;
        //Get OT Hours Based on Comp Off Day Leave Application for Each Employee 
        //if (checkRecordExists == true)
        //{
        foreach (DataRow dRow in dsOtMinsEmployee.Tables[0].Rows)
        {
            if (dRow["Employee_Code_Id"].ToString() != strEmployeeId)
            {
                dtLeaveApplicationOTHrs = objOT.SelectOverTimeLeaveApplication(dRow["Employee_Id"].ToString());
                dRowOTDetails = dtLeaveOTDetails.NewRow();
                dRowOTDetails["EmployeeCodeId"] = dRow["Employee_Code_Id"];
                if (dtLeaveApplicationOTHrs.Rows.Count > 0)
                {
                    dRowOTDetails["OTMinsLeaveApplication"] = Convert.ToInt32(dtLeaveApplicationOTHrs.Rows[0]["OTMinsLeaveApplication"]);
                    dRowOTDetails["OTHours"] = dtLeaveApplicationOTHrs.Rows[0]["OtMinHrs"];
                }
                else
                {
                }
                dRowOTDetails.EndEdit();
                dtLeaveOTDetails.Rows.Add(dRowOTDetails);
                strEmployeeId = dRow["Employee_Code_Id"].ToString();
            }
        }
        return dtLeaveOTDetails;
        //}
    }
    #endregion

    private void loadcss()
    {
        CultureInfo ci;
        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;
        //if Standard Demo
        htmlOTpop.Attributes.Add("dir", rm.GetString("Direction", ci));
        if (source_Language == "Resources.Resource_AR")
        {
            stylebootstrap.Href = "../bootstrap/css/bootstrap-rtl.min.css";
            stylefontawesome.Href = "../bootstrap/font-awesome/css/font-awesome-rtl.css";
            styleAdminLTE.Href = "../dist/css/AdminLTE.min-rtl.css";
            stylecustom.Href = "../dist/css/custom-rtl.css";
            styledatepicker3.Href = "../plugins/datepicker/datepicker3-rtl.css";
            styledaterangepicker.Href = "../plugins/daterangepicker/daterangepicker-bs3-rtl.css";
        }
        else
        {
            //htmlOTpop.Attributes.Add("dir", "rtl");
            //stylebootstrap.Href = "../bootstrap/css/bootstrap-rtl.min.css";
            //stylefontawesome.Href = "../bootstrap/font-awesome/css/font-awesome-rtl.css";
            //styleAdminLTE.Href = "../dist/css/AdminLTE.min-rtl.css";
            //stylecustom.Href = "../dist/css/custom-rtl.css";
            //styledatepicker3.Href = "../plugins/datepicker/datepicker3-rtl.css";
            //styledaterangepicker.Href = "../plugins/daterangepicker/daterangepicker-bs3-rtl.css";
            stylebootstrap.Href = "../bootstrap/css/bootstrap.min.css";
            stylefontawesome.Href = "../bootstrap/font-awesome/css/font-awesome.css";
            styleAdminLTE.Href = "../dist/css/AdminLTE.min.css";
            stylecustom.Href = "../dist/css/custom.css";
            styledatepicker3.Href = "../plugins/datepicker/datepicker3.css";
            styledaterangepicker.Href = "../plugins/daterangepicker/daterangepicker-bs3.css";
        }
    }
}
