private void Search() { string codigoProfesion = DropDownListProfesion.SelectedValue, genero = DropDownListGenero.SelectedValue, direccion = autocomplete.Value, _lat = lat.Value, _lng = lng.Value, _radio = radio.Value; string ResultJson = string.Empty; if (string.IsNullOrEmpty(direccion) && string.IsNullOrEmpty(_lat) && string.IsNullOrEmpty(_lng) && codigoProfesion.Equals("0") && genero.Equals("0") && string.IsNullOrEmpty(_lat) && string.IsNullOrEmpty(_lng) && string.IsNullOrEmpty(_radio)) { ViewState["Consulta"] = null; } else { string sql = string.Format( "SELECT IdContacto,CONCAT(Apellido,'-',c.Nombre) NombreCompleto,Imagen, Direccion, Telefono, Genero = (CASE Genero WHEN 'M' THEN 'Masculino' WHEN 'F' THEN 'Femenino' END),p.Nombre Profesion, Geography " + " FROM Contacto c" + " INNER JOIN Profesion p" + " ON p.IdProfesion = c.Codigo_Profesion" + " WHERE Codigo_Usuario = {0} ", ((int)Session["IdUsuario"]).ToString()); if (!string.IsNullOrEmpty(codigoProfesion) && !codigoProfesion.Equals("0")) { sql += " and Codigo_Profesion = " + codigoProfesion; } if (!string.IsNullOrEmpty(genero) && !genero.Equals("0")) { sql += " and Genero = '" + genero + "' "; } if (!string.IsNullOrEmpty(direccion) && !string.IsNullOrEmpty(_lat) && !string.IsNullOrEmpty(_lng) && !string.IsNullOrEmpty(_radio)) { sql += string.Format(" and geography::STGeomFromText('POINT({0} {1})', 4326).STDistance(Geography) <= {2} ", _lng, _lat, _radio); } ContactoRepositorio cr = new ContactoRepositorio(); DataTable data = cr.ObtenerContacto(sql); ViewState["Consulta"] = data; if (data != null && data.Rows.Count > 0) { JArray array = new JArray(); foreach (DataRow dr in data.Rows) { JObject item = new JObject(); item.Add("ID", dr[0].ToString()); item.Add("Geozona", dr[7].ToString()); array.Add(item); } ResultJson = array.ToString(); } } LoadGrid(); UpdatePanel1.Update(); dataGeographic.Value = ResultJson; ScriptManager.RegisterStartupScript(this.UpdatePanel1, this.GetType(), "LoadMap", "LoadMapSearch()", true); }
public static string GetInfo(int id) { string mensaje = "false"; ContactoRepositorio cr = new ContactoRepositorio(); string sql = string.Format( "SELECT IdContacto,CONCAT(c.Nombre,' ',Apellido) NombreCompleto,Imagen, Direccion, Telefono, Genero = (CASE Genero WHEN 'M' THEN 'Masculino' WHEN 'F' THEN 'Femenino' END),p.Nombre Profesion, Codigo_Usuario " + " FROM Contacto c" + " INNER JOIN Profesion p" + " ON p.IdProfesion = c.Codigo_Profesion" + " WHERE IdContacto = {0}", id); DataTable data = cr.ObtenerContacto(sql); if (data != null && data.Rows.Count > 0) { JArray array = new JArray(); foreach (DataRow dr in data.Rows) { JObject item = new JObject(); item.Add("ID", dr[0].ToString()); item.Add("Nombre", dr[1].ToString()); item.Add("Imagen", GetSrcImageAjax(dr[2].ToString(), id, dr[7].ToString())); item.Add("Direccion", dr[3].ToString()); item.Add("Telefono", dr[4].ToString()); item.Add("Genero", dr[5].ToString()); item.Add("Profesion", dr[6].ToString()); array.Add(item); } mensaje = array.ToString(); } return(mensaje); }
private void LoadForm() { buttonEditar.Attributes.Add("onclick", "javascript: if(!ValidarForm()) return false;"); try { int IdContact = int.Parse(Request.QueryString["id"]), IdUsuario = (int)Session["IdUsuario"]; ContactoRepositorio cr = new ContactoRepositorio(); Contacto contacto = cr.ObtenerContacto(IdUsuario, IdContact); nombre.Value = contacto.Nombre; apellido.Value = contacto.Apellido; autocomplete.Value = contacto.Direccion; telefono.Value = contacto.Telefono.ToString(); CargarProfesion(contacto.Codigo_Profesion.ToString()); DropDownListGenero.SelectedValue = contacto.Genero; lat.Value = contacto.Geographic.Latitude.ToString().Replace(',', '.'); lng.Value = contacto.Geographic.Longitude.ToString().Replace(',', '.'); imageTitle.Text = contacto.Imagen; AvatarMin.Src = GetSrcImage(contacto.Imagen, contacto.IdContacto); } catch (Exception) { Response.Redirect("NuevoContacto.aspx"); } }