public ActionResult Delete(int id) { var dao = new BookDAO(); dao.Delete(id); return(RedirectToAction("Index")); }
public ActionResult Delete(int id) { Book book = dao.Find(id); bookAuthorsDAO.Delete(book); dao.Delete(book); return(RedirectToAction("Index")); }
public ActionResult Delete(int id) { BookDAO bookDAO = new BookDAO(); bookDAO.Delete(id); List <Book> bookList = bookDAO.GetAll(); return(View("BookList", bookList)); }
private void btnDeleteBook_Click(object sender, EventArgs e) { Book b = new Book(); b.BookNumber = Convert.ToInt32(txtBookNumber.Text); BookDAO.Delete(b); dgvBooks.DataSource = BookDAO.GetDataTable(); MessageBox.Show("Delete Successful"); display(0); }
public ActionResult Delete(int id) { var dao = new BookDAO(); var result = dao.Delete(id); if (result) { return(RedirectToAction("Index", "Book")); } else { ModelState.AddModelError("", "Xóa không thành công"); } return(View("Index")); }
private void btnDelete_Click(object sender, EventArgs e) { if (!isSelected()) { return; } int bookNumber = (int)dataGridView1.SelectedRows[0].Cells["bookNumber"].Value; DialogResult dr = MessageBox.Show(String.Format("Do you want to delete this book number {0}?", bookNumber), "Confirm deteting", MessageBoxButtons.YesNo); if (dr == DialogResult.No) { return; } BookDAO.Delete(bookNumber); View(); }
public JsonResult Delete(long[] id) { try { int[] status = new int[id.Length]; for (int i = 0; i < id.Length; i++) { status[i] = dao.Delete(id[i]); } return(Json(new { status = status })); } catch (Exception) { return(Json(new { status = 0 })); } }
public ActionResult Delete(int id) { bookDAO.Delete(SearchById(id)); return(RedirectToAction("Index")); }
//button select or delete on grid view protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName == "Select") { //must add inside or else exception index=-1(default) occurs int index = Int32.Parse(e.CommandArgument.ToString()); if (copyExist == false) { GridViewRow gvRow = GridView1.Rows[index]; txtTitle.Text = gvRow.Cells[3].Text; //title //default blank in gridview = txtAuthor.Text = gvRow.Cells[4].Text.Trim().Equals(" ") ? "" : gvRow.Cells[4].Text; //author txtPublisher.Text = gvRow.Cells[5].Text.Trim().Equals(" ") ? "" : gvRow.Cells[5].Text; //publisher bo = new Book(); bo.BookNumber = Int32.Parse(gvRow.Cells[2].Text.ToString()); //book number } else { GridViewRow gridViewRow = GridView2.Rows[index]; txtTypecopy.Text = gridViewRow.Cells[5].Text.ToString(); // type txtPrice.Text = gridViewRow.Cells[6].Text.Equals(" ") ? "" : gridViewRow.Cells[6].Text; // price co = new Copy(); co.CopyNumber = Int32.Parse(gridViewRow.Cells[2].Text.ToString()); } } //delete if (e.CommandName == "Del") { int index = Int32.Parse(e.CommandArgument.ToString()); if (copyExist == false) { GridViewRow gvRow = GridView1.Rows[index]; int bookNum = Int32.Parse(gvRow.Cells[2].Text.ToString()); if (BookDAO.Delete(bookNum)) { reload(); } else { return; } } else { GridViewRow gridViewRow = GridView2.Rows[index]; int copyNum = Int32.Parse(gridViewRow.Cells[2].Text.ToString()); if (CopyDAO.Delete(copyNum)) { reload(); } else { return; } } } }