예제 #1
0
        void addHandler(object sender, RoutedEventArgs e)
        {
            int bookId;

            if (((CheckBox)FindName("handwritten_check")).IsChecked == true)
            {
                String      author = ((TextBox)this.FindName("author_text")).Text;
                String      title  = ((TextBox)this.FindName("title_text")).Text;
                String      genre  = ((TextBox)this.FindName("genre_text")).Text;
                Models.Book book   = new Models.Book();
                book.Author = author;
                book.Title  = title;
                book.Genre  = genre;
                book.UserId = -1;
                book.ISBN   = "...";
                bookId      = new Helpers.BookDbHelper().addBook(book);
            }
            else
            {
                ComboBox combo = (ComboBox)FindName("book_combo");
                bookId = ((KeyValuePair <int, string>)combo.SelectedItem).Key;
            }
            Models.OwnedBook oBook = new Models.OwnedBook();
            oBook.Favorite = false;
            oBook.UserId   = -1;
            oBook.BookId   = bookId;
            oBook.Aquired  = DateTime.Now;
            new Helpers.OwnedDbHelper().addOwnedBook(oBook);
            this.Close();
            caller.Visibility = Visibility.Visible;
            caller.refresh();
        }
예제 #2
0
 public EditBook(MainWindow caller, int bookId)
 {
     InitializeComponent();
     this.caller = caller;
     editedBook  = new Helpers.BookDbHelper().getBook(bookId);
     ((Button)this.FindName("confirm_button")).Click += confirmHandler;
     ((Button)this.FindName("cancel_button")).Click  += cancelHandler;
     ((TextBox)this.FindName("author_text")).Text     = editedBook.Author;
     ((TextBox)this.FindName("title_text")).Text      = editedBook.Title;
     ((TextBox)this.FindName("genre_text")).Text      = editedBook.Genre;
     this.Closing += closeHandler;
 }
예제 #3
0
        void addHandler(object sender, RoutedEventArgs e)
        {
            String author = ((TextBox)this.FindName("author_text")).Text;
            String title  = ((TextBox)this.FindName("title_text")).Text;
            String genre  = ((TextBox)this.FindName("genre_text")).Text;

            Models.Book book = new Models.Book();
            book.Author = author;
            book.Title  = title;
            book.Genre  = genre;
            book.UserId = -1;
            book.ISBN   = "...";
            new Helpers.BookDbHelper().addBook(book);
            this.Close();
            caller.Visibility = Visibility.Visible;
            caller.refresh();
        }