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.Resources;
using System.Globalization;
using System.Threading;
public partial class Transactions_TA_UI_Transactions_ManualCompensationEntry : Base.BasePage
{
    #region Variable Declaration
    ResourceManager rm;
    CultureInfo ci;
    Cls_CheckUser objCheckUser = new Cls_CheckUser();
    DataSet ds_Checkuser = new DataSet();
    LeaveApplicationEventData objEmployeeEventData = new LeaveApplicationEventData();
    string strEmpFirstName, strEmpLastName;
    DataSet dsEmployeeDetails = new DataSet();
    string strEmailIdSanctioningAuthority, strEmailIdReportingTo, strEmployeeCodeId, strEmployeeName, strlevelName, strEmailID;
    Email_Triggering ObjEmailTrigger = new Email_Triggering();
    DataSet dsCompensation = new DataSet();
    cls_Common objClassCommon = new cls_Common();
    string gstrDateFormat, FromDate, Todate;
    DateTime dtFromDate, dtToDate;
    DataTable dt = new DataTable();
    string source_Language;
    bool blnCheckEmail = true;
    int CompoffID, iEmployeeID = 0;
    #endregion
    #region Page Load Event
    protected override void Page_Load(object sender, EventArgs e)
    {
        base.Page_Load(sender, e);
        gvCompensationList.Styles.CssFilePath = Convert.ToString(Session["GridCSS"]);
        if (!Page.IsPostBack)
        {
            base.CheckPages(0);
            objClassCommon.menu("OverTime", "254");
        }
        string source_Language;
        source_Language = Convert.ToString(Session["Session_ActiveLanguage"]);
        rm = new ResourceManager(source_Language, System.Reflection.Assembly.Load("App_GlobalResources"));
        ci = Thread.CurrentThread.CurrentCulture;
        site.SiteMapProvider = Convert.ToString(Session["SiteMapProvider"]);
        LoadStrings(ci);
        Hidden1.Value = Convert.ToString(Session["IDateFormat"]);
        string strSetAlert = "";
        strSetAlert = strSetAlert + "<script language='javascript'>";
        strSetAlert = strSetAlert + "MaxLengthh('" + rm.GetString("Alert_MaximumLengthis", ci) + "');";
        strSetAlert = strSetAlert + "SetAlertMessages('" + rm.GetString("Alert_FillDetails", ci) + "','" + rm.GetString("Alert_FillFromToDate", ci) + "');";
        strSetAlert = strSetAlert + "SetAlertCheckDate('" + rm.GetString("Alert_Validmonthdatefourdigit", ci) + "','" + rm.GetString("Alert_Validdatemonthfourdigit", ci) + "','" + rm.GetString("Alert_Invalidyearentry", ci) + "','" + rm.GetString("Alert_Invalidmonthentry", ci) + "','" + rm.GetString("Alert_Invaliddateentry", ci) + "','" + rm.GetString("Alert_IncorrectdateformatDDMONYYYY", ci) + "','" + rm.GetString("Alert_Entertime", ci) + "','" + rm.GetString("Alert_Invalidvalueforhours", ci) + "','" + rm.GetString("Alert_Invalidvalueforminites", ci) + "','" + rm.GetString("Alert_Invalidtimeformat1", ci) + "','" + rm.GetString("Alert_PleaseentervalidDateandTime", ci) + "','" + rm.GetString("Alert_ValiddatemonthMMDDYYHHMM", ci) + "','" + rm.GetString("Alert_ValiddatemonthMMDDYYHHMMTT", ci) + "','" + rm.GetString("Alert_PleaseentervalidDateandTime", ci) + "','" + rm.GetString("Alert_Invalidvalueforhours", ci) + "','" + rm.GetString("Alert_Invalidvalueforminites", ci) + "');";
        strSetAlert = strSetAlert + "</script>";
        Page.RegisterStartupScript("SetAlertMessages", strSetAlert);
        UserRights();

        DataSet dsEmployeeGroup = new DataSet();
        dsEmployeeGroup = objEmployeeEventData.GetEmployeeGroupName(Convert.ToInt32(Session["EmpAutoId"]));
        if (dsEmployeeGroup.Tables[0].Rows.Count > 0)
        {
            if (Convert.ToString(dsEmployeeGroup.Tables[0].Rows[0]["GroupName"]) == "SuperAdmin" || Convert.ToString(Session["IndividualUsers"]) != "True")
            {
                gvCompensationList.DataSourceID = "";
                gvCompensationList.DataSourceID = ObjectDataSource1.ID;
                ViewState["GroupName"] = "SuperAdmin";
            }
            else
            {
                gvCompensationList.DataSourceID = ObjectDataSource2.ID;
                gvCompensationList.Columns[1].Visible = false;
                gvCompensationList.Columns[2].Visible = false;
                gvCompensationList.Columns[3].Visible = false;
                //gvCompensationList.Columns[4].Visible = false;
                ViewState["GroupName"] = "Normal";
            }
        }
        else
        {
            gvCompensationList.DataSourceID = ObjectDataSource2.ID;
            gvCompensationList.Columns[1].Visible = false;
            gvCompensationList.Columns[2].Visible = false;
            gvCompensationList.Columns[3].Visible = false;
            //gvCompensationList.Columns[4].Visible = false;
            ViewState["GroupName"] = "Normal";
        }
        if (Convert.ToString(ViewState["GroupName"]) == "Normal")
        {
            divAdmin.Visible = false;
        }
    }
    #endregion
    #region User Defined Function
    private void UserRights()
    {
        ds_Checkuser = objCheckUser.checkRights(254, Convert.ToInt32(Session["userGroup_Id"]), "");
        if (ds_Checkuser.Tables[0].Rows.Count > 0)
        {
            if (ds_Checkuser.Tables[0].Rows[0]["addPrv"] != DBNull.Value && Convert.ToInt32(ds_Checkuser.Tables[0].Rows[0]["addPrv"]) == 1)
            {
                this.btn_Add.Visible = true;
            }
            else
            {
                this.btn_Add.Visible = false;
            }
            if (ds_Checkuser.Tables[0].Rows[0]["viewPrv"] != DBNull.Value && Convert.ToInt32(ds_Checkuser.Tables[0].Rows[0]["viewPrv"]) == 1)
            {
                this.gvCompensationList.Columns[8].Visible = true;
            }
            else
            {
                this.gvCompensationList.Columns[8].Visible = false;
            }
            if (ds_Checkuser.Tables[0].Rows[0]["ModifyPrv"] != DBNull.Value && Convert.ToInt32(ds_Checkuser.Tables[0].Rows[0]["ModifyPrv"]) == 1)
            {
                this.gvCompensationList.Columns[9].Visible = true;
            }
            else
            {
                this.gvCompensationList.Columns[9].Visible = false;
            }
            if (ds_Checkuser.Tables[0].Rows[0]["deletePrv"] != DBNull.Value && Convert.ToInt32(ds_Checkuser.Tables[0].Rows[0]["deletePrv"]) == 1)
            {
                this.gvCompensationList.Columns[10].Visible = true;
            }
            else
            {
                this.gvCompensationList.Columns[10].Visible = false;
            }
        }
        else
        {
            Response.Redirect("TransactionLandingPage.aspx");
        }

        //ds_Checkuser = objCheckUser.checkRights(254, Convert.ToInt32(Session["userGroup_Id"]), "");
        //if (ds_Checkuser.Tables[0].Rows.Count > 0)
        //{
        //    if (ds_Checkuser.Tables[0].Rows[0]["addPrv"] != DBNull.Value && Convert.ToInt32(ds_Checkuser.Tables[0].Rows[0]["addPrv"]) == 1)
        //    {
        //        this.btn_Add.Visible = true;
        //    }
        //    else
        //    {
        //        this.btn_Add.Visible = false;
        //    }
        //}
        //else
        //{
        //    Response.Redirect("TransactionLandingPage.aspx");
        //}
    }
    private void LoadStrings(CultureInfo ci)
    {
        lbl_Header.Text = rm.GetString("Transaction_CompensationEntry", ci);
        lbl_EmployeeName.Text = rm.GetString("email_EmployeeName", ci);
        lbl_EmployeeId.Text = rm.GetString("email_EmployeeId", ci);
        lblTimePeriod.Text = rm.GetString("ShiftExchange_DateRange", ci);
        lblStartDate.Text = rm.GetString("email_FromDate", ci);
        lblEndDate.Text = rm.GetString("email_ToDate", ci);
        btn_Search.Text = "&nbsp;&nbsp;" + rm.GetString("btn_Search", ci);
        btn_Clear.Text = "&nbsp;&nbsp;" + rm.GetString("btn_Clear", ci);
        btn_Add.Text = "&nbsp;&nbsp;" + rm.GetString("btn_Add", ci);
        btn_Cancel.Text = "&nbsp;&nbsp;" + rm.GetString("btn_Back", ci);
        gvCompensationList.Columns[0].Caption = rm.GetString("LeaveApplication_LeaveApplicationDate", ci);
        gvCompensationList.Columns[1].Caption = rm.GetString("email_EmployeeId", ci);
        gvCompensationList.Columns[2].Caption = rm.GetString("email_EmployeeName", ci);
        gvCompensationList.Columns[3].Caption = rm.GetString("LevelDetails_LevelName", ci);
        gvCompensationList.Columns[4].Caption = rm.GetString("lbl_DateofDuty", ci);
        gvCompensationList.Columns[5].Caption = rm.GetString("lbl_Dayworked", ci);
        gvCompensationList.Columns[6].Caption = rm.GetString("lbl_ExtraWorkedHrs", ci);
        gvCompensationList.Columns[7].Caption = rm.GetString("email_Status", ci);
        gvCompensationList.Columns[8].Caption = rm.GetString("email_Reason", ci);

    }
    public SortDirection gridviewsortdirection
    {
        get
        {
            if (ViewState["sortdirection"] == null)
            {
                ViewState["sortdirection"] = SortDirection.Ascending;
            }
            return (SortDirection)ViewState["sortdirection"];
        }
        set
        {
            ViewState["sortdirection"] = value;
        }
    }
    public void sortgridview(string sortexpression, string direction)
    {
        DataTable dt = new DataTable();
        dt = (DataTable)ViewState["Compensation"];
        DataView dv = new DataView(dt);
        dv.Sort = sortexpression + " " + direction;
        ViewState["Compensation"] = dv.ToTable();
        gvCompensationList.DataSource = dv;
        gvCompensationList.DataBind();
    }
    #endregion
    #region Button Events
    protected void btn_Add_Click(object sender, System.EventArgs e)
    {
        Response.Redirect("../Transactions/TA_UI_Transactions_ManualCompensationEntry_Add.aspx");
    }
    protected void btn_Clear_Click(object sender, System.EventArgs e)
    {
        txtEmployeeId.Text = string.Empty;
        txt_EmpName.Text = string.Empty;
        txtStartDate.Text = "";
        txtEndDate.Text = string.Empty;
        txtSwipeCard.Text = string.Empty;
        //LoadGrid();
    }
    protected void btn_Search_Click(object sender, System.EventArgs e)
    {
        LoadGrid();
    }
    protected void EditLinkButton_Click(object sender, EventArgs e)
    {
        LinkButton btn = sender as LinkButton;
        CompoffID = Convert.ToInt32(btn.CommandName);
        ViewDetails();
        ViewState["EmpID"] = btn.ValidationGroup.ToString();
        ViewState["EmpName"] = btn.CommandArgument;
        string strLeaveStatus = string.Empty;
        DataSet dsDeleteRecord = new DataSet();
        int approvalSettingsPageExists = 0;
        approvalSettingsPageExists = objClassCommon.CheckPageExistsInLicense(228);
        if (approvalSettingsPageExists == 1)
        {
            int intCompanyId = base.GetCompanyId(Convert.ToInt32(ViewState["iEmployeeID"]));
            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]["LeaveSanction"]) == false)
                        {
                            strLeaveStatus = "ApprovalNotRequired";
                        }
                    }
                    else
                    {
                        base.Message(rm.GetString("Msg_ApprovalSettings", ci));
                        return;
                    }
                }
            }
        }
        else
        {
            strLeaveStatus = "ApprovalNotRequired";
        }
        if (ViewState["StatusOfApplication"].ToString() == "Rejected")
        {
            if (Convert.ToString(Session["UserGroupName"]) == "SuperAdmin" || Convert.ToString(Session["HasSpecialRights"]) == "True")
            {
                if (Convert.ToString(Session["IndividualUsers"]) == "True")
                {
                    Page.RegisterStartupScript("statusalert", "<script language='javascript'>alert('" + rm.GetString("Alert_RejectedCompoffApplicationCannotbeModify", ci) + "');</script>");
                }
                else
                {
                    checkCompOffEntry();
                }
            }
            else
            {
                Page.RegisterStartupScript("statusalert", "<script language='javascript'>alert('" + rm.GetString("Alert_RejectedCompoffApplicationCannotbeModify", ci) + "');</script>");
            }
        }
        else if (ViewState["StatusOfApplication"].ToString() == "Pending" || strLeaveStatus == "ApprovalNotRequired")
        {
            checkCompOffEntry();
        }
        else
        {
            if (Convert.ToString(Session["UserGroupName"]) == "SuperAdmin" || Convert.ToString(Session["HasSpecialRights"]) == "True")
            {
                if (Convert.ToString(Session["IndividualUsers"]) == "True")
                {
                    Page.RegisterStartupScript("statusalert", "<script language='javascript'>alert('" + rm.GetString("Alert_CannotEditthisrecorddComp", ci) + "');</script>");
                }
                else
                {
                    checkCompOffEntry();
                }
            }
            else
            {
                Page.RegisterStartupScript("statusalert", "<script language='javascript'>alert('" + rm.GetString("Alert_CannotEditthisrecorddComp", ci) + "');</script>");
            }
        }
    }
    private void checkCompOffEntry()
    {
        DataSet dsDeleteRecord = new DataSet();
        dsDeleteRecord = objEmployeeEventData.CheckCompensationMapped(CompoffID);
        if (dsDeleteRecord.Tables[0].Rows[0][0].ToString() == "1")
        {
            Response.Redirect("../Transactions/TA_UI_Transactions_ManualCompensationEntry_Edit.aspx?CoffId=" + Convert.ToString(CompoffID));
        }
        else if (dsDeleteRecord.Tables[0].Rows[0][0].ToString() == "Availed")
        {
            string strScript = "";
            strScript = strScript + "<script language='javascript'>";
            strScript = strScript + "alert('" + rm.GetString("Alert_ComoffEntryisalreadyMappedwithLeave", ci) + "');";
            strScript = strScript + "location.replace('TA_UI_Transactions_ManualCompensationEntry.aspx');";
            strScript = strScript + "</script>";
            //Dispaly alert messsage.
            Page.RegisterStartupScript("AlertPAdd65507866", strScript);
        }
    }
    private void LoadGrid()
    {
        string strLeaveStartDate;
        string strLeaveEndDate;
        bool boolErrorStatus = true;
        string gstrDateFormat = Convert.ToString(Session["MDateFormat"]);
        strLeaveStartDate = objClassCommon.DateConvertion(gstrDateFormat, Convert.ToString(txtStartDate.Text));
        strLeaveEndDate = objClassCommon.DateConvertion(gstrDateFormat, Convert.ToString(txtEndDate.Text));
        string strSwipeCard = "";
        strSwipeCard = Convert.ToString(txtSwipeCard.Text).Trim().Replace("'", "''");
        if (strLeaveStartDate == string.Empty && strLeaveEndDate == string.Empty)
        {
            boolErrorStatus = false;
        }
        else if (strLeaveStartDate != string.Empty && strLeaveEndDate != string.Empty)
        {
            if (Convert.ToDateTime(strLeaveEndDate).Date < Convert.ToDateTime(strLeaveStartDate).Date)
            {
                base.Message(rm.GetString("Alert_FromDateLessThanToDate"));
                gvCompensationList.DataSourceID = "";
                return;
                boolErrorStatus = true;
            }
            else
            {
                boolErrorStatus = false;
            }
        }
    }
    protected void btn_delete_Click_1(object sender, EventArgs e)
    {
        LinkButton btn = sender as LinkButton;
        CompoffID = Convert.ToInt32(btn.CommandName);
        ViewDetails();
        ViewState["EmpID"] = btn.ValidationGroup.ToString();
        ViewState["EmpName"] = btn.CommandArgument;
        string strLeaveStatus = string.Empty;
        DataSet dsDeleteRecord = new DataSet();
        int approvalSettingsPageExists = 0;
        approvalSettingsPageExists = objClassCommon.CheckPageExistsInLicense(228);
        if (approvalSettingsPageExists == 1)
        {
            //Get Compnay Id of the Employeee
            int intCompanyId = base.GetCompanyId(Convert.ToInt32(ViewState["iEmployeeID"]));
            //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]["LeaveSanction"]) == false)
                        {
                            strLeaveStatus = "ApprovalNotRequired";
                        }
                    }
                    else
                    {
                        base.Message(rm.GetString("Msg_ApprovalSettings", ci));
                        return;
                    }
                }
            }
        }
        else
        {
            strLeaveStatus = "ApprovalNotRequired";
        }
        if (ViewState["StatusOfApplication"].ToString() == "Rejected")
        {
            if (Convert.ToString(Session["UserGroupName"]) == "SuperAdmin" || Convert.ToString(Session["HasSpecialRights"]) == "True")
            {
                if (Convert.ToString(Session["IndividualUsers"]) == "True")
                {
                    Page.RegisterStartupScript("statusalert", "<script language='javascript'>alert('" + rm.GetString("Alert_RejectedCompoffApplicationCannotbeDeleted", ci) + "');</script>");
                }
                else
                {
                    dsDeleteRecord = objEmployeeEventData.DeletedCompensationEntrybyID(CompoffID);
                    if (dsDeleteRecord.Tables[0].Rows[0][0].ToString() == "1")
                    {
                        SendMail();
                        if (blnCheckEmail == true)
                        {
                            string strScript = "";
                            strScript = strScript + "<script language='javascript'>";
                            strScript = strScript + "alert('" + rm.GetString("Alert_CompoffCreditentrydeleteSuccessfully", ci) + "');";
                            strScript = strScript + "location.replace('TA_UI_Transactions_ManualCompensationEntry.aspx');";
                            strScript = strScript + "</script>";
                            //Dispaly alert messsage.
                            Page.RegisterStartupScript("AlertPAdd65507866", strScript);
                        }
                        else
                        {
                            string strScript = "";
                            strScript = strScript + "<script language='javascript'>";
                            strScript = strScript + "alert('" + rm.GetString("Alert_CompoffCreditentrydeleteSuccessfullyEmailNotSend", ci) + "');";
                            strScript = strScript + "location.replace('TA_UI_Transactions_ManualCompensationEntry.aspx');";
                            strScript = strScript + "</script>";
                            //Dispaly alert messsage.
                            Page.RegisterStartupScript("AlertPAdd65507866", strScript);
                        }
                    }
                    else if (dsDeleteRecord.Tables[0].Rows[0][0].ToString() == "Availed")
                    {
                        string strScript = "";
                        strScript = strScript + "<script language='javascript'>";
                        strScript = strScript + "alert('" + rm.GetString("Alert_ComoffEntryisalreadyMappedwithLeave", ci) + "');";
                        strScript = strScript + "location.replace('TA_UI_Transactions_ManualCompensationEntry.aspx');";
                        strScript = strScript + "</script>";
                        //Dispaly alert messsage.
                        Page.RegisterStartupScript("AlertPAdd65507866", strScript);
                    }
                }
            }
            else
            {
                Page.RegisterStartupScript("statusalert", "<script language='javascript'>alert('" + rm.GetString("Alert_RejectedCompoffApplicationCannotbeDeleted", ci) + "');</script>");
            }
        }
        else if (ViewState["StatusOfApplication"].ToString() == "Pending" || strLeaveStatus == "ApprovalNotRequired")
        {
            dsDeleteRecord = objEmployeeEventData.DeletedCompensationEntrybyID(CompoffID);
            if (dsDeleteRecord.Tables[0].Rows[0][0].ToString() == "1")
            {
                SendMail();
                if (blnCheckEmail == true)
                {
                    string strScript = "";
                    strScript = strScript + "<script language='javascript'>";
                    strScript = strScript + "alert('" + rm.GetString("Alert_CompoffCreditentrydeleteSuccessfully", ci) + "');";
                    strScript = strScript + "location.replace('TA_UI_Transactions_ManualCompensationEntry.aspx');";
                    strScript = strScript + "</script>";
                    //Dispaly alert messsage.
                    Page.RegisterStartupScript("AlertPAdd65507866", strScript);
                }
                else
                {
                    string strScript = "";
                    strScript = strScript + "<script language='javascript'>";
                    strScript = strScript + "alert('" + rm.GetString("Alert_CompoffCreditentrydeleteSuccessfullyEmailNotSend", ci) + "');";
                    strScript = strScript + "location.replace('TA_UI_Transactions_ManualCompensationEntry.aspx');";
                    strScript = strScript + "</script>";
                    //Dispaly alert messsage.
                    Page.RegisterStartupScript("AlertPAdd65507866", strScript);
                }
            }
            else if (dsDeleteRecord.Tables[0].Rows[0][0].ToString() == "Availed")
            {
                string strScript = "";
                strScript = strScript + "<script language='javascript'>";
                strScript = strScript + "alert('" + rm.GetString("Alert_ComoffEntryisalreadyMappedwithLeave", ci) + "');";
                strScript = strScript + "location.replace('TA_UI_Transactions_ManualCompensationEntry.aspx');";
                strScript = strScript + "</script>";
                //Dispaly alert messsage.
                Page.RegisterStartupScript("AlertPAdd65507866", strScript);
            }
        }
        else
        {
            if (Convert.ToString(Session["UserGroupName"]) == "SuperAdmin" || Convert.ToString(Session["HasSpecialRights"]) == "True")
            {
                if (Convert.ToString(Session["IndividualUsers"]) == "True")
                {
                    Page.RegisterStartupScript("statusalert", "<script language='javascript'>alert('" + rm.GetString("Alert_CannotdeletethisrecorddComp", ci) + "');</script>");
                }
                else
                {
                    dsDeleteRecord = objEmployeeEventData.DeletedCompensationEntrybyID(CompoffID);
                    if (dsDeleteRecord.Tables[0].Rows[0][0].ToString() == "1")
                    {
                        SendMail();
                        if (blnCheckEmail == true)
                        {
                            string strScript = "";
                            strScript = strScript + "<script language='javascript'>";
                            strScript = strScript + "alert('" + rm.GetString("Alert_CompoffCreditentrydeleteSuccessfully", ci) + "');";
                            strScript = strScript + "location.replace('TA_UI_Transactions_ManualCompensationEntry.aspx');";
                            strScript = strScript + "</script>";
                            //Dispaly alert messsage.
                            Page.RegisterStartupScript("AlertPAdd65507866", strScript);
                        }
                        else
                        {
                            string strScript = "";
                            strScript = strScript + "<script language='javascript'>";
                            strScript = strScript + "alert('" + rm.GetString("Alert_CompoffCreditentrydeleteSuccessfullyEmailNotSend", ci) + "');";
                            strScript = strScript + "location.replace('TA_UI_Transactions_ManualCompensationEntry.aspx');";
                            strScript = strScript + "</script>";
                            //Dispaly alert messsage.
                            Page.RegisterStartupScript("AlertPAdd65507866", strScript);
                        }
                      
                    }
                    else if (dsDeleteRecord.Tables[0].Rows[0][0].ToString() == "Availed")
                    {
                        string strScript = "";
                        strScript = strScript + "<script language='javascript'>";
                        strScript = strScript + "alert('" + rm.GetString("Alert_ComoffEntryisalreadyMappedwithLeave", ci) + "');";
                        strScript = strScript + "location.replace('TA_UI_Transactions_ManualCompensationEntry.aspx');";
                        strScript = strScript + "</script>";
                        //Dispaly alert messsage.
                        Page.RegisterStartupScript("AlertPAdd65507866", strScript);
                    }
                }
            }
            else
            {
                Page.RegisterStartupScript("statusalert", "<script language='javascript'>alert('" + rm.GetString("Alert_CannotdeletethisrecorddComp", ci) + "');</script>");
            }
        }
    }
    public void ViewDetails()
    {
        DataSet dsCompensation = new DataSet();
        dsCompensation = objEmployeeEventData.SelectCompensationDatabyid(CompoffID);
        iEmployeeID = Convert.ToInt32(dsCompensation.Tables[0].Rows[0]["E_Employee_Id"]);
        gstrDateFormat = Convert.ToString(Session["MDateFormat"]);
        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();
    }
    #endregion
    #region Grid Events
    protected void gvCompensationList_HtmlRowCreated(object sender, DevExpress.Web.ASPxGridViewTableRowEventArgs e)
    {
        
    }
    #endregion
    public void SendMail()
    {
        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"]), "Delete", strlevelName, "Add");
            }
        }
    }
}
