protected void CityAdd_Click(object sender, System.EventArgs e)
    {
        EnterCity.Validate();
        InvalidCity.Validate();

        if (!EnterCity.IsValid || !InvalidCity.IsValid)
        {
            return;
        }

        DataRow newrow = CitiesSet.Tables["Cities"].NewRow();

        newrow["City"] = NewCity.Text;
        try
        {
            newrow["StateProvinceID"] = Convert.ToInt32(StateList.SelectedValue);

            CitiesSet.Tables["Cities"].Rows.Add(newrow);

            //lock (CommonFunctions.Connection)
            CitiesAdapter.Update(CitiesSet);

            Finish();
        }
        catch (Exception)
        {
        }
    }
Esempio n. 2
0
    protected void CityAdd_Click(object sender, System.EventArgs e)
    {
        EnterCity.Validate();
        InvalidCity.Validate();

        if (!EnterCity.IsValid || !InvalidCity.IsValid)
        {
            return;
        }


        LatLongInfo latinfo = MainHelper.getCityLocation(NewCity.Text, StateList.SelectedItem.Text, CountryList.SelectedItem.Text);

        if (latinfo.status == 0) //Fail to get location info
        {
            error_msg = String.Format("Fail to get {0} location.", NewCity.Text);
        }
        else if (latinfo.status == 1) //Fail to verify the address
        {
            error_msg = String.Format("Fail to verify the location of {0}.", NewCity.Text);
        }
        else  //Success to get the latitude and longitude
        {
            DataRow newrow = CitiesSet.Tables["Cities"].NewRow();

            newrow["City"] = NewCity.Text;
            try
            {
                newrow["StateProvinceID"] = Convert.ToInt32(StateList.SelectedValue);

                CitiesSet.Tables["Cities"].Rows.Add(newrow);

                //lock (CommonFunctions.Connection)
                CitiesAdapter.Update(CitiesSet);
                List <SqlParameter> param = new List <SqlParameter>();
                param.Add(new SqlParameter("@stateid", StateList.SelectedValue));
                param.Add(new SqlParameter("@city", NewCity.Text));
                param.Add(new SqlParameter("@lat", latinfo.latitude));
                param.Add(new SqlParameter("@lng", latinfo.longitude));
                BookDBProvider.getDataSet("uspAddLatLong", param);
                Finish();
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }

/*
 *
 *
 *                  List<SqlParameter> param = new List<SqlParameter>();
 *                  param.Add(new SqlParameter("@country", country));
 *                  param.Add(new SqlParameter("@state", state));
 *                  param.Add(new SqlParameter("@city", city));
 *                  param.Add(new SqlParameter("@lat", latitude));
 *                  param.Add(new SqlParameter("@lng", longtitude));
 *                  BookDBProvider.getDataSet("uspAddLatLong", param);
 *
 */
    }