private void chongzhimima_Click(object sender, EventArgs e) { DialogResult dr; Boolean flag = false; if (grid1[grid1.Selection.ActivePosition.Row, 0] != null) { dr = MessageBox.Show("您确认将用户\"" + grid1[grid1.Selection.ActivePosition.Row, 0].ToString() + "\"的密码重置为初始密码\"123456\"吗?", "请确认", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (dr == DialogResult.Yes) { Account acc = new Account(); //flag = acc.deleteFaultById(grid1[grid1.Selection.ActivePosition.Row, 0].ToString()); //flag = acc.deleteKnowledgeById(grid1[grid1.Selection.ActivePosition.Row, 0].ToString()); flag = acc.updatePasswordForInit(grid1[grid1.Selection.ActivePosition.Row, 0].ToString(), "123456"); if (flag) { MessageBox.Show("密码重置成功!"); } else { MessageBox.Show("密码重置失败!"); } } } }