public JsonResult CargarListados() { StringBuilder puerto_html = new StringBuilder(); var respuesta = new { mensaje = "", puerto = "" }; List <Puertos> ls_puerto = new List <Puertos>(); ls_puerto = Mantenedores.GetPuertos(); puerto_html.AppendLine("<option value='" + "0" + "' selected>" + "Seleccione" + "</option>"); if (ls_puerto.Count > 0) { foreach (Puertos item in ls_puerto) { puerto_html.AppendLine("<option value='" + item.Id + "' data-rut='" + item.Rut + "'>" + item.Nombre + "</option>"); } } respuesta = new { mensaje = "", puerto = puerto_html.ToString() }; return(Json(respuesta)); }
public JsonResult CargarListados() { StringBuilder puerto_html = new StringBuilder(); StringBuilder empresas_html = new StringBuilder(); StringBuilder tipos_html = new StringBuilder(); StringBuilder nacion_html = new StringBuilder(); StringBuilder vehiculo_html = new StringBuilder(); var respuesta = new { mensaje = "", puerto = "", empresa = "", tipo_ingreso = "", nacion = "", vehiculo = "" }; List <Puertos> ls_puerto = new List <Puertos>(); List <Empresas> ls_empresa = new List <Empresas>(); List <TipoIngreso> ls_tipos = new List <TipoIngreso>(); List <Nacionalidad> ls_nacion = new List <Nacionalidad>(); List <TipoVehiculo> ls_vehiculo = new List <TipoVehiculo>(); ls_puerto = Mantenedores.GetPuertos(); ls_empresa = Mantenedores.GetEmpresas("111", "N"); ls_tipos = Mantenedores.GetTipoIngreso(); ls_nacion = Mantenedores.GetNacionalidad(); ls_vehiculo = Mantenedores.GetTipoVehiculos(); //puerto_html.AppendLine("<option value='" + "0" + "' selected>" + "Seleccione" + "</option>"); empresas_html.AppendLine("<option value='" + "0" + "' selected>" + "No Informada" + "</option>"); tipos_html.AppendLine("<option value='" + "0" + "' selected>" + "Seleccione" + "</option>"); nacion_html.AppendLine("<option value='" + "0" + "'>" + "Seleccione" + "</option>"); vehiculo_html.AppendLine("<option value='" + "0" + "' selected>" + "Seleccione" + "</option>"); if (ls_puerto.Count > 0) { foreach (Puertos item in ls_puerto) { puerto_html.AppendLine("<option value='" + item.Id + "'>" + item.Nombre + "</option>"); } } if (ls_empresa.Count > 0) { foreach (Empresas item in ls_empresa) { empresas_html.AppendLine("<option value='" + item.Id + "'>" + item.Info + "</option>"); } } if (ls_tipos.Count > 0) { foreach (TipoIngreso item in ls_tipos) { tipos_html.AppendLine("<option value='" + item.Id + "'>" + item.Nombre + "</option>"); } } if (ls_nacion.Count > 0) { foreach (Nacionalidad item in ls_nacion) { if (item.Id == 39) { nacion_html.AppendLine("<option selected='selected' value='" + item.Id + "'>" + item.Nombre + "</option>"); } else { nacion_html.AppendLine("<option value='" + item.Id + "'>" + item.Nombre + "</option>"); } } } if (ls_vehiculo.Count > 0) { foreach (TipoVehiculo item in ls_vehiculo) { vehiculo_html.AppendLine("<option value='" + item.id + "'>" + item.glosa + "</option>"); } } respuesta = new { mensaje = "", puerto = puerto_html.ToString(), empresa = empresas_html.ToString(), tipo_ingreso = tipos_html.ToString(), nacion = nacion_html.ToString(), vehiculo = vehiculo_html.ToString() }; return(Json(respuesta)); }