Exemplo n.º 1
0
        private void listAuthorButton_Click(object sender, System.EventArgs e)
        {
            //clear the data grid
            dataGrid1.DataSource = null;

            //Call the service layer and
            //ask it to fetch all authors
            IList authors = AuthorServices.FetchAllAuthors(context);

            //bind the result to the data grid
            dataGrid1.DataSource = authors;
        }
Exemplo n.º 2
0
        private void createAuthorButton_Click(object sender, System.EventArgs e)
        {
            //Call the service layer and
            //ask it to create a new author object
            Author author = AuthorServices.CreateAuthor(
                context,
                firstNameTextBox.Text,
                lastNameTextBox.Text);

            //Display the id of the new author
            idTextBox.Text = author.Id.ToString();
        }
Exemplo n.º 3
0
        private void deleteAuthorButton_Click(object sender, System.EventArgs e)
        {
            //Make sure the user has entered an author id
            if (idTextBox.Text == "")
            {
                MessageBox.Show("Please enter the id of the author first!");
                return;
            }

            //Call the service layer and
            //ask it to delete the author
            AuthorServices.DeleteAuthor(
                context,
                int.Parse(idTextBox.Text));
        }
Exemplo n.º 4
0
        private void filterButton_Click(object sender, System.EventArgs e)
        {
            //clear the data grid
            dataGrid1.DataSource = null;

            //Call the service layer and
            //ask it to fetch all authors
            //matching the filter
            IList authors = AuthorServices.FilterAuthors(
                context,
                firstNameFilterTextBox.Text,
                lastNameFilterTextBox.Text);

            //bind the result to the data grid
            dataGrid1.DataSource = authors;
        }
Exemplo n.º 5
0
        private void fetchAuthorButton_Click(object sender, System.EventArgs e)
        {
            //Make sure the user has entered an author id
            if (idTextBox.Text == "")
            {
                MessageBox.Show("Please enter the id of the author first!");
                return;
            }

            //Call the service layer and
            //ask it to fetch an author by id
            Author author = AuthorServices.FetchAuthorById(
                context,
                int.Parse(idTextBox.Text));

            //Display the author's name
            firstNameTextBox.Text = author.FirstName;
            lastNameTextBox.Text  = author.LastName;
        }
Exemplo n.º 6
0
        private void removeAuthorButton_Click(object sender, System.EventArgs e)
        {
            //Make sure the user has entered an author id
            if (idTextBox.Text == "")
            {
                MessageBox.Show("Please enter the id of the author first!");
                return;
            }

            //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 remove the author from the book
            AuthorServices.RemoveAuthorFromBook(
                context,
                int.Parse(bookIdTextBox.Text),
                int.Parse(idTextBox.Text));
        }