private void deleteUser_Click(object sender, EventArgs e) { if (this.start) { MessageBox.Show("脚本运行中,不可删除!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if (this.dataGridView1.SelectedRows.Count > 0) { DataGridViewRow row = this.dataGridView1.SelectedRows[0]; DialogResult dialogResult = MessageBox.Show("您确定要删除 " + row.Cells[1].Value + " 吗?", "删除提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (dialogResult == DialogResult.Yes) { using (DataBaseService d = new DataBaseService()) { if (d.DelOneUserById((int)row.Cells[0].Value)) { InitDatabase(); MessageBox.Show("删除成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } } } } else { MessageBox.Show("请先选择要删除的行!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); } }