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; }
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(); }
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)); }
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; }
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; }
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)); }