コード例 #1
0
 public static List <Book> Listbook()
 {
     using (Bookshop entities = new Bookshop())
     {
         return(entities.Books.ToList <Book>());
     }
 }
コード例 #2
0
 public static void DeleteBooks(int BookId)
 {
     using (Bookshop entities = new Bookshop())
     {
         Book book = entities.Books.Where(p => p.BookID == BookId).First <Book>();
         entities.Books.Remove(book);
         entities.SaveChanges();
     }
 }
コード例 #3
0
        protected void GridView2_SelectedIndexChanged(object sender, EventArgs e)
        {
            int BookId = (int)GridView2.SelectedDataKey.Value;

            using (Bookshop entities = new Bookshop())
            {
                Book book = entities.Books.Where(p => p.BookID == BookId).First <Book>();
                DetailsView1.DataSource = new Book[] { book };
                DetailsView1.DataBind();
            }
        }
コード例 #4
0
        public static void UpdateBooks(int BookId,
                                       string Title, int CategoryID, string Author, string ISBN, int Stock, decimal Price)
        {
            using (Bookshop entities = new Bookshop())
            {
                Book book = entities.Books.Where(p => p.BookID == BookId).First <Book>();
                book.Title      = Title;
                book.CategoryID = CategoryID;
                book.Author     = Author;
                book.ISBN       = ISBN;
                book.Stock      = Stock;
                book.Price      = Price;


                entities.SaveChanges();
            }
        }