private void btnGetSqlBooks_Click(object sender, RoutedEventArgs e) { try { books = BookShop.GetBooks(true); dgBooks.DataContext = books; } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void btnGetBooks_Click(object sender, RoutedEventArgs e) { //Haetaan kirjat tietokannasta ORM=muutetaan Book-olioiksi try { books = BookShop.GetTestBooks(); dgBooks.DataContext = books; } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void btnSave_Click(object sender, RoutedEventArgs e) { //Valittu Book-olio tallennetaan kantaan try { Book current = (Book)spBook.DataContext; BookShop.UpdateBook(current); MessageBox.Show(string.Format("Kirja {0} päivitetty kantaan onnistuneesti", current.ToString())); } catch (Exception ex) { MessageBox.Show(ex.Message); } }