using System;
using System.Data;
using System.Globalization;
using System.IO;
using System.Resources;
using System.Threading;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using DevExpress.Web;
using System.Configuration;
using System.Text;
using System.Collections;
using System.Collections.Generic;
using System.Linq;

public partial class Masters_Landmarks : Base.BasePage
{
    #region VariableDeclaration
    ResourceManager rm;
    CultureInfo ci;
    EmployeeEventData objEmployee = new EmployeeEventData();
    cls_Common objcommon = new cls_Common();
    Cls_CheckUser objCheckUser = new Cls_CheckUser();
    DemoVersion objDemoVersion = new DemoVersion();
    DataSet ds_Checkuser = new DataSet();
    int EmployeeID = 0;
    string source_Language;
    LeaveEventData objLeave = new LeaveEventData();
    Licensing objLicense = new Licensing();
    string strScript = string.Empty;
    ResetPwd obj_ResetPwd = new ResetPwd();
    int isTriggered = 0;
    Email_Triggering objEmail = new Email_Triggering();
    Geofencing objgeo = new Geofencing();
    int intIndividualUser = 0;
    Int64 geoLandMarkID = 0;
    Int64 geoFencingID = 0;
    string[] arrayHdnChk;
    string gstrUserGroupName = string.Empty;
    ShiftEvenData objShift = new ShiftEvenData();
    Table tbl_FencingLocation = new Table();
    int CompanyID;
    DataTable dt_Landmarkvalue = new DataTable();
    #endregion    
    protected override void Page_Load(object sender, EventArgs e)
    {
        base.Page_Load(sender, e);
        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"]);
        EmployeeID = Convert.ToInt32(Session["EmpAutoID"]);
        grvLandmarks.Styles.CssFilePath = Convert.ToString(Session["GridCSS"]);
        gstrUserGroupName = Convert.ToString(Session["UserGroupName"]);
        if (!Page.IsPostBack)
        {
            //Set UserRights
            base.CheckPages(18);
            UserRights();
            LoadStrings(ci);
            Session["Level"] = string.Empty;
            Session["EmployeeData"] = null;
            objcommon.menu("Geofencing", "286");
            StringBuilder map = new StringBuilder();
            StringBuilder sb = new StringBuilder();
            sb.Append("<script type='text/javascript' src='" + ConfigurationManager.AppSettings["googleMapKey"].ToString() + "'></script>");
            Page.ClientScript.RegisterStartupScript(this.GetType(), "scriptsKey", sb.ToString());

            string strSetAlert = "";
            strSetAlert = strSetAlert + "<script language='javascript'>";
            strSetAlert = strSetAlert + "loadMapControl();";
            strSetAlert = strSetAlert + "</script>";
            Page.RegisterStartupScript("MaxLengthh", strSetAlert);
            GetLandmarkStatus();
            ClearFields(this);
            CompanyBinding();

            //LoadDynamicPanel();


            // Dynamic Fencing Table From Create
            //TaxSlabAutoGenerate();
            //PH_DynmCtrl.Controls.Add(tbl_FencingLocation);

        }
        BindLandmarkGridview(0);
        BindFencingGridview(0);
        BindLandamrkIdsGridView(0);
        // DynamicLoadLandMark(string.Empty);
    }

    //public void page_init()
    //{
    //    DataSet dsFencing = new DataSet();
    //    DataSet dsLandmark = new DataSet();
    //    DataSet dsLandmarkIds = new DataSet();

    //    if (Session["FencingGrid"] != null)
    //    {
    //        dsFencing = (DataSet)Session["FencingGrid"];
    //        grvFencing.DataSource = dsFencing;
    //        grvFencing.DataBind();
    //    }
    //    if (Session["LandamrkGrid"] != null)
    //    {
    //        dsLandmark = (DataSet)Session["LandamrkGrid"];
    //        grvLandmarks.DataSource = dsLandmark;
    //        grvLandmarks.DataBind();
    //    }
    //    if(Session["LandamarkIdsGrid"]!=null)
    //    {
    //        dsLandmarkIds = (DataSet)Session["LandamarkIdsGrid"];
    //        grvLandmarkIds.DataSource = dsLandmarkIds;
    //        grvLandmarkIds.DataBind();
    //    }
    //}

    public void BindLandmarkGridview(int landMarkID)
    {
        if (ViewState["CanView"] != null)
        {
            if (Convert.ToBoolean(ViewState["CanView"]) == false)
            {
                grvLandmarks.Visible = false;
                return;
            }
        }
        DataSet dslandmarkDetails = new DataSet();
        dslandmarkDetails = objgeo.GetLandmarkDetails(landMarkID);
        if (dslandmarkDetails.Tables.Count > 0)
        {
            if (dslandmarkDetails.Tables[0].Rows.Count > 0)
            {
                grvLandmarks.Visible = true;
                grvLandmarks.DataSource = dslandmarkDetails;
                grvLandmarks.DataBind();
                Session["LandamrkGrid"] = dslandmarkDetails;


            }
        }
    }

    private void BindLandamrkIdsGridView(int landmarkIds)
    {

        DataSet dsLanmarkIds = new DataSet();

        if (landmarkIds > 0)
        {
            dsLanmarkIds = objgeo.GetLandmarkDetails(landmarkIds);
            grvLandmarkIds.DataSource = dsLanmarkIds;
            grvLandmarkIds.DataBind();
            dt_Landmarkvalue = dsLanmarkIds.Tables[0];
        }
        else if (landmarkIds == 0 && Convert.ToString(hdnSelectLandamrkIdsRow.Value) != "")
        {
            dsLanmarkIds = objgeo.GetLandmarkDetails(landmarkIds);
            grvLandmarkIds.DataSource = dsLanmarkIds;
            grvLandmarkIds.DataBind();


            String Check = "";
            String lbllatitude = "";
            String lbllongitude = "";
            String ids = "";
            int Count = Convert.ToInt32(grvLandmarkIds.Rows.Count.ToString());
            for (int i = 0; i < Count; i++)
            {
                string valuesToCheck = Convert.ToString(hdnSelectLandamrkIdsRow.Value);
                string[] valuesArray = valuesToCheck.Split(',');
                Check = (grvLandmarkIds.Rows[i].FindControl("lblLandID") as Label).Text;
                foreach (string id in valuesArray)
                {
                    ids = id;
                    if (Check == ids)
                    {
                        (grvLandmarkIds.Rows[i].FindControl("chkSelects") as HtmlInputCheckBox).Checked = true;
                        //(grvLandmarkIds.Rows[i].FindControl("chkSelects") as CheckBox).Checked = true;
                        lbllatitude = (grvLandmarkIds.Rows[i].FindControl("lbllatitude") as Label).Text;
                        lbllongitude = (grvLandmarkIds.Rows[i].FindControl("lbllongitude") as Label).Text;

                        hdnSelectedLandmarkValue.Value += ids + ",";
                        hdnSelectedLat.Value += lbllatitude + ",";
                        hdnSelectedLong.Value += lbllongitude + ",";

                        //hdnSelectedLat.Value 
                        //hdnSelectedLong.Value 

                    }
                }






            }




            string jsScript = string.Empty;
            string viewLandmark = "<script>";
            viewLandmark += " FencingPolygon(1,1); ";
            viewLandmark += "</script>";
            ScriptManager.RegisterStartupScript(this, this.GetType(), "viewLandmark", viewLandmark, false);
            hdnSelectLandamrkIdsRow.Value = "";
        }
        else
        {
            dsLanmarkIds = objgeo.GetLandmarkDetails(landmarkIds);
            grvLandmarkIds.DataSource = dsLanmarkIds;
            grvLandmarkIds.DataBind();



            Session["LandamarkIdsGrid"] = dsLanmarkIds;
            dt_Landmarkvalue = dsLanmarkIds.Tables[0];
        }
    }

    //private void GetEmployeeIdsInOtherPagesOfGrid(bool chkboxstatus)
    //{

    //    DataSet ds = new DataSet();
    //    ds = (DataSet)Session["LandamarkIdsGrid"];
    //    foreach (DataRow dr in ds.Tables[0].Rows)
    //    {
    //        if (Convert.ToString(dr["EmailId"]) != "")
    //            dr["emailScheduler_flag"] = Convert.ToInt16(chkboxstatus);
    //    }
    //    ds.Tables[0].AcceptChanges();
    //    ViewState["Employees"] = ds;
    //    CheckBox deleteChkBxItem = new CheckBox();
    //    foreach (GridViewRow gr in grv_EmpDetails.Rows)
    //    {
    //        deleteChkBxItem = (CheckBox)gr.Cells[0].FindControl("deletethis");
    //        Label lblEmailId = (Label)gr.Cells[3].FindControl("lblEmailId");
    //        if (lblEmailId != null)
    //        {
    //            if (lblEmailId.Text != "")
    //            {
    //                if (deleteChkBxItem != null)
    //                {
    //                    deleteChkBxItem.Checked = chkboxstatus;
    //                }
    //            }
    //        }
    //    }
    //}

    private void BindFencingGridview(int fecningId)
    {
        DataSet dsFencingDetails = new DataSet();
        dsFencingDetails = objgeo.GetFencingDetails(fecningId);
        if (dsFencingDetails.Tables.Count > 0)
        {
            if (dsFencingDetails.Tables[0].Rows.Count > 0)
            {
                grvFencing.Visible = true;
                grvFencing.DataSource = dsFencingDetails;
                grvFencing.DataBind();
                Session["FencingGrid"] = dsFencingDetails;
            }
        }


    }


    /// <summary>
    /// To check rights for the logged in user
    /// </summary>
    private void UserRights()
    {
        if (ViewState["vs_ds_Checkuser"] == null)
        {
            ds_Checkuser = objCheckUser.checkRights(286, Convert.ToInt32(Session["userGroup_Id"]), "");
            ViewState["vs_ds_Checkuser"] = ds_Checkuser;
        }
        else
            ds_Checkuser = (DataSet)ViewState["vs_ds_Checkuser"];
        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.lnkbtnSave.Visible = true;
                ViewState["CanAdd"] = true;
            }
            else
            {
                this.lnkbtnSave.Visible = false;
                ViewState["CanAdd"] = false;
            }
            if (ds_Checkuser.Tables[0].Rows[0]["viewPrv"] != DBNull.Value && Convert.ToInt32(ds_Checkuser.Tables[0].Rows[0]["viewPrv"]) == 1)
            {
                ViewState["CanView"] = true;
            }
            else
            {
                ViewState["CanView"] = false;
                grvLandmarks.Visible = false;
            }
            if (ds_Checkuser.Tables[0].Rows[0]["modifyPrv"] != DBNull.Value && Convert.ToInt32(ds_Checkuser.Tables[0].Rows[0]["modifyPrv"]) == 1)
            {
                this.grvLandmarks.Columns[1].Visible = true;
            }
            else
                this.grvLandmarks.Columns[1].Visible = false;
            if (ds_Checkuser.Tables[0].Rows[0]["deletePrv"] != DBNull.Value && Convert.ToInt32(ds_Checkuser.Tables[0].Rows[0]["deletePrv"]) == 1)
            {
                this.lnkbtnDelete.Visible = true;
                this.grvLandmarks.Columns[2].Visible = true;
            }
            else
            {
                this.lnkbtnDelete.Visible = false;
                this.grvLandmarks.Columns[2].Visible = false;
            }
        }
        else
        {
            Response.Redirect("MasterLandingPage.aspx");
        }
    }
    /// <summary>
    /// Getting Information from resource file and display it in label
    /// </summary>
    /// <param name="ci"></param>
    private void LoadStrings(CultureInfo ci)
    {
        lblfenchType.Text = rm.GetString("fenchType", ci);
        lblLocat.Text = rm.GetString("LocationName", ci);
        lblDescript.Text = rm.GetString("Description", ci);
        lblAddress.Text = rm.GetString("Address", ci);
        lbllatelng.Text = rm.GetString("LatLng", ci);
        btnAddress.Text = rm.GetString("LocateMe", ci);
        lnkbtnSave.Text = "&nbsp;&nbsp;" + rm.GetString("AddLocation", ci);
        lblcompany.Text = rm.GetString("EntranceMaster_Company", ci);
        //lbl_IndicatesMandatoryFields.Text = rm.GetString("IndicatesMandatoryFields", ci);
        btnCancel.Text = rm.GetString("btn_Cancel", ci);
    }

    protected void lnkbtnSave_Click(object sender, EventArgs e)
    {
        if (txtLocationName.Text == string.Empty)
        {
            Message("Enter Location Name");
            return;
        }
        if (ddlType.SelectedItem.Value == "1")
        {
            if (txtstreet.Text == string.Empty)
            {
                Message("Enter Address");
                return;
            }
        }
        else if (ddlType.SelectedItem.Value == "1")
        {
            if (txtlat.Text == string.Empty)
            {
                Message("Enter Address");
                return;
            }
            else if (txtlong.Text == string.Empty)
            {
                Message("Enter Address");
                return;
            }
        }
        bool isDuplicate = objgeo.CheckDuplicateLandmarkName((ViewState["Id"] != null) ? "" : txtLocationName.Text.Trim());

        if (isDuplicate)
        {
            string alertMsg = "<script>alert('Given Location Name is already available, please give some other name');showControls(document.getElementById('ctl00_BodyContentPH_ddlType').selectedIndex);SetCenter();</script>";
            ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "regJSDupLandmark", alertMsg, false);
            txtLocationName.Focus();
            return;
        }
        Int32 radius = (Convert.ToString(txtRadius.Text) == "") ? 0 : Convert.ToInt16(txtRadius.Text);
        objgeo.InsertGeoLocationDetails(Convert.ToString(ddlType.SelectedItem.Text), Convert.ToString(txtLocationName.Text), radius, Convert.ToString(txtLocationDesc.Text), Convert.ToString(txtstreet.Text), Convert.ToString(txtcity.Text), Convert.ToString(txtstate.Text), Convert.ToString(txtCountry.Text), Convert.ToString(txtlat.Text), Convert.ToString(txtlong.Text), Convert.ToString(Session["EmpAutoID"]), (ViewState["Id"] == null) ? "I" : "U", (ViewState["strEditLandMarkId"] == null) ? 0 : Convert.ToInt64(ViewState["strEditLandMarkId"]));

        if (ViewState["Id"] == null)
        {
            Altermessage("add");
        }
        else
        {
            Altermessage("modify");
        }
        BindGridview(0);
        BindLandamrkIdsGridView(0);

        //landamarkDiv.Visible = false;
        //landmarkGrid.Visible = true;
        //btn_Add.Visible = true;
        //lnkbtnDelete.Visible = true;
        ////DynamicLoadLandMark(string.Empty);
        //ClearFields(this);
    }

    private void Altermessage(string isAddOrupdate)
    {
        string strScript = "";
        strScript = strScript + "<script language='javascript'>";
        string alertmsg = (isAddOrupdate == "add") ? "Location Details Saved Successfully" : "Location Details Modified Successfully";
        strScript = strScript + "showControls(document.getElementById('ctl00_BodyContentPH_ddlType').selectedIndex);alert('" + alertmsg + "');";
        strScript = strScript + "</script>";
        ScriptManager.RegisterStartupScript(this, this.GetType(), "Alert", strScript, false);


    }


    /// <summary>
    /// Multilingual for Landmark type
    /// </summary>
    public void GetLandmarkStatus()
    {
        if (ddlType.Items.Count == 0)
        {
            ListItem lidefault = new ListItem();
            lidefault.Text = "--- Select----";
            lidefault.Value = "0";
            ddlType.Items.Add(lidefault);
            ListItem liStreet = new ListItem();
            liStreet.Text = "Street Address";
            liStreet.Value = "addr";
            ddlType.Items.Add(liStreet);
            ListItem liMessages = new ListItem();
            liMessages.Text = "Map Coordinates";
            liMessages.Value = "ltlng";
            ddlType.Items.Add(liMessages);
            ddlType.SelectedIndex = 0;
        }
    }
    protected void btnAddress_Click(object sender, EventArgs e)
    {
        string jsScript = string.Empty;
        string viewLandmark = "<script>";
        viewLandmark += "showControls(document.getElementById('ctl00_BodyContentPH_ddlType').selectedIndex);";
        viewLandmark += "showAddress(); ";
        viewLandmark += "</script>";
        ScriptManager.RegisterStartupScript(grvLandmarks, this.GetType(), "viewLandmark", viewLandmark, false);
    }
    public void BindGridview(int landMarkID)
    {
        if (ViewState["CanView"] != null)
        {
            if (Convert.ToBoolean(ViewState["CanView"]) == false)
            {
                grvLandmarks.Visible = false;
                return;
            }
        }
        DataSet dslandmarkDetails = new DataSet();
        dslandmarkDetails = objgeo.GetLandmarkDetails(landMarkID);
        if (dslandmarkDetails.Tables.Count > 0)
        {
            if (dslandmarkDetails.Tables[0].Rows.Count > 0)
            {
                grvLandmarks.Visible = true;
                grvLandmarks.DataSource = dslandmarkDetails;
                grvLandmarks.DataBind();
                dt_Landmarkvalue = dslandmarkDetails.Tables[0];
            }
        }


    }

    protected void ibEdit_Click(object sender, EventArgs e)
    {
        LinkButton btnEdit = (LinkButton)sender;
        string strLandMarkId = btnEdit.CommandArgument.ToString();
        if (ViewState["strEditLandMarkId"] == null || ViewState["strEditLandMarkId"].ToString() != strLandMarkId)
        {
            ClearFields(this);
            string strLandmarkType = Convert.ToString(grvLandmarks.GetRowValuesByKeyValue(strLandMarkId, "Options"));
            string strLandMark = Convert.ToString(grvLandmarks.GetRowValuesByKeyValue(strLandMarkId, "LocationName"));
            string strRadius = Convert.ToString(grvLandmarks.GetRowValuesByKeyValue(strLandMarkId, "Radius"));
            string strLandMarkDesc = Convert.ToString(grvLandmarks.GetRowValuesByKeyValue(strLandMarkId, "Description"));
            string strAddress = Convert.ToString(grvLandmarks.GetRowValuesByKeyValue(strLandMarkId, "Address")).Replace("\r\n", "");
            string strLat = Convert.ToString(grvLandmarks.GetRowValuesByKeyValue(strLandMarkId, "latitude"));
            string strLong = Convert.ToString(grvLandmarks.GetRowValuesByKeyValue(strLandMarkId, "longitude"));
            string strState = Convert.ToString(grvLandmarks.GetRowValuesByKeyValue(strLandMarkId, "State"));
            string strCity = Convert.ToString(grvLandmarks.GetRowValuesByKeyValue(strLandMarkId, "City"));
            string strCountry = Convert.ToString(grvLandmarks.GetRowValuesByKeyValue(strLandMarkId, "Country"));

            ViewState["Id"] = strLandMarkId;
            ddlType.SelectedIndex = (strLandmarkType == "addr") ? Convert.ToInt16(0) : 1;
            txtLocationName.Text = strLandMark;
            txtRadius.Text = strRadius;
            txtLocationDesc.Text = strLandMarkDesc;
            txtstreet.Text = strAddress;
            txtlat.Text = strLat;
            txtlong.Text = strLong;
            txtstate.Text = strState;
            txtcity.Text = strCity;
            txtCountry.Text = strCountry;
            string editLandmark = "<script>showControls(document.getElementById('ctl00_BodyContentPH_ddlType').selectedIndex);";
            if (ddlType.SelectedIndex == 0)
            {
                editLandmark += "loadMapControl(); showAddress();";
            }
            else
            {
                //editLandmark += "showAddress('" + "" + "','" + ViewState["MapPositionImage"].ToString() + "','" + strAddress.Replace("\n", "") + "'); chkValue = 0;";
                editLandmark += "showAddress();";
            }
            editLandmark += "collapeshow();";
            editLandmark += "</script>";
            ScriptManager.RegisterStartupScript(grvLandmarks, this.GetType(), Guid.NewGuid().ToString(), editLandmark, false);
            updPanel.Update();
            UpdPanel3.Update();
            ViewState["strEditLandMarkId"] = strLandMarkId;
            BindGridview(0);
            lnkbtnSave.Text = "&nbsp;&nbsp;" + Convert.ToString(rm.GetString("ModifyLoaction", ci));
            landamarkDiv.Visible = true;
            landmarkGrid.Visible = false;
            lnkbtnDelete.Visible = false;
            //btn_Back.Visible = true;
            btn_Add.Visible = false;
        }
    }

    //protected void ibView_Click(object sender, EventArgs e)
    //{
    //    LinkButton btnView = (LinkButton)sender;
    //    string strLandMarkId = btnView.CommandArgument.ToString();
    //    if (ViewState["strEditLandMarkId"] == null || ViewState["strEditLandMarkId"].ToString() != strLandMarkId)
    //    {
    //        ClearFields(this);
    //        string strLandmarkType = Convert.ToString(grvLandmarks.GetRowValuesByKeyValue(strLandMarkId, "Options"));
    //        string strLandMark = Convert.ToString(grvLandmarks.GetRowValuesByKeyValue(strLandMarkId, "LocationName"));
    //        string strRadius = Convert.ToString(grvLandmarks.GetRowValuesByKeyValue(strLandMarkId, "Radius"));
    //        string strLandMarkDesc = Convert.ToString(grvLandmarks.GetRowValuesByKeyValue(strLandMarkId, "Description"));
    //        string strAddress = Convert.ToString(grvLandmarks.GetRowValuesByKeyValue(strLandMarkId, "Address")).Replace("\r\n", "");
    //        string strLat = Convert.ToString(grvLandmarks.GetRowValuesByKeyValue(strLandMarkId, "latitude"));
    //        string strLong = Convert.ToString(grvLandmarks.GetRowValuesByKeyValue(strLandMarkId, "longitude"));
    //        string strState = Convert.ToString(grvLandmarks.GetRowValuesByKeyValue(strLandMarkId, "State"));
    //        string strCity = Convert.ToString(grvLandmarks.GetRowValuesByKeyValue(strLandMarkId, "City"));
    //        string strCountry = Convert.ToString(grvLandmarks.GetRowValuesByKeyValue(strLandMarkId, "Country"));

    //        ViewState["Id"] = strLandMarkId;
    //        ddlType.SelectedIndex = (strLandmarkType == "addr") ? Convert.ToInt16(0) : 1;
    //        txtLocationName.Text = strLandMark;
    //        txtRadius.Text = strRadius;
    //        txtLocationDesc.Text = strLandMarkDesc;
    //        txtstreet.Text = strAddress;
    //        txtlat.Text = strLat;
    //        txtlong.Text = strLong;
    //        txtstate.Text = strState;
    //        txtcity.Text = strCity;
    //        txtCountry.Text = strCountry;
    //        string editLandmark = "<script>showControls(document.getElementById('ctl00_BodyContentPH_ddlType').selectedIndex);";
    //        if (ddlType.SelectedIndex == 0)
    //        {
    //            editLandmark += "loadMapControl(); showAddress();";
    //        }
    //        else
    //        {
    //            //editLandmark += "showAddress('" + "" + "','" + ViewState["MapPositionImage"].ToString() + "','" + strAddress.Replace("\n", "") + "'); chkValue = 0;";
    //            editLandmark += "showAddress();";
    //        }
    //        editLandmark += "</script>";
    //        ScriptManager.RegisterStartupScript(grvLandmarks, this.GetType(), Guid.NewGuid().ToString(), editLandmark, false);
    //        updPanel.Update();
    //        ViewState["strEditLandMarkId"] = strLandMarkId;
    //        BindGridview(0);
    //        lnkbtnSave.Text = "&nbsp;&nbsp;" + Convert.ToString(rm.GetString("ModifyLoaction", ci));
    //    }
    //}

    protected void ibDelete_Click(object sender, EventArgs e)
    {
        LinkButton btnDelete = (LinkButton)sender;
        string strLandMarkId = btnDelete.CommandArgument.ToString();
        if (strLandMarkId != null)
        {
            objgeo.DeleteGEOLocationDetails(Convert.ToString(strLandMarkId));
            BindGridview(0);
            BindLandamrkIdsGridView(0);
            //DynamicLoadLandMark(string.Empty);
            //updPanel.Update();
            UpdPanel3.Update();
            ClearFields(this);
            string strScript = "";
            strScript = strScript + "<script language='javascript'>";
            strScript = strScript + "alert('Location Details Deleted Successfully');";
            strScript = strScript + "</script>";
            ScriptManager.RegisterStartupScript(this, this.GetType(), "Alert", strScript, false);
        }
    }
    public void ClearFields(Control ctrl)
    {
        txtcity.Text = string.Empty;
        txtCountry.Text = string.Empty;
        txtlat.Text = string.Empty;
        txtLocationDesc.Text = string.Empty;
        txtLocationName.Text = string.Empty;
        txtlong.Text = string.Empty;
        txtRadius.Text = string.Empty;
        txtstate.Text = string.Empty;
        txtstreet.Text = string.Empty;
        ddlType.SelectedIndex = 0;
        // updPanel.Update();
        //modified on 03-Aug-2010 for showing Map for read only users
        //ScriptManager.RegisterStartupScript(btnCancel, this.GetType(), Guid.NewGuid().ToString(), "loadForLandMark();" + ((!IsPostBack) ?
        //  (hdnCanAddLandmarks.Value.ToString().Equals("true")? "document.getElementById('ddlType').focus();":"") : ""), true);
        //if (ViewState["CanAdd"] != null && Convert.ToBoolean(ViewState["CanAdd"]) == false)
        //{
        ScriptManager.RegisterStartupScript(btnCancel, this.GetType(), Guid.NewGuid().ToString(), "loadMapControl();", true);

        //}
        //else
        //{
        //    ScriptManager.RegisterStartupScript(btnCancel, this.GetType(), Guid.NewGuid().ToString(), "loadMapControl();", true);
        //}
    }

    protected void btnCancel_Click(object sender, EventArgs e)
    {
        ViewState["strEditLandMarkId"] = null;
        if (ViewState["CanAdd"] != null && Convert.ToBoolean(ViewState["CanAdd"]) == false)
        {
            ControlVisibility(false);
        }
        else
        {
            ControlVisibility(true);
        }
        //End
        grvLandmarks.Selection.UnselectAll();
        ClearFields(btnCancel);

        ScriptManager.RegisterClientScriptBlock(ddlType, this.GetType(), Guid.NewGuid().ToString(),
            "showControls(" + ddlType.SelectedIndex + ");", true);

        //btn_Back.Visible = false;
        btn_Add.Visible = true;
        landamarkDiv.Visible = false;
        landmarkGrid.Visible = true;
        lnkbtnDelete.Visible = true;


    }
    /// <summary>
    /// Function to enable/disable & show/hide controls
    /// </summary>
    /// <param name="isEnable"></param>
    private void ControlVisibility(bool isEnable)
    {
        ddlType.Enabled = isEnable;
        txtLocationName.Enabled = isEnable;
        txtRadius.Enabled = isEnable;
        txtLocationDesc.Enabled = isEnable;
        txtstreet.Enabled = isEnable;
        txtcity.Enabled = isEnable;
        txtstate.Enabled = isEnable;
        txtCountry.Enabled = isEnable;
        txtlat.Enabled = isEnable;
        txtlong.Enabled = isEnable;
        btnAddress.Enabled = isEnable;
        //updPanel.Update();
    }

    protected void lnkbtnDelete_Click(object sender, EventArgs e)
    {
        string[] ChkBoxIDs;
        if (hdnSelectRow.Value != string.Empty && hdnSelectRow.Value != null)
        {
            ChkBoxIDs = objLeave.commaStringToArray(hdnSelectRow.Value);
            for (int i = 0; i < ChkBoxIDs.Length; i++)
            {
                int Count = objgeo.CheckGEOLocationUtilization(Convert.ToInt32(ChkBoxIDs[i]));
                if (Count > 0)
                {
                    base.Message("Location cant be deleted");
                    return;
                }
            }
            objgeo.DeleteGEOLocationDetails(Convert.ToString(hdnSelectRow.Value));
            BindGridview(0);
            //updPanel.Update();
            UpdPanel3.Update();
            BindLandamrkIdsGridView(0);
            //DynamicLoadLandMark(string.Empty);
            Message("Location details was deleted Successfully");
        }
        else
        {
            Message(rm.GetString("DeletionRecordAlert", ci));
            return;
        }
    }

    protected void grvLandmarks_HtmlRowCreated(object sender, ASPxGridViewTableRowEventArgs e)
    {
        if (e.RowType == GridViewRowType.Data)
        {
            HtmlInputCheckBox deleteChkBxItem = (HtmlInputCheckBox)grvLandmarks.FindRowCellTemplateControl(e.VisibleIndex, null, "chkSelect");

            if (deleteChkBxItem != null)
            {
                geoLandMarkID = Convert.ToInt16(e.GetValue("id"));
                int Count = objgeo.CheckGEOLocationUtilization(geoLandMarkID);
                LinkButton LnkbtnDelete = (LinkButton)grvLandmarks.FindRowCellTemplateControl(e.VisibleIndex, null, "ibDelete");
                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;
                    }
                }
            }
        }
    }

    #region ICallbackEventHandler Members

    string callbackResult;

    /// <summary>
    /// Gets the callback result.
    /// </summary>
    /// <returns></returns>
    public string GetCallbackResult()
    {
        return callbackResult;
    }

    /// <summary>
    /// Raises the callback event.
    /// </summary>
    /// <param name="eventArgument">The event argument.</param>
    public void RaiseCallbackEvent(string eventArgument)
    {

    }

    #endregion

    protected void btnFencing_Click(object sender, EventArgs e)
    {
        string jsScript = string.Empty;
        string viewLandmark = "<script>";
        viewLandmark += "showControls(document.getElementById('ctl00_BodyContentPH_ddlType').selectedIndex);";
        viewLandmark += "Fencingpolygon(); ";
        viewLandmark += "</script>";
        ScriptManager.RegisterStartupScript(grvLandmarks, this.GetType(), "viewLandmark", viewLandmark, false);

    }

    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)
            {
                BindDropDown(dsCompany, ddlCompany);

            }
        }
    }

    private void BindDropDown(DataSet dsCompany, DropDownList ddl)
    {
        ddl.DataSource = dsCompany;
        ddl.DataTextField = "CompanyName";
        ddl.DataValueField = "CompanyId";
        ddl.DataBind();
        FillTitle(ddl);
    }
    private void FillTitle(DropDownList ddl)
    {
        foreach (ListItem item in ddl.Items)
        {
            item.Attributes.Add("title", item.Text);
        }
    }


    protected void lbtnAddFencing_Click(object sender, EventArgs e)
    {

        LoadLandmarkGrid();
    }


    private void LoadLandmarkGrid()
    {
        if (hdnSelectLandamrkIdsRow.Value != "")
        {
            List<string> lst = hdnSelectLandamrkIdsRow.Value.Split(',').ToList();


            int i = 0;

            if (dt_Landmarkvalue.Rows.Count > 0)
            {
                foreach (DataRow dRow in dt_Landmarkvalue.Rows)
                {
                    if (lst.Count != i)
                    {
                        if (Convert.ToString(dRow["id"]) == lst[i])
                        {
                            hdnSelectedLandmarkValue.Value += lst[i] + ",";
                            hdnSelectedLat.Value += dRow["latitude"] + ",";
                            hdnSelectedLong.Value += dRow["longitude"] + ",";
                            i = i + 1;
                        }
                        else
                        {
                            continue;
                        }
                    }
                    else
                    {
                        break;
                    }

                }
            }
            string jsScript = string.Empty;
            string viewLandmark = "<script>";
            viewLandmark += " FencingPolygon(1,1); ";
            viewLandmark += "</script>";
            ScriptManager.RegisterStartupScript(this, this.GetType(), "viewLandmark", viewLandmark, false);

            CompanyID = ddlCompany.SelectedIndex;
            String FencingNAme = txtFencName.Text;
            int EmpID = EmployeeID;
            //var grid=(GridView) grvLandmarks.
            String LatLong = hdnSelectedLandmarkValue.Value;
            if (CompanyID != 0)
            {
                if (FencingNAme != "" && EmpID != 0 && LatLong != "")
                {
                    DataSet ds = new DataSet();
                    if (Convert.ToString(ViewState["FencingId"]) == "")
                    {
                        ds = objgeo.InsertUpdateGeoFencing("I", FencingNAme, CompanyID, EmpID, LatLong, 0);
                        ScriptManager.RegisterStartupScript(this, this.GetType(), "Alert", "alert('Geofecning saved sucessfully')", true);
                        BindFencingGridview(0);
                        BindLandamrkIdsGridView(0);
                        UpdPanel4.Update();

                    }
                    else
                    {
                        ds = objgeo.InsertUpdateGeoFencing("U", FencingNAme, CompanyID, EmpID, LatLong, Convert.ToInt32(ViewState["FencingId"]));
                        ScriptManager.RegisterStartupScript(this, this.GetType(), "Alert", "alert('Geofecing modify sucessfully')", true);
                        BindFencingGridview(0);
                        BindLandamrkIdsGridView(0);
                        UpdPanel4.Update();
                    }
                }
            }
        }
        else
        {

            string jsScript = string.Empty;
            string viewLandmark = "<script>";
            viewLandmark += " FencingPolygon(1,1); ";
            viewLandmark += "</script>";
            ScriptManager.RegisterStartupScript(this, this.GetType(), "viewLandmark", viewLandmark, false);

            CompanyID = ddlCompany.SelectedIndex;
            String FencingNAme = txtFencName.Text;
            int EmpID = EmployeeID;
            //var grid=(GridView) grvLandmarks.
            String LatLong = hdnSelectRow.Value;
            //String LatLong = hdnSelectedLandmarkValue.Value;
            if (CompanyID != 0)
            {
                if (FencingNAme != "" && EmpID != 0 && LatLong != "")
                {
                    DataSet ds = new DataSet();
                    if (Convert.ToString(ViewState["FencingId"]) == "")
                    {
                        ds = objgeo.InsertUpdateGeoFencing("I", FencingNAme, CompanyID, EmpID, LatLong, 0);
                        ScriptManager.RegisterStartupScript(this, this.GetType(), "Alert", "alert('Geofecning saved sucessfully')", true);
                        BindFencingGridview(0);
                        BindLandamrkIdsGridView(0);
                        UpdPanel4.Update();

                    }
                    else
                    {
                        ds = objgeo.InsertUpdateGeoFencing("U", FencingNAme, CompanyID, EmpID, LatLong, Convert.ToInt32(ViewState["FencingId"]));
                        ScriptManager.RegisterStartupScript(this, this.GetType(), "Alert", "alert('Geofecing modify sucessfully')", true);
                        BindFencingGridview(0);
                        BindLandamrkIdsGridView(0);
                        UpdPanel4.Update();
                    }
                }
            }
        }
        FencingGrid.Visible = true;
        lbtnFecingAdd.Visible = true;
        lbtnFencingDelete.Visible = false;
        FencingDiv.Visible = false;

    }

    //    //private void LoadLandmarkGrid()
    //    {
    //        hdnSelectedLandmarkValue.Value = "";

    //        if (dt_Landmarkvalue.Rows.Count > 0)
    //        {
    //            foreach (DataRow dRow in dt_Landmarkvalue.Rows)
    //            {
    //                CheckBox chk = (CheckBox)PH_DynmCtrl.FindControl(Convert.ToString(dRow["ID"]));
    //                if (chk.Checked)
    //                {
    //                    hdnSelectedLandmarkValue.Value += chk.ID + ",";
    //                    hdnSelectedLat.Value += dRow["latitude"] + ",";
    //                    hdnSelectedLong.Value += dRow["longitude"] + ",";
    //                }
    //            }
    //        }

    //        string jsScript = string.Empty;
    //string viewLandmark = "<script>";
    //viewLandmark += " FencingPolygon(1,1); ";
    //        viewLandmark += "</script>";
    //        ScriptManager.RegisterStartupScript(this, this.GetType(), "viewLandmark", viewLandmark, false);

    //CompanyID = ddlCompany.SelectedIndex;
    //String FencingNAme = txtFencName.Text;
    //        int EmpID = EmployeeID;
    ////var grid=(GridView) grvLandmarks.
    //String LatLong = hdnSelectedLandmarkValue.Value;
    //        if (CompanyID != 0)
    //        {
    //    if (FencingNAme != "" && EmpID != 0 && LatLong != "")
    //    {
    //        DataSet ds = new DataSet();
    //        if (Convert.ToString(ViewState["FencingId"]) == "")
    //        {
    //            ds = objgeo.InsertUpdateGeoFencing("I", FencingNAme, CompanyID, EmpID, LatLong, 0);
    //            ScriptManager.RegisterStartupScript(this, this.GetType(), "Alert", "alert('Geofecning saved sucessfully')", true);
    //            BindFencingGridview(0);
    //            BindLandamrkIdsGridView();
    //            UpdPanel4.Update();
    //        }
    //        else
    //        {
    //            ds = objgeo.InsertUpdateGeoFencing("U", FencingNAme, CompanyID, EmpID, LatLong, Convert.ToInt32(ViewState["FencingId"]));
    //            ScriptManager.RegisterStartupScript(this, this.GetType(), "Alert", "alert('Geofecing modify sucessfully')", true);
    //            BindFencingGridview(0);
    //            BindLandamrkIdsGridView(0);
    //            UpdPanel4.Update();
    //        }
    //    }
    //}

    //}

    //private void DynamicLoadLandMark(string LocationId)
    //{
    //    PH_DynmCtrl.Controls.Clear();

    //    if(LocationId!="")
    //    {
    //        hdnSelectedLat.Value = "";
    //        hdnSelectedLong.Value = "";
    //    }
    //    int lantmarkId = 0;
    //    DataSet dslandmarkDetails = new DataSet();
    //    dslandmarkDetails = objgeo.GetLandmarkDetails(lantmarkId);
    //    tbl_FencingLocation = new Table();
    //    dt_Landmarkvalue = dslandmarkDetails.Tables[0];

    //    if (dslandmarkDetails.Tables.Count > 0)
    //    {
    //        if(LocationId!="")
    //        {
    //            arrayHdnChk = objLeave.commaStringToArray(LocationId);
    //            hdnSelectedLandmarkValue.Value =LocationId;
    //            //hdnSelectedLong.Value = "";
    //            //hdnSelectedLat.Value = "";
    //        }
    //        int i = 0;
    //        foreach (DataRow row in dslandmarkDetails.Tables[0].Rows)
    //        {
    //            CheckBox chk = new CheckBox();
    //            chk.ID =row["ID"].ToString();
    //            chk.CssClass = "checkboxLeave checkboxLeave-primary";
    //            chk.Attributes.Add("style", "margin-top:0px;margin-bottom:0px;padding-top:10px;min-height: 17px;");
    //            chk.CssClass = "col-md-3";
    //            chk.Text = row["LocationName"].ToString();
    //            chk.CheckedChanged += new EventHandler(CheckBox_Checked);
    //            chk.EnableViewState = true;
    //            hdnChkBoxValue.Value += row["ID"].ToString()+",";
    //            if (LocationId != "")
    //            {
    //                if (arrayHdnChk[i] == row["ID"].ToString())
    //                {
    //                    chk.Checked = true;
    //                    hdnSelectedLat.Value += row["latitude"] + ",";
    //                    hdnSelectedLong.Value += row["longitude"] + ",";
    //                    i++;
    //                }
    //                else
    //                {
    //                    chk.Checked = false;
    //                }

    //            }
    //            PH_DynmCtrl.Controls.Add(chk);
    //            UpdPanel3.Update();
    //        }

    //    }
    //}

    //private void CheckBox_Checked(object sender, EventArgs e)
    //{
    //    CheckBox chk = (sender as CheckBox);


    //}

    protected void grvLandmarkFencing_HtmlRowCreated(object sender, ASPxGridViewTableRowEventArgs e)
    {
        if (e.RowType == GridViewRowType.Data)
        {
            HtmlInputCheckBox deleteChkBxItem = (HtmlInputCheckBox)grvFencing.FindRowCellTemplateControl(e.VisibleIndex, null, "chkSelect");

            if (deleteChkBxItem != null)
            {
                geoFencingID = Convert.ToInt16(e.GetValue("FencingId"));
                int Count = objgeo.CheckGEOFencingUtilization(geoFencingID);
                LinkButton LnkbtnDelete = (LinkButton)grvFencing.FindRowCellTemplateControl(e.VisibleIndex, null, "ibFencingDelete");
                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;
                    }
                }
            }
        }

    }

    protected void ibtnFencingEdit_Click(object sender, EventArgs e)
    {
        LinkButton btnEdit = (LinkButton)sender;
        string strFencingId = btnEdit.CommandArgument.ToString();

        if (ViewState["strEditFencingId"] == null || ViewState["strEditFencingId"].ToString() != strFencingId)
        {
            ClearFields(this);
            string strCompanyId = Convert.ToString(grvFencing.GetRowValuesByKeyValue(strFencingId, "CompanyId"));
            string strFencingName = Convert.ToString(grvFencing.GetRowValuesByKeyValue(strFencingId, "Fencing_Name"));
            string strLandmarkIds = Convert.ToString(grvFencing.GetRowValuesByKeyValue(strFencingId, "LandmarkId"));


            ViewState["FencingId"] = strFencingId;
            ddlCompany.SelectedIndex = Convert.ToInt32(strCompanyId);
            txtFencName.Text = strFencingName;
            hdnSelectLandamrkIdsRow.Value = strLandmarkIds;
            //int lanmarkIds = Convert.ToInt32(strLandmarkIds);
            BindLandamrkIdsGridView(0);

            FencingDiv.Visible = true;
            FencingGrid.Visible = false;

            string editLandmark = "<script>";
            editLandmark += "FencingPolygon(1,1);";
            editLandmark += "</script>";
            ScriptManager.RegisterStartupScript(grvFencing, this.GetType(), Guid.NewGuid().ToString(), editLandmark, false);
            UpdPanel2.Update();
            //UpdPanel1.Update();
            landmarkGrid.Visible = true;
            ViewState["strEditFencingId"] = strFencingId;
            BindFencingGridview(0);
            lbtnAddFencing.Text = "&nbsp;&nbsp;" + "Modify Fencing";
            lbtnFecingAdd.Visible = false;
            lbtnFencingDelete.Visible = false;

            //BindFencingGridview(0);
            //grvFencing.SettingsPager.PageSize = 15;
            //grvFencing.DataBind();



        }
    }

    protected void ibFencingDelete_Click(object sender, EventArgs e)
    {
        LinkButton btnDelete = (LinkButton)sender;
        string strFencingId = btnDelete.CommandArgument.ToString();
        if (strFencingId != null)
        {
            objgeo.DeleteGEOFencingDetails(Convert.ToString(strFencingId));
            BindFencingGridview(0);
            ClearFecningFields();
            string strScript = "";
            strScript = strScript + "<script language='javascript'>";
            strScript = strScript + "alert('Geofencing Details Deleted Successfully');";
            strScript = strScript + "</script>";
            ScriptManager.RegisterStartupScript(this, this.GetType(), "Alert", strScript, false);
        }
    }

    private void ClearFecningFields()
    {

        ddlCompany.SelectedIndex = 0;
        txtFencName.Text = "";
        BindLandamrkIdsGridView(0);
        //DynamicLoadLandMark(string.Empty);
        UpdPanel2.Update();
        UpdPanel3.Update();
        UpdPanel4.Update();


        ScriptManager.RegisterStartupScript(this, this.GetType(), Guid.NewGuid().ToString(), "loadMapControl();", true);

    }

    protected void lbtnFencingDelete_Click(object sender, EventArgs e)
    {
        string[] ChkBoxIDs;

        if (hdnSelectFencingRow.Value != string.Empty && hdnSelectFencingRow.Value != null)
        {
            ChkBoxIDs = objLeave.commaStringToArray(hdnSelectFencingRow.Value);
            for (int i = 0; i < ChkBoxIDs.Length; i++)
            {
                int Count = objgeo.CheckGEOFencingUtilization(Convert.ToInt32(ChkBoxIDs[i]));
                if (Count > 0)
                {
                    base.Message("Geofencing cant be deleted");
                    return;
                }
            }
            objgeo.DeleteGEOFencingDetails(Convert.ToString(hdnSelectFencingRow.Value));
            BindFencingGridview(0);
            ClearFecningFields();
            base.Message("Geofencing details was deleted Successfully");
        }
        else
        {
            base.Message(rm.GetString("DeletionRecordAlert", ci));
            return;
        }

    }

    protected void lbtnCancel_Click(object sender, EventArgs e)
    {
        ViewState["strEditFencingId"] = null;

        grvFencing.Selection.UnselectAll();
        ClearFecningFields();


    }




    protected void btn_Landmark_blur_Click(object sender, EventArgs e)
    {
        // updPanel.Update();
        BindLandmarkGridview(0);
        // DynamicLoadLandMark(string.Empty);
    }

    protected void btn_Add_Click(object sender, EventArgs e)
    {
        landamarkDiv.Visible = true;
        landmarkGrid.Visible = false;
        lnkbtnDelete.Visible = false;
        //btn_Back.Visible = true;
        StringBuilder sb = new StringBuilder();
        sb.Append("<script type='text/javascript' src='" + ConfigurationManager.AppSettings["googleMapKey"].ToString() + "'></script>");
        Page.ClientScript.RegisterStartupScript(this.GetType(), "scriptsKey", sb.ToString());

        string strSetAlert = "";
        strSetAlert = strSetAlert + "<script language='javascript'>";
        strSetAlert = strSetAlert + "loadMapControl();";
        strSetAlert = strSetAlert + "</script>";
        Page.RegisterStartupScript("MaxLengthh", strSetAlert);
        btn_Add.Visible = false;
        lnkbtnSave.Text = "&nbsp;&nbsp;" + rm.GetString("AddLocation", ci);
    }

    protected void btn_Back_Click(object sender, EventArgs e)
    {
        //btn_Back.Visible = false;
        btn_Add.Visible = true;
        landamarkDiv.Visible = false;
        landmarkGrid.Visible = true;
        lnkbtnDelete.Visible = true;
    }

    protected void lbtnFecingAdd_Click(object sender, EventArgs e)
    {
        FencingDiv.Visible = true;
        FencingGrid.Visible = false;
        lbtnFencingCancel.Visible = true;
        lbtnFencingDelete.Visible = false;
        lbtnFecingAdd.Visible = false;
    }

    protected void lbtnFencingCancel_Click(object sender, EventArgs e)
    {
        lbtnAddFencing.Visible = true;
        FencingDiv.Visible = false;
        FencingGrid.Visible = true;
        lbtnFencingCancel.Visible = false;
        lbtnFencingDelete.Visible = true;
        lbtnFecingAdd.Visible = true;
    }
    public void GetEmptyText(object sender, EventArgs e)
    {
        Label lblNoRecords = (Label)sender;
        lblNoRecords.Text = rm.GetString("Alert_Norecordsfound", ci);
    }

    protected void chkLandamrkIdsChecked_CheckedChanged(object sender, EventArgs e)
    {

    }

    protected void chkAllLandamrkIdsChecked_CheckedChanged(object sender, EventArgs e)
    {
        CheckBox ChkBoxHeader = (CheckBox)grvLandmarkIds.HeaderRow.FindControl("chkAllLandamrkIdsChecked");
        foreach (GridViewRow row in grvLandmarkIds.Rows)
        {
            CheckBox ChkBoxRows = (CheckBox)row.FindControl("chkLandamrkIdsChecked");
            if (ChkBoxHeader.Checked == true)
            {
                ChkBoxRows.Checked = true;
            }
            else
            {
                ChkBoxRows.Checked = false;
            }
        }
    }

    protected void checkallLandmarkIds_CheckedChanged(object sender, EventArgs e)
    {
        CheckBox chkSelect = new CheckBox();
        chkSelect = (CheckBox)grvLandmarkIds.HeaderRow.Cells[0].FindControl("checkallLandmarkIds");
        string ChkBoxIDs = string.Empty;
        //if (chkSelect.Checked)
        //{
        //    ChkBoxIDs = GetEmployeeIdsInOtherPagesOfGrid();
        //    if (Session["EmployeeIds"].ToString() == "")
        //    {
        //        Session["EmployeeIds"] = ChkBoxIDs;
        //    }
        //    else
        //    {
        //        if (ChkBoxIDs != "")
        //        {
        //            Session["EmployeeIds"] = Session["EmployeeIds"] + "," + ChkBoxIDs;
        //        }
        //    }
        //}
        //else
        //{
        //    Session["EmployeeIds"] = string.Empty;
        //}
        foreach (GridViewRow gr in grvLandmarkIds.Rows)
        {
            chkSelect = (CheckBox)gr.Cells[0].FindControl("deletethis");
            chkSelect.Checked = ((CheckBox)sender).Checked;
        }

    }



    protected void checkallIds_CheckedChanged(object sender, EventArgs e)
    {

    }

    protected void NewCheck_CheckedChanged(object sender, EventArgs e)
    {

    }
}