コード例 #1
0
        public IHttpActionResult Putlibros(int id, libros libros)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != libros.id_Libro)
            {
                return(BadRequest());
            }

            db.Entry(libros).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!librosExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
コード例 #2
0
        public IHttpActionResult Getlibros(int id)
        {
            libros libros = db.libros.Find(id);

            if (libros == null)
            {
                return(NotFound());
            }

            return(Ok(libros));
        }
コード例 #3
0
        public IHttpActionResult Postlibros(libros libros)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.libros.Add(libros);
            db.SaveChanges();

            return(CreatedAtRoute("DefaultApi", new { id = libros.id_Libro }, libros));
        }
コード例 #4
0
        public IHttpActionResult Deletelibros(int id)
        {
            libros libros = db.libros.Find(id);

            if (libros == null)
            {
                return(NotFound());
            }

            db.libros.Remove(libros);
            db.SaveChanges();

            return(Ok(libros));
        }
コード例 #5
0
 private void button1_Click(object sender, EventArgs e)
 {
     libros nuevo = new libros();
     buscado = textBox2.Text;
     Conexion bd = new Conexion();
     List<string> lista = bd.consulta("SELECT * FROM libros WHERE titulo LIKE '%" + buscado + "%';");
     for (int i = 0; i < lista.Count; i = i + 10)
     {
         string id = lista[i];
         string nombre = lista[i + 1];
         nuevo.agregar(id, nombre);
         LISTA.Add(nuevo);
     }
     this.buscar();
 }
コード例 #6
0
        private void button1_Click(object sender, EventArgs e)
        {
            libros nuevo = new libros();
            buscado = buscador.Text;
            Conexion bd = new Conexion();
            List<string> lista = bd.consulta("SELECT * FROM libros WHERE titulo LIKE'%" + buscado + "%';");
            for (int i = 0; i < lista.Count; i = i + 10)
            {
                string id = lista[i];
                string nombre = lista[i + 1];

                string categoria = lista[i + 2];
                string cant_hojas = lista[i + 3];
                string editorial = lista[i + 5];
                string precio = lista[i + 6];
                string año = lista[i + 7];
                string indice = lista[i + 8];
                string stock = lista[i + 9];

                nuevo.agregar(id, nombre, categoria, cant_hojas, editorial, precio, año, indice, stock);
                LISTA.Add(nuevo);
            }
            this.buscar();
        }
コード例 #7
0
ファイル: autores_abm.cs プロジェクト: Julian-VC/CookBooks
        private void mostrarLibros()
        {
            Conexion bd = new Conexion();
            List<string> lista = bd.consulta("SELECT * FROM libros");
            libros libro = new libros();
            List<string> columnas = new List<string> { "id", "Nombre", "Categoria", "Cant Hojas", "Editorial", "Precio", "Año", "Stock" };

            foreach (String columna in columnas)
            {
                DataGridViewColumn nueva = new DataGridViewTextBoxColumn();
                nueva.Name = columna;
                nueva.DataPropertyName = columna;
                nueva.HeaderText = columna;
                dataGridView1.Columns.Add(nueva);
            }

            for (int i = 0; i < lista.Count; i = i + 10)
            {
                string id = lista[i];
                string nombre = lista[i + 1];

                string categoria = lista[i + 2];
                string cant_hojas = lista[i + 3];
                string editorial = lista[i + 5];
                string precio = lista[i + 6];
                string año = lista[i + 7];
                string indice = lista[i + 8];
                string stock = lista[i + 9];

                libro.agregar(id, nombre, categoria, cant_hojas, editorial, precio, año, indice, stock);

                dataGridView1.Rows.Add(libro.getId(), libro.getNombre(), libro.getCategoria(), libro.getCantHojas(), libro.getEditorial(), libro.getPrecio(), libro.getAño(), libro.getStock());
            }
            // Resize the master DataGridView columns to fit the newly loaded data.
            dataGridView1.AutoResizeColumns();
            dataGridView1.AutoSize = false;
            // Configure the details DataGridView so that its columns automatically
            // adjust their widths when the data changes.
            dataGridView1.AutoSizeColumnsMode =
                DataGridViewAutoSizeColumnsMode.AllCells;
        }