Exemplo n.º 1
0
        public void NewBook(string connectionString, AvailableBooks book, SimlpeAthor athor)
        {
            var p = new
            {
                isbn        = book.ISBN,
                tytul       = book.Tytuł,
                rok_wydania = book.Rok_wydania,
                wydawca     = book.Wydawca,
                kategoria   = book.Kategoria,
                nr_autora   = athor.Nr_autora
            };

            using (IDbConnection cnn = new SqlConnection(connectionString))
            {
                cnn.Execute("[dbo].[SpNewBook]", p, commandType: CommandType.StoredProcedure);
            }
        }
Exemplo n.º 2
0
        private void dodaj_książke(object sender, RoutedEventArgs e)
        {
            try
            {
                AvailableBooks book = new AvailableBooks();
                book.ISBN        = string.IsNullOrWhiteSpace(isbn.Text) ? throw new Exception() : isbn.Text;
                book.Rok_wydania = rok_wydania.Text;
                book.Wydawca     = wydawca.Text;
                book.Tytuł       = string.IsNullOrWhiteSpace(tytul.Text) ? throw new Exception() : tytul.Text;

                SimlpeAthor author = new SimlpeAthor();

                author.imie_nazwisko = autor.SelectedItem?.ToString() ?? throw new Exception();
                autors.ForEach(x =>
                {
                    if (x.imie_nazwisko == author.imie_nazwisko)
                    {
                        author.Nr_autora = x.Nr_autora;
                    }
                });

                categories.ForEach(x =>
                {
                    if (x.nazwa_kategorii == kategoria.SelectedItem?.ToString())
                    {
                        book.Kategoria = x.id_kategorii.ToString();
                    }
                });


                _data.NewBook(_module.SqlProfile.connectionString.ToString(), book, author);
            }
            catch
            {
                buttOn.Background = Brushes.DarkRed;
            }
            refresh();
            Clean();
        }