private void btnSearch_Click_1(object sender, EventArgs e) { //string catalog = this.cboSearch.Text; string key = this.txtSearch.Text; if (key == "") { MessageBox.Show("Please enter keyword!", "Notice"); return; } string catalog = "tentheloai"; TypeOfBookBLL typeOfBookBLL = new TypeOfBookBLL(); List <TypeOfBookBLL> typeOfBookArr = new List <TypeOfBookBLL>(); //MessageBox.Show(catalog + " " + key); typeOfBookArr = TypeOfBookDAL.search(catalog, key); this.dgvTypeOfBook.Rows.Clear(); foreach (TypeOfBookBLL row in typeOfBookArr) { this.dgvTypeOfBook.Rows.Add(row.TypeOfBookId, row.Name); } this.GetSelectedValue(); this.dgvTypeOfBook.CellClick += new DataGridViewCellEventHandler(dgvTypeOfBook_CellClick); }
private void btnDelete_Click(object sender, EventArgs e) { if (this.dgvTypeOfBook.SelectedCells.Count > 0) { int selectedrowindex = this.dgvTypeOfBook.SelectedCells[0].RowIndex; DataGridViewRow selectedRow = this.dgvTypeOfBook.Rows[selectedrowindex]; TypeOfBookBLL typeOfBookBLL = new TypeOfBookBLL(Convert.ToInt32(selectedRow.Cells["clmnId"].Value), selectedRow.Cells["clmnId"].Value.ToString()); DialogResult result = MessageBox.Show("Do you want to delete type of book: " + selectedRow.Cells["clmnName"].Value + "?", "Warning", MessageBoxButtons.OKCancel); switch (result) { case DialogResult.Cancel: break; case DialogResult.OK: if (TypeOfBookDAL.getTypeOfBookItem(typeOfBookBLL) != null) { MessageBox.Show("Can't delete! Please delete all book title has type " + selectedRow.Cells["clmnName"].Value + " before delete this type!", "Error"); break; } else { TypeOfBookDAL.deleteTypeOfBook(typeOfBookBLL); MessageBox.Show("Delete complete!", "Success"); this.LoadDataToGridView(); break; } } } }
private void btnAdd_Click(object sender, EventArgs e) { TypeOfBookBLL typeOfBookBLL = new TypeOfBookBLL(); typeOfBookBLL.Name = this.txtTypeOfBookName.Text; if (typeOfBookBLL.Name == "") { MessageBox.Show("Author name is not null!", "Notice"); return; } TypeOfBookDAL.addTypeOfBook(typeOfBookBLL); MessageBox.Show("Add success!", "Success"); this.LoadDataToGridView(); }
private void LoadDataToGridView() { this.dgvTypeOfBook.Rows.Clear(); TypeOfBookBLL typeOfBookBLL = new TypeOfBookBLL(); List <TypeOfBookBLL> typeOfBookArr = new List <TypeOfBookBLL>(); typeOfBookArr = TypeOfBookDAL.getTypeOfBookList(); foreach (TypeOfBookBLL row in typeOfBookArr) { this.dgvTypeOfBook.Rows.Add(row.TypeOfBookId, row.Name); } this.GetSelectedValue(); this.dgvTypeOfBook.CellClick += new DataGridViewCellEventHandler(this.dgvTypeOfBook_CellClick); }
public List <ComboboxItem> getComboboxItemTypeOfBook() { List <TypeOfBookBLL> typeOfBookList = new List <TypeOfBookBLL>(); typeOfBookList = TypeOfBookDAL.getTypeOfBookList(); List <ComboboxItem> comboboxItemList = new List <ComboboxItem>(); for (int i = 0; i < typeOfBookList.Count; i++) { ComboboxItem item = new ComboboxItem(); item.Value = typeOfBookList[i].TypeOfBookId; item.Text = typeOfBookList[i].Name; comboboxItemList.Add(item); } return(comboboxItemList); }
private void btnSave_Click(object sender, EventArgs e) { if (this.dgvTypeOfBook.SelectedCells.Count > 0) { int selectedrowindex = this.dgvTypeOfBook.SelectedCells[0].RowIndex; DataGridViewRow selectedRow = this.dgvTypeOfBook.Rows[selectedrowindex]; TypeOfBookBLL typeOfBookBLL = new TypeOfBookBLL(Convert.ToInt32(selectedRow.Cells["clmnId"].Value), txtTypeOfBookName.Text); if (typeOfBookBLL.Name == "") { MessageBox.Show("Author name is not null!", "Notice"); return; } TypeOfBookDAL.updateTypeOfBook(typeOfBookBLL); MessageBox.Show("Update success!", "Success"); this.LoadDataToGridView(); } }
private void LoadDataToDataGridViewBookTitle() { this.dgvBookTitle.Rows.Clear(); List <BookTitleBLL> bookTitleList = new List <BookTitleBLL>(); bookTitleList = BookTitleDAL.getBookTitleList(); TypeOfBookBLL typeOfBookBLL = new TypeOfBookBLL(); foreach (BookTitleBLL row in bookTitleList) { typeOfBookBLL = TypeOfBookDAL.getTypeOfBookItem(row.TypeOfBookId); PublisherBLL publisherBLL = new PublisherBLL(); publisherBLL = PublisherDAL.getPublisherItem(row.PublisherId); BookTitleStatusBLL status = new BookTitleStatusBLL(); status = BookTitleStatusDAL.getBookTitleStatusItem(row.BookTitleStatusId); this.dgvBookTitle.Rows.Add(row.BookTitleId, row.Name, row.TypeOfBookId, typeOfBookBLL.Name, row.PublisherId, publisherBLL.Name, row.BookTitleStatusId, status.Name, row.Summary); } GetSelectedValueDataGridViewBookTitle(); this.dgvBookTitle.SelectionChanged += new EventHandler(dgvBookTitle_SelectionChanged); }
public List <BookTitleBLL> search(string catalog, string key) { if (catalog == "matinhtrang") { List <BookTitleBLL> bookTitleList = new List <BookTitleBLL>(); List <BookTitleStatusBLL> bookTitleStatusList = new List <BookTitleStatusBLL>(); bookTitleStatusList = BookTitleStatusDAL.getBookTitleStatusItem(key); if (bookTitleStatusList != null) { foreach (BookTitleStatusBLL bookTitleStatusBLL in bookTitleStatusList) { List <BookTitleBLL> results = new List <BookTitleBLL>(); results = BookTitleDAL.getBookTitleList(catalog, bookTitleStatusBLL.BookTitleStatusId); if (results != null) { foreach (BookTitleBLL bookTitleBLL in results) { bookTitleList.Add(bookTitleBLL); } } } return(bookTitleList); } return(null); } else if (catalog == "manxb") { List <BookTitleBLL> bookTitleList = new List <BookTitleBLL>(); List <PublisherBLL> publisherList = new List <PublisherBLL>(); publisherList = PublisherDAL.getPublisherItem(key); if (publisherList != null) { foreach (PublisherBLL publisherBLL in publisherList) { List <BookTitleBLL> results = new List <BookTitleBLL>(); results = BookTitleDAL.getBookTitleList(catalog, publisherBLL.PublisherId); if (results != null) { foreach (BookTitleBLL bookTitleBLL in results) { bookTitleList.Add(bookTitleBLL); } } return(bookTitleList); } } return(null); } else if (catalog == "matheloai") { List <BookTitleBLL> bookTitleList = new List <BookTitleBLL>(); List <TypeOfBookBLL> typeOfBookList = new List <TypeOfBookBLL>(); typeOfBookList = TypeOfBookDAL.getTypeOfBookItem(key); if (typeOfBookList != null) { foreach (TypeOfBookBLL typeOfBookBLL in typeOfBookList) { List <BookTitleBLL> results = new List <BookTitleBLL>(); results = BookTitleDAL.getBookTitleList(catalog, typeOfBookBLL.TypeOfBookId); if (results != null) { foreach (BookTitleBLL bookTitleBLL in results) { bookTitleList.Add(bookTitleBLL); } } return(bookTitleList); } } return(null); } else if (catalog == "tensach" || catalog == "tomtat") { List <BookTitleBLL> bookTitleList = new List <BookTitleBLL>(); bookTitleList = BookTitleDAL.search(catalog, key); return(bookTitleList); } return(null); }