Exemplo n.º 1
0
        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;
        }
Exemplo n.º 2
0
        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();
        }
Exemplo n.º 3
0
        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));
        }
Exemplo n.º 4
0
        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;
        }