Esempio n. 1
0
        protected void Button10_Click(object sender, EventArgs e)
        {
            //prida do BookCategory
            DatabaseLibrary.BookCategory bookCat = new DatabaseLibrary.BookCategory();

            bookCat.book_id = Convert.ToInt32(DropDownList_bookCatogery_book_id.SelectedValue);
            bookCat.category_id = Convert.ToInt32(DropDownList_bookCatogery_category_id.SelectedValue);

            new DatabaseLibrary.BookCategoryTable().InsertBookCategory(bookCat);

            Response.Redirect(Request.RawUrl);
        }
Esempio n. 2
0
        public void InsertBookCategory(BookCategory bookcat)
        {
            using (MySqlConnection conn = new MySqlConnection(connString))
            {
                conn.Open();
                MySqlCommand command = new MySqlCommand(INSERT_BOOKCATEGORY, conn);

                /* Add parameters into the command */
                command.Parameters.AddWithValue("@category_id", bookcat.category_id);
                command.Parameters.AddWithValue("@book_id", bookcat.book_id);

                /* Executes the command */
                command.ExecuteNonQuery();
            }
        }
Esempio n. 3
0
        public List<BookCategory> SelectAll()
        {
            List<BookCategory> bookcatList = new List<BookCategory>();
            using (MySqlConnection conn = new MySqlConnection(connString))
            {
                conn.Open();
                MySqlCommand command = new MySqlCommand(SELECT_ALL, conn);

                MySqlDataReader reader = command.ExecuteReader();

                while (reader.Read())
                {
                    BookCategory bookcat = new BookCategory();
                    bookcat.category_id = reader.GetInt32(0);
                    bookcat.book_id = reader.GetInt32(1);

                    bookcatList.Add(bookcat);
                }
            }
            return bookcatList;
        }
Esempio n. 4
0
        public List<BookCategory> SelectAllByBook(int bookId)
        {
            List<BookCategory> bookcatList = new List<BookCategory>();
            using (MySqlConnection conn = new MySqlConnection(connString))
            {
                conn.Open();
                MySqlCommand command = new MySqlCommand(SELECT_ALL_BY_BOOK_ID, conn);
                command.Parameters.AddWithValue("@book_id", bookId);
                MySqlDataReader reader = command.ExecuteReader();

                while (reader.Read())
                {
                    BookCategory bookcat = new BookCategory();
                    bookcat.category_id = reader.GetInt32(0);
                    bookcat.book_id = reader.GetInt32(1);

                    bookcatList.Add(bookcat);
                }
            }
            return bookcatList;
        }