using System;
using System.Data;
using System.Globalization;
using System.Resources;
using System.Threading;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using DevExpress.Web;
using DevExpress.XtraPrinting;
using System.Web;
using System.Net.Mime;
/****************************************************************************************************************************
* Project Name    : TimeCheck                                         Started Date  : 12-Aug-2007
* Module          : Shift Master                                      Last Modified : 20-Aug-2007
* Programmer      : Janakaraj.P
* Current Storage : \\Angler56\Projects\Inprogress\SCREEN1206\code\Time_AttendanceApp
* BackUp          :
* 
* Modified By      :   Manjula.P
* Modified On      :   05-Oct-2013
* Descriptinos     :   Added codes for adding timing cell into grid based on checkbox loading Mantis : 0019281
****************************************************************************************************************************/
public partial class Masters_TA_UI_MasterShiftDetails : Base.BasePage
{
    #region "Variable Declaration"
    LeaveEventData objLeave = new LeaveEventData();
    ResourceManager rm;
    CultureInfo ci;
    cls_Common objCommon = new cls_Common();
    Cls_CheckUser objCheckUser = new Cls_CheckUser();
    ShiftEvenData obj_Shift = new ShiftEvenData();
    DataSet ds_Checkuser = new DataSet();
    ShiftEvenData obj = new ShiftEvenData();
    string source_Language;
    int ShiftId, auEmpId;
    string strScript = string.Empty;
    string gstrUserGroupName = string.Empty;
    #endregion
    #region Pageload
    protected override void Page_Load(object sender, EventArgs e)
    {
        // session checking
        base.Page_Load(sender, e);
        GridView1.Styles.CssFilePath = Convert.ToString(Session["GridCSS"]);
        //get the culture info to set the language
        if (!Page.IsPostBack)
            objCommon.menu("ShiftMaster", "19");
        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"]);
        auEmpId = Convert.ToInt32(Session["EmpAutoID"]);
        //Set UserRights        
        this.btn_Add.Focus();
        if (!Page.IsPostBack)
        {
            UserRights();
            LoadStrings(ci);
            string strSetAlert = "";
            strSetAlert = strSetAlert + "<script language='javascript'>";
            strSetAlert = strSetAlert + "RestoreAlert('" + rm.GetString("Alert_Norecordsfound", ci) + "','" + rm.GetString("Alert_Areyousuretorestore", ci) + "','" + rm.GetString("Alert_Selecteddataisnotindeletedstatus", ci) + "','" + rm.GetString("Alert_Selectdatatorestore", ci) + "','" + rm.GetString("Alert_Nodeletedrecordsavailable", ci) + "');";
            strSetAlert = strSetAlert + "</script>";
            Page.RegisterStartupScript("RestoreAlert", strSetAlert);
            btn_Add.Focus();
            btn_Add.Style.Add("outline", "none");
        }
        gstrUserGroupName = Convert.ToString(Session["UserGroupName"]);
    }
    #endregion
    #region ButtonEvents
    protected void btn_Add_Click(object sender, EventArgs e)
    {
        Response.Redirect("TA_UI_Master_ShiftAdd.aspx");
    }
    protected void btn_Delete_Click(object sender, EventArgs e)
    {
        string[] ChkBoxIDs;
        string SelectedChkBoxIDs = "";
        if (hdnSelectRow.Value != string.Empty && hdnSelectRow.Value != null)
        {
            ChkBoxIDs = objLeave.commaStringToArray(hdnSelectRow.Value);
            for (int i = 0; i < ChkBoxIDs.Length; i++)
            {
                int count = obj.CheckShift_Delete(Convert.ToInt32(ChkBoxIDs[i]));
                if (count > 0)
                {
                    base.Message(rm.GetString("Master_Shift_Cannot_delete", ci));
                    hdnSelectRow.Value = "";
                    return;
                }
                if (SelectedChkBoxIDs == "")
                    SelectedChkBoxIDs = Convert.ToString(ChkBoxIDs[i]);
                else
                    SelectedChkBoxIDs = SelectedChkBoxIDs + "," + Convert.ToString(ChkBoxIDs[i]);
            }
            obj.DeleteShiftAll(SelectedChkBoxIDs, "TemporaryDelete", auEmpId);
            base.MessageWithRedirect(rm.GetString("Alert_Shiftdeletedsuccessfully", ci), "TA_UI_Master_ShiftDetails.aspx");
        }
        else
        {
            Message(rm.GetString("DeletionRecordAlert", ci));
            return;
        }
    }
    protected void btn_PermanentDelete_Click(object sender, EventArgs e)
    {
        string[] ChkBoxIDs;
        string SelectedChkBoxIDs = "";
        if (hdnSelectRow.Value != string.Empty && hdnSelectRow.Value != null)
        {
            ChkBoxIDs = objLeave.commaStringToArray(hdnSelectRow.Value);
            for (int i = 0; i < ChkBoxIDs.Length; i++)
            {
                int count = obj.CheckShift_Delete(Convert.ToInt32(ChkBoxIDs[i]));
                if (count > 0)
                {
                    base.Message(rm.GetString("Master_Shift_Cannot_delete", ci));
                    hdnSelectRow.Value = "";
                    return;
                }
                if (SelectedChkBoxIDs == "")
                {
                    SelectedChkBoxIDs = Convert.ToString(ChkBoxIDs[i]);
                }
                else
                {
                    SelectedChkBoxIDs = SelectedChkBoxIDs + "," + Convert.ToString(ChkBoxIDs[i]);
                }
            }
            obj.PermanentDeleteShiftAll(SelectedChkBoxIDs, "PermanentDelete", auEmpId);
            base.MessageWithRedirect(rm.GetString("Alert_Shiftdeletedsuccessfully", ci), "TA_UI_Master_ShiftDetails.aspx");
        }
        else
        {
            strScript = "";
            strScript = strScript + "<script language='javascript'>";
            strScript = strScript + "alert('" + rm.GetString("DeletionRecordAlert", ci) + "')";
            strScript = strScript + "</script>";
            Page.RegisterStartupScript("DelAlert1", strScript);
            return;
        }
    }
    protected void btn_Restore_Click(object sender, EventArgs e)
    {
        string[] ChkBoxIDs;
        string SelectedChkBoxIDs = "";
        if (hdnSelectRow.Value != string.Empty && hdnSelectRow.Value != null)
        {
            ChkBoxIDs = objLeave.commaStringToArray(hdnSelectRow.Value);
            for (int i = 0; i < ChkBoxIDs.Length; i++)
            {
                int count = obj.CheckShift_Restore(Convert.ToInt32(ChkBoxIDs[i]));
                if (count > 0)
                {
                    base.Message(rm.GetString("Message_Cannot_Restore", ci));
                    hdnSelectRow.Value = "";
                    GridView1.DataBind();
                    return;
                }
                if (SelectedChkBoxIDs == "")
                {
                    SelectedChkBoxIDs = Convert.ToString(ChkBoxIDs[i]);
                }
                else
                {
                    SelectedChkBoxIDs = SelectedChkBoxIDs + "," + Convert.ToString(ChkBoxIDs[i]);
                }
            }
            obj.RestoreShiftAll(SelectedChkBoxIDs, "Restore", auEmpId);
            base.MessageWithRedirect(rm.GetString("Alert_Shiftrestoredsuccessfully", ci), "TA_UI_Master_ShiftDetails.aspx");
        }
        else
        {
            strScript = "";
            strScript = strScript + "<script language='javascript'>";
            strScript = strScript + "alert('" + rm.GetString("DeletionRecordAlert", ci) + "')";
            strScript = strScript + "</script>";
            Page.RegisterStartupScript("DelAlert1", strScript);
            return;
        }
    }
    protected void btn_Clear_Click(object sender, EventArgs e)
    {
        //Restores the Default view of the grid
        ddlShift.Items.Clear();
        ListItem ls1 = new ListItem();
        ls1.Text = "-Select-";
        ls1.Value = "0";
        ddlShift.Items.Insert(0, ls1);
        ddlCompany.SelectedIndex = 0;
        ddlShift.SelectedIndex = 0;
        GridView1.DataSourceID = ObjectDataSource1.ID;
        GridView1.Visible = true;
        GridView1.PageIndex = 0;
        txtSearchShort.Text = "";
    }
    protected void btnSearch_Click(object sender, EventArgs e)
    {
        int iCompanyID = 0;
        if (ddlCompany.SelectedIndex != 0)
            iCompanyID = Convert.ToInt32(ddlCompany.SelectedValue);
        string strShortName = txtSearchShort.Text.Trim();
        GridView1.Visible = false;
        ShiftEvenData objShift = new ShiftEvenData();
        DataSet ds = new DataSet();
        ds = objShift.SearchShiftByShortName(strShortName, iCompanyID);
        if (ds != null)
        {
            if (ds.Tables[0].Rows.Count > 0)
            {
            }
            else
            {
                string str = "alert('" + rm.GetString("Alert_ShiftnotFound", ci) + "');";
                Page.ClientScript.RegisterStartupScript(this.GetType(), "alertBox", str, true);
            }
        }
    }
    #endregion
    #region UserDefinedFunctions
    //Getting Information from resource file and display it in label
    private void LoadStrings(CultureInfo ci)
    {
        lbl_HeaderShift.Text = rm.GetString("Masters_Shift_ShiftTiming", ci);
        btn_Add.Text = "&nbsp;&nbsp;" + rm.GetString("btn_Add", ci);
        btn_Delete.Text = rm.GetString("btn_Delete", ci);
        btn_PermanentDelete.Text = "&nbsp;&nbsp;" + rm.GetString("btn_Delete", ci);
        lblDataView.Text = rm.GetString("lblDataView", ci);
        btn_Restore.Text = rm.GetString("btn_Restore", ci);
        GridView1.Columns[2].Caption = rm.GetString("ShiftTiming_ShiftName", ci);
        GridView1.Columns[3].Caption = rm.GetString("Shift_Time", ci);
        GridView1.Columns[1].Caption = rm.GetString("EntranceMaster_Company", ci);
        //GridView1.Columns[6].Caption = rm.GetString("DeleteStatus", ci);
        GridView1.Columns[4].Caption = rm.GetString("ShiftTiming_ShiftShortName", ci);
        GridView1.Columns[5].Caption = rm.GetString("ShiftTiming_ShiftType", ci);
        GridView1.Columns[6].Caption = rm.GetString("Shift_24Hrs", ci);
        lblDataView.Text = rm.GetString("lblDataView", ci);
        //ASPxButton1.Text = "Export to PDF";

        GridView1.Columns[10].Caption = rm.GetString("ShiftTiming_GraceShiftIn", ci);
        GridView1.Columns[11].Caption = rm.GetString("ShiftTiming_GraceShiftOut", ci);
        GridView1.Columns[12].Caption = rm.GetString("ShiftTiming_MinimumExtraTimeForOT", ci);
        GridView1.Columns[13].Caption = rm.GetString("ShiftTiming_MaximumExtraTimeForOT", ci);
        GridView1.Columns[14].Caption = rm.GetString("ShiftTiming_OverTimeOnWorkingDays", ci);
        GridView1.Columns[15].Caption = rm.GetString("ShiftTiming_FirstHalfStartTime", ci);
        GridView1.Columns[16].Caption = rm.GetString("ShiftTiming_FirstHalfEndTime", ci);
        GridView1.Columns[17].Caption = rm.GetString("ShiftTiming_SecondHalfStartTime", ci);
        GridView1.Columns[18].Caption = rm.GetString("ShiftTiming_SecondHalfEndTime", ci);
        GridView1.Columns[19].Caption = "Break 1 Start Time";
        GridView1.Columns[20].Caption = "Break 1 End Time";
        GridView1.Columns[21].Caption = "Break 2 Start Time";
        GridView1.Columns[22].Caption = "Break 2 End Time";
        GridView1.Columns[23].Caption = "Break 3 Start Time";
        GridView1.Columns[24].Caption = "Break 3 End Time";
        GridView1.Columns[25].Caption = rm.GetString("Masters_Shift_DefaultShift", ci);
        GridView1.Columns[26].Caption = "Created Date";
        GridView1.Columns[27].Caption = "Modified Date";
    }
    protected string GetShowingOnPage()
    {
        int pageSize = GridView1.SettingsPager.PageSize;
        int startIndex = GridView1.PageIndex * pageSize + 1;
        int endIndex = (GridView1.PageIndex + 1) * pageSize;
        if (endIndex > GridView1.VisibleRowCount)
        {
            endIndex = GridView1.VisibleRowCount;
        }
        return string.Format("Showing {0}-{1} of {2}", startIndex, endIndex, GridView1.VisibleRowCount);
    }
    protected string WriteSelectedIndex(int pageSize)
    {
        return pageSize == GridView1.SettingsPager.PageSize ? "selected='selected'" : string.Empty;
    }
    protected void ddlCompany_SelectedIndexChanged(object sender, EventArgs e)
    {
        GridView1.Visible = false;
        txtSearchShort.Text = "";
        if (ddlCompany.SelectedIndex != 0)
        {
            int iCompanyID = 0;
            iCompanyID = Convert.ToInt32(ddlCompany.SelectedValue);
            ShiftEvenData objShift = new ShiftEvenData();
            DataSet ds = new DataSet();
            ds = objShift.SelectShiftByCompany(iCompanyID);
            ddlShift.Items.Clear();
            if (ds != null)
            {
                if (ds.Tables[0].Rows.Count > 0)
                {
                    for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                    {
                        ListItem ls = new ListItem();
                        ls.Text = Convert.ToString(ds.Tables[0].Rows[i]["Shift_ShortName"]) + " - " + Convert.ToString(ds.Tables[0].Rows[i]["Shift_Name"]);
                        ls.Value = Convert.ToString(ds.Tables[0].Rows[i]["Shift_Id"]);
                        ddlShift.Items.Add(ls);
                    }
                    DataSet dsShift = new DataSet();
                    dsShift = objShift.SearchShift(0, iCompanyID);
                    if (dsShift != null)
                        if (dsShift.Tables[0].Rows.Count < 0)
                        {
                            string str = "alert('" + rm.GetString("Alert_ShiftnotFound", ci) + "');";
                            Page.ClientScript.RegisterStartupScript(this.GetType(), "alertBox", str, true);
                        }
                }
                else
                {
                    string str = "alert('" + rm.GetString("Alert_ShiftnotFound", ci) + "');";
                    Page.ClientScript.RegisterStartupScript(this.GetType(), "alertBox", str, true);
                }
            }
            ListItem ls1 = new ListItem();
            ls1.Text = rm.GetString("Select", ci);
            ls1.Value = "0";
            ddlShift.Items.Insert(0, ls1);
        }
        else
        {
            ddlShift.Items.Clear();
            ListItem ls1 = new ListItem();
            ls1.Text = "-Select-";
            ls1.Value = "0";
            ddlShift.Items.Insert(0, ls1);
        }
    }
    protected void ddlShift_SelectedIndexChanged(object sender, EventArgs e)
    {
        ShiftEvenData objShift = new ShiftEvenData();
        DataSet ds = new DataSet();
        int iShiftID = 0;
        txtSearchShort.Text = "";
        int iCompanyID = 0;
        iCompanyID = Convert.ToInt32(ddlCompany.SelectedValue);
        if (ddlShift.SelectedIndex != 0)
        {
            iShiftID = Convert.ToInt32(ddlShift.SelectedValue);
            GridView1.Visible = false;
            ds = objShift.SearchShift(iShiftID, iCompanyID);
            if (ds != null)
            {
                if (ds.Tables[0].Rows.Count > 0)
                {
                }
                else
                {
                    string str = "alert('" + rm.GetString("Alert_ShiftnotFound", ci) + "');";
                    Page.ClientScript.RegisterStartupScript(this.GetType(), "alertBox", str, true);
                }
            }
        }
        else
        {
            ds = objShift.SearchShift(iShiftID, iCompanyID);
            if (ds != null)
            {
                if (ds.Tables[0].Rows.Count > 0)
                {
                }
                else
                {
                    string str = "alert('" + rm.GetString("Alert_ShiftnotFound", ci) + "');";
                    Page.ClientScript.RegisterStartupScript(this.GetType(), "alertBox", str, true);
                }
            }
        }
    }
    //protected void ASPxButton1_Click(object sender, EventArgs e)
    //{
    //    using (MemoryStream ms = new MemoryStream())
    //    {
    //        PrintableComponentLinkBase pcl = new PrintableComponentLinkBase(new PrintingSystemBase());
    //        pcl.Component = ASPxGridViewExporter1;
    //        pcl.Margins.Left = pcl.Margins.Right = 50;
    //        pcl.Landscape = true;
    //        pcl.CreateDocument(false);
    //        pcl.PrintingSystemBase.Document.AutoFitToPagesWidth = 1;
    //        pcl.ExportToPdf(ms);
    //        WriteResponse(this.Response, ms.ToArray(), System.Net.Mime.DispositionTypeNames.Inline.ToString());
    //    }
    //}
    public static void WriteResponse(HttpResponse response, byte[] filearray, string type)
    {
        response.ClearContent();
        response.Buffer = true;
        response.Cache.SetCacheability(HttpCacheability.Private);
        response.ContentType = "application/pdf";
        ContentDisposition contentDisposition = new ContentDisposition();
        contentDisposition.FileName = "test.pdf";
        contentDisposition.DispositionType = DispositionTypeNames.Inline;
        response.AddHeader("Content-Disposition", contentDisposition.ToString());
        response.BinaryWrite(filearray);
        HttpContext.Current.ApplicationInstance.CompleteRequest();
        try
        {
            response.End();
        }
        catch (System.Threading.ThreadAbortException)
        {
        }

    }
    private void UserRights()
    {
        ds_Checkuser = objCheckUser.checkRights(19, 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.GridView1.Columns[7].Visible = true;
            else
                this.GridView1.Columns[7].Visible = false;
            if (ds_Checkuser.Tables[0].Rows[0]["modifyPrv"] != DBNull.Value && Convert.ToInt32(ds_Checkuser.Tables[0].Rows[0]["modifyPrv"]) == 1)
                this.GridView1.Columns[8].Visible = true;
            else
                this.GridView1.Columns[8].Visible = false;
            if (ds_Checkuser.Tables[0].Rows[0]["deletePrv"] != DBNull.Value && Convert.ToInt32(ds_Checkuser.Tables[0].Rows[0]["deletePrv"]) == 1)
            {
                this.btn_Delete.Visible = false;
                this.btn_PermanentDelete.Visible = true;
                this.btn_Restore.Visible = false;
                this.GridView1.Columns[0].Visible = true;
                this.GridView1.Columns[9].Visible = true;
            }
            else
            {
                this.btn_Delete.Visible = false;
                this.btn_PermanentDelete.Visible = false;
                this.btn_Restore.Visible = false;
                this.GridView1.Columns[0].Visible = false;
                this.GridView1.Columns[9].Visible = false;
            }
        }
        else
        {
            Response.Redirect("MasterLandingPage.aspx");
        }
    }
    #endregion
    #region Gridview Events
    protected void GridView1_HtmlRowCreated(object sender, DevExpress.Web.ASPxGridViewTableRowEventArgs e)
    {
        base.Page_Load(sender, e);
        if (e.RowType == GridViewRowType.Data)
        {
            //Added by Manjula.P on 05-Oct-2013 Mantis : 0019281 
            int strShortShift = 3;
            source_Language = Convert.ToString(Session["Session_ActiveLanguage"]);
            rm = new ResourceManager(source_Language, System.Reflection.Assembly.Load("App_GlobalResources"));
            ci = Thread.CurrentThread.CurrentCulture;
            Label lbl_ShiftName = (Label)GridView1.FindRowCellTemplateControl(e.VisibleIndex, null, "lbl_ShiftName");
            if (lbl_ShiftName != null)
                if (lbl_ShiftName.Text == "No Shift")
                {
                    lbl_ShiftName.Text = rm.GetString("Caption_NoShift", ci);
                }
            Label lblShortName = (Label)GridView1.FindRowCellTemplateControl(e.VisibleIndex, null, "lblShortName");
            if (lblShortName != null)
                if (Convert.ToString(lblShortName.Text) == "No Shift")
                {
                    lblShortName.Text = rm.GetString("Caption_NoShift", ci);
                }
            Label DeletedRecord = (Label)GridView1.FindRowCellTemplateControl(e.VisibleIndex, null, "lblIsDeleted");
            if (DeletedRecord != null)
                if (DeletedRecord != null)
                {
                    if (DeletedRecord.Text == "True" || DeletedRecord.Text == rm.GetString("Grid_True", ci))
                    {
                        DeletedRecord.ForeColor = System.Drawing.Color.Red;
                    }
                }
            HtmlInputCheckBox deleteChkBxItem = (HtmlInputCheckBox)GridView1.FindRowCellTemplateControl(e.VisibleIndex, null, "chkSelect");

            if (deleteChkBxItem != null)
            {
                if (gstrUserGroupName == "SuperAdmin")
                {
                    ShiftId = Convert.ToInt16(e.GetValue("Shift_Id"));
                    int Count = obj.CheckShift_Delete(ShiftId);
                    LinkButton LnkbtnDelete = (LinkButton)GridView1.FindRowCellTemplateControl(e.VisibleIndex, null, "btnDelete");
                    if (Count > 0)
                    {
                        deleteChkBxItem.Disabled = true;
                        if (LnkbtnDelete != null)
                        {
                            LnkbtnDelete.Enabled = false;
                            LnkbtnDelete.OnClientClick = null;
                        }
                    }
                    else
                    {
                        deleteChkBxItem.Disabled = false;
                        if (LnkbtnDelete != null)
                        {
                            LnkbtnDelete.Enabled = true;
                        }
                    }
                }
            }
            //Added by Manjula.P on 05-Oct-2013 Mantis : 0019281 
            else
            {
                //Added by Manjula.P on 05-Oct-2013 Mantis : 0019281 
                strShortShift = 2;
            }
            if (DeletedRecord != null)
            {
                switch (DeletedRecord.Text)
                {
                    case "True":
                        DeletedRecord.Text = rm.GetString("Grid_True", ci);
                        if (hdnDeletedData.Value == string.Empty)
                            hdnDeletedData.Value = Convert.ToString(e.GetValue("Shift_Id"));
                        else
                            if (hdnDeletedData.Value.Contains(Convert.ToString(e.GetValue("Shift_Id"))) == false)
                            hdnDeletedData.Value = hdnDeletedData.Value + "," + Convert.ToString(e.GetValue("Shift_Id"));
                        break;
                    case "False":
                        DeletedRecord.Text = rm.GetString("Grid_False", ci);
                        break;
                    default:
                        break;
                }
            }
            // setting time format
            DateTime shiftStartTime = Convert.ToDateTime(e.GetValue("shiftstart"));
            DateTime shiftEndTime = Convert.ToDateTime(e.GetValue("shiftend"));
            string shiftTiminings = shiftStartTime.ToString(Convert.ToString(Session["MTimeFormat"])) + " " + "TO" + " " + shiftEndTime.ToString(Convert.ToString(Session["MTimeFormat"]));
            e.Row.Cells[strShortShift].Text = shiftTiminings;
            e.Row.Cells[strShortShift].Style.Add("color", "#5D5D5D");
        }
    }
    #endregion
    protected void EditLinkButton_Click(object sender, EventArgs e)
    {
        LinkButton btn = sender as LinkButton;
        int ShiftId = Convert.ToInt32(btn.CommandName);
        Response.Redirect("TA_UI_Master_ShiftModify.aspx?SID=" + ShiftId);
    }
    protected void btn_delete_Click_1(object sender, EventArgs e)
    {
        cls_Master_Transportation objTransportationRoute = new cls_Master_Transportation();
        LinkButton btn = sender as LinkButton;
        int ShiftId = Convert.ToInt32(btn.CommandName);
        int count = obj_Shift.CheckShift_Delete(ShiftId);
        if (count > 0)
        {
            base.Message(rm.GetString("Master_Shift_Cannot_delete", ci));
            return;
        }
        obj.PermanentDeleteShiftAll(Convert.ToString(ShiftId), "PermanentDelete", auEmpId);
        base.MessageWithRedirect(rm.GetString("Alert_Shiftdeletedsuccessfully", ci), "TA_UI_Master_ShiftDetails.aspx");
    }

    protected void btnExport_Click(object sender, EventArgs e)
    {
        GridView1.Columns[0].Visible = false;
        LinkButton lnkbtn = (LinkButton)sender;  //Called From  Grid Report Icon click / both excel and pdf
        ASPxGridViewExporter1.Landscape = true;
        ASPxGridViewExporter1.LeftMargin = 10;
        ASPxGridViewExporter1.RightMargin = 10;
        ASPxGridViewExporter1.ExportedRowType = DevExpress.Web.GridViewExportedRowType.All;
        ASPxGridViewExporter1.MaxColumnWidth = 400;
        //ASPxGridViewExporter1.GridViewID = "gvData";
        string saveAsFileName = string.Format("ShiftDetails", DateTime.Now).Replace("/", "-").Replace(" ", "");
        ASPxGridViewExporter1.FileName = saveAsFileName;
        ASPxGridViewExporter1.PaperKind = System.Drawing.Printing.PaperKind.A3;
        ASPxGridViewExporter1.PageHeader.Center = "List of Shifts";
        switch (lnkbtn.CommandName)
        {
            case "excel":
                ASPxGridViewExporter1.WriteXlsxToResponse();
                break;
            case "pdf":
                ASPxGridViewExporter1.WritePdfToResponse();
                break;
            case "csv":
                ASPxGridViewExporter1.WriteCsvToResponse();
                break;
        }
    }
}
