public static Boolean DeleteBook(int id) { if (BookDAO.DeleteBook(id)) { return(true); } return(false); }
protected void btnDelete_Click(object sender, EventArgs e) { BookDAO dao = new BookDAO(); dao.DeleteBook(inBookID.Value); init(); }
protected void GridViewBook_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName.Equals("DeleteRow")) { int bookID = int.Parse(e.CommandArgument.ToString()); BookDAO.DeleteBook(bookID); GridViewBook.DataBind(); } }
/// <summary> /// called when right click->Delete book is called /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void deleteBookToolStripMenuItem_Click(object sender, EventArgs e) { if (MessageBox.Show("Are you sure you want to delete these books?", "Delete?", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question) == DialogResult.Yes) { MainForm parent = (MainForm)this.ParentForm.MdiParent; BookDAO dao = new BookDAO(parent.CurrentDatabase.FullName); foreach (string id in this.SelectedIds) { dao.DeleteBook(id); } this.Refresh(); } }
private void btnDeleteBook_Click(object sender, EventArgs e) { BookDAO book = new BookDAO(); string MaSach = txtMaSach.Text; if (book.DeleteBook(MaSach)) { MessageBox.Show("Xóa thành công"); ShowBook(); } else { MessageBox.Show("Có lỗi khi xóa"); } }
/// <summary> /// Delete a book. /// </summary> /// <param name="isbn">string isbn</param> /// <returns>int rowsAffected</returns> /// <exception cref="ex">BusinnessException</exception> /// <exception cref="ex">Exception</exception> public int DeleteBook(string isbn) { try { _bookDAO = new BookDAO(); return(_bookDAO.DeleteBook(isbn)); } catch (DataAccessLayerException ex) { //Error log simulate Console.WriteLine(ex.ToString()); Console.WriteLine(ex.GetBaseException().ToString()); throw new BusinessLogicException(ex.Message); } catch (Exception ex) { //Error log simulate Console.WriteLine(ex.ToString()); Console.WriteLine(ex.GetBaseException().ToString()); throw; } }
public void DeleteBook(int id) { dao.DeleteBook(this.GetBook(id)); }