private void gridViewBill_CellContentClick(object sender, DataGridViewCellEventArgs e) { string Action = this.gridViewBill.Columns[e.ColumnIndex].HeaderText; if (Action == "Edit") { frmEntryBills frmbill = new frmEntryBills(); frmbill.BillId = Convert.ToInt32(gridViewBill.Rows[e.RowIndex].Cells[0].Value); frmbill.FormClosed += frmbill_FormClosed; frmbill.ShowDialog(); } if (Action == "Delete") { try { var messageBoxResult = MessageBox.Show("Are you sure want to delete this record?", "Delete", MessageBoxButtons.YesNo); if (messageBoxResult == DialogResult.Yes) { var result = BillBusinessLogic.Delete(Convert.ToInt32(gridViewBill.Rows[e.RowIndex].Cells[0].Value)); MessageBox.Show("Bill deleted successfully."); FillGridData(); } } catch (Exception) { MessageBox.Show("Bill already used some where else can't deleted successfully."); } } }
public JsonResult DeleteBill(int billId) { var result = BillBusinessLogic.Delete(billId); if (result) { return(Json(new { Success = true, Message = "Delete Successfully." })); } return(Json(new { Success = false, Message = "Error in transaction." })); }