Beispiel #1
0
        private void UpdateList()
        {
            //实例化一个bookDao
            //Dao数据库访问操作
            BookDao bookDao = new BookDao();
            //通过bookDao对象取出所有的书的信息
            List <BookInfo> list = bookDao.GetAllBooks();

            if (list != null)
            {
                StringBuilder sb = new StringBuilder();
                //遍历列表
                foreach (BookInfo book in list)
                {
                    //生成html
                    sb.AppendFormat("<tr class='odd gradeX'><td>{0}</td><td style='width:20%;'><img width='99%' src='{4}'/></td><td>{1}</td><td>{2}</td><td>{3}</td><td>{5}</td><td>{6}</td><td><div bookId = '{0}' class='btn-group-sm text-center'><button type = 'button' class='btn btn-success btn_update'>编辑</button><p> </p><button type = 'button' class='btn btn-danger btn_delete' data-toggle='modal' data-target='#confirm-delete'>删除</button></div></td>", book.Id, book.Name, book.Author, book.Description, book.Image, book.Price, book.TypeName);
                }
                //返回给页面
                ProductsList = sb.ToString();
            }
        }
Beispiel #2
0
 public List <Book> GetAllBooks()
 {
     return(bookDao.GetAllBooks());
 }