protected void acbGeographicLocation_DeleteClick(object sender, EventArgs e)
        {
            try
            {
                switch (mvGeographicLocation.GetActiveView().ID.ToLower())
                {
                    case "vwcountry":
                        StringBuilder CountryId = new StringBuilder();
                        int result = 0;
                        if (ViewState[PageConstants.vsItemIndexes] != null)
                            htItemIndex = (Hashtable)ViewState[PageConstants.vsItemIndexes];

                        if (htItemIndex != null)
                        {
                            foreach (int i in htItemIndex.Values)
                            {

                                Label lblCountryId = (Label)radgrdCountry.Items[i].FindControl("lblGrdCountryIdItem");
                                if (lblCountryId != null)
                                {
                                    CountryId.Append(lblCountryId.Text + ",");
                                }
                            }
                        }
                        objGeographicLocation = new GeographicLocationDal();
                        String ContryId = CountryId.ToString().TrimEnd(',');
                        result = objGeographicLocation.DeleteCountry(ContryId);

                        if (result == 1)
                        {
                            Master.DisplayMessage(ConfigurationSettings.AppSettings[SuccessMessage.Delete].ToString());
                            Master.MessageCssClass = "successMessage";
                            ViewState[PageConstants.vsItemIndexes] = null;
                            BindGridCountry();
                        }
                        else if (result == 547)
                        {
                            Master.DisplayMessage(ConfigurationSettings.AppSettings[FailureMessage.Delete].ToString());
                            Master.MessageCssClass = "errorMessage";
                        }
                        break;
                    case "vwstate":
                        StringBuilder StateId = new StringBuilder();
                        if (ViewState[PageConstants.vsItemIndexes] != null)
                            htItemIndex = (Hashtable)ViewState[PageConstants.vsItemIndexes];

                        if (htItemIndex != null)
                        {
                            foreach (int i in htItemIndex.Values)
                            {

                                Label lblStateId = (Label)radgrdState.Items[i].FindControl("lblGrdStateIdItem");
                                if (lblStateId != null)
                                {
                                    StateId.Append(lblStateId.Text + ",");
                                }
                            }
                        }
                        objGeographicLocation = new GeographicLocationDal();
                        String StatId = StateId.ToString().TrimEnd(',');
                        result = objGeographicLocation.DeleteState(StatId);

                        if (result == 1)
                        {
                            Master.DisplayMessage(ConfigurationSettings.AppSettings[SuccessMessage.Delete].ToString());
                            Master.MessageCssClass = "successMessage";
                            ViewState[PageConstants.vsItemIndexes] = null;
                            BindGridState();
                        }
                        else if (result == 547)
                        {
                            Master.DisplayMessage(ConfigurationSettings.AppSettings[FailureMessage.Delete].ToString());
                            Master.MessageCssClass = "errorMessage";
                        }
                        break;
                    case "vwcity":
                        StringBuilder CityId = new StringBuilder();
                        if (ViewState[PageConstants.vsItemIndexes] != null)
                            htItemIndex = (Hashtable)ViewState[PageConstants.vsItemIndexes];

                        if (htItemIndex != null)
                        {
                            foreach (int i in htItemIndex.Values)
                            {

                                Label lblCityId = (Label)radgrdCity.Items[i].FindControl("lblGrdCityIdItem");
                                if (lblCityId != null)
                                {
                                    CityId.Append(lblCityId.Text + ",");
                                }
                            }
                        }
                        objGeographicLocation = new GeographicLocationDal();
                        String CtyId = CityId.ToString().TrimEnd(',');
                        result = objGeographicLocation.DeleteCity(CtyId);

                        if (result == 1)
                        {
                            Master.DisplayMessage(ConfigurationSettings.AppSettings[SuccessMessage.Delete].ToString());
                            Master.MessageCssClass = "successMessage";
                            ViewState[PageConstants.vsItemIndexes] = null;
                            BindGridCity();
                        }
                        else if (result == 547)
                        {
                            Master.DisplayMessage(ConfigurationSettings.AppSettings[FailureMessage.Delete].ToString());
                            Master.MessageCssClass = "errorMessage";
                        }
                        break;

                }


            }
            catch (Exception ex)
            {
                bool rethrow = ExceptionPolicy.HandleException(ex, DALHelper.DAL_EXP_POLICYNAME);
                if (rethrow)
                { throw ex; }
            }
        }
        protected void acbGeographicLocation_SearchClick(object sender, EventArgs e)
        {
            try
            {
                switch (mvGeographicLocation.GetActiveView().ID.ToLower())
                {
                    case "vwcountry":
                        objGeographicLocation = new GeographicLocationDal();
                        DataSet dsGeographicCountry = objGeographicLocation.GetCountryName(acbGeographicLocation.SearchTextBox.Text);
                        radgrdCountry.DataSource = dsGeographicCountry;
                        radgrdCountry.DataBind();
                        ViewState[vsGeographicCountry] = dsGeographicCountry;
                        Reset();
                        break;
                    case "vwstate":
                        objGeographicLocation = new GeographicLocationDal();
                        DataSet dsGeographicState = objGeographicLocation.GetStateName(acbGeographicLocation.SearchTextBox.Text);
                        radgrdState.DataSource = dsGeographicState;
                        radgrdState.DataBind();
                        ViewState[vsGeographicState] = dsGeographicState;
                        Reset();
                        break;
                    case "vwcity":
                        objGeographicLocation = new GeographicLocationDal();
                        DataSet dsGeographicCity = objGeographicLocation.GetCityName(acbGeographicLocation.SearchTextBox.Text);
                        radgrdCity.DataSource = dsGeographicCity;
                        radgrdCity.DataBind();
                        ViewState[vsGeographicCity] = dsGeographicCity;
                        Reset();
                        break;
                }

            }
            catch (Exception ex)
            {
                bool rethrow = ExceptionPolicy.HandleException(ex, DALHelper.DAL_EXP_POLICYNAME);
                if (rethrow)
                { throw ex; }
            }
        }
        protected void acbGeographicLocation_SaveClick(object sender, EventArgs e)
        {
            try
            {
                int result = 0;
                objGeographicLocation = new GeographicLocationDal();
                switch (acbGeographicLocation.SaveButton.CommandName)
                {
                    case "Save":
                        switch (mvGeographicLocation.GetActiveView().ID.ToLower())
                        {
                            case "vwcountry":
                                vwCountrySave();
                                pnlAddCountry.Visible = false;
                                acbGeographicLocation.EditableMode = false;
                                break;
                            case "vwstate":
                                vwStateSave();
                                pnlAddState.Visible = false;
                                acbGeographicLocation.EditableMode = false;
                                break;
                            case "vwcity":
                                vwCitySave();
                                pnlAddCity.Visible = false;
                                acbGeographicLocation.EditableMode = false;
                                break;
                        }
                        break;
                    case "Update":
                        switch (mvGeographicLocation.GetActiveView().ID.ToLower())
                        {

                            case "vwcountry":
                                String xmlDataCountry = GenerateXmlStringCountry(radgrdCountry);
                                result = objGeographicLocation.UpdateCountry(xmlDataCountry);
                                if (result == 1)
                                {
                                    acbGeographicLocation.DefaultMode = true;
                                    Master.DisplayMessage(ConfigurationSettings.AppSettings[SuccessMessage.Update].ToString());
                                    Master.MessageCssClass = "successMessage";

                                    if (ViewState[PageConstants.vsItemIndexes] != null)
                                        htItemIndex = (Hashtable)ViewState[PageConstants.vsItemIndexes];
                                    for (int i = 0; i < htItemIndex.Count; i++)
                                        radgrdCountry.Items[Convert.ToInt32(htItemIndex[i])].Edit = false;
                                    bisEdit = false;
                                    ViewState[PageConstants.vsItemIndexes] = null;
                                    BindGridCountry();
                                }
                                else
                                {
                                    Master.DisplayMessage(ConfigurationSettings.AppSettings[FailureMessage.Update].ToString());
                                    Master.MessageCssClass = "errorMessage";
                                }
                                break;
                            case "vwstate":
                                String xmlDataState = GenerateXmlStringState(radgrdState);
                                result = objGeographicLocation.UpdateState(xmlDataState);
                                if (result == 1)
                                {
                                    acbGeographicLocation.DefaultMode = true;
                                    Master.DisplayMessage(ConfigurationSettings.AppSettings[SuccessMessage.Update].ToString());
                                    Master.MessageCssClass = "successMessage";

                                    if (ViewState[PageConstants.vsItemIndexes] != null)
                                        htItemIndex = (Hashtable)ViewState[PageConstants.vsItemIndexes];
                                    for (int i = 0; i < htItemIndex.Count; i++)
                                        radgrdState.Items[Convert.ToInt32(htItemIndex[i])].Edit = false;
                                    bisEdit = false;
                                    ViewState[PageConstants.vsItemIndexes] = null;
                                    BindGridState();
                                }
                                else
                                {
                                    Master.DisplayMessage(ConfigurationSettings.AppSettings[FailureMessage.Update].ToString());
                                    Master.MessageCssClass = "errorMessage";
                                }
                                break;
                            case "vwcity":
                                String xmlDataCity = GenerateXmlStringCity(radgrdCity);
                                result = objGeographicLocation.UpdateCity(xmlDataCity);
                                if (result == 1)
                                {
                                    acbGeographicLocation.DefaultMode = true;
                                    Master.DisplayMessage(ConfigurationSettings.AppSettings[SuccessMessage.Update].ToString());
                                    Master.MessageCssClass = "successMessage";

                                    if (ViewState[PageConstants.vsItemIndexes] != null)
                                        htItemIndex = (Hashtable)ViewState[PageConstants.vsItemIndexes];
                                    for (int i = 0; i < htItemIndex.Count; i++)
                                        radgrdCity.Items[Convert.ToInt32(htItemIndex[i])].Edit = false;
                                    bisEdit = false;
                                    ViewState[PageConstants.vsItemIndexes] = null;
                                    BindGridCity();
                                }
                                else
                                {
                                    Master.DisplayMessage(ConfigurationSettings.AppSettings[FailureMessage.Update].ToString());
                                    Master.MessageCssClass = "errorMessage";
                                }
                                break;
                        }

                        break;
                }

                Reset();
            }
            catch (Exception ex)
            {
                bool rethrow = ExceptionPolicy.HandleException(ex, DALHelper.DAL_EXP_POLICYNAME);
                if (rethrow)
                { throw ex; }
            }
        }
 private void vwCitySave()
 {
     try
     {
         int result = 0;
         objGeographicLocation = new GeographicLocationDal();
         objGeographicLocationBDto = new GeographicLocationBDto();
         objGeographicLocationBDto.CityName = txtCityName.Text;
         objGeographicLocationBDto.CountryId = int.Parse(cmbCountryNameCity.SelectedValue);
         objGeographicLocationBDto.StateId = int.Parse(cmbStateNameCity.SelectedValue);
         objGeographicLocationBDto.UserProfile = objAuthorizationBDto.UserProfile;
         result = objGeographicLocation.InsertCity(objGeographicLocationBDto);
         if (result >= 1)
         {
             Master.DisplayMessage(ConfigurationSettings.AppSettings[SuccessMessage.Save].ToString());
             Master.MessageCssClass = "successMessage";
         }
         else
         {
             Master.DisplayMessage(ConfigurationSettings.AppSettings[FailureMessage.Save].ToString());
             Master.MessageCssClass = "errorMessage";
         }
         BindGridCity();
         Reset();
     }
     catch (Exception ex)
     {
         bool rethrow = ExceptionPolicy.HandleException(ex, DALHelper.DAL_EXP_POLICYNAME);
         if (rethrow)
         { throw ex; }
     }
 }
        ///// <summary>
        ///// Saves checkbox checked status into hashtable after check status changed.
        ///// </summary>
        ///// <param name="sender">The object which raised the event</param>
        ///// <param name="e">The event listener object</param>
        //public void chkItemWrt_CheckChanged(object sender, EventArgs e)
        //{
        //    CheckBox chkBox = (CheckBox)sender;
        //    GridDataItem item = (GridDataItem)chkBox.NamingContainer;
        //    if ((ViewState[PageConstants.vsItemIndexes] != null))
        //    {
        //        htItemIndex = (Hashtable)ViewState[PageConstants.vsItemIndexes];
        //    }
        //    else
        //    {
        //        htItemIndex = new Hashtable();
        //    }
        //    if (chkBox.Checked == true)
        //    {
        //        hdnCheckIndex.Value = item.ItemIndex.ToString();
        //        htItemIndex.Add(htItemIndex.Count, item.ItemIndex);
        //        item.Selected = true;
        //    }
        //    else
        //    {
        //        item.Selected = false;
        //        for (int i = 0; i <= htItemIndex.Count - 1; i++)
        //        {
        //            if (htItemIndex[i] != null)
        //            {
        //                if (htItemIndex[i].ToString() == item.ItemIndex.ToString())
        //                {
        //                    radgrdCountry.Items[htItemIndex[i].ToString()].Edit = false;
        //                    htItemIndex.Remove(i);

        //                    break;
        //                }
        //            }
        //        }
        //    }
        //    ViewState.Add(PageConstants.vsItemIndexes, htItemIndex);
        //}

        #endregion

        #region Save

        #region Save vwCountry
        private void vwCountrySave()
        {
            try
            {
                int result = 0;
                objGeographicLocation = new GeographicLocationDal();
                GeographicLocationBDto objGeographicLocationBDto = new GeographicLocationBDto();
                objGeographicLocationBDto = new GeographicLocationBDto();
                objGeographicLocationBDto.CountryName = txtCountryName.Text;
                objGeographicLocationBDto.CountryCode = txtCountryCode.Text;
                objGeographicLocationBDto.CurrencySymbol = txtCurrencySymbol.Text;
                objGeographicLocationBDto.CurrencyName = txtCurrencyName.Text;
                objGeographicLocationBDto.UserProfile = objAuthorizationBDto.UserProfile;
                result = objGeographicLocation.InsertCountryName(objGeographicLocationBDto);
                if (result >= 1)
                {
                    Master.DisplayMessage(ConfigurationSettings.AppSettings[SuccessMessage.Save].ToString());
                    Master.MessageCssClass = "successMessage";
                }
                else
                {
                    Master.DisplayMessage(ConfigurationSettings.AppSettings[FailureMessage.Save].ToString());
                    Master.MessageCssClass = "errorMessage";
                }
                BindGridCountry();
                Reset();
            }
            catch (Exception ex)
            {
                bool rethrow = ExceptionPolicy.HandleException(ex, DALHelper.DAL_EXP_POLICYNAME);
                if (rethrow)
                { throw ex; }
            }
        }
        /// <summary>
        /// Bind GeographicLocationLookupCity grid
        /// </summary>
        private void BindGridCity()
        {
            try
            {
                objGeographicLocation = new GeographicLocationDal();
                DataSet dsGeographicCity = objGeographicLocation.GetCityName("");
                radgrdCity.DataSource = dsGeographicCity;
                radgrdCity.DataBind();
                ViewState[vsGeographicCity] = dsGeographicCity;
                if (radgrdCity != null)
                {
                    for (int i = 0; i < radgrdCity.Items.Count; i++)
                        radgrdCity.Items[i].Edit = false;
                }
            }
            catch (Exception ex)
            { }

        }
        /// <summary>
        /// Bind GeographicLocationLookupState grid
        /// </summary>
        private void BindGridState()
        {
            try
            {
                objGeographicLocation = new GeographicLocationDal();
                DataSet dsGeographicState = objGeographicLocation.GetStateName("");
                radgrdState.DataSource = dsGeographicState;
                radgrdState.DataBind();
                ViewState[vsGeographicState] = dsGeographicState;
                if (radgrdState != null)
                {
                    for (int i = 0; i < radgrdState.Items.Count; i++)
                        radgrdState.Items[i].Edit = false;
                }
            }
            catch (Exception ex)
            { }

        }