Пример #1
0
    protected void CityRename_Click(object sender, System.EventArgs e)
    {
        if (CityName.Text.Length < 1)
        {
            return;
        }

        LatLongInfo latinfo = MainHelper.getCityLocation(CityName.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
        {
            try
            {
                //Update
                foreach (DataRow datarow in CitiesSet.Tables["Cities"].Rows)
                {
                    if (datarow.RowState != DataRowState.Deleted)
                    {
                        if ((int)datarow["ID"] == Convert.ToInt32(CityList.SelectedValue))
                        {
                            datarow["City"] = CityName.Text;
                            break;
                        }
                    }
                }

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

                List <SqlParameter> param = new List <SqlParameter>();
                param.Add(new SqlParameter("@stateid", StateList.SelectedValue));
                param.Add(new SqlParameter("@city", CityName.Text));
                param.Add(new SqlParameter("@lat", latinfo.latitude));
                param.Add(new SqlParameter("@lng", latinfo.longitude));
                BookDBProvider.getDataSet("uspAddLatLong", param);

                Finish();
            }
            catch {
                error_msg = "Something is wrong.";
            }
        }
    }
Пример #2
0
    public List <SqlParameter> getParamListBasicInfo(int newid)
    {
        List <SqlParameter> param = new List <SqlParameter>();

        try {
            if (Request["citylist"].ToString() == "0")
            {
                string newcity   = Request["additionalcity"];
                int    stateid   = int.Parse(Request["statelist"]);
                int    newcityid = createNewCity(stateid, newcity);
                if (newcityid == -1)
                {
                    return(null);
                }
                param.Add(new SqlParameter("@CityID", newcityid));

                if (Request["statename"] != null && Request["countryname"] != null)
                {
                    LatLongInfo latinfo = MainHelper.getCityLocation(newcity, Request["statename"].ToString(), Request["countryname"].ToString());
                    if (latinfo.status == 0) //Fail to get location info
                    {
                        error_msg = String.Format("Fail to get {0} location.", newcity);
                    }
                    else if (latinfo.status == 1) //Fail to verify the address
                    {
                        error_msg = String.Format("Fail to verify the location of {0}.", newcity);
                    }
                    else  //Success to get the latitude and longitude
                    {
                        try
                        {
                            //Update
                            List <SqlParameter> tmpparam = new List <SqlParameter>();
                            tmpparam.Add(new SqlParameter("@stateid", stateid));
                            tmpparam.Add(new SqlParameter("@city", newcity));
                            tmpparam.Add(new SqlParameter("@lat", latinfo.latitude));
                            tmpparam.Add(new SqlParameter("@lng", latinfo.longitude));
                            BookDBProvider.getDataSet("uspAddLatLong", tmpparam);
                        }
                        catch
                        {
                            error_msg = "Something is wrong.";
                        }
                    }
                }
            }
            else
            {
                param.Add(new SqlParameter("@CityID", Request["citylist"]));
            }

            param.Add(new SqlParameter("@ID", newid));
            param.Add(new SqlParameter("@UserID", userid));
            // param.Add(new SqlParameter("@UserID", 7332));
            param.Add(new SqlParameter("@Name", Request["_propname"]));
            param.Add(new SqlParameter("@Name2", Request["_propname2"]));
            param.Add(new SqlParameter("@VirtualTour", Request["_virttour"]));
            param.Add(new SqlParameter("@Address", Request["_propaddr"]));
            param.Add(new SqlParameter("@IfShowAddress", Request["_propdisplay"]));
            param.Add(new SqlParameter("@NumBedrooms", Request["_propbedroom"]));
            param.Add(new SqlParameter("@NumBaths", Request["_propbathrooms"]));
            param.Add(new SqlParameter("@NumSleeps", Request["_propsleep"]));
            param.Add(new SqlParameter("@MinimumNightlyRentalID", Request["_propminrental"]));
            param.Add(new SqlParameter("@NumTVs", Request["_proptv"]));
            param.Add(new SqlParameter("@NumVCRs", 0));
            param.Add(new SqlParameter("@NumCDPlayers", Request["_propcd"]));
            param.Add(new SqlParameter("@DateAdded", DateTime.Now));
            param.Add(new SqlParameter("@DateStartViewed", DateTime.Now));

            string newtype      = Request["additional_type"];
            int    categorytype = int.Parse(Request["propcategory"]);
            int    newtypeid    = createNewPropertyType(categorytype, newtype);
            if (newtypeid == -1)
            {
                return(null);
            }
            param.Add(new SqlParameter("@TypeID", newtypeid));
        }
        catch (Exception ex)
        {
            throw ex;
            return(null);
        }
        return(param);
    }
Пример #3
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);
 *
 */
    }