private void listBooksButton_Click(object sender, System.EventArgs e) { //clear the data grid dataGrid1.DataSource = null; //Call the service layer and //ask it to fetch all books IList books = BookServices.FetchAllBooks(context); //bind the result to the data grid dataGrid1.DataSource = books; }
private void createBookButton_Click(object sender, System.EventArgs e) { //Call the service layer and //ask it to create a new book object Book book = BookServices.CreateBook( context, titleTextBox.Text, isbnTextBox.Text); //Display the id of the new author bookIdTextBox.Text = book.Id.ToString(); }
private void deleteBookButton_Click(object sender, System.EventArgs e) { //Make sure the user has entered a book id if (bookIdTextBox.Text == "") { MessageBox.Show("Please enter the id of the book first!"); return; } //Call the service layer and //ask it to delete the book BookServices.DeleteBook( context, int.Parse(bookIdTextBox.Text)); }
private void fetchBookButton_Click(object sender, System.EventArgs e) { //Make sure the user has entered a book id if (bookIdTextBox.Text == "") { MessageBox.Show("Please enter the id of the book first!"); return; } //Call the service layer and //ask it to fetch a book by id Book book = BookServices.FetchBookById( context, int.Parse(bookIdTextBox.Text)); //Display the title and isbn titleTextBox.Text = book.Title; isbnTextBox.Text = book.Isbn; }