protected void Page_Load(object sender, EventArgs e) { if (Session["teaId"] != null) { string teaId = Session["teaId"].ToString(); teaNews1 = TeacherInfoManager.Getteachernews(teaId); TeacherInfoManager.Showteachernews(teaNews1, lblteaId, lblteaName, lblgender, lblphone, imgphoto); } else { Response.Redirect("Login.aspx"); } }
protected void Page_Load(object sender, EventArgs e) { if (Session["teaId"] != null) { if (txtteaId.Text == "") { if (Session["teaId"] != null) { string teaId = Session["teaId"].ToString(); teaNews1 = TeacherInfoManager.Getteachernews(teaId); TeacherInfoManager.Showteachernews2(teaNews1, txtteaId, txtteaName, rdolistgender, txtemail, imgphoto, txttel); lblgender.Text = teaNews1.gender; } } } else { Response.Redirect("Login.aspx"); } }
//密码修改 protected void btnSubmit_Click(object sender, EventArgs e) { string teaId = txtteaId.Text; teaNews1 = TeacherInfoManager.Getteachernews(teaId); string password = txtpsw1.Text; if (txtpsw.Text != teaNews1.password) { //Response.Write("<script type = 'text/javascript'> alert('原密码输入错误!'); </script>"); RegisterClientScriptBlock("", "<script>alert('原密码输入错误!')</script>"); txtpsw.Focus(); } else { TeacherInfo teacherInfo1 = new TeacherInfo(teaId, password); TeacherInfoManager.UpdatePsw(teacherInfo1); //Response.Write("<script type = 'text/javascript'> alert('密码修改成功!'); </script>"); RegisterClientScriptBlock("", "<script>alert('密码修改成功!')</script>"); } }
//保存修改 protected void btnSubmit0_Click(object sender, EventArgs e) { string teaId = txtteaId.Text; teaNews1 = TeacherInfoManager.Getteachernews(teaId); string photo = teaNews1.photo; string teaName = txtteaName.Text; string email = txtemail.Text; string gender = "男"; if (rdolistgender.Items[1].Selected == true) { gender = "女"; } string telephone = txttel.Text; Boolean fileOK = false; // 指定路径 String path = Server.MapPath("~/"); // 文件上传控件中如果已经包含文件 if (fUpload.HasFile) { // 得到文件的后缀 String fileExtension = System.IO.Path.GetExtension(fUpload.FileName).ToLower(); // 允许的文件后缀 String[] allowedExtensions = { ".gif", ".png", ".jpeg", ".jpg" }; // 看包含的文件是否是被允许的文件后缀 for (int i = 0; i < allowedExtensions.Length; i++) { if (fileExtension == allowedExtensions[i]) { // 如果是,标志位置为真 fileOK = true; } } } if (fileOK) { try { // 文件另存在服务器指定目录下 fUpload.PostedFile.SaveAs(Server.MapPath("./load/") + fUpload.FileName); lbText.Text = "文件上传成功!"; photo = "~/load/" + fUpload.FileName; } catch (Exception ex) { lbText.Text = "文件上传失败!"; } } else { lbText.Text = "注意:只能上传gif、png、jpeg或者jpg图像文件!"; } TeacherInfo teaInfo = new TeacherInfo(teaId, teaName, email, photo, gender, telephone); TeacherInfoManager.UpdateTeacher(teaInfo); teaNews1 = TeacherInfoManager.Getteachernews(teaId); TeacherInfoManager.Showteachernews2(teaNews1, txtteaId, txtteaName, rdolistgender, txtemail, imgphoto, txttel); lblgender.Text = teaNews1.gender; //Response.Write("<script type = 'text/javascript'> alert('修改成功!'); </script>"); RegisterClientScriptBlock("", "<script>alert('修改成功!')</script>"); return; }
//点击登录按钮事件 protected void ImageButton1_Click(object sender, ImageClickEventArgs e) { //判断是否选择用户类型 if (RadioButton1.Checked == false && RadioButton2.Checked == false) { //Response.Write("<script type = 'text/javascript'> alert('请选择用户类型!'); </script>"); RegisterClientScriptBlock("", "<script>alert('请选择用户类型!')</script>"); return; } //判断选择学生用户 else if (RadioButton2.Checked == true) { StudentInfo studentInfo = new StudentInfo(txtName.Text, txtPassword.Text); //登录成功 if (StudentInfoManager.StudentLoginCheck(studentInfo) && (txtcode.Text == lblcode.Text)) { Session["stuId"] = txtName.Text; Session["password"] = txtPassword.Text; Response.Redirect("StudentDefault.aspx"); //跳转到系统学生主界面 } //登录失败 else if ((!(StudentInfoManager.StudentLoginCheck(studentInfo))) && (txtcode.Text == lblcode.Text)) { //Response.Write("<script type = 'text/javascript'> alert('用户名或密码错误!'); </script>"); RegisterClientScriptBlock("", "<script>alert('用户名或密码错误!')</script>"); txtName.Text = ""; txtPassword.Text = ""; txtName.Focus(); } else if (StudentInfoManager.StudentLoginCheck(studentInfo) && (txtcode.Text != lblcode.Text)) { //Response.Write("<script type = 'text/javascript'> alert('验证码错误!'); </script>"); RegisterClientScriptBlock("", "<script>alert('验证码错误!')</script>"); txtcode.Text = ""; txtcode.Focus(); } else if ((!(StudentInfoManager.StudentLoginCheck(studentInfo))) && (txtcode.Text != lblcode.Text)) { //Response.Write("<script type = 'text/javascript'> alert('用户名或密码错误!'); </script>"); RegisterClientScriptBlock("", "<script>alert('用户名或密码错误!')</script>"); txtName.Text = ""; txtPassword.Text = ""; txtName.Focus(); } } //判断选择教师用户 else if (RadioButton1.Checked == true) { TeacherInfo teacherInfo = new TeacherInfo(txtName.Text, txtPassword.Text); //登录成功 if (TeacherInfoManager.TeacherLoginCheck(teacherInfo) && (txtcode.Text == lblcode.Text)) { Session["teaId"] = txtName.Text; Response.Redirect("TeacherDefault.aspx"); //跳转到系统教师主界面 } //登录失败 else if ((!(TeacherInfoManager.TeacherLoginCheck(teacherInfo))) && (txtcode.Text == lblcode.Text)) { //Response.Write("<script type = 'text/javascript'> alert('用户名或密码错误!'); </script>"); RegisterClientScriptBlock("", "<script>alert('用户名或密码错误!')</script>"); txtName.Text = ""; txtPassword.Text = ""; txtName.Focus(); } else if (TeacherInfoManager.TeacherLoginCheck(teacherInfo) && (txtcode.Text != lblcode.Text)) { //Response.Write("<script type = 'text/javascript'> alert('验证码错误!'); </script>"); RegisterClientScriptBlock("", "<script>alert('验证码错误!')</script>"); txtcode.Text = ""; txtcode.Focus(); } else if ((!(TeacherInfoManager.TeacherLoginCheck(teacherInfo))) && (txtcode.Text != lblcode.Text)) { //Response.Write("<script type = 'text/javascript'> alert('用户名或密码错误!'); </script>"); RegisterClientScriptBlock("", "<script>alert('用户名或密码错误!')</script>"); txtName.Text = ""; txtPassword.Text = ""; txtName.Focus(); } } }