using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Globalization;
using System.Threading;
using System.Reflection;
using System.Resources;
/****************************************************************************************************************************
* Project Name    : TimeCheck                    Started Date  : 12-Aug-2007
* Module          : Shift Exchange               Last Modified : 09-May-2011
* Programmer      : Janakaraj.P
* Modified by     : Sashma
****************************************************************************************************************************/
public partial class Transactions_TA_UI_Transaction_ShiftExchange : Base.BasePage
{
    #region Variable Declaration
    ResourceManager rm;
    ShiftAllocationEvendata objShiftAllocation = new ShiftAllocationEvendata();
    ShiftExchangeEventData obj = new ShiftExchangeEventData();
    ManualEntryEventData objManualEntryEventData = new ManualEntryEventData();
    ShiftEvenData objShift = new ShiftEvenData();
    cls_Common objcls_Common = new cls_Common();
    Rpt_Common rptcommon = new Rpt_Common();
    DataSet ds_EmployeeAutoId1 = new DataSet();
    DataSet ds_EmployeeAutoId2 = new DataSet();
    CultureInfo ci;
    DateTime Edate1, Edate2;
    string date1, date2, month1, month2, year1, year2, gstrDateFormat, gstrShiftFormat, ExchangeDate;
    int shiftId1, shiftId2;
    int gintUserId;
    string gstrUserGroupName = string.Empty;
    #endregion
    #region PageLoad Event
    protected override void Page_Load(object sender, EventArgs e)
    {
        // session checking
        base.Page_Load(sender, e);
        //get the culture info to set the language
        string source_Language;
        source_Language = Convert.ToString(Session["Session_ActiveLanguage"]);
        rm = new ResourceManager(source_Language, System.Reflection.Assembly.Load("App_GlobalResources"));
        ci = Thread.CurrentThread.CurrentCulture;
        site.SiteMapProvider = Convert.ToString(Session["SiteMapProvider"]);
        LoadStrings(ci);
        string strSetAlert = "";
        strSetAlert = strSetAlert + "<script language='javascript'>";
        strSetAlert = strSetAlert + "MaxLengthh('" + rm.GetString("Alert_MaximumLengthis", ci) + "');";
        // strSetAlert = strSetAlert + "SetAlertMessages_DeleteRestore('" + rm.GetString("Alert_ConfirmDelete", ci) + "','" + rm.GetString("Alert_SelectItemsToDelete", ci) + "','" + rm.GetString("Alert_ConfirmDeletePermanent", ci) + "','" + rm.GetString("Alert_Areyousuretorestore", ci) + "','" + rm.GetString("Alert_SelectItemsToRestore", 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 + "SetAlertMessages('" + rm.GetString("Alert_EnterDatee", ci) + "','" + rm.GetString("Alert_Select_Company", ci) + "','" + rm.GetString("Alert_FillEmployee1Code", ci) + "','" + rm.GetString("Alert_Selectshiftdate", ci) + "','" + rm.GetString("Alert_FillEmployee2Code", ci) + "','" + rm.GetString("Alert_EmployeeIdshouldnotbesame", ci) + "','" + rm.GetString("Alert_Employee1ActualShiftShouldnotbeempty", ci) + "','" + rm.GetString("Alert_Employee2ActualShiftShouldnotbeempty", ci) + "','" + rm.GetString("Alert_ActualShiftsforbothEmployeeshouldnotbeunique", ci) + "','" + rm.GetString("Alert_AresuretoExchangetheshifts", ci) + "','" + rm.GetString("Alert_Shiftnotallocated", ci) + "');";
        strSetAlert = strSetAlert + "</script>";
        Page.RegisterStartupScript("SetAlertMessages", strSetAlert);
        Hidden1.Value = Convert.ToString(Session["IDateFormat"]);
        gstrUserGroupName = Convert.ToString(Session["UserGroupName"]);
        if (!Page.IsPostBack)
        {
            ddlCompany.Focus();
            CompanyBinding();
            objcls_Common.menu("ShiftTransaction", "60");
        }
        gintUserId = Int32.Parse(Session["EmpAutoID"].ToString());
    }
    #endregion
    #region User Defined Functions
    private void CompanyBinding()
    {
        DataSet dsCompany = new DataSet();
        dsCompany = objShift.SelectCompany(gstrUserGroupName, Convert.ToString(Session["LevelRights"]), 0);
        if (dsCompany != null)
        {
            if (dsCompany.Tables[0].Rows.Count > 0)
            {
                ddlCompany.DataSource = dsCompany;
                ddlCompany.DataTextField = "CompanyName";
                ddlCompany.DataValueField = "CompanyId";
                ddlCompany.DataBind();
                foreach (ListItem item in ddlCompany.Items)
                {
                    item.Attributes.Add("title", item.Text);
                }
            }
        }
    }
    /// <summary>
    /// Getting Information from resource file and display it in label
    /// </summary>
    /// <param name="ci"></param>
    private void LoadStrings(CultureInfo ci)
    {
        lbl_Header.Text = rm.GetString("UserGroups_ShiftExchange", ci);
        lbl_ActualShift1.Text = rm.GetString("ShiftExchange_ActualShift", ci);
        lbl_ActualShift2.Text = rm.GetString("ShiftExchange_ActualShift", ci);
        lbl_Date1.Text = rm.GetString("Reports_Date", ci);
        //lbl_Date2.Text = rm.GetString("Reports_Date", ci);
        lbl_Employee1Code.Text = rm.GetString("ShiftExchange_Empoyee1Code", ci);
        lbl_Employee1Name.Text = rm.GetString("ShiftExchange_Employee1Name", ci);
        lbl_Employee2Code.Text = rm.GetString("ShiftExchange_Employee2Code", ci);
        lbl_Employee2Name.Text = rm.GetString("ShiftExchange_Empoyee2Name", ci);
        lbl_IndicatesMandatoryFields.Text = rm.GetString("IndicatesMandatoryFields", ci);
        // RequiredFieldValidator1.ErrorMessage = rm.GetString("Validator_ShiftExchange_Employee2Code", ci);
        btn_Back.Text = "&nbsp;&nbsp;" + rm.GetString("btn_Back", ci);
        lblCompany.Text = rm.GetString("EntranceMaster_Company", ci);
        btn_Search.Text = "";
        btn_search2.Text = "";
        lblSelectEmployee.Text = rm.GetString("Shift_SelectEmployee", ci);
        lbl_Mandatory.Text = rm.GetString("IndicatesMandatoryFields", ci);
        btn_Save.Text = "&nbsp;&nbsp;" + rm.GetString("btn_Save", ci);
        ddlCompany.Items[0].Text = rm.GetString("Select", ci);
        lblLoading.Text = rm.GetString("ProgressBarText", ci);
    }
    private int CheckOverLapping(DateTime dtmStartDate, DateTime dtmToDate, string EmployeeId, int shiftId)
    {
        //Get Permanent Shift Allocation table data from Database using (Previous Date shift to Shift Exchange Date and Next Day shift to Shift Exchange Date and EmployeeId)  
        DataSet dsPermanentShiftAllocation = new DataSet();
        dsPermanentShiftAllocation = objShiftAllocation.SelectPermanentShiftAllocationForDates(dtmStartDate, dtmToDate, EmployeeId);
        DataTable dtPermanentShiftAllocation = new DataTable();
        DataColumn dcEmployeeId = new DataColumn("EmployeeId");
        DataColumn dcShiftDate = new DataColumn("ShiftDate", System.Type.GetType("System.DateTime"));
        DataColumn dcShiftId = new DataColumn("ShiftId");
        DataRow dRow;
        dtPermanentShiftAllocation.Columns.Add(dcEmployeeId);
        dtPermanentShiftAllocation.Columns.Add(dcShiftDate);
        dtPermanentShiftAllocation.Columns.Add(dcShiftId);
        for (DateTime StartDate = dtmStartDate; StartDate <= dtmToDate; StartDate = StartDate.AddDays(1))
        {
            dRow = dtPermanentShiftAllocation.NewRow();
            dRow["EmployeeId"] = EmployeeId;
            dRow["ShiftDate"] = StartDate.ToShortDateString();
            dRow["ShiftId"] = "0";
            dRow.EndEdit();
            dtPermanentShiftAllocation.Rows.Add(dRow);
        }
        foreach (DataRow dRowPermanentShift in dsPermanentShiftAllocation.Tables[0].Rows)
        {
            foreach (DataRow dRowPermanentdt in dtPermanentShiftAllocation.Rows)
            {
                if (Convert.ToDateTime(dRowPermanentShift["ShiftDate"]).ToShortDateString() == Convert.ToDateTime(dRowPermanentdt["ShiftDate"]).ToShortDateString())
                {
                    if (Convert.ToInt32(dRowPermanentShift["ShiftId"]) != 0)
                    {
                        dRowPermanentdt["ShiftId"] = dRowPermanentShift["ShiftId"];
                    }
                }
            }
        }
        DataSet dsTempShiftAllocation = new DataSet();
        dsTempShiftAllocation = objShiftAllocation.SelectTemporarayShiftAllocationForDates(dtmStartDate, dtmToDate, EmployeeId);
        DataTable dtTempShiftAllocation = new DataTable();
        DataColumn dcTempEmployeeId = new DataColumn("EmployeeId");
        DataColumn dcTempShiftDate = new DataColumn("ShiftDate", System.Type.GetType("System.DateTime"));
        DataColumn dcTempShiftId = new DataColumn("ShiftId");
        DataRow dRowTemp;
        dtTempShiftAllocation.Columns.Add(dcTempEmployeeId);
        dtTempShiftAllocation.Columns.Add(dcTempShiftDate);
        dtTempShiftAllocation.Columns.Add(dcTempShiftId);
        for (DateTime StartDate = dtmStartDate; StartDate <= dtmToDate; StartDate = StartDate.AddDays(1))
        {
            dRowTemp = dtTempShiftAllocation.NewRow();
            dRowTemp["ShiftDate"] = StartDate.ToShortDateString();
            dRowTemp["ShiftId"] = "0";
            dRowTemp["EmployeeId"] = EmployeeId;
            dRowTemp.EndEdit();
            dtTempShiftAllocation.Rows.Add(dRowTemp);
        }
        foreach (DataRow dRowTemporaryShift in dsTempShiftAllocation.Tables[0].Rows)
        {
            foreach (DataRow dRowTempdt in dtTempShiftAllocation.Rows)
            {
                if (Convert.ToDateTime(dRowTemporaryShift["ShiftDate"]).ToShortDateString() == Convert.ToDateTime(dRowTempdt["ShiftDate"]).ToShortDateString())
                {
                    if (Convert.ToInt32(dRowTemporaryShift["ShiftId"]) != 0)
                    {
                        dRowTempdt["ShiftId"] = dRowTemporaryShift["ShiftId"];
                    }
                }
            }
        }
        //OverWrite Temporary Table on Permanent Table
        foreach (DataRow dRowTempOver in dtTempShiftAllocation.Rows)
        {
            foreach (DataRow dRowPermanentOver in dtPermanentShiftAllocation.Rows)
            {
                if (Convert.ToDateTime(dRowPermanentOver["ShiftDate"]).ToShortDateString() == dtmStartDate.AddDays(1).ToShortDateString())
                {
                    dRowPermanentOver["ShiftId"] = shiftId;
                }
                else if (Convert.ToInt32(dRowTempOver["ShiftId"]) != 0)
                {
                    dRowPermanentOver["ShiftId"] = dRowTempOver["ShiftId"];
                }
            }
        }
        //Check shift Time Overlapping 
        ShiftPatternEventData objShiftPatternOverLap = new ShiftPatternEventData();
        DataSet dsOverLapping = new DataSet();
        int intOverLap = 0;
        int ShiftCount = dtPermanentShiftAllocation.Rows.Count;
        for (int i = 0; i < ShiftCount - 1; i++)
        {
            int ShiftId1 = Convert.ToInt32(dtPermanentShiftAllocation.Rows[i]["ShiftId"]);
            int ShiftId2 = Convert.ToInt32(dtPermanentShiftAllocation.Rows[i + 1]["ShiftId"]);
            dsOverLapping = objShiftPatternOverLap.CheckShiftOverLapping(ShiftId1, ShiftId2);
            if (dsOverLapping.Tables.Count > 0)
            {
                if (dsOverLapping.Tables[0].Rows.Count > 0)
                {
                    intOverLap = Convert.ToInt32(dsOverLapping.Tables[0].Rows[0]["ShiftOverLapping"]);
                }
            }
            if (intOverLap > 0)
            {
                return intOverLap;
            }
        }
        return 0;
    }
    #endregion
    #region Button Events
    protected void btn_Save_Click(object sender, EventArgs e)
    {
        int intCompanyId = 0;
        string level = string.Empty;
        gstrDateFormat = Convert.ToString(Session["MDateFormat"]);
        gstrShiftFormat = objcls_Common.DateConvertion(gstrDateFormat, txt_E1Date.Text);
        ExchangeDate = gstrShiftFormat;
        Edate1 = Convert.ToDateTime(gstrShiftFormat);
        date1 = Edate1.Day.ToString();
        month1 = Edate1.Month.ToString();
        year1 = Edate1.Year.ToString();
        //Select Employee1 ShiftId
        shiftId1 = obj.SelectShiftId(txt_Ecode1.Text.Trim(), year1, month1, date1);
        gstrShiftFormat = objcls_Common.DateConvertion(gstrDateFormat, txt_E1Date.Text);
        Edate2 = Convert.ToDateTime(gstrShiftFormat);
        date2 = Edate2.Day.ToString();
        month2 = Edate2.Month.ToString();
        year2 = Edate2.Year.ToString();
        DateTime curDate = DateTime.Now.Date;
        int dateDiff = 0;
        dateDiff = curDate.CompareTo(Edate2);
        if (ddlCompany.SelectedValue != "0")
        {
            intCompanyId = Convert.ToInt32(ddlCompany.SelectedValue);
        }
        else
        {
            //lbl_Error.Text = "Select Company";
            //base.Message(rm.GetString ("Alert_ShiftpatternSelectCompany",ci));
            ScriptManager.RegisterStartupScript(this, this.GetType(), "Alert", "alert('" + rm.GetString("Alert_Select_Company", ci) + "');", true);
            return;
        }
        #region Comment The Code As Per Discussion With Team Meeting To Allow Past Date Entry Ref Bug No : 0020702 By A.K.T.Moorthi
        ////if (gstrUserGroupName != "SuperAdmin")
        ////{
        //if (dateDiff > 0)
        //{
        //    //lbl_Info.Text = "Shift cannot be exchanged for past days";
        //    ScriptManager.RegisterStartupScript(this, this.GetType(), "Alert", "alert('" + rm.GetString("Alert_Shiftcannotbeexchangedforpastdays", ci) + "');", true);
        //    // base.Message(rm.GetString ("Alert_Shiftcannotbeexchangedforpastdays",ci));
        //    return;
        //}
        ////} 
        #endregion
        //Select Employee2 ShiftId
        shiftId2 = obj.SelectShiftId(txt_Ecode2.Text.Trim(), year2, month2, date2);
        //shift exchanging
        string strDateShift = month2 + "/1/" + year2;
        //level = rptcommon.getNodes(Convert.ToInt16(Session["parentLevelId"]), Convert.ToString(Session["LevelRights"]));
        level = rptcommon.getNodes(Convert.ToInt16(ddlCompany.SelectedValue), Convert.ToString(Session["LevelRights"]));
        ds_EmployeeAutoId1 = objManualEntryEventData.SelectEmpName(Convert.ToInt32(Session["EmpAutoId"]), txt_Ecode1.Text.Trim(), Convert.ToString(Session["UserGroupName"]), Convert.ToString(Session["GradeLevel"]), level, Convert.ToInt16(ddlCompany.SelectedValue),"");
        string EmployeeId1 = string.Empty;
        if (ds_EmployeeAutoId1.Tables.Count > 0)
        {
            if (ds_EmployeeAutoId1.Tables[0].Rows.Count > 0)
            {
                EmployeeId1 = ds_EmployeeAutoId1.Tables[0].Rows[0]["Employee_Id"].ToString();
            }
            else
            {
                //lbl_Error.Text = "Employee1 not exist in this company";
                ScriptManager.RegisterStartupScript(this, this.GetType(), "Alert", "alert('" + rm.GetString("Msg_Employee1notexistinthiscompany", ci) + "');", true);
                //base.Message(rm.GetString ("Msg_Employee1notexistinthiscompany",ci));
                return;
            }
        }
        //int Employee1Count = obj.CheckShiftExchangeEmployee(level, EmployeeId1);
        //if (Employee1Count == 0)
        //{
        //    lbl_Error.Text = "Employee1 Not in the Organization";
        //    return;
        //}
        ds_EmployeeAutoId2 = objManualEntryEventData.SelectEmpName(Convert.ToInt32(Session["EmpAutoId"]), txt_Ecode2.Text.Trim(), Convert.ToString(Session["UserGroupName"]), Convert.ToString(Session["GradeLevel"]), level, Convert.ToInt16(ddlCompany.SelectedValue),"");
        string EmployeeId2 = string.Empty;
        if (ds_EmployeeAutoId2.Tables.Count > 0)
        {
            if (ds_EmployeeAutoId2.Tables[0].Rows.Count > 0)
            {
                EmployeeId2 = ds_EmployeeAutoId2.Tables[0].Rows[0]["Employee_Id"].ToString();
            }
            else
            {
                //lbl_Error.Text = "Employee2 not exist in this company";
                //base.Message(rm.GetString ("Msg_Employee2notexistinthiscompany",ci));
                ScriptManager.RegisterStartupScript(this, this.GetType(), "Alert", "alert('" + rm.GetString("Msg_Employee2notexistinthiscompany", ci) + "');", true);
                return;
            }
        }
        //Check Overlapping for Employee1
        int OverLapping = 0;
        DateTime StartDate = Edate1.AddDays(-1);
        DateTime EndDate = Edate1.AddDays(1);
        OverLapping = CheckOverLapping(StartDate, EndDate, EmployeeId1, shiftId2);
        if (OverLapping > 0)
        {
            //lbl_Error.Text = "Shift Over Lapped for Employee1";
            // base.Message(rm.GetString ("Msg_ShiftOverLappedforEmployee1",ci));
            ScriptManager.RegisterStartupScript(this, this.GetType(), "Alert", "alert('" + rm.GetString("Msg_ShiftOverLappedforEmployee1", ci) + "');", true);
            return;
        }
        //Check Overlapping for Employee2
        OverLapping = CheckOverLapping(StartDate, EndDate, EmployeeId2, shiftId1);
        if (OverLapping > 0)
        {
            //lbl_Error.Text = "Shift Over Lapped for Employee2";
            // base.Message(rm.GetString ("Msg_ShiftOverLappedforEmployee2",ci));
            ScriptManager.RegisterStartupScript(this, this.GetType(), "Alert", "alert('" + rm.GetString("Msg_ShiftOverLappedforEmployee2", ci) + "');", true);
            return;
        }
        DataSet ds_Shift = objShiftAllocation.CheckLeaveAndPermissionWhileDeleteEmpShift((EmployeeId1 + ", " + EmployeeId2), gstrShiftFormat, gstrShiftFormat, "SEC");
        if (ds_Shift.Tables.Count > 0)
        {
            if (ds_Shift.Tables[0].Rows.Count > 0)
            {
                string strMessage = Convert.ToString(ds_Shift.Tables[0].Rows[0][0]);
                if (strMessage != string.Empty)
                {
                    ScriptManager.RegisterStartupScript(this, this.GetType(), "Alert", "alert('" + rm.GetString(strMessage, ci) + "');", true);
                    txt_E1Date.Focus();
                    return;
                }
            }
        }
        //Get Year Setting Id
        DataSet dsYearSetting = new DataSet();
        YearSettingsEventData objYearSettingsEventData = new YearSettingsEventData();
        int YearSettingsId;
        dsYearSetting = objYearSettingsEventData.GetActiveYearSettings();
        if (dsYearSetting.Tables[0].Rows.Count <= 0)
        {
            return;
        }
        else
        {
            YearSettingsId = Convert.ToInt32(dsYearSetting.Tables[0].Rows[0]["YearSettings_Id"]);
        }
        int intCount = objShiftAllocation.CheckTempShiftAllocation(int.Parse(EmployeeId1), int.Parse(year2), int.Parse(month2));
        if (intCount == 0)
        {
            objShiftAllocation.InsertTempShiftAllocation(int.Parse(EmployeeId1), int.Parse(year2), int.Parse(month2), gintUserId, DateTime.Now.ToString("MM/dd/yyyy HH:mm:ss tt"), strDateShift);
            obj.UpdateTempShift_ShiftExch(int.Parse(EmployeeId1), shiftId2, int.Parse(date2), int.Parse(month2), int.Parse(year2), gintUserId, DateTime.Now.ToString("MM/dd/yyyy HH:mm:ss tt"), strDateShift);
        }
        else
        {
            obj.UpdateTempShift_ShiftExch(int.Parse(EmployeeId1), shiftId2, int.Parse(date2), int.Parse(month2), int.Parse(year2), gintUserId, DateTime.Now.ToString("MM/dd/yyyy HH:mm:ss tt"), strDateShift);
        }
        string strDateShift1 = month1 + "/1/" + year1;
        //ds_EmployeeAutoId2 = objManualEntryEventData.SelectEmpName(txt_Ecode2.Text.Trim(),Convert.ToString(Session["UserGroupName"]), Convert.ToString(Session["GradeLevel"]));
        //string EmployeeId2 = ds_EmployeeAutoId2.Tables[0].Rows[0]["Employee_Id"].ToString();
        //int Employee2Count = obj.CheckShiftExchangeEmployee(level, EmployeeId2);
        //if (Employee2Count == 0)
        //{
        //    lbl_Error.Text = "Employee2 Not in the Organization";
        //    return;
        //}
        // Check for Duplicate
        int intCount1 = objShiftAllocation.CheckTempShiftAllocation(int.Parse(EmployeeId2), int.Parse(year1), int.Parse(month1));
        if (intCount1 == 0)
        {
            objShiftAllocation.InsertTempShiftAllocation(int.Parse(EmployeeId2), int.Parse(year1), int.Parse(month1), gintUserId, DateTime.Now.ToString("MM/dd/yyyy HH:mm:ss tt"), strDateShift1);
            obj.UpdateTempShift_ShiftExch(int.Parse(EmployeeId2), shiftId1, int.Parse(date1), int.Parse(month1), int.Parse(year1), gintUserId, DateTime.Now.ToString("MM/dd/yyyy HH:mm:ss tt"), strDateShift1);
        }
        else
        {
            obj.UpdateTempShift_ShiftExch(int.Parse(EmployeeId2), shiftId1, int.Parse(date1), int.Parse(month1), int.Parse(year1), gintUserId, DateTime.Now.ToString("MM/dd/yyyy HH:mm:ss tt"), strDateShift1);
        }
        //Insert Shift Exchange details in Shift Exchange table
        obj.InsertEmployeeShiftExchange(intCompanyId, ExchangeDate, int.Parse(EmployeeId1), shiftId1, int.Parse(EmployeeId2), shiftId2, gintUserId, DateTime.Now.ToString("MM/dd/yyyy HH:mm:ss tt"), YearSettingsId);
        txt_E1ActualShift.Text = "";
        txt_E1Date.Text = "";
        txt_E2ActualShift.Text = "";
        //txt_E2Date2.Text = "";
        txt_Ecode1.Text = "";
        txt_Ecode2.Text = "";
        string strScript = "";
        strScript = strScript + "<script language='javascript'>";
        strScript = strScript + "alert('" + rm.GetString("Alert_ShiftExchangedSuccessfully", ci) + "');";
        strScript = strScript + "location.replace('TA_UI_Transaction_ShiftExchangeList.aspx');";
        strScript = strScript + "</script>";
        //Dispaly alert messsage.
        ScriptManager.RegisterStartupScript(this, this.GetType(), "Alert", strScript, false);
        //Page.RegisterStartupScript("alert", strScript);
        //lbl_Info.Text = "Shift Exchanged Successfully";
    }
    protected void btn_Back_Click(object sender, EventArgs e)
    {
        Response.Redirect("TA_UI_Transaction_ShiftExchangeList.aspx");
    }
    #endregion
}
