Example #1
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            BookDAO dao = new BookDAO();

            if (mode == "add")
            {
                if (isFormValid())
                {
                    Book book = new Book();
                    book.BookID       = inBookID.Value;
                    book.BookName     = inBookName.Value;
                    book.BookPrice    = int.Parse(inBookPrice.Value);
                    book.BookQuantity = int.Parse(inBookQuantity.Value);
                    book.BookDiscount = int.Parse(inBookDiscount.Value);

                    book.AuthorID   = inAuthor.SelectedValue;
                    book.CategoryID = inCategory.SelectedValue;
                    book.ProducerID = inProducer.SelectedValue;

                    book.Pages       = int.Parse(inPages.Value);
                    book.Size        = inSize.Value;
                    book.Year        = int.Parse(inYear.Value);
                    book.Description = inDescription.Value;

                    dao.AddBook(book);
                    init();
                }
            }
            if (mode == "edit")
            {
                Book book = new Book();
                book.BookID       = inBookID.Value;
                book.BookName     = inBookName.Value;
                book.BookPrice    = int.Parse(inBookPrice.Value);
                book.BookQuantity = int.Parse(inBookQuantity.Value);
                book.BookDiscount = int.Parse(inBookDiscount.Value);

                book.AuthorID   = inAuthor.SelectedValue;
                book.CategoryID = inCategory.SelectedValue;
                book.ProducerID = inProducer.SelectedValue;

                book.Pages       = int.Parse(inPages.Value);
                book.Size        = inSize.Value;
                book.Year        = int.Parse(inYear.Value);
                book.Description = inDescription.Value;

                dao.UpdateBook(book);
                init();
            }
        }