示例#1
0
文件: ENBook.cs 项目: rlm33/svn
        /// <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);
        }
示例#2
0
文件: ENUsedBook.cs 项目: rlm33/svn
        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"];
        }
示例#3
0
 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 });
     }
 }
示例#4
0
文件: ENBook.cs 项目: rlm33/svn
        /// <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);
        }
示例#5
0
 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);
 }
示例#6
0
 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);
 }
示例#7
0
        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"];
        }
示例#8
0
 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 });
     }
 }
示例#9
0
文件: ENBook.cs 项目: rlm33/svn
        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;
            }
        }
示例#10
0
 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);
 }
示例#11
0
 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);
     }
 }
示例#12
0
 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);
 }
示例#13
0
        private void buttonEliminarLibro_Click(object sender, EventArgs e)
        {
            ENBook book = new ENBook();
            book = book.read(textBoxIdLibroBuscar.Text);
            book.delete();

            buttonEliminarLibro.Visible = false;
        }
示例#14
0
 /// <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;
 }
示例#15
0
 /// <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;
 }
示例#16
0
        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;
            }
        }
示例#17
0
 public ENYearHasBooks(ENBook book, ENYear year)
 {
     this.book = book;
     this.year = year;
 }
示例#18
0
 public ENYearHasBooks()
 {
     cadYearHasBook = new CADYearsHasBooks();
     year = new ENYear();
     book = new ENBook();
 }
示例#19
0
 public ENYearHasBooks(ENBook book, ENYear year)
 {
     this.book = book;
     this.year = year;
 }
示例#20
0
 public ENYearHasBooks()
 {
     cadYearHasBook = new CADYearsHasBooks();
     year           = new ENYear();
     book           = new ENBook();
 }
示例#21
0
 public JsonResult BookUpdate(ENBook updatedBook)
 {
     try
     {
         updatedBook.Save();
         return Json(new { Result = "OK" });
     }
     catch (Exception ex)
     {
         return Json(new { Result = "ERROR", Message = ex.Message });
     }
 }
示例#22
0
 public void BookConnecting()
 {
     var actual = new List<ENBook>();
     var book = new ENBook();
     Assert.AreEqual(0, book.Id);
 }
示例#23
0
 public void BookReadingAll()
 {
     var actual = new List<ENBook>();
     var book = new ENBook();
     actual = book.ReadAll();
 }