コード例 #1
0
        private void btnDelete_Click(object sender, EventArgs e)
        {
            if (dgvMain.SelectedRows.Count >= 1)
            {
                DialogResult dr = MessageBox.Show("Are you serious?", "BE CAREFUL", MessageBoxButtons.YesNo);
                if (dr == DialogResult.Yes)
                {
                    var  rows      = dgvMain.SelectedRows;
                    bool isSuccess = false;
                    switch (CurrentPoco)
                    {
                    case CurrentPoco.Shipper:
                        for (int i = 0; i < rows.Count; i++)
                        {
                            var       s  = rows[i].DataBoundItem as Shipper;
                            ShipperBO sb = new ShipperBO();
                            if (sb.Delete(s.ShipperID))
                            {
                                isSuccess = true;
                            }
                        }
                        break;

                    case CurrentPoco.Category:
                        for (int i = 0; i < rows.Count; i++)
                        {
                            var        c  = rows[i].DataBoundItem as Category;
                            CategoryBO cb = new CategoryBO();
                            if (cb.Delete(c.CategoryID))
                            {
                                isSuccess = true;
                            }
                        }
                        break;

                    default:
                        break;
                    }
                    if (isSuccess)
                    {
                        MessageBox.Show("Successful");
                    }
                    else
                    {
                        MessageBox.Show("Error");
                    }
                }
            }
        }
コード例 #2
0
 public ActionResult Delete(int id)
 {
     sbo.Delete(id);
     return(RedirectToAction("Index", "Shipper"));
 }