private void btnDelecteAward_Click(object sender, EventArgs e) { int success = 0; int error = 0; //判断是否选中行 if (dgvAwards.SelectedRows.Count > 0) { //循环 foreach (DataGridViewRow row in dgvAwards.SelectedRows) { string awardid = row.Cells[0].Value.ToString(); int i = StudentsInfoBLL.DeleteAward(awardid); if (i > 0) { success++; } else { error++; } } //统计共执行多少行 int sum = success + error; MessageBox.Show("共操作了" + sum + "行;成功" + success + "行,失败" + error + "行!"); BinderAward(); } }