Exemple #1
0
    public void registrarLibro(Elibro libro)
    {
        DataTable        libroNuevo = new DataTable();
        NpgsqlConnection conection  = new NpgsqlConnection(ConfigurationManager.ConnectionStrings["postgres"].ConnectionString);

        try
        {
            NpgsqlDataAdapter dataAdapter = new NpgsqlDataAdapter("libros.f_insertar_libros", conection);
            dataAdapter.SelectCommand.CommandType = CommandType.StoredProcedure;
            dataAdapter.SelectCommand.Parameters.Add("_foto_libro", NpgsqlDbType.Text).Value      = libro.FotoLibro1;
            dataAdapter.SelectCommand.Parameters.Add("_nombre_libro", NpgsqlDbType.Text).Value    = libro.NombreLibro1;
            dataAdapter.SelectCommand.Parameters.Add("_genero", NpgsqlDbType.Text).Value          = libro.Genero1;
            dataAdapter.SelectCommand.Parameters.Add("_descripcion", NpgsqlDbType.Text).Value     = libro.Descripcion1;
            dataAdapter.SelectCommand.Parameters.Add("_autor", NpgsqlDbType.Text).Value           = libro.Autor1;
            dataAdapter.SelectCommand.Parameters.Add("_ano_publicacion", NpgsqlDbType.Text).Value = libro.AñoPublicacion1;

            conection.Open();
            dataAdapter.Fill(libroNuevo);
        }
        catch (Exception Ex)
        {
            throw Ex;
        }
        finally
        {
            if (conection != null)
            {
                conection.Close();
            }
        }
    }
    public void mostrarLibros()
    {
        Elibro    encapsular = new Elibro();
        DALibros  libros     = new DALibros();
        DataTable data       = libros.listarLibros();

        ImgLibro.ImageUrl = data.Rows[0]["foto_libro"].ToString();
        LB_nomb_lib.Text  = data.Rows[0]["nombre_libro"].ToString();
        LB_autor.Text     = data.Rows[0]["autor"].ToString();
        LB_genero.Text    = data.Rows[0]["genero"].ToString();
        LB_ano_plub.Text  = data.Rows[0]["ano_publicacion"].ToString();
        LB_descrip.Text   = data.Rows[0]["descripcion"].ToString();
    }
Exemple #3
0
    protected void BTN_subir_Click(object sender, EventArgs e)
    {
        Elibro   encapsular  = new Elibro();
        DALibros agregaLibro = new DALibros();

        encapsular.FotoLibro1      = cargarImagen();
        encapsular.NombreLibro1    = TB_nomLibro.Text;
        encapsular.AñoPublicacion1 = TB_año.Text;
        encapsular.Genero1         = TB_genero.Text;
        encapsular.Descripcion1    = TB_descripcion.Text;
        encapsular.Autor1          = TB_autor.Text;

        agregaLibro.registrarLibro(encapsular);
    }