Пример #1
0
 private void btnSearchSQL_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         //Haetaan kirjat BL-kerroksesta
         dgBooks.DataContext = BookShop.GetBooks(true);
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
Пример #2
0
 private void btnNew_Click(object sender, RoutedEventArgs e)
 {
     if (btnNew.Content.ToString() == "Uusi")
     {
         //luodaan uusi kirja olio
         Book newBook = new Book(0);
         newBook.Name       = "Anna kirjan nimi";
         spBook.DataContext = newBook;
         btnNew.Content     = "Tallenna uusi kantaan";
     }
     else
     {
         Book current = (Book)spBook.DataContext;
         BookShop.InsertBook(current);
         dgBooks.DataContext = BookShop.GetBooks(true);
         MessageBox.Show(string.Format("Kirja {0} tallennettu kantaan onnistuneesti", current.ToString()));
         btnNew.Content = "Uusi";
     }
 }