/// <summary> /// Busca el libro en la base de datos y lo devuelve. /// </summary> /// <param name="id">Identificador del libro a buscar.</param> /// <returns>ENBook del libro encontrado en la base de datos.</returns> public ENBook Read(int id) { cad = new CADBook(); ENBook ret = new ENBook(); List <object> param = new List <object>(); param.Add((object)id); ret.FromRow(cad.Select(param)); return(ret); }
protected override void FromRow(DataRow Row) { ENBook t = base.Read((int)Row["Books"]); this.Subject = t.Subject; this.Bussiness = t.Bussiness; this.Name = t.Name; this.Description = t.Description; this.Picture = t.Picture; this.id = (int)Row["ID"]; this.quantity = (int)Row["Quantity"]; }
public JsonResult BookCreate(ENBook newBook) { try { newBook.Save(); return Json(new { Result = "OK", Record = newBook }); } catch (Exception ex) { return Json(new { Result = "ERROR", Message = ex.Message }); } }
/// <summary> /// Devuelve todos los libros que existen en la base de datos. /// </summary> /// <returns>Lista de ENBooks con todos los libros de la base de datos.</returns> public List <ENBook> ReadAll() { List <ENBook> ret = new List <ENBook>(); DataTable tabla = cad.SelectAll(); foreach (DataRow rows in tabla.Rows) { ENBook nuevo = new ENBook(); nuevo.FromRow(rows); ret.Add(nuevo); } return(ret); }
public void BookUpdate() { var book = new ENBook(); book = book.Read(1); var oldName = book.Name; book.Name = "testUpdateName"; book.Save(); var actual = book.Read(1); var actualName = actual.Name; actual.Name = oldName; actual.Save(); Assert.AreEqual("testUpdateName", actualName); }
public void BookInsert() { var book = new ENBook(); book.IdBook = "testInsertID"; book.Name = "testInsertName"; var testSubject = new ENSubject(); testSubject = testSubject.Read(1); book.Subject = testSubject; book.Bussiness = (new ENBusiness()).Read(1); book.Save(); var bookList = book.ReadAll(); var actual = bookList[bookList.Count - 1]; actual.Delete(); Assert.AreEqual("testInsertID", actual.IdBook); }
protected override void FromRow(DataRow Row) { ENBook t = base.Read((int)Row["idNewBooks"]); this.IdBook = t.IdBook; this.Subject = t.Subject; this.Bussiness = t.Bussiness; this.Name = t.Name; this.Description = t.Description; this.Picture = t.Picture; this.id = (int)Row["ID"]; this.idNewBooks = (int)Row["idNewBooks"]; this.quantity = (int)Row["Quantity"]; this.price = (float)(double)Row["Price"]; }
public JsonResult BookList() { try { var reader = new ENBook(); var list = reader.ReadAll(); /* var list = new List<Models.Book>(); list.Add(new Models.Book("1", "The First", 3.05f, "url/to/first.img")); list.Add(new Models.Book("2", "The Second", 21.95f, "url/to/second.img")); list.Add(new Models.Book("3", "The Third", 70.25f, "url/to/third.img")); */ return Json(new { Result = "OK", Records = list, TotalRecordCount = list.Count }); } catch (Exception ex) { return Json(new { Result = "ERROR", Message = ex.Message }); } }
public List <ENBook> Filter(String where) { List <ENBook> ret = new List <ENBook>(); DataTable table = cad.SelectWhere(where); try { foreach (DataRow row in table.Rows) { ENBook course = new ENBook(); course.FromRow(row); ret.Add(course); } return(ret); } catch (Exception ex) { throw ex; } }
private void buttonBuscarLibro_Click(object sender, EventArgs e) { if (textBoxIdLibroBuscar.Text != "") { //try //{ ENBook book = new ENBook(); book = book.read(textBoxIdLibroBuscar.Text); textBoxAsignaturasLibroBuscar.Text = book.Subject.Name; textBoxCursosLibroBuscar.Text = book.Course.Courses; textBoxNombreLibroBuscar.Text = book.Name; textBoxEditorialBuscaLibro.Text = book.CIF; textBoxDescripcionBuscaLibro.Text = book.Description; pictureBoxImagenLibro.Image = Image.FromFile(book.Image); buttonEliminarLibro.Visible = true; /* } catch { MessageBox.Show("Inserte un libro correcto.", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error); }*/ } else MessageBox.Show("Inserte un curso.", "Atención!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); }
private void buttonMostrarLibros_Click(object sender, EventArgs e) { ENBook libro = new ENBook(); List<ENBook> lista = libro.readAll(); dataGridViewMostrarLibros.Rows.Clear(); foreach (ENBook b in lista) { dataGridViewMostrarLibros.Rows.Add(b.IDBook,b.Subject.Name,b.Course.Courses,b.CIF,b.Years,b.Name,b.Description); } }
private void buttonGuardarNuevoLibro_Click(object sender, EventArgs e) { if (textBoxNuevoLibroIdBook.Text != "") { // try //{ ENCourse course = new ENCourse(); course = course.Read(comboBoxNuevoLibroCurso.Text); ENPublisher publisher = new ENPublisher(); publisher = publisher.read(comboBoxNuevoLibroEditorial.Text); ENSubject subject = new ENSubject(); //subject = subject.Course ENBook book = new ENBook(textBoxNuevoLibroIdBook.Text,subject,course,publisher.Cif, null,textBoxNuevoLibroNombre.Text, 1,textBoxNuevoLibroDescripcion.Text); book.insert(); /* } catch { MessageBox.Show("Inserte un libro correcto.", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error); }*/ } else MessageBox.Show("Inserte un ISBN/EAN13.", "Atención!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); }
private void buttonEliminarLibro_Click(object sender, EventArgs e) { ENBook book = new ENBook(); book = book.read(textBoxIdLibroBuscar.Text); book.delete(); buttonEliminarLibro.Visible = false; }
/// <summary> /// Devuelve todos los libros que existen en la base de datos. /// </summary> /// <returns>Lista de ENBooks con todos los libros de la base de datos.</returns> public List<ENBook> ReadAll() { List<ENBook> ret = new List<ENBook>(); DataTable tabla = cad.SelectAll(); foreach (DataRow rows in tabla.Rows) { ENBook nuevo = new ENBook(); nuevo.FromRow(rows); ret.Add(nuevo); } return ret; }
/// <summary> /// Busca el libro en la base de datos y lo devuelve. /// </summary> /// <param name="id">Identificador del libro a buscar.</param> /// <returns>ENBook del libro encontrado en la base de datos.</returns> public ENBook Read(int id) { cad = new CADBook(); ENBook ret = new ENBook(); List<object> param = new List<object>(); param.Add((object)id); ret.FromRow(cad.Select(param)); return ret; }
public List<ENBook> Filter(String where) { List<ENBook> ret = new List<ENBook>(); DataTable table = cad.SelectWhere(where); try { foreach (DataRow row in table.Rows) { ENBook course = new ENBook(); course.FromRow(row); ret.Add(course); } return ret; } catch (Exception ex) { throw ex; } }
public ENYearHasBooks(ENBook book, ENYear year) { this.book = book; this.year = year; }
public ENYearHasBooks() { cadYearHasBook = new CADYearsHasBooks(); year = new ENYear(); book = new ENBook(); }
public JsonResult BookUpdate(ENBook updatedBook) { try { updatedBook.Save(); return Json(new { Result = "OK" }); } catch (Exception ex) { return Json(new { Result = "ERROR", Message = ex.Message }); } }
public void BookConnecting() { var actual = new List<ENBook>(); var book = new ENBook(); Assert.AreEqual(0, book.Id); }
public void BookReadingAll() { var actual = new List<ENBook>(); var book = new ENBook(); actual = book.ReadAll(); }