private void gridViewParty_CellContentClick(object sender, DataGridViewCellEventArgs e) { string Action = this.gridViewParty.Columns[e.ColumnIndex].HeaderText; if (Action == "Edit") { frmParty frmParty = new frmParty(); PartyId = Convert.ToInt32(gridViewParty.Rows[e.RowIndex].Cells[0].Value); frmParty.PartyId = PartyId; frmParty.FormClosed += frmParty_FormClosed; frmParty.ShowInTaskbar = false; frmParty.Show(); } if (Action == "Delete") { try { PartyId = Convert.ToInt32(gridViewParty.Rows[e.RowIndex].Cells[0].Value); var messageBoxResult = MessageBox.Show("Are you sure want to delete this record?", "Delete", MessageBoxButtons.YesNo); if (messageBoxResult == DialogResult.Yes) { var result = ConsignorBusinessLogic.Delete(PartyId); MessageBox.Show("Party deleted successfully."); FillGridData(); } } catch (Exception) { MessageBox.Show("Party already used some where else can't deleted successfully."); } } }
public JsonResult DeleteConsignor(int id) { var result = ConsignorBusinessLogic.Delete(id); if (result) { return(Json(new { Success = true, Message = "Delete Successfully." })); } return(Json(new { Success = false, Message = "Error in transaction." })); }