using System;
using System.Globalization;
using System.Resources;
using System.Threading;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Configuration;
using System.Net.Mail;
using System.IO;
using System.Text.RegularExpressions;
using DevExpress.Web;

public partial class Reports_TA_UI_Report_LateInGrid : Base.BasePage
{
    #region Varaiable Declaration
    GetReports rptEmp = new GetReports();
    GetReports LateUpdate = new GetReports();
    GetReports getMail = new GetReports();
    GetReports EarlyUpdate = new GetReports();
    GetReports AbsentUpdate = new GetReports();
    Rpt_Common rptcommon = new Rpt_Common();
    DataSet ds_Checkuser = new DataSet();
    Cls_CheckUser objCheckUser = new Cls_CheckUser();
    ResourceManager rm;
    CultureInfo ci;
    string EmpID = string.Empty;
    LeaveApplicationEventData objLeaveApplicationEventData = new LeaveApplicationEventData();
    CultureInfo objCultureInfo;
    bool blnCheckEmail = true, blnCheckSMS = true;
    cls_Common objClassCommon = new cls_Common();
    //GetReports rptEmp = new GetReports();
    int shiftID = 0;
    string levelID = string.Empty;
    string from = string.Empty;
    string to = string.Empty;
    string Empname = string.Empty;
    int employeeCategory = 0;
    int employeeType = 0;
    string userGroupName = string.Empty;
    string gradeLevel = string.Empty;
    string strReportType = string.Empty;
    string ParentLevelid = string.Empty;
    string strSwipeCard = string.Empty;
    string Designation = string.Empty;
    string Gender = string.Empty;
    string source_Language;
    cls_Common objCommon = new cls_Common();
    String hdnEmpID = "";
    String HdnReportName = "";
    String HdnFrom = "";
    string HdnTo = "";
    Int64 EmpAutoID = 0;
    #endregion
    #region Page Load Events
    /// <summary>
    /// On page loading
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected override void Page_Load(object sender, EventArgs e)
    {

        base.CheckPages(0);
        //Todo: need to add below lines into main applications
        objCommon.menu("Others", "37");
        // LoadStrings(ci);
        UserRights();
        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"]);

        // session checking
        base.Page_Load(sender, e);
        hdnLink.Value = Convert.ToString(Request.QueryString["link"]);
        grv_LateIn.Styles.CssFilePath = Convert.ToString(Session["GridCSS"]);
        //get the culture info to set the 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);
        EmpID = Convert.ToString(Request.QueryString["EmpID"]);
        shiftID = Convert.ToInt32(Request.QueryString["Shift"]);
        from = Convert.ToString(Request.QueryString["From"]);
        to = Convert.ToString(Request.QueryString["To"]);
        Empname = Convert.ToString(Request.QueryString["EmpName"]);
        ParentLevelid = Convert.ToString(Request.QueryString["ParentLevelId"]);
        levelID = rptcommon.getNodes(Convert.ToInt16(ParentLevelid), Convert.ToString(Session["LevelRights"]));
        employeeCategory = Convert.ToInt32(Request.QueryString["employeeCategory"]);
        employeeType = Convert.ToInt32(Request.QueryString["employeeType"]);
        userGroupName = Convert.ToString(Request.QueryString["userGroupName"]);
        gradeLevel = Convert.ToString(Request.QueryString["gradeLevel"]);
        strReportType = Convert.ToString(Request.QueryString["ReportType"]);
        strSwipeCard = Convert.ToString(Request.QueryString["SwipeCard"]);
        Designation = Convert.ToString(Request.QueryString["Designation"]);
        Gender = Convert.ToString(Request.QueryString["Gender"]);
        EmpAutoID = Convert.ToInt64(Request.QueryString["EmpAutoID"]);
        //Linkvalue = Convert.ToString(Session["EmailNotificationLink"]);
        hdnEmpID = Convert.ToString(Session["hdnEmpID"]);
        HdnReportName = Convert.ToString(Session["HdnReportName"]);
        HdnFrom = Convert.ToString(Session["HdnFrom"]);
        HdnTo = Convert.ToString(Session["HdnTo"]);
        String Datess = Convert.ToString(Session["IDateFormat"]);
        string Timee = Convert.ToString(Session["ITimeFormat"]);
        if (Datess == "MM/DD/YYYY")
        {
            Datess = "MM/dd/yyyy";
        }
        else if (Datess == "DD/MM/YYYY")
        {
            Datess = "dd/MM/yyyy";
        }
        else
        {
            Datess = "dd/MMM/yyyy";
        }

        //String Timee = Convert.ToString(Session["ITimeFormat"]);

        if (hdnEmpID != "" & HdnReportName != "" & HdnFrom != "" & HdnTo != "")
        {
            UpdatePanel1.Update();
            btn_View.Visible = false;
            lnktbnexcel.Visible = false;
            lnkbtnpdf.Visible = false;
            btnCustWindow.Visible = false;
            btnBack.Visible = false;
            grv_LateIn.Visible = false;
            if (HdnReportName == "Absent")
            {
                DataSet daAbsent = new DataSet();
                daAbsent = rptEmp.SelectAbsentForEmailNotification(hdnEmpID, HdnFrom, HdnReportName, "");
                DataTable dtable = new DataTable();
                dtable.Columns.Add("EmailtriggetID", typeof(int));
                dtable.Columns.Add("EmployeeID", typeof(int));
                dtable.Columns.Add("Employee_Code_Id", typeof(String));
                dtable.Columns.Add("Employee_Name", typeof(String));
                dtable.Columns.Add("ShiftDate", typeof(String));
                dtable.Columns.Add("AbsentAN", typeof(String));
                dtable.Columns.Add("AbsentFN", typeof(String));
                dtable.Columns.Add("Reason", typeof(String));

                for (int i = 0; i < daAbsent.Tables[0].Rows.Count; i++)
                {
                    DataRow dr = dtable.NewRow();

                    dr["EmailtriggetID"] = Convert.ToInt32(daAbsent.Tables[0].Rows[i]["EmailtriggetID"]);
                    dr["EmployeeID"] = Convert.ToInt32(daAbsent.Tables[0].Rows[i]["EmployeeID"]);
                    dr["Employee_Code_Id"] = Convert.ToString(daAbsent.Tables[0].Rows[i]["Employee_Code_Id"]);
                    dr["Employee_Name"] = Convert.ToString(daAbsent.Tables[0].Rows[i]["Employee_Name"]);
                    dr["ShiftDate"] = Convert.ToDateTime(daAbsent.Tables[0].Rows[i]["ShiftDate"]).ToString("dd/MM/yyyy");
                    dr["AbsentAN"] = Convert.ToString(daAbsent.Tables[0].Rows[i]["AbsentAN"]);
                    dr["AbsentFN"] = Convert.ToString(daAbsent.Tables[0].Rows[i]["AbsentFN"]);
                    dr["Reason"] = Convert.ToString(daAbsent.Tables[0].Rows[i]["Reason"]);
                    dtable.Rows.Add(dr);
                }
                GrvAbsents.DataSource = dtable;
                GrvAbsents.DataBind();
                Grv_LateIn_Email.Visible = false;
                GrvEarlyExitEmail.Visible = false;
                GrvAbsents.Visible = true;
                Btn_Absent_save.Visible = true;
                Btn_Late_save.Visible = false;
                Btn_Early_Save.Visible = false;

                TxtAbsent.Visible = true;
                TxtEarlyExit.Visible = false;
                TxtReason.Visible = false;
                lblReason3.Visible = false;
                lblReason2.Visible = true;
                lblReason1.Visible = false;
                lblLateEntry.Text = "";
                lblLateEntry.Text = "Absent Reason Entry";



            }
            else if (HdnReportName == "EarlyExit")
            {
                DataSet daEarlyExit = new DataSet();
                daEarlyExit = rptEmp.SelectAbsentForEmailNotification(hdnEmpID, HdnFrom, HdnReportName, "");
                DataTable dtable = new DataTable();
                dtable.Columns.Add("EmailtriggetID", typeof(int));
                dtable.Columns.Add("EmployeeID", typeof(int));
                dtable.Columns.Add("Employee_Code_Id", typeof(String));
                dtable.Columns.Add("Employee_Name", typeof(String));
                dtable.Columns.Add("ShiftDate", typeof(String));
                dtable.Columns.Add("EarlyExit", typeof(String));
                dtable.Columns.Add("EarlyExitHrs", typeof(String));
                dtable.Columns.Add("Reason", typeof(String));

                for (int i = 0; i < daEarlyExit.Tables[0].Rows.Count; i++)
                {
                    DataRow dr = dtable.NewRow();

                    dr["EmailtriggetID"] = Convert.ToInt32(daEarlyExit.Tables[0].Rows[i]["EmailtriggetID"]);
                    dr["EmployeeID"] = Convert.ToInt32(daEarlyExit.Tables[0].Rows[i]["EmployeeID"]);
                    dr["Employee_Code_Id"] = Convert.ToString(daEarlyExit.Tables[0].Rows[i]["Employee_Code_Id"]);
                    dr["Employee_Name"] = Convert.ToString(daEarlyExit.Tables[0].Rows[i]["Employee_Name"]);
                    dr["ShiftDate"] = Convert.ToDateTime(daEarlyExit.Tables[0].Rows[i]["ShiftDate"]).ToString("dd/MM/yyyy");
                    dr["EarlyExit"] = Convert.ToString(daEarlyExit.Tables[0].Rows[i]["EarlyExit"]);
                    dr["EarlyExitHrs"] = Convert.ToString(daEarlyExit.Tables[0].Rows[i]["EarlyExitHrs"]);
                    dr["Reason"] = Convert.ToString(daEarlyExit.Tables[0].Rows[i]["Reason"]);
                    dtable.Rows.Add(dr);
                }
                GrvEarlyExitEmail.DataSource = dtable;
                GrvEarlyExitEmail.DataBind();
                Grv_LateIn_Email.Visible = false;
                GrvEarlyExitEmail.Visible = true;
                GrvAbsents.Visible = false;
                Btn_Absent_save.Visible = false;
                Btn_Late_save.Visible = false;
                Btn_Early_Save.Visible = true;
                TxtAbsent.Visible = false;
                TxtEarlyExit.Visible = true;
                TxtReason.Visible = false;
                lblReason3.Visible = true;
                lblReason2.Visible = false;
                lblReason1.Visible = false;
                lblLateEntry.Text = "";
                lblLateEntry.Text = "Early Exit Reason Entry";

            }
            else if (HdnReportName == "LateEntry")
            {
                DataSet dalate = new DataSet();
                dalate = rptEmp.SelectAbsentForEmailNotification(hdnEmpID, HdnFrom, HdnReportName, "");
                DataTable dtable = new DataTable();
                dtable.Columns.Add("EmailtriggetID", typeof(int));
                dtable.Columns.Add("EmployeeID", typeof(int));
                dtable.Columns.Add("Employee_Code_Id", typeof(String));
                dtable.Columns.Add("Employee_Name", typeof(String));
                dtable.Columns.Add("ShiftDate", typeof(String));
                dtable.Columns.Add("LateEntry", typeof(String));
                dtable.Columns.Add("LateHrs", typeof(String));
                dtable.Columns.Add("Reason", typeof(String));

                for (int i = 0; i < dalate.Tables[0].Rows.Count; i++)
                {
                    DataRow dr = dtable.NewRow();

                    dr["EmailtriggetID"] = Convert.ToInt32(dalate.Tables[0].Rows[i]["EmailtriggetID"]);
                    dr["EmployeeID"] = Convert.ToInt32(dalate.Tables[0].Rows[i]["EmployeeID"]);
                    dr["Employee_Code_Id"] = Convert.ToString(dalate.Tables[0].Rows[i]["Employee_Code_Id"]);
                    dr["Employee_Name"] = Convert.ToString(dalate.Tables[0].Rows[i]["Employee_Name"]);
                    dr["ShiftDate"] = Convert.ToDateTime(dalate.Tables[0].Rows[i]["ShiftDate"]).ToString(Datess);
                    dr["LateEntry"] = Convert.ToString(dalate.Tables[0].Rows[i]["LateEntry"]);
                    dr["LateHrs"] = Convert.ToString(dalate.Tables[0].Rows[i]["LateHrs"]);
                    dr["Reason"] = Convert.ToString(dalate.Tables[0].Rows[i]["Reason"]);
                    dtable.Rows.Add(dr);
                }

                Grv_LateIn_Email.DataSource = dtable;
                Grv_LateIn_Email.DataBind();
                Grv_LateIn_Email.Visible = true;
                GrvEarlyExitEmail.Visible = false;
                GrvAbsents.Visible = false;
                Btn_Absent_save.Visible = false;
                Btn_Late_save.Visible = true;
                Btn_Early_Save.Visible = false;
                TxtAbsent.Visible = false;
                TxtEarlyExit.Visible = false;
                TxtReason.Visible = true;
                lblReason3.Visible = false;
                lblReason2.Visible = false;
                lblReason1.Visible = true;
                lblLateEntry.Text = "";
                lblLateEntry.Text = "Late Reason Entry";

            }

        }
        else
        {
            Grv_LateIn_Email.Visible = false;
            GrvEarlyExitEmail.Visible = false;
            GrvAbsents.Visible = false;
            Btn_Absent_save.Visible = false;
            Btn_Late_save.Visible = false;
            Btn_Early_Save.Visible = false;
            TxtAbsent.Visible = false;
            TxtEarlyExit.Visible = false;
            TxtReason.Visible = false;
            lblReason3.Visible = false;
            lblReason2.Visible = false;
            lblReason1.Visible = false;
        }


    }

    private void UserRights()
    {
        ds_Checkuser = objCheckUser.checkRights(37, 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
    #region Button Events
    /// <summary>
    /// To view the crystal report
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void btn_View_Click(object sender, EventArgs e)
    {
        try
        {
            if (Page.IsValid == true)
            {
                //Redirect the page to the report viewer
                string strScript = "";
                //strScript = "TA_UI_Report_ReportViewer.aspx";
                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=edge' />";
                strScript = strScript + "<script language='javascript'>";
                strScript = strScript + "window.open('TA_UI_Report_ReportViewer.aspx?ReportName=LateEntry&dtFrom="
                    + from + "&dtTo=" + to + "&empid=" + EmpID + "&shft=" + shiftID + "&EmpName=" + Empname +
                    "&Level=" + ParentLevelid + "&EmpCategory=" + employeeCategory + "&EmpType=" + employeeType +
                    "&ParentLevelId=" + ParentLevelid + "&UserGroupName=" + userGroupName + "&GradeLevel=" + gradeLevel +
                    "&Normal=" + strReportType + "&SwipeCard=" + strSwipeCard + "&Designation=" + Convert.ToInt32(Designation) + "&Gender=" + Gender + "','','left=10px, top=60px, width=1000px, height=600px, scrollbars=yes, status=no, resizable=yes');";
                strScript = strScript + "</script>";
                Response.Write(strScript);
            }
        }
        catch (Exception ex)
        {
            throw ex;
        }
    }
    #endregion
    #region User Defined Function
    /// <summary>
    /// Getting Information from resource file and display it in label
    /// </summary>
    /// <param name="ci"></param>
    private void LoadStrings(CultureInfo ci)
    {
        btn_View.Text = "&nbsp;&nbsp;" + rm.GetString("btn_View", ci);
        btnBack.Text = "&nbsp;&nbsp;" + rm.GetString("btn_Back", ci);
        lblLateEntry.Text = rm.GetString("Reports_LateEntry_Report", ci);
        grv_LateIn.Columns[0].Caption = rm.GetString("email_EmployeeCLId", ci);
        grv_LateIn.Columns[1].Caption = rm.GetString("email_EmployeeCL", ci);
        grv_LateIn.Columns[2].Caption = rm.GetString("LevelDetails_LevelName", ci);
        grv_LateIn.Columns[3].Caption = rm.GetString("Contractor_Name", ci);
        grv_LateIn.Columns[4].Caption = rm.GetString("Master_Category", ci);
        grv_LateIn.Columns[5].Caption = rm.GetString("Reports_Date", ci);
        grv_LateIn.Columns[6].Caption = rm.GetString("ManualTimeEntry_In_Time", ci);
        grv_LateIn.Columns[7].Caption = rm.GetString("Late_Entry_LateBy", ci);
        grv_LateIn.Columns[8].Caption = rm.GetString("email_Reason", ci);
        grv_LateIn.Columns[9].Caption = rm.GetString("Master_Designation", ci);
        grv_LateIn.Columns[10].Caption = rm.GetString("EmployeeMaster_Gender", ci);
    }
    #endregion
    #region Grid Events    
    protected void grv_LateIn_HtmlRowCreated(object sender, DevExpress.Web.ASPxGridViewTableRowEventArgs e)
    {
    }
    #endregion

    protected void btnExport_Click(object sender, EventArgs e)
    {
        LinkButton lnkbtn = (LinkButton)sender;
        ASPxGridViewExporter1.Landscape = true;
        ASPxGridViewExporter1.LeftMargin = 10;
        ASPxGridViewExporter1.RightMargin = 10;
        ASPxGridViewExporter1.ExportedRowType = DevExpress.Web.GridViewExportedRowType.All;
        ASPxGridViewExporter1.MaxColumnWidth = 400;
        ASPxGridViewExporter1.GridViewID = "grv_LateIn";
        string saveAsFileName = string.Format("Late Entry Report -{0:d}", DateTime.Now).Replace("/", "-").Replace(" ", "");
        ASPxGridViewExporter1.FileName = saveAsFileName;
        ASPxGridViewExporter1.PaperKind = System.Drawing.Printing.PaperKind.A3;
        ASPxGridViewExporter1.PageHeader.Center = "Late Entry report From - " + Convert.ToString(from) + " To - " + Convert.ToString(to);
        switch (lnkbtn.CommandName)
        {
            case "excel":
                ASPxGridViewExporter1.WriteXlsxToResponse();
                break;
            case "pdf":
                ASPxGridViewExporter1.WritePdfToResponse();
                break;
        }
    }
    // Email Trigger Code
    protected void TextBox1_TextChanged(object sender, EventArgs e)
    {




    }







    protected void grv_LateIn_RowUpdated(object sender, DevExpress.Web.Data.ASPxDataUpdatedEventArgs e)
    {
        string SS = (e.ToString());


    }

    protected void GrvAbsent_HtmlRowCreated(object sender, DevExpress.Web.ASPxGridViewTableRowEventArgs e)
    {

    }

    protected void GrvAbsent_RowUpdated(object sender, DevExpress.Web.Data.ASPxDataUpdatedEventArgs e)
    {


    }

    protected void grv_LateIn_RowUpdated1(object sender, DevExpress.Web.Data.ASPxDataUpdatedEventArgs e)
    {

    }



    protected void Grv_LateIn_Email_RowEditing(object sender, GridViewEditEventArgs e)
    {

    }


    protected void Grv_LateIn_Email_RowUpdating(object sender, GridViewUpdateEventArgs e)
    {

    }

    protected void Grv_LateIn_Email_PageIndexChanging(object sender, GridViewPageEventArgs e)
    {
        Grv_LateIn_Email.PageIndex = e.NewPageIndex;
    }

    protected void Grv_LateIn_Email_RowDeleting(object sender, GridViewDeleteEventArgs e)
    {

    }

    protected void Grv_LateIn_Email_RowDataBound(object sender, GridViewRowEventArgs e)
    {

    }


    protected void Btn_Late_save_Click(object sender, EventArgs e)
    {


    }

    protected void Btn_Absent_save_Click(object sender, EventArgs e)
    {
        // Btn_Late_save_Click1(sender, e);
        string Reason = "";
        string EMPAutoID = "";
        string EmailtriggetID = "";
        string EmployeeNameGrid = "";
        string lblAbsentANa = "";
        string lblAbsentFNa = "";
        //( sender,  e);



        // re = Session["Reason"].ToString();
        for (int i = 0; i < GrvAbsents.Rows.Count; i++)
        {
            lblAbsentANa = (GrvAbsents.Rows[i].FindControl("lblAbsentANa") as Label).Text;
            lblAbsentFNa = (GrvAbsents.Rows[i].FindControl("lblAbsentFNa") as Label).Text;
            EmployeeNameGrid = (GrvAbsents.Rows[i].FindControl("lbl_Employee_Code_Ida") as Label).Text;
            EmailtriggetID = (GrvAbsents.Rows[i].FindControl("lblEmailtriggetIDA") as Label).Text;
            Session["EmailtriggetID"] = EmailtriggetID;
            Session["lbl_Employee_Code_Ida"] = EmployeeNameGrid;
            Session["lblAbsentANa"] = lblAbsentANa;
            Session["lblAbsentFNa"] = lblAbsentFNa;
            //Reason = (Grv_LateIn_Email.Rows[i].FindControl("TxtReason") as TextBox).Text;

            //TextBox txt = (TextBox)Grv_LateIn_Email.Rows[i].Cells[6].FindControl("TxtReason");
            //String rr = txt.Text;


        }
        // string ShiftDates = ShiftDate.Substring(0, 10);


        if (TxtAbsent.Text == "")
        {
            string strScript;
            strScript = "<script language='javascript'>";
            strScript = strScript + "alert('" + " Enter the Reason" + "');";
            strScript = strScript + "</script>";
            Page.RegisterStartupScript("Alert", strScript);
        }
        else
        {
            // s = Reason.Substring(0,10);

            EmailSend();
            Session["LateEmailSave"] = "Reason Save successfully";
            string strScript;
            strScript = "<script language='javascript'>";
            strScript = strScript + "alert('" + "Reason Save successfully" + "');";
            strScript = strScript + "</script>";
            Page.RegisterStartupScript("Alert", strScript);

            string strScripts = "";
            strScripts = strScripts + "<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Transitional//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'>";
            strScripts = strScripts + "<meta http-equiv='X-UA-Compatible' content='IE=edge' />";
            strScripts = strScripts + "<script language='javascript'>";
            Response.Redirect("../DashBoard.aspx");
            Response.Write(strScripts);

        }



    }

    protected void Btn_Late_save_Click1(object sender, EventArgs e)
    {

        string Reason = "";
        string EMPAutoID = "";
        string EmailtriggetID = "";
        string EmployeeNameGrid = "";
        string lblLateHrsl = "";
        string lblLateEntryl = "";
        //( sender,  e);



        // re = Session["Reason"].ToString();
        for (int i = 0; i < Grv_LateIn_Email.Rows.Count; i++)
        {
            //EMPAutoID = (Grv_LateIn_Email.Rows[i].FindControl("lbl_Employee_Code_Idl") as Label).Text;
            EmployeeNameGrid = (Grv_LateIn_Email.Rows[i].FindControl("lblEmployee_Namel") as Label).Text;
            EmailtriggetID = (Grv_LateIn_Email.Rows[i].FindControl("lblEmailtriggetID") as Label).Text;
            lblLateHrsl = (Grv_LateIn_Email.Rows[i].FindControl("lblLateHrsl") as Label).Text;
            lblLateEntryl = (Grv_LateIn_Email.Rows[i].FindControl("lblLateEntryl") as Label).Text;
            Session["EmailtriggetID"] = EmailtriggetID;
            Session["lblEmployee_Namel"] = EmployeeNameGrid;
            Session["lblLateEntryl"] = lblLateEntryl;
            Session["lblLateHrsl"] = lblLateHrsl;
            //Reason = (Grv_LateIn_Email.Rows[i].FindControl("TxtReason") as TextBox).Text;

            //TextBox txt = (TextBox)Grv_LateIn_Email.Rows[i].Cells[6].FindControl("TxtReason");
            //String rr = txt.Text;


        }
        //string ShiftDates = ShiftDate.Substring(0, 10);


        if (TxtReason.Text == "")
        {
            string strScript;
            strScript = "<script language='javascript'>";
            strScript = strScript + "alert('" + " Enter the Reason" + "');";
            strScript = strScript + "</script>";
            Page.RegisterStartupScript("Alert", strScript);
        }
        else
        {
            // s = Reason.Substring(0,10);
            //LateUpdate.ReasonEntry_LateInEmailUpdate(Convert.ToInt32(EmailtriggetID), TxtReason.Text);
            EmailSend();
            Session["LateEmailSave"] = "Reason Save successfully";
            string strScript;
            strScript = "<script language='javascript'>";
            strScript = strScript + "alert('" + "Reason Save successfully" + "');";
            strScript = strScript + "</script>";
            Page.RegisterStartupScript("Alert", strScript);

            string strScripts = "";
            strScripts = strScripts + "<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Transitional//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'>";
            strScripts = strScripts + "<meta http-equiv='X-UA-Compatible' content='IE=edge' />";
            strScripts = strScripts + "<script language='javascript'>";
            Response.Redirect("../DashBoard.aspx");
            Response.Write(strScripts);

        }
    }

    protected void Btn_Early_Save_Click(object sender, EventArgs e)
    {
        //Btn_Late_save_Click1(sender, e);
        string Reason = "";
        string EMPAutoID = "";
        string EmailtriggetID = "";
        string EmployeeNameGrid = "";
        string lblEarlyExit = "";
        string lblEarlyExitHrs = "";
        //( sender,  e);



        // re = Session["Reason"].ToString();
        for (int i = 0; i < GrvEarlyExitEmail.Rows.Count; i++)
        {
            lblEarlyExitHrs = (GrvEarlyExitEmail.Rows[i].FindControl("lblEarlyExitHrs") as Label).Text;
            lblEarlyExit = (GrvEarlyExitEmail.Rows[i].FindControl("lblEarlyExit") as Label).Text;
            EmployeeNameGrid = (GrvEarlyExitEmail.Rows[i].FindControl("lblEmployee_NameE") as Label).Text;
            EmailtriggetID = (GrvEarlyExitEmail.Rows[i].FindControl("lblEmailtriggetIDE") as Label).Text;
            Session["EmailtriggetID"] = EmailtriggetID;
            Session["lblEmployee_NameE"] = EmployeeNameGrid;
            Session["lblEarlyExit"] = lblEarlyExit;
            Session["lblEarlyExitHrs"] = lblEarlyExitHrs;
            //Reason = (Grv_LateIn_Email.Rows[i].FindControl("TxtReason") as TextBox).Text;

            //TextBox txt = (TextBox)Grv_LateIn_Email.Rows[i].Cells[6].FindControl("TxtReason");
            //String rr = txt.Text;


        }
        //string ShiftDates = ShiftDate.Substring(0, 10);


        if (TxtEarlyExit.Text == "")
        {
            string strScript;
            strScript = "<script language='javascript'>";
            strScript = strScript + "alert('" + " Enter the Reason" + "');";
            strScript = strScript + "</script>";
            Page.RegisterStartupScript("Alert", strScript);


        }
        else
        {
            // s = Reason.Substring(0,10);
            //LateUpdate.ReasonEntry_LateInEmailUpdate(Convert.ToInt32(EmailtriggetID), TxtEarlyExit.Text);
            EmailSend();
            Session["LateEmailSave"] = "Reason Save successfully";
            string strScript;
            strScript = "<script language='javascript'>";
            strScript = strScript + "alert('" + "Reason Save successfully" + "');";
            strScript = strScript + "</script>";
            Page.RegisterStartupScript("Alert", strScript);

            string strScripts = "";
            strScripts = strScripts + "<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Transitional//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'>";
            strScripts = strScripts + "<meta http-equiv='X-UA-Compatible' content='IE=edge' />";
            strScripts = strScripts + "<script language='javascript'>";
            Response.Write(strScripts);


            Response.Redirect("../DashBoard.aspx");

        }
    }

    protected void TextBox1l_TextChanged(object sender, EventArgs e)
    {
        TextBox textBox = (TextBox)sender;
        GridViewRow row = (GridViewRow)textBox.NamingContainer;

        // Find the HiddenField controls that hold the values

        TextBox Reason = (TextBox)row.FindControl("TextBox1l");
        Session["Reason"] = Reason;
        //EmailSend();
    }

    private void EmailSend()
    {

        DataTable dtTableScript = new DataTable();
        string scriptText = "";
        string strFromEmailId = string.Empty;
        MailMessage mailMessage = new MailMessage();
        AlternateView loHTMLView = null;


        dtTableScript = objLeaveApplicationEventData.GetEmailScripts("Late IN Reason Approval");
        scriptText = Convert.ToString(dtTableScript.Rows[0]["ScriptText"]);
        string strLeaveType = "";

        if (hdnEmpID != "" & HdnReportName == "LateEntry" & HdnFrom != "" & HdnTo != "")
        {
            strLeaveType = "LateEntry";
        }
        else if (hdnEmpID != "" & HdnReportName == "Absent" & HdnFrom != "" & HdnTo != "")
        {
            strLeaveType = "Absent";
        }
        else if (hdnEmpID != "" & HdnReportName == "EarlyExit" & HdnFrom != "" & HdnTo != "")
        {
            strLeaveType = "EarlyExit";
        }
        //DataTable dtTableScript = new DataTable();
        //dtTableScript = objLeaveApplicationEventData.GetEmailScripts("New Leave Application Form");
        DateTime ShiftDateCofirm = Convert.ToDateTime(HdnFrom);
        DateTime ShiftD = Convert.ToDateTime(ShiftDateCofirm.ToString("dd/MMM/yyyy"));



        string FormName = "";
        String Status = "";
        String EmployeeName = "";
        DataSet EmailGet = new DataSet();
        EmailGet = getMail.SelectTriggerEmail(hdnEmpID);
        string EmployeeEmail = EmailGet.Tables[0].Rows[0]["EmployeeEmail"].ToString();
        string ReportPerEmail = EmailGet.Tables[0].Rows[1]["EmployeeEmail"].ToString();
        string AthorityEmail = EmailGet.Tables[0].Rows[2]["EmployeeEmail"].ToString();
        string Empdepartment = EmailGet.Tables[0].Rows[3]["EmployeeEmail"].ToString();
        string EmpReportNo = EmailGet.Tables[0].Rows[1]["EmployeeCodes"].ToString();
        string EmpAuthorityNo = EmailGet.Tables[0].Rows[2]["EmployeeCodes"].ToString();
        strFromEmailId = EmployeeEmail;
        if (ReportPerEmail == AthorityEmail)
        {

            Status = "Forwarded";
            mailMessage.To.Add(new MailAddress(AthorityEmail));

            if (hdnEmpID != "" & HdnReportName == "LateEntry" & HdnFrom != "" & HdnTo != "")
            {

                FormName = "Timecheck Notification-Late Entry Reason -Forwarded ";
                EmployeeName = Session["lblEmployee_Namel"].ToString();

            }
            else if (hdnEmpID != "" & HdnReportName == "Absent" & HdnFrom != "" & HdnTo != "")
            {
                FormName = "Timecheck Notification-Absent Entry Reason -Forwarded ";
                EmployeeName = Session["lbl_Employee_Code_Ida"].ToString();
            }
            else if (hdnEmpID != "" & HdnReportName == "EarlyExit" & HdnFrom != "" & HdnTo != "")
            {
                FormName = "Timecheck Notification-Early Exit Entry Reason -Forwarded ";
                EmployeeName = Session["lblEmployee_NameE"].ToString();
            }

            mailMessage.Subject = FormName + " | " + ShiftD.ToString("dd/MMM/yyyy") + " | " + Session["hdnEmpID"].ToString() + " - " + EmployeeName;

        }
        else
        {

            Status = "Pending";
            mailMessage.To.Add(new MailAddress(ReportPerEmail));

            if (hdnEmpID != "" & HdnReportName == "LateEntry" & HdnFrom != "" & HdnTo != "")
            {

                FormName = "Timecheck Notification-Late Entry Reason -Pending ";
                EmployeeName = Session["lblEmployee_Namel"].ToString();

            }
            else if (hdnEmpID != "" & HdnReportName == "Absent" & HdnFrom != "" & HdnTo != "")
            {
                FormName = "Timecheck Notification-Absent Entry Reason -Pending ";
                EmployeeName = Session["lbl_Employee_Code_Ida"].ToString();
            }
            else if (hdnEmpID != "" & HdnReportName == "EarlyExit" & HdnFrom != "" & HdnTo != "")
            {
                FormName = "Timecheck Notification-Early Entry Reason -Pending ";
                EmployeeName = Session["lblEmployee_NameE"].ToString();
            }
            mailMessage.Subject = FormName + " | " + ShiftD.ToString("dd/MMM/yyyy") + " | " + Session["hdnEmpID"].ToString() + " - " + EmployeeName;

        }

        //Session["lblLateEntryl"]
        //Session["lblLateHrsl"] 
        if (hdnEmpID != "" & HdnReportName == "LateEntry" & HdnFrom != "" & HdnTo != "")
        {
            String LateIN = "";
            if (ReportPerEmail == AthorityEmail)
            {
                LateIN = "Notification for the Late IN occurence Form";
                mailMessage.From = new MailAddress(EmployeeEmail);
                mailMessage.Body = mailMessage.Body.Replace("<<ltr_rtl>>", rm.GetString("Direction", objCultureInfo));
                mailMessage.Body = scriptText.Replace("<<lblEmailNotificationapplicationform>>", "Notification for the Late IN occurence Form");

                mailMessage.Body = mailMessage.Body.Replace("<<lblemployeeid>>", "Employee ID");
                mailMessage.Body = mailMessage.Body.Replace("<<employeeid>>", hdnEmpID);

                mailMessage.Body = mailMessage.Body.Replace("<<employeename>>", EmployeeName);
                mailMessage.Body = mailMessage.Body.Replace("<<lblemployeename>>", "Employee Name");

                mailMessage.Body = mailMessage.Body.Replace("<<lblDepartmentname>>", "Department");
                mailMessage.Body = mailMessage.Body.Replace("<<departmentname>>", Empdepartment);

                mailMessage.Body = mailMessage.Body.Replace("<<lblShiftdate>>", "Shift Date");
                mailMessage.Body = mailMessage.Body.Replace("<<Shiftdate>>", ShiftD.ToString("dd/MMM/yyyy"));

                mailMessage.Body = mailMessage.Body.Replace("<<lblPunchtime>>", "Shift In Time");
                mailMessage.Body = mailMessage.Body.Replace("<<punchtime>>", Session["lblLateEntryl"].ToString());

                mailMessage.Body = mailMessage.Body.Replace("<<lblhours>>", "Late In Hours");
                mailMessage.Body = mailMessage.Body.Replace("<<hours>>", Session["lblLateHrsl"].ToString());

                mailMessage.Body = mailMessage.Body.Replace("<<lblReason>>", "Reason");
                mailMessage.Body = mailMessage.Body.Replace("<<Reason>>", TxtReason.Text);

                mailMessage.Body = mailMessage.Body.Replace("<<LinkData>>", Convert.ToString(Session["HostServerURL"]) +
                    "?EmpID=" + hdnEmpID + "&ReportName=" + HdnReportName + "&From=" + HdnFrom + "&Authority=" + EmpAuthorityNo);
                objClassCommon.SendMail(mailMessage);

            }
            else
            {
                LateIN = "Notification for the Late IN occurence Form";
                mailMessage.From = new MailAddress(EmployeeEmail);
                mailMessage.Body = mailMessage.Body.Replace("<<ltr_rtl>>", rm.GetString("Direction", objCultureInfo));
                mailMessage.Body = scriptText.Replace("<<lblEmailNotificationapplicationform>>", "Notification for the Late IN occurence Form");

                mailMessage.Body = mailMessage.Body.Replace("<<lblemployeeid>>", "Employee ID");
                mailMessage.Body = mailMessage.Body.Replace("<<employeeid>>", hdnEmpID);

                mailMessage.Body = mailMessage.Body.Replace("<<employeename>>", EmployeeName);
                mailMessage.Body = mailMessage.Body.Replace("<<lblemployeename>>", "Employee Name");

                mailMessage.Body = mailMessage.Body.Replace("<<lblDepartmentname>>", "Department");
                mailMessage.Body = mailMessage.Body.Replace("<<departmentname>>", Empdepartment);

                mailMessage.Body = mailMessage.Body.Replace("<<lblShiftdate>>", "Shift Date");
                mailMessage.Body = mailMessage.Body.Replace("<<Shiftdate>>", ShiftD.ToString("dd/MMM/yyyy"));

                mailMessage.Body = mailMessage.Body.Replace("<<lblPunchtime>>", "Shift In Time");
                mailMessage.Body = mailMessage.Body.Replace("<<punchtime>>", Session["lblLateEntryl"].ToString());

                mailMessage.Body = mailMessage.Body.Replace("<<lblhours>>", "Late In Hours");
                mailMessage.Body = mailMessage.Body.Replace("<<hours>>", Session["lblLateHrsl"].ToString());

                mailMessage.Body = mailMessage.Body.Replace("<<lblReason>>", "Reason");
                mailMessage.Body = mailMessage.Body.Replace("<<Reason>>", TxtReason.Text);

                mailMessage.Body = mailMessage.Body.Replace("<<LinkData>>", Convert.ToString(Session["HostServerURL"]) +
                    "?EmpID=" + hdnEmpID + "&ReportName=" + HdnReportName + "&From=" + HdnFrom + "&Rep=" + EmpReportNo);
                objClassCommon.SendMail(mailMessage);

            }


        }
        else if (hdnEmpID != "" & HdnReportName == "Absent" & HdnFrom != "" & HdnTo != "")
        {
            //Session["lblAbsentANa"] = lblAbsentANa;
            //Session["lblAbsentFNa"] = lblAbsentFNa;
            String LateIN = "";
            if (ReportPerEmail == AthorityEmail)
            {
                LateIN = "Notification for the Absent occurence Form";
                mailMessage.From = new MailAddress(EmployeeEmail);
                mailMessage.Body = mailMessage.Body.Replace("<<ltr_rtl>>", rm.GetString("Direction", objCultureInfo));
                mailMessage.Body = scriptText.Replace("<<lblEmailNotificationapplicationform>>", LateIN);

                mailMessage.Body = mailMessage.Body.Replace("<<lblemployeeid>>", "Employee ID");
                mailMessage.Body = mailMessage.Body.Replace("<<employeeid>>", hdnEmpID);

                mailMessage.Body = mailMessage.Body.Replace("<<employeename>>", EmployeeName);
                mailMessage.Body = mailMessage.Body.Replace("<<lblemployeename>>", "Employee Name");

                mailMessage.Body = mailMessage.Body.Replace("<<lblDepartmentname>>", "Department");
                mailMessage.Body = mailMessage.Body.Replace("<<departmentname>>", Empdepartment);

                mailMessage.Body = mailMessage.Body.Replace("<<lblShiftdate>>", "Shift Date");
                mailMessage.Body = mailMessage.Body.Replace("<<Shiftdate>>", ShiftD.ToString("dd/MMM/yyyy"));

                mailMessage.Body = mailMessage.Body.Replace("<<lblPunchtime>>", "First Session");
                mailMessage.Body = mailMessage.Body.Replace("<<punchtime>>", Session["lblAbsentFNa"].ToString());

                mailMessage.Body = mailMessage.Body.Replace("<<lblhours>>", "Secound Session");
                mailMessage.Body = mailMessage.Body.Replace("<<hours>>", Session["lblAbsentANa"].ToString());

                mailMessage.Body = mailMessage.Body.Replace("<<lblReason>>", "Reason");
                mailMessage.Body = mailMessage.Body.Replace("<<Reason>>", TxtAbsent.Text);

                mailMessage.Body = mailMessage.Body.Replace("<<LinkData>>", Convert.ToString(Session["HostServerURL"]) +
                    "?EmpID=" + hdnEmpID + "&ReportName=" + HdnReportName + "&From=" + HdnFrom + "&Authority=" + EmpAuthorityNo);
                objClassCommon.SendMail(mailMessage);

            }
            else
            {
                LateIN = "Notification for the Absent occurence Form";
                mailMessage.From = new MailAddress(EmployeeEmail);
                mailMessage.Body = mailMessage.Body.Replace("<<ltr_rtl>>", rm.GetString("Direction", objCultureInfo));
                mailMessage.Body = scriptText.Replace("<<lblEmailNotificationapplicationform>>", LateIN);

                mailMessage.Body = mailMessage.Body.Replace("<<lblemployeeid>>", "Employee ID");
                mailMessage.Body = mailMessage.Body.Replace("<<employeeid>>", hdnEmpID);

                mailMessage.Body = mailMessage.Body.Replace("<<employeename>>", EmployeeName);
                mailMessage.Body = mailMessage.Body.Replace("<<lblemployeename>>", "Employee Name");

                mailMessage.Body = mailMessage.Body.Replace("<<lblDepartmentname>>", "Department");
                mailMessage.Body = mailMessage.Body.Replace("<<departmentname>>", Empdepartment);

                mailMessage.Body = mailMessage.Body.Replace("<<lblShiftdate>>", "Shift Date");
                mailMessage.Body = mailMessage.Body.Replace("<<Shiftdate>>", ShiftD.ToString("dd/MMM/yyyy"));

                mailMessage.Body = mailMessage.Body.Replace("<<lblPunchtime>>", "First Session");
                mailMessage.Body = mailMessage.Body.Replace("<<punchtime>>", Session["lblAbsentFNa"].ToString());

                mailMessage.Body = mailMessage.Body.Replace("<<lblhours>>", "Secound Session");
                mailMessage.Body = mailMessage.Body.Replace("<<hours>>", Session["lblAbsentANa"].ToString());

                mailMessage.Body = mailMessage.Body.Replace("<<lblReason>>", "Reason");
                mailMessage.Body = mailMessage.Body.Replace("<<Reason>>", TxtAbsent.Text);

                mailMessage.Body = mailMessage.Body.Replace("<<LinkData>>", Convert.ToString(Session["HostServerURL"]) +
                    "?EmpID=" + hdnEmpID + "&ReportName=" + HdnReportName + "&From=" + HdnFrom + "&Rep=" + EmpReportNo);
                objClassCommon.SendMail(mailMessage);

            }


            // Session["lblEarlyExit"] = lblEarlyExit;
            //Session["lblEarlyExitHrs"] = lblEarlyExitHrs;
        }
        else
         if (hdnEmpID != "" & HdnReportName == "EarlyExit" & HdnFrom != "" & HdnTo != "")
        {
            String LateIN = "";
            if (ReportPerEmail == AthorityEmail)
            {
                LateIN = "Notification for the Early Exit occurence Form";
                mailMessage.From = new MailAddress(EmployeeEmail);
                mailMessage.Body = mailMessage.Body.Replace("<<ltr_rtl>>", rm.GetString("Direction", objCultureInfo));
                mailMessage.Body = scriptText.Replace("<<lblEmailNotificationapplicationform>>", LateIN);

                mailMessage.Body = mailMessage.Body.Replace("<<lblemployeeid>>", "Employee ID");
                mailMessage.Body = mailMessage.Body.Replace("<<employeeid>>", hdnEmpID);

                mailMessage.Body = mailMessage.Body.Replace("<<employeename>>", EmployeeName);
                mailMessage.Body = mailMessage.Body.Replace("<<lblemployeename>>", "Employee Name");

                mailMessage.Body = mailMessage.Body.Replace("<<lblDepartmentname>>", "Department");
                mailMessage.Body = mailMessage.Body.Replace("<<departmentname>>", Empdepartment);

                mailMessage.Body = mailMessage.Body.Replace("<<lblShiftdate>>", "Shift Date");
                mailMessage.Body = mailMessage.Body.Replace("<<Shiftdate>>", ShiftD.ToString("dd/MMM/yyyy"));

                mailMessage.Body = mailMessage.Body.Replace("<<lblPunchtime>>", "Early Out");
                mailMessage.Body = mailMessage.Body.Replace("<<punchtime>>", Session["lblEarlyExit"].ToString());

                mailMessage.Body = mailMessage.Body.Replace("<<lblhours>>", "Early Hrs");
                mailMessage.Body = mailMessage.Body.Replace("<<hours>>", Session["lblEarlyExitHrs"].ToString());

                mailMessage.Body = mailMessage.Body.Replace("<<lblReason>>", "Reason");
                mailMessage.Body = mailMessage.Body.Replace("<<Reason>>", TxtEarlyExit.Text);

                mailMessage.Body = mailMessage.Body.Replace("<<LinkData>>", Convert.ToString(Session["HostServerURL"]) +
                    "?EmpID=" + hdnEmpID + "&ReportName=" + HdnReportName + "&From=" + HdnFrom + "&Authority=" + EmpAuthorityNo);
                objClassCommon.SendMail(mailMessage);
            }
            else
            {
                LateIN = "Notification for the Early Exit occurence Form";
                mailMessage.From = new MailAddress(EmployeeEmail);
                mailMessage.Body = mailMessage.Body.Replace("<<ltr_rtl>>", rm.GetString("Direction", objCultureInfo));
                mailMessage.Body = scriptText.Replace("<<lblEmailNotificationapplicationform>>", LateIN);

                mailMessage.Body = mailMessage.Body.Replace("<<lblemployeeid>>", "Employee ID");
                mailMessage.Body = mailMessage.Body.Replace("<<employeeid>>", hdnEmpID);

                mailMessage.Body = mailMessage.Body.Replace("<<employeename>>", EmployeeName);
                mailMessage.Body = mailMessage.Body.Replace("<<lblemployeename>>", "Employee Name");

                mailMessage.Body = mailMessage.Body.Replace("<<lblDepartmentname>>", "Department");
                mailMessage.Body = mailMessage.Body.Replace("<<departmentname>>", Empdepartment);

                mailMessage.Body = mailMessage.Body.Replace("<<lblShiftdate>>", "Shift Date");
                mailMessage.Body = mailMessage.Body.Replace("<<Shiftdate>>", ShiftD.ToString("dd/MMM/yyyy"));

                mailMessage.Body = mailMessage.Body.Replace("<<lblPunchtime>>", "Early Out");
                mailMessage.Body = mailMessage.Body.Replace("<<punchtime>>", Session["lblEarlyExit"].ToString());

                mailMessage.Body = mailMessage.Body.Replace("<<lblhours>>", "Early Hrs");
                mailMessage.Body = mailMessage.Body.Replace("<<hours>>", Session["lblEarlyExitHrs"].ToString());

                mailMessage.Body = mailMessage.Body.Replace("<<lblReason>>", "Reason");
                mailMessage.Body = mailMessage.Body.Replace("<<Reason>>", TxtEarlyExit.Text);

                mailMessage.Body = mailMessage.Body.Replace("<<LinkData>>", Convert.ToString(Session["HostServerURL"]) +
                    "?EmpID=" + hdnEmpID + "&ReportName=" + HdnReportName + "&From=" + HdnFrom + "&Rep=" + EmpReportNo);
                objClassCommon.SendMail(mailMessage);

            }


        }

        int TriggerID = Convert.ToInt32(Session["EmailtriggetID"]);
        if (Status == "Forwarded")
        {
            if (TxtReason.Text != "")
            {
                LateUpdate.ReasonEntry_LateInEmailUpdate(TriggerID, TxtReason.Text, "Forwarded");
            }
            else if (TxtAbsent.Text != "")
            {
                LateUpdate.ReasonEntry_LateInEmailUpdate(TriggerID, TxtAbsent.Text, "Forwarded");
            }
            else if (TxtEarlyExit.Text != "")
            {
                LateUpdate.ReasonEntry_LateInEmailUpdate(TriggerID, TxtEarlyExit.Text, "Forwarded");
            }

        }
        else
        {
            if (TxtReason.Text != "")
            {
                LateUpdate.ReasonEntry_LateInEmailUpdate(TriggerID, TxtReason.Text, "Pending");
            }
            else if (TxtAbsent.Text != "")
            {
                LateUpdate.ReasonEntry_LateInEmailUpdate(TriggerID, TxtAbsent.Text, "Pending");
            }
            else if (TxtEarlyExit.Text != "")
            {
                LateUpdate.ReasonEntry_LateInEmailUpdate(TriggerID, TxtEarlyExit.Text, "Pending");
            }

        }


    }
}
