Пример #1
0
        static void Main(string[] args)
        {
            BookLibrary bookLibrary = new BookLibrary("ул. Хуюкина 6", 10, 18);

            bookLibrary.run();
            Console.ReadKey();
        }
Пример #2
0
 private void btnGetSQLBooks_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         dgBooks.DataContext = BookLibrary.GetBooks(true);
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
Пример #3
0
 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);
     }
 }
Пример #4
0
 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);
     }
 }
Пример #5
0
 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);
     }
 }
Пример #6
0
 private void btnGetTestBooks_Click(object sender, RoutedEventArgs e)
 {
     dgBooks.DataContext = BookLibrary.GetTestBooks();
 }