/// <summary> /// 重置密码 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btResetPsw_Click(object sender, EventArgs e) { Admin admin = new Admin(); int length = 0; //胡媛媛添加,判断当前有无用户,2010-01-15 if (GridView1.Rows.Count == 0) { Page.ClientScript.RegisterStartupScript(this.GetType(), "Alert", "<script>alert('当前已无任何用户!')</script>"); return; } else { //胡媛媛添加,判断当前有无用户,2010-01-15 for (int i = 0; i <= GridView1.Rows.Count - 1; i++) { //建立模板列中CheckBox控件的引用 CheckBox chk = (CheckBox)GridView1.Rows[i].FindControl("chkCheck"); if (chk.Checked == true) { length++; } } if (length == 0) { Page.ClientScript.RegisterStartupScript(this.GetType(), "Alert", "<script>alert('请先选中要重设密码的用户!')</script>"); return; } int[] iTchIdArray = new int[length]; int k = 0; for (int i = 0; i <= GridView1.Rows.Count - 1; i++) { //建立模板列中CheckBox控件的引用 CheckBox chk = (CheckBox)GridView1.Rows[i].FindControl("chkCheck"); if (chk.Checked == true) { iTchIdArray[k] = Convert.ToInt32(GridView1.DataKeys[i].Value); k++; } } try { admin.ResetTeachersPassword(iTchIdArray); Page.ClientScript.RegisterStartupScript(this.GetType(), "Alert", "<script>alert('重置成功!')</script>"); GridViewBind(); } catch { Page.ClientScript.RegisterStartupScript(this.GetType(), "Alert", "<script>alert('重置失败!')</script>"); } //胡媛媛添加,去掉全选前面的复选框,2010-01-07 finally { if (chkAll.Checked == true) { chkAll.Checked = false; } } //胡媛媛添加,去掉全选前面的复选框,2010-01-07 } }