//删除按钮事件 private void Admin_del_Click(object sender, EventArgs e) { int id = 0; try { id = (int)dataGridView1.CurrentRow.Cells[0].Value; } catch { MessageBox.Show("请选择有效数据行!"); return; } if (id == 8) { MessageBox.Show("不允许删除管理员账号", "提示"); return; } else if (MessageBox.Show("确定要删除吗?", "询问", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) != DialogResult.Yes) { return; } if (bll.delete(id.ToString())) { MessageBox.Show("删除成功!"); } else { MessageBox.Show("删除失败!"); } Fill(); }