Beispiel #1
0
        //[ScriptMethod(ResponseFormat = ResponseFormat.Json)]
        public google_geocodeClass googlegeocode(string address)    //you can't pass any querystring params
        {
            Dictionary <string, string> options        = new Dictionary <string, string>();
            google_geocodeClass         google_geocode = Functions.google_geocode("AIzaSyCCpsWhkuuHlAe6EKhSi5zSlmmIVMN9M8c", address, options);

            return(google_geocode);
        }
Beispiel #2
0
        protected void btn_geocode_Click(object sender, EventArgs e)
        {
            string systemPrefix = "Community"; // WebConfigurationManager.AppSettings["systemPrefix"];
                                               //string systemPrefix = WebConfigurationManager.AppSettings["systemPrefix"];
            String connectionString = ConfigurationManager.ConnectionStrings[systemPrefix + "ConnectionString"].ConnectionString + ";MultipleActiveResultSets=true";


            SqlConnection con = new SqlConnection(connectionString);

            con.Open();
            SqlCommand cmd = new SqlCommand();

            cmd.CommandType = CommandType.Text;
            cmd.CommandText = "select location_ctr, location from location where isnull(lng,'') = ''";

            cmd.Connection = con;
            SqlDataReader dr = cmd.ExecuteReader();

            while (dr.Read())
            {
                string location_ctr = dr["location_ctr"].ToString();
                string address      = dr["location"].ToString();

                options.Clear();
                google_geocodeClass google_geocode = Functions.google_geocode("AIzaSyCCpsWhkuuHlAe6EKhSi5zSlmmIVMN9M8c", address, options);
                SqlCommand          cmd1           = new SqlCommand();
                cmd1.CommandType = CommandType.Text;
                cmd1.CommandText = "update location set lng = '" + google_geocode.lng + "', lat='" + google_geocode.lat + "' where location_ctr = " + location_ctr;
                cmd1.Connection  = con;
                cmd1.ExecuteNonQuery();
                cmd1.Dispose();
            }
            dr.Close();
            cmd.Dispose();
            con.Close();
            con.Dispose();
        }
Beispiel #3
0
        protected void btn_submit_Click(object sender, EventArgs e)
        {
            Boolean Creating     = false;
            string  systemPrefix = "Community"; // WebConfigurationManager.AppSettings["systemPrefix"];
                                                //string systemPrefix = WebConfigurationManager.AppSettings["systemPrefix"];
            String        connectionString = ConfigurationManager.ConnectionStrings[systemPrefix + "ConnectionString"].ConnectionString;
            SqlConnection con = new SqlConnection(connectionString);
            SqlCommand    cmd = new SqlCommand();

            cmd.CommandType = CommandType.StoredProcedure;

            person_guid = ViewState["person_guid"].ToString();
            if (person_guid == "new")
            {
                Creating = true;
            }

            string lng = "0";
            string lat = "0";

            if (Request.Form["fld_location"].Trim() != "")
            {
                options.Clear();
                google_geocodeClass google_geocode = Functions.google_geocode("AIzaSyCCpsWhkuuHlAe6EKhSi5zSlmmIVMN9M8c", Request.Form["fld_location"].Trim(), options);
                lng = google_geocode.lng;
                lat = google_geocode.lat;
            }

            cmd.CommandText = "Update_Person";
            cmd.Parameters.Add("@person_guid", SqlDbType.VarChar).Value = person_guid;

            cmd.Parameters.Add("@username", SqlDbType.VarChar).Value  = Username;
            cmd.Parameters.Add("@firstname", SqlDbType.VarChar).Value = Request.Form["fld_firstname"].Trim();
            cmd.Parameters.Add("@lastname", SqlDbType.VarChar).Value  = Request.Form["fld_lastname"].Trim();
            cmd.Parameters.Add("@knownas", SqlDbType.VarChar).Value   = Request.Form["fld_knownas"].Trim();
            cmd.Parameters.Add("@gender", SqlDbType.VarChar).Value    = Request.Form["fld_gender"].Trim();
            cmd.Parameters.Add("@note", SqlDbType.VarChar).Value      = Request.Form["fld_note"].Trim();
            cmd.Parameters.Add("@location", SqlDbType.VarChar).Value  = Request.Form["fld_location"].Trim();
            cmd.Parameters.Add("@PAF", SqlDbType.VarChar).Value       = Request.Form["fld_PAF"].Trim();
            cmd.Parameters.Add("@phone", SqlDbType.VarChar).Value     = Request.Form["fld_phone"].Trim();
            cmd.Parameters.Add("@age", SqlDbType.VarChar).Value       = Request.Form["fld_age"].Trim();
            cmd.Parameters.Add("@lng", SqlDbType.VarChar).Value       = lng;
            cmd.Parameters.Add("@lat", SqlDbType.VarChar).Value       = lat;


            cmd.Parameters.Add("@contact_ctr", SqlDbType.VarChar).Value = Request.Form["fld_contact"].Trim();

            cmd.Connection = con;

            con.Open();
            person_guid = cmd.ExecuteScalar().ToString();
            con.Close();

            foreach (string key in Request.Form)
            {
                if (key.StartsWith("update_"))
                {
                    string person_update_id = key.Substring(7);
                    if (person_update_id.EndsWith("_delete"))
                    {
                        cmd.CommandText = "Delete_Person_update";
                        cmd.Parameters.Clear();
                        cmd.Parameters.Add("@username", SqlDbType.VarChar).Value          = Username;
                        cmd.Parameters.Add("@person_update_ctr", SqlDbType.VarChar).Value = person_update_id.Substring(0, person_update_id.Length - 7);
                    }
                    else
                    {
                        if (person_update_id.StartsWith("new"))
                        {
                            person_update_id = "new";
                        }

                        string[] valuesSplit = Request.Form[key].Split('\x00FE');
                        cmd.CommandText = "Update_Person_update";
                        cmd.Parameters.Clear();
                        cmd.Parameters.Add("@username", SqlDbType.VarChar).Value          = Username;
                        cmd.Parameters.Add("@person_update_ctr", SqlDbType.VarChar).Value = person_update_id;
                        cmd.Parameters.Add("@person_guid", SqlDbType.VarChar).Value       = person_guid;
                        //cmd.Parameters.Add("@person_ctr", SqlDbType.VarChar).Value = ;
                        cmd.Parameters.Add("@datetime", SqlDbType.VarChar).Value       = valuesSplit[0];
                        cmd.Parameters.Add("@Contact_CTR", SqlDbType.VarChar).Value    = valuesSplit[1];
                        cmd.Parameters.Add("@note", SqlDbType.VarChar).Value           = valuesSplit[2];
                        cmd.Parameters.Add("@followupaction", SqlDbType.VarChar).Value = valuesSplit[3];
                        cmd.Parameters.Add("@followupdate", SqlDbType.VarChar).Value   = valuesSplit[4];
                        cmd.Parameters.Add("@followupdone", SqlDbType.VarChar).Value   = valuesSplit[5];
                    }
                    con.Open();
                    cmd.ExecuteNonQuery();
                    con.Close();
                }
            }
            con.Dispose();
            //}

            string returnto = ViewState["returnto"].ToString();

            ;
            if (Creating)
            {
                if (returnto == "")
                {
                    returnto = "person.aspx?id=" + person_guid;
                }
                else
                {
                    returnto = "person.aspx?id=" + person_guid + "&returnto=" + returnto + ".aspx";
                }
            }
            else
            {
                if (returnto == "")
                {
                    returnto = "search.aspx";
                }
            }

            Response.Redirect(returnto);
        }