protected void btConfirm_Click(object sender, EventArgs e) { Admin admin = new Admin(); Search thisSearch = new Search(); StudentInfo thisStudent = new StudentInfo(); // 从界面读取学生信息 thisStudent.StrStudentNO = tbxStuNO.Text;// 读取学号 thisStudent.StrStudentName = tbxStuName.Text;// 姓名 thisStudent.StrIdentityId = tbxIdentityNO.Text;// 身份证号 MD5CryptoServiceProvider HashMD5 = new MD5CryptoServiceProvider();// 设置初始密码 thisStudent.StrPassword = ASCIIEncoding.ASCII.GetString(HashMD5.ComputeHash(ASCIIEncoding.ASCII.GetBytes("888888"))); string stuNO=this.tbxStuNO.Text;// 获取学号 if (Convert.ToInt32(this.DropDownList1.SelectedValue) == 0) { Page.ClientScript.RegisterStartupScript(this.GetType(), "Alert", "<script>alert('请选择班级!')</script>"); return; } ////else if (thisStudent.StrIdentityId == thisSearch.GetStudentByUsername(stuNO).StrIdentityId) // 武剑洁修改,2009-9-11 else if (thisSearch.GetStudentIdByUsername(tbxStuNO.Text) > 0) {// 用户名重复,则禁止添加新用户 Response.Write("<script>alert('用户名重复,该同学已存在!')</script>"); tbxStuNO.Text = "";// 清空输入 return; } else if (thisSearch.GetStudentIdByIdentityID(tbxIdentityNO.Text) > 0) {// 身份证号重复,则禁止添加新用户 Page.ClientScript.RegisterStartupScript(this.GetType(), "Alert","<script>alert('身份证号重复,该同学已经存在!')</script>"); tbxIdentityNO.Text = "";// 清空输入 return; } thisStudent.StrStudentNO=this.tbxStuNO.Text; thisStudent.StrStudentName=this.tbxStuName.Text; thisStudent.StrIdentityId=this.tbxIdentityNO.Text; thisStudent.ClassName = this.DropDownList1.SelectedItem.Text; HashMD5 = new MD5CryptoServiceProvider(); thisStudent.StrPassword = ASCIIEncoding.ASCII.GetString(HashMD5.ComputeHash(ASCIIEncoding.ASCII.GetBytes("888888"))); if (admin.AddStudent(thisStudent)) { //Page.ClientScript.RegisterStartupScript(this.GetType(), "Alert", // "<script>alert('添加成功!')</script>"); // 武剑洁修改,添加页面跳转,2009-9-10 Response.Write("<script>alert('添加成功!');window.location='./Student_Manage.aspx'</script>"); } else { //Page.ClientScript.RegisterStartupScript(this.GetType(), "Alert", // "<script>alert('添加失败!')</script>"); // 武剑洁修改,添加页面跳转,2009-9-10 Response.Write("<script>alert('添加成功!');window.location='./Student_Manage.aspx'</script>"); } }