private void btnDelete_Click(object sender, EventArgs e) { if (MessageBox.Show("Do You really want to delete this Agent?", "DELETE", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes) { int refagent = (int)gridAll.Rows[gridAll.CurrentRow.Index].Cells[0].Value; if (admin.Delete_Agent(refagent)) { MessageBox.Show("Agent ID" + refagent + " is successfully Deleted", "Agent Deleted"); } else { MessageBox.Show("Agent " + refagent + " is not deleted.", "Try Again"); } } gridAll.DataSource = admin.Search_All_Agents(); ButtonControl(true, true, false, false, true, false); }