static void Main(string[] args) { BookLibrary bookLibrary = new BookLibrary("ул. Хуюкина 6", 10, 18); bookLibrary.run(); Console.ReadKey(); }
private void btnGetSQLBooks_Click(object sender, RoutedEventArgs e) { try { dgBooks.DataContext = BookLibrary.GetBooks(true); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void btnRemove_Click(object sender, RoutedEventArgs e) { try { Book current = spBooks.DataContext as Book; BookLibrary.DeleteBook(current); dgBooks.DataContext = BookLibrary.GetBooks(true); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void btnSave_Click(object sender, RoutedEventArgs e) { try { Book current = spBooks.DataContext as Book; if (BookLibrary.UpdateBook(current) > 0) { MessageBox.Show("Updated"); } else { MessageBox.Show("Update failed"); } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void btnAdd_Click(object sender, RoutedEventArgs e) { try { if (btnAdd.Content.ToString() == "Uusi") { Book newBook = new Book(0); newBook.Name = "Anna kirjan nimi"; spBooks.DataContext = newBook; btnAdd.Content = "Tallenna uusi kantaan"; } else { Book current = spBooks.DataContext as Book; BookLibrary.InsertBook(current); dgBooks.DataContext = BookLibrary.GetBooks(true); btnAdd.Content = "Uusi"; } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void btnGetTestBooks_Click(object sender, RoutedEventArgs e) { dgBooks.DataContext = BookLibrary.GetTestBooks(); }