//点击注册按钮 protected void sign_up_Click(object sender, EventArgs e) { Modeluser user = new Modeluser(); Blluser blluser = new Blluser(); //判断是否选中了复选框同意条款 if (!this.CheckBox1.Checked) { Response.Write("<script>alert('请同意并勾选隐私条款');</script>"); } else { //获取Textbox中的值 user.userName = this.name.Text; user.userPwd = this.Password.Text; user.userEmail = this.Email.Text; if (user.userName.Equals("") || user.userPwd.Equals("") || user.userEmail.Equals("")) { this.name.Focus(); Response.Write("<script>alert('注册信息不能存在空值');</script>"); } else if (!IsEmail(user.userEmail)) { this.Email.Focus(); Response.Write("<script>alert('请输入有效的邮箱');</script>"); } else if (!Iscan(user.userPwd)) { this.Password.Focus(); Response.Write("<script>alert('密码只能由数字字母和下划线组成');</script>"); } else if (user.userName.Length > 12) { this.name.Focus(); Response.Write("<script>alert('用户名过长');</script>"); } else { //注册该用户 if (!blluser.signup(user))//用户已经注册过 { Response.Write("<script>alert('该邮箱已注册,您可以使用该邮箱登录');</script>"); } else { //跳转到添加个人信息页面 user.Id = blluser.queryUserIdByEmail(user.userEmail); Session.Add("id", user.Id); Response.Redirect("inputuserinfo.aspx"); } } } }
protected void signin_Click(object sender, EventArgs e) { //用户登录并跳转到首页 Modeluser user = new Modeluser(); Blluser blluser = new Blluser(); if (IsEmail(this.email.Text) == true) { user = blluser.signin(this.email.Text, this.password.Text); if (user == null) { Response.Write("<script>alert('邮箱或密码错误');</script>"); } else { if (user.Id == 0) { Response.Write("<script>alert('没有该用户,请检查输入是否正确');</script>"); } else if (user.Id == -1) { Response.Write("<script>alert('该用户被封禁,请联系客服人员。');</script>"); } else { Session.Add("userid", user.Id); Session.Add("username", user.userName); Session.Add("userpwd", user.userPwd); Session.Add("useremail", user.userEmail); Response.Redirect("default.aspx"); } } } else { Response.Write("<script>alert('请输入有效的邮箱');</script>"); } }