private void button1_Click(object sender, RoutedEventArgs e) { try { dataGrid.DataContext = BLBookshop.GetBooks(true); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void btnRemove_Click(object sender, RoutedEventArgs e) { try { Book book = (Book)spRigth.DataContext; if (BLBookshop.DeleteBook(book)) { MessageBox.Show("Poistettu"); } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void btnSave_Click(object sender, RoutedEventArgs e) { try { Book current = (Book)spRigth.DataContext; if (BLBookshop.UpdateBook(current) > 0) { MessageBox.Show("Tallennus onnistui!"); } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void btnNew_Click(object sender, RoutedEventArgs e) { if (btnNew.Content.ToString() == "Uusi") { Book book = new Book(0); book.Name = "Anna kirjan nimi"; spRigth.DataContext = book; btnNew.Content = "Tallenna uusi kirja"; } else { Book book = (Book)spRigth.DataContext; BLBookshop.InsertBook(book); dataGrid.DataContext = BLBookshop.GetBooks(true); btnNew.Content = "Uusi"; } }
private void button_Click(object sender, RoutedEventArgs e) { spRigth.DataContext = BLBookshop.GetTestBooks(); }