示例#1
0
        //Zamykanie wypożyczenia
        private void Btn_zamknij_wyp_Click(object sender, RoutedEventArgs e)
        {
            int indexwyp = listViewRent1.SelectedIndex;

            try
            {
                if (indexwyp > -1)
                {
                    if (MessageBox.Show("Czy chcesz zamknąć wypożyczenie ? ", "Uwaga", MessageBoxButton.YesNo) == MessageBoxResult.Yes)
                    {
                        Order order1 = new Order();

                        order1 = (Order)listViewRent1.SelectedItem;


                        Rent wypozyczenia1 = new Rent();

                        wypozyczenia1 = db.Rent.Find(order1.id_rent);

                        db.Rent.Remove(wypozyczenia1);
                        db.SaveChanges();

                        ShowList(wys);
                    }
                }
                else
                {
                    MessageBox.Show("Musisz wybrać wypożyczenie", "Uwaga");
                }
            }
            catch (SqlException f)
            {
                MessageBox.Show(f.Message);
            }
        }
示例#2
0
        private void Btn_usun_ksiazke_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                if (MessageBox.Show("Czy chcesz usuną książkę " + books1.Title + " ?", "", MessageBoxButton.YesNo) == MessageBoxResult.Yes)
                {
                    var linqdeleteBook = from x in db.AuthorsBook
                                         where x.IdBook == books1.IdBook
                                         select x;

                    foreach (var x in linqdeleteBook)
                    {
                        AuthorsBook authorsBook1 = new AuthorsBook();
                        authorsBook1 = db.AuthorsBook.Find(x.IdAK);

                        db.AuthorsBook.Remove(authorsBook1);
                    }

                    db.Books.Remove(books1);
                    db.SaveChanges();
                }


                MessageBox.Show("Usunięto");
                frame1.Content = new Page2(frame1, db);
            }
            catch (SqlException f)
            {
                MessageBox.Show(f.Message);
            }
            catch (Exception f)
            {
                MessageBox.Show(f.Message);
            }
        }
示例#3
0
        private void Btn_dodaj_autora_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                string imie     = txt_Name.Text;
                string nazwisko = txt_Surename.Text;
                string uwaga    = "Czy chcesz dodać autora " + imie + " " + nazwisko + " ?";

                if (imie != "" && nazwisko != "")
                {
                    if (MessageBox.Show(uwaga, "Uwaga", MessageBoxButton.YesNo) == MessageBoxResult.Yes)
                    {
                        Author autor1 = new Author();
                        autor1.FirstName = txt_Name.Text;
                        autor1.Surename  = txt_Surename.Text;

                        db.Author.Add(autor1);
                        db.SaveChanges();


                        frame1.Content = new Autorzy_Page(frame1, db);
                    }
                }
            }
            catch (Exception f)
            {
                MessageBox.Show(f.Message);
            }
        }
示例#4
0
        //Edytowanie autora
        private void Btn_edytuj_autora_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                author1.FirstName = txt_name.Text;
                author1.Surename  = txt_surename.Text;

                db.Entry(author1).State = EntityState.Modified;
                db.SaveChanges();
                frame1.Content = new Autorzy_Page(frame1, db);
            }
            catch (SqlException f)
            {
                MessageBox.Show(f.Message);
            }
            catch (FormatException f)
            {
                MessageBox.Show(f.Message);
            }
        }
示例#5
0
        //Dodawanie ksiazki
        private void Btn_dodaj_ksiazke_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                //Dodawanie ksiazek
                string title = txt_title.Text;

                Books books1 = new Books();
                books1.Title = title;

                db.Books.Add(books1);
                db.SaveChanges();



                Author autor2 = (Author)cmbAutor.SelectedItem;
                MessageBox.Show(autor2.IdAuthor.ToString());



                AuthorsBook authorsBook1 = new AuthorsBook();

                authorsBook1.IdAuthor = autor2.IdAuthor;
                authorsBook1.IdBook   = books1.IdBook;

                db.AuthorsBook.Add(authorsBook1);
                db.SaveChanges();
            }
            catch (FormatException)
            {
                MessageBox.Show("Wprowadzono błędne dane");
            }
            catch (SqlException f)
            {
                MessageBox.Show(f.Message);
            }
        }
示例#6
0
        //Przycisk dodawania wspolautora
        private void Btn_dodaj_autora_Click(object sender, RoutedEventArgs e)
        {
            if (cmb_CoAuthor.SelectedIndex > -1)
            {
                AuthorsBook authorsBook1 = new AuthorsBook();

                Author autor1 = (Author)cmb_CoAuthor.SelectedItem;

                authorsBook1.IdAuthor = autor1.IdAuthor;
                authorsBook1.IdBook   = bookAuthor1.IdBook;


                db.AuthorsBook.Add(authorsBook1);
                db.SaveChanges();

                this.Close();
            }
        }
示例#7
0
        //Dodawanie wypozyczen do tabeli wypozyczenia czyli do bazy danych
        private void Btn_Wypozycz_Film_Copy_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                int      nrOfOrders = Listview_rent.Items.Count;
                DateTime dateNow    = DateTime.Now;
                DateTime dateNext   = dateNow.AddDays(30);

                if (nrOfOrders > 0)
                {
                    Rent rent1 = new Rent();

                    foreach (var x in order2)
                    {
                        rent1.IdClient   = x.idclient;
                        rent1.IdBook     = x.idbook;
                        rent1.DateStart  = dateNow;
                        rent1.DateReturn = dateNext;

                        //MessageBox.Show(rent1.id_klienta + "  "+rent1.id_ksiazki);

                        db.Rent.Add(rent1);
                        db.SaveChanges();
                    }



                    MessageBox.Show("Złożono zamówienie");
                    Listview_rent.ItemsSource = null;

                    order2.Clear();
                    // Listview_rent.Items.Clear();
                }
                else
                {
                    MessageBox.Show("Złóż zamówienia");
                }
            }
            catch (SqlException f)
            {
                MessageBox.Show(f.Message);
            }
        }