Ejemplo n.º 1
0
 private void btnDelete_Click(object sender, RoutedEventArgs e)
 {
     try {
         //poistetaan valittu kirja
         Book current = (Book)spInfo.DataContext;
         var  retval  = MessageBox.Show("Haluatko varmasti poistaa kirjan " + current.ToString(), "Wanhat kirjat kysyy", MessageBoxButton.YesNo);
         if (retval == MessageBoxResult.Yes)
         {
             Bookshop.DeleteBook(current);
             dgBooks.DataContext = Bookshop.GetBooks(true);
             MessageBox.Show(string.Format("Kirja {0} poistetaan", current.ToString()));
         }
     } catch (Exception ex) {
         MessageBox.Show(ex.Message);
     }
 }
Ejemplo n.º 2
0
 private void btnDelete_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         // Poistetaan valittu kirja
         Book current = (Book)spContent.DataContext;
         var  retval  = MessageBox.Show("Do you really want to delete book" + current.ToString(), "QUESTION", MessageBoxButton.YesNo);
         if (retval == MessageBoxResult.Yes)
         {
             Bookshop.DeleteBook(current);
             dgBooks.DataContext = Bookshop.GetBooks(true);
             MessageBox.Show(string.Format("Book {0} deleted from the database successfully", current.ToString()));
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }