Esempio n. 1
0
 private void button2_Click(object sender, EventArgs e)
 {
     if (ErrorControls.EmptyTextBox(tbName)) // add in db
     {
         Genre genre = new Genre();
         genre.name = tbName.Text;
         dbCatalog.Genre.Add(genre);
         dbCatalog.SaveChanges();
         this.Close();
     }
 }
Esempio n. 2
0
 private void btnOK_Click(object sender, EventArgs e)
 {
     if (ErrorControls.EmptyTextBox(tbName)) // add in db
     {
         Publishing pb = new Publishing();
         pb.name = tbName.Text;
         pb.year = (int)nudYear.Value;
         dbCatalog.Publishing.Add(pb);
         dbCatalog.SaveChanges();
         this.Close();
     }
 }
Esempio n. 3
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            int res = CheckUser();

            if (res == 0)
            {
                Book book = new Book();
                book.name       = tbName.Text;
                book.author     = tbAuthor.Text;
                book.Genre      = (Genre)cmbGenre.SelectedItem;
                book.Publishing = (Publishing)cmbPublishing.SelectedItem;
                dbCatalog.Book.Add(book);
                dbCatalog.SaveChanges();
                // take count records in db Book
                int lastId =
                    (from bk in dbCatalog.Book
                     select bk.id).Count();
                parent.UpdateListBook(lastId - 1);
                this.Close();
            }
        }