private void AddAuthorButton_Click(object sender, RoutedEventArgs e) { if (string.IsNullOrEmpty(AuthorNameBox.Text) || string.IsNullOrEmpty(AuthorSurnameBox.Text) || string.IsNullOrWhiteSpace(AuthorNameBox.Text) || string.IsNullOrWhiteSpace(AuthorSurnameBox.Text)) { MessageBox.Show("Puste pola!", "Błąd przy dodawaniu do bazy danych", MessageBoxButton.OK, MessageBoxImage.Error); } else { var name = AuthorNameBox.Text; var surname = AuthorSurnameBox.Text; var dateOfBirth = AuthorDateOfBirthPicker.SelectedDate; var biography = AuthorBiographyBox.Text; var author = new AuthorModel() { Imię = name, Nazwisko = surname, DataUrodzenia = dateOfBirth, Biografia = biography }; DataInsertionController.InsertAuthorIntoDatabase(author); //WszyscyAutorzyDataGrid.Items.Add(author); UpdateDataGrid(); AuthorNameBox.Text = ""; AuthorSurnameBox.Text = ""; AuthorBiographyBox.Text = ""; } }
private void AddBookButton_Click(object sender, RoutedEventArgs e) { if (string.IsNullOrEmpty(BookTitleBox.Text) || string.IsNullOrWhiteSpace(BookTitleBox.Text) || string.IsNullOrEmpty(BookGenreBox.Text) || string.IsNullOrWhiteSpace(BookGenreBox.Text) || string.IsNullOrEmpty(AuthorNameBox.Text) || string.IsNullOrWhiteSpace(AuthorNameBox.Text)) { MessageBox.Show("Puste pola!", "Błąd przy dodawaniu do bazy danych", MessageBoxButton.OK, MessageBoxImage.Error); } else { var title = BookTitleBox.Text; //imię + nazwisko var authorName = AuthorNameBox.Text; var genreName = BookGenreBox.Text; var author = Autorzy.First(x => x.Nazwa == authorName); var książka = new BookModel() { Tytuł = title, Autor = author, Gatunek = GenresDatabaseConnectionController.GetGenreByName(genreName), IsBorrowed = false, }; DataInsertionController.InsertBookIntoDatabase(książka); UpdateDataGrid(); AuthorNameBox.Text = ""; BookTitleBox.Text = ""; BookGenreBox.Text = ""; } }
private void UpdateAmounts() { var amounts = DataInsertionController.GetAmountsOfItems(); AmountOfBooks.Text = amounts.Item1.ToString(); AmountOfAuthors.Text = amounts.Item2.ToString(); AmountOfGenres.Text = amounts.Item3.ToString(); AmountOfUsers.Text = amounts.Item4.ToString(); }
private void AddGenreButton_Click(object sender, RoutedEventArgs e) { if (string.IsNullOrEmpty(GenreNameBox.Text) || string.IsNullOrWhiteSpace(GenreNameBox.Text)) { MessageBox.Show("Puste pola!", "Błąd przy dodawaniu do bazy danych", MessageBoxButton.OK, MessageBoxImage.Error); } else { var name = GenreNameBox.Text; var gatunek = new GenreModel() { Nazwa = name }; DataInsertionController.InsertGenreIntoDatabase(gatunek); UpdateDataGrid(); GenreNameBox.Text = ""; } }