Ejemplo n.º 1
0
        private void oautorachButton_Click(object sender, RoutedEventArgs e)
        {
            Autorzy okno = new Autorzy();

            okno.Show();
        }
Ejemplo n.º 2
0
        private void Dodaj()
        {
            Kategoria e = null;
            Autorzy   c = null;
            Tytuły    d = null;

            foreach (Autorzy t in db.GetTable <Autorzy>())
            {
                if (t.Autor == cbAutor.Text)
                {
                    c = t;
                    break;
                }
            }
            foreach (Tytuły t in db.GetTable <Tytuły>())
            {
                if (t.Tytuł == cbTytuł.Text)
                {
                    d = t;
                    break;
                }
            }
            foreach (Kategoria t in db.GetTable <Kategoria>())
            {
                if (t.Kategorie == cbGatunek.Text)
                {
                    e = t;
                    break;
                }
            }
            if (c == null)
            {
                c = new Autorzy()
                {
                    id_Autor = db.GetTable <Autorzy>().Count() + 1,
                    Autor    = cbAutor.Text
                };
                db.GetTable <Autorzy>().InsertOnSubmit(c);
            }
            if (d == null)
            {
                d = new Tytuły()
                {
                    id_Tytuł = db.GetTable <Tytuły>().Count() + 1,
                    Tytuł    = cbTytuł.Text
                };
                db.GetTable <Tytuły>().InsertOnSubmit(d);
            }
            if (e == null)
            {
                e = new Kategoria()
                {
                    id_Kategorie = db.GetTable <Kategoria>().Count() + 1,
                    Kategorie    = cbGatunek.Text
                };
                db.GetTable <Kategoria>().InsertOnSubmit(e);
            }


            Książki książki = new Książki()
            {
                id_Książka   = db.GetTable <Książki>().Count() + 1,
                id_Autor     = c.id_Autor,
                id_Kategorie = e.id_Kategorie,
                id_Tytuł     = d.id_Tytuł
            };

            db.GetTable <Książki>().InsertOnSubmit(książki);
            db.SubmitChanges();
        }