Ejemplo n.º 1
0
        public List <_Comunidad> ObtenerComunidadesEncuesta()
        {
            List <_Comunidad> ListaComunidad = new List <_Comunidad>();
            MySqlCommand      comando        = new MySqlCommand("SELECT Comunidad.idComunidad, Comunidad.Nombre FROM comunidad where activo=true order by Comunidad.Nombre ASC", conex);

            comando.CommandTimeout = 12280;
            DataSet          ds      = new DataSet();
            MySqlDataAdapter Adapter = new MySqlDataAdapter();

            Adapter.SelectCommand = comando;
            Adapter.Fill(ds);
            DataTable tabla = new DataTable();

            tabla = ds.Tables[0];
            for (int i = 0; i < tabla.Rows.Count; i++)
            {
                DataRow    row         = tabla.Rows[i];
                _Comunidad Comunidades = new _Comunidad(Convert.ToInt32(row["idComunidad"]), Convert.ToString(row["Nombre"]));
                ListaComunidad.Add(Comunidades);
            }
            return(ListaComunidad);
        }
Ejemplo n.º 2
0
        public List <_Comunidad> ObtenerComunidades()
        {
            List <_Comunidad> ListaComunidad = new List <_Comunidad>();
            MySqlCommand      comando        = new MySqlCommand("SELECT Comunidad.idComunidad, Comunidad.Nombre, municipio.NombreM, departamento.NombreD FROM comunidad inner join Departamento on Departamento_idDepartamento = idDepartamento inner join Municipio  on Municipio_idMunicipio = idMunicipio where activo=true group by comunidad.Nombre", conex);

            comando.CommandTimeout = 12280;
            DataSet          ds      = new DataSet();
            MySqlDataAdapter Adapter = new MySqlDataAdapter();

            Adapter.SelectCommand = comando;
            Adapter.Fill(ds);
            DataTable tabla = new DataTable();

            tabla = ds.Tables[0];
            for (int i = 0; i < tabla.Rows.Count; i++)
            {
                DataRow    row         = tabla.Rows[i];
                _Comunidad Comunidades = new _Comunidad(Convert.ToInt32(row["idComunidad"]), Convert.ToString(row["Nombre"]), Convert.ToString(row["NombreM"]), Convert.ToString(row["NombreD"]));
                ListaComunidad.Add(Comunidades);
            }
            return(ListaComunidad);
        }