コード例 #1
0
        public ActionResult Delete(int id)
        {
            var dao = new BookDAO();

            dao.Delete(id);
            return(RedirectToAction("Index"));
        }
コード例 #2
0
        public ActionResult Delete(int id)
        {
            Book book = dao.Find(id);

            bookAuthorsDAO.Delete(book);
            dao.Delete(book);
            return(RedirectToAction("Index"));
        }
コード例 #3
0
        public ActionResult Delete(int id)
        {
            BookDAO bookDAO = new BookDAO();

            bookDAO.Delete(id);
            List <Book> bookList = bookDAO.GetAll();

            return(View("BookList", bookList));
        }
コード例 #4
0
        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);
        }
コード例 #5
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"));
        }
コード例 #6
0
        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();
        }
コード例 #7
0
        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
                }));
            }
        }
コード例 #8
0
 public ActionResult Delete(int id)
 {
     bookDAO.Delete(SearchById(id));
     return(RedirectToAction("Index"));
 }
コード例 #9
0
ファイル: BookGUI.aspx.cs プロジェクト: tvad0905/PRN292
        //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 = &nbsp;
                    txtAuthor.Text    = gvRow.Cells[4].Text.Trim().Equals("&nbsp;") ? "" : gvRow.Cells[4].Text; //author
                    txtPublisher.Text = gvRow.Cells[5].Text.Trim().Equals("&nbsp;") ? "" : 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("&nbsp;") ? "" : 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;
                    }
                }
            }
        }