Esempio n. 1
0
        private void button1_Click(object sender, EventArgs e) // USUN CZYTELNIKA
        {
            var usun = MessageBox.Show("Czy na pewno chcesz usunąć tego czytelnika?", "Potwierdź usunięcie", MessageBoxButtons.YesNo);

            if (usun == DialogResult.Yes)
            {
                try
                {
                    db.Wypozyczenie.RemoveRange(db.Wypozyczenie.Where(x => x.Czytelnik_ID == aktualnyCzytelnik.ID));
                    db.Czytelnik.Remove(aktualnyCzytelnik);
                    db.SaveChanges();
                }
                catch
                {
                    MessageBox.Show("Niepoprawny wybór");
                }
                finally
                {
                    Odswiez();
                    aktualnyCzytelnik = null;
                    tbImie.Text       = null;
                    tbNazwisko.Text   = null;
                    tbPesel.Text      = null;
                    tbEmail.Text      = null;
                    tbTelefon.Text    = null;
                }
            }
        }
Esempio n. 2
0
        // -------------------------------------------------------------------------------
        // ----------------------------- C Z Y T E L N I K -------------------------------
        // -------------------------------------------------------------------------------
        private void dataGridView1_CellContentClick_1(object sender, DataGridViewCellEventArgs e) // INFO O CZYTELNIKU
        {
            aktualnyCzytelnik = czytelnikBindingSource.Current as Czytelnik;

            tbImie.Text     = aktualnyCzytelnik.Imie;
            tbNazwisko.Text = aktualnyCzytelnik.Nazwisko;
            tbPesel.Text    = aktualnyCzytelnik.PESEL;
            tbEmail.Text    = aktualnyCzytelnik.Email;
            tbTelefon.Text  = aktualnyCzytelnik.Telefon;
            try
            {
                ksiazkaTableAdapter.FillBy2(bibliotekaDataSet.Ksiazka, aktualnyCzytelnik.ID);
            }
            catch {}

            if (db.Wypozyczenie.Any(x => x.Czytelnik_ID == aktualnyCzytelnik.ID))
            {
                wypozyczenieTableAdapter.FillByKsiazka(bibliotekaDataSet.Wypozyczenie, int.Parse(listBox1.SelectedValue.ToString()), aktualnyCzytelnik.ID);
            }
            Odswiez();
        }
Esempio n. 3
0
        private void btDodaj_Click(object sender, EventArgs e) // DODAJ CZYTELNIKA
        {
            if (!String.IsNullOrEmpty(tbImie.Text) && !String.IsNullOrEmpty(tbNazwisko.Text) && !String.IsNullOrEmpty(tbPesel.Text))
            {
                Czytelnik nowyCzytelnik = new Czytelnik();
                nowyCzytelnik.Imie     = tbImie.Text;
                nowyCzytelnik.Nazwisko = tbNazwisko.Text;
                nowyCzytelnik.PESEL    = tbPesel.Text;
                nowyCzytelnik.Email    = tbEmail.Text;
                nowyCzytelnik.Telefon  = tbTelefon.Text;
                db.Czytelnik.Add(nowyCzytelnik);

                db.SaveChanges();
                dataGridView1.Update();
                dataGridView1.Refresh();
                Odswiez();
            }
            else
            {
                MessageBox.Show("Sprawdź poprawność danych");
            }
            Odswiez();
        }