예제 #1
0
        public List <EspeciesBO> ObtenerEspecie(int id)
        {
            var        especies = new List <EspeciesBO>();
            SqlCommand cmd      = new SqlCommand("SELECT * FROM Especie WHERE id=@id");

            cmd.Parameters.Add("@id", SqlDbType.Int).Value = id;

            cmd.Connection = con.establecerConexion();
            con.AbrirConexion();
            var query = cmd;

            using (var dr = query.ExecuteReader())
            {
                while (dr.Read())
                {
                    var e = new BO.EspeciesBO
                    {
                        id            = Convert.ToInt32(dr["id"].ToString()),
                        nomCientifico = dr["nomCientifico"].ToString(),
                        nomComun      = dr["nomComun"].ToString()
                    };
                    especies.Add(e);
                }
            }
            con.CerrarConexion();
            return(especies);
        }
예제 #2
0
        public List <EspeciesBO> DropDownEspecie()
        {
            var        especies = new List <EspeciesBO>();
            SqlCommand cmd      = new SqlCommand("SELECT e.id, (e.nomCientifico + ' ('+ e.nomComun+')') AS nombre FROM Especie e");

            cmd.Connection = con.establecerConexion();
            con.AbrirConexion();
            var query = cmd;

            using (var dr = query.ExecuteReader())
            {
                while (dr.Read())
                {
                    var p = new BO.EspeciesBO
                    {
                        id            = Convert.ToInt32(dr["id"].ToString()),
                        nomCientifico = dr["nombre"].ToString()
                    };
                    especies.Add(p);
                }
            }
            con.CerrarConexion();
            return(especies);
        }