Beispiel #1
0
        private void List_Users_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            var books_list = from ksiazka in dc.Ksiazka
                             join autor in dc.Autor on ksiazka.Fk_Author_Id equals autor.Pk_Autor_Id
                             join kategoria in dc.Kategoria on ksiazka.Fk_Kategoria_Id equals kategoria.Pk_Kategoria_Id
                             select new { ksiazka.Tytul, autor.Imie, autor.Nazwisko, kategoria.Kategoria1, ksiazka.Wydawnictwo, ksiazka.Dostepnosc };

            if (dc.DatabaseExists())
            {
                List_Book.ItemsSource = books_list;
            }

            index_users = List_Users.SelectedIndex + 1;

            BookList.Visibility  = Visibility.Visible;
            RentBook.Visibility  = Visibility.Collapsed;
            AddBook.Visibility   = Visibility.Collapsed;
            USERSLIST.Visibility = Visibility.Collapsed;

            Czytelnik czytelnik = dc.Czytelnik.SingleOrDefault(x => x.Pk_Czytelnik_Id == index_users);
            var       name      = czytelnik.Imie;
            var       surname   = czytelnik.Naziwsko;
            string    user      = name + ' ' + surname;

            string index1 = user;

            User.Text = index1;

            var books_to_return = from wypozyczenie in dc.Wypozyczenie
                                  join ksiazka in dc.Ksiazka on wypozyczenie.Fk_Ksiazka_Id equals ksiazka.Pk_Ksiazka_Id
                                  join czytelnik1 in dc.Czytelnik on wypozyczenie.Fk_Czytelnik_Id equals czytelnik1.Pk_Czytelnik_Id
                                  join autor in dc.Autor on ksiazka.Fk_Author_Id equals autor.Pk_Autor_Id
                                  where wypozyczenie.Fk_Czytelnik_Id == index_users
                                  select new { wypozyczenie.Pk_Wypozyczenie_Id, ksiazka.Tytul, autor.Imie, autor.Nazwisko, wypozyczenie.Data_oddania };

            if (dc.DatabaseExists())
            {
                Return1_Book.ItemsSource = books_to_return;
            }
        }
Beispiel #2
0
        private void ButtonAddUser_Click(object sender, RoutedEventArgs e)
        {
            int last_number_ID = dc.Czytelnik.Max(u => u.Pk_Czytelnik_Id) + 1;

            string name    = Name.Text;
            string surname = Surname.Text;
            string email   = Email.Text;
            string phone   = Phone.Text;
            string address = Address.Text;


            Czytelnik nowyCzytelnik = new Czytelnik
            {
                Pk_Czytelnik_Id = last_number_ID,
                Imie            = name,
                Naziwsko        = surname,
                Email           = email,
                Telefon         = phone,
                Adres           = address
            };

            dc.Czytelnik.InsertOnSubmit(nowyCzytelnik);
            dc.SubmitChanges();
            //Dodać uzytkownika do bazy (poszczególne informacje w stringach)



            //powrót do listy użytkowników
            var users_list = from czytelnik in dc.Czytelnik
                             select new { czytelnik.Imie, czytelnik.Naziwsko, czytelnik.Email, czytelnik.Telefon, czytelnik.Adres };

            if (dc.DatabaseExists())
            {
                List_Users.ItemsSource = users_list;
            }

            Add_Users.Visibility = Visibility.Collapsed;
        }
 partial void DeleteCzytelnik(Czytelnik instance);
 partial void UpdateCzytelnik(Czytelnik instance);
 partial void InsertCzytelnik(Czytelnik instance);