예제 #1
0
        public List <entAutores> ListarAutores()
        {
            SqlCommand        cmd   = null;
            SqlDataReader     dr    = null;
            List <entAutores> Lista = null;

            try
            {
                SqlConnection cn = Conexion.Instancia.Conectar();
                cmd = new SqlCommand("spListarAutores", cn);
                cn.Open();
                dr    = cmd.ExecuteReader();
                Lista = new List <entAutores>();
                while (dr.Read())
                {
                    entAutores m = new entAutores();
                    m.AutoresCodigo  = Convert.ToUInt16(dr["AutoresCodigo"]);
                    m.AutoresNombres = dr["AutoresNombres"].ToString();
                    m.AutoresEstado  = dr["AutoresEstado"].ToString();
                    Lista.Add(m);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally { cmd.Connection.Close(); }
            return(Lista);
        }
예제 #2
0
        public List <entLibros> ListarLibrosXImagen(Int16 _idLibro)
        {
            SqlCommand       cmd   = null;
            SqlDataReader    dr    = null;
            List <entLibros> Lista = null;

            try
            {
                SqlConnection cn = Conexion.Instancia.Conectar();
                cmd             = new SqlCommand("spListarLibroXImagen", cn);
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.AddWithValue("@prmintId", _idLibro);
                cn.Open();
                dr    = cmd.ExecuteReader();
                Lista = new List <entLibros>();
                while (dr.Read())
                {
                    entLibros l = new entLibros();
                    l.LibrosCodigo        = Convert.ToInt32(dr["LibrosCodigo"]);
                    l.LibrosDescripcion   = dr["LibrosDescripcion"].ToString();
                    l.LibrosEstado        = dr["LibrosEstado"].ToString();
                    l.LibrosTitulo        = dr["LibrosTitulo"].ToString();
                    l.LibrosEjemplares    = Convert.ToInt16(dr["LibrosEjemplares"]);
                    l.LibrosImagen        = dr["LibrosImagen"].ToString();
                    l.LibrosObservaciones = dr["LibrosObservaciones"].ToString();
                    l.LibrosStock         = Convert.ToInt16(dr["LibrosStock"]);
                    entCategorias c = new entCategorias();
                    c.CategoriasCodigo  = Convert.ToInt32(dr["CategoriasCodigo"]);
                    c.CategoriasNombres = dr["DCategoria"].ToString();
                    l.Categorias        = c;
                    entAutores a = new entAutores();
                    a.AutoresCodigo  = Convert.ToInt32(dr["AutoresCodigo"]);
                    a.AutoresNombres = dr["DAutores"].ToString();
                    l.Autores        = a;
                    entEditores e = new entEditores();
                    e.EditoresCodigo  = Convert.ToInt32(dr["EditoresCodigo"]);
                    e.EditoresNombres = dr["DEditores"].ToString();
                    l.Editores        = e;
                    Lista.Add(l);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally { cmd.Connection.Close(); }
            return(Lista);
        }