public BookTitleBLL getBookTile(int bookId) { BookBLL bookBLL = new BookBLL(); bookBLL = BookDAL.getBookByBookId(bookId); if (bookBLL != null) { BookTitleBLL bookTitleBLL = new BookTitleBLL(); return BookTitleDAL.getBookTitleItem(bookBLL.BookTitleId); } return null; }
public BookTitleBLL getBookTile(int bookId) { BookBLL bookBLL = new BookBLL(); bookBLL = BookDAL.getBookByBookId(bookId); if (bookBLL != null) { BookTitleBLL bookTitleBLL = new BookTitleBLL(); return(BookTitleDAL.getBookTitleItem(bookBLL.BookTitleId)); } return(null); }
public static List<BookBLL> getBookList(BookTitleBLL bookTitleBLL) { string sql = "SELECT * FROM [sach] WHERE madausach=" + bookTitleBLL.BookTitleId; DataTable dt = BookDAL._condb.getDataTable(sql); if (dt.Rows.Count > 0) { List<BookBLL> bookList = new List<BookBLL>(); foreach (DataRow row in dt.Rows) { BookBLL bookBLL = new BookBLL(Int32.Parse(row["masach"].ToString()), Int32.Parse(row["madausach"].ToString()), Int32.Parse(row["matinhtrangsach"].ToString())); bookList.Add(bookBLL); } return bookList; } return null; }
private void btnBookAdd_Click(object sender, EventArgs e) { if (this.dgvBookTitle.SelectedCells.Count > 0 && this.dgvBookTitle.CurrentRow.Index < this.dgvBookTitle.Rows.Count - 1) { DataGridViewRow selectedRow = this.dgvBookTitle.Rows[this.dgvBookTitle.CurrentRow.Index]; int bookTitleId = Convert.ToInt32(selectedRow.Cells["clmnBookTitleId"].Value); int quantity = Convert.ToInt32(this.txtBookTotal.Text); if (quantity < 1) { MessageBox.Show("The quantity can't less than 1"); return; } BookBLL bookBLL = new BookBLL(); bookBLL.BookTitleId = bookTitleId; bookBLL.BookStatusId = 1; //Điều này có thể thay đổi for (int i = 0; i < quantity; i++ ) BookDAL.addBook(bookBLL); MessageBox.Show("Add success!"); } }
public static void addBook(BookBLL bookBLL) { String sql = "INSERT INTO [sach] (madausach, matinhtrangsach) VALUES ( '" + bookBLL.BookTitleId + "', '" + bookBLL.BookStatusId + "')"; BookDAL._condb.ExecuteNonQuery(sql); }