Example #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);
     }
 }
Example #2
0
 private void btnSave_Click(object sender, RoutedEventArgs e)
 {
     //Mistä tiedetään mitä muokata ---> book-olion ID:stä
     try
     {
         Book current = (Book)spBook.DataContext;
         if (BookShop.UpdateBook(current) > 0)
         {
             MessageBox.Show(string.Format("kirja {0} päivitetty tietokantaan onnistuneesti", current.ToString()));
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
Example #3
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";
     }
 }
Example #4
0
 private void btnSearchTest_Click(object sender, RoutedEventArgs e)
 {
     dgBooks.DataContext = BookShop.GetTestBooks();
 }