private void ButtonAdd_Click(object sender, RoutedEventArgs e) { //instantiate the object int genreId = ComboGenre.SelectedIndex + 1; try { Book b = new Book(0, TbAuthor.Text, TbTitle.Text, genreId, decimal.Parse(TbPrice.Text), DateTime.Parse(TbPubDate.Text), TbDescription.Text); db.AddBooks(b); } catch (ArgumentException ex) { MessageBox.Show("the values are out of range" + ex.StackTrace); } catch (FormatException ex) { MessageBox.Show("not A valid Format" + ex.StackTrace); } refreshBookList(); LvBooks.Items.Refresh(); //clear the field of textboxes TbAuthor.Clear(); TbTitle.Clear(); ComboGenre.SelectedValue = false; TbPubDate.Clear(); TbDescription.Clear(); TbPrice.Clear(); }
//Clears all text boxes after a spell is added public void ClearTB() { TbSearch.Clear(); TbName.Clear(); TbLevel.Clear(); TbSchool.Clear(); TbTime.Clear(); TbRange.Clear(); TbComponents.Clear(); TbDuration.Clear(); TbAvailableClass.Clear(); TbDescription.Clear(); }