Пример #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();
            }
        }