Beispiel #1
0
        protected void btnRegister_Click(object sender, EventArgs e)
        {
            if (!CheckBox1.Checked)
            {
                Response.Write("<script>alert('服务条款未勾选!')</script>");
                return;
            }
            if (!UserNameIselgal || !PwdIselgal || !EmailIselgal)
            {
                return;
            }

            registerUser.UserName = rUserNameText.Text;
            registerUser.Pwd      = rPwdText.Text;
            registerUser.Email    = rEmailText.Text;
            registerUser.Nick     = rNickText.Text == "" || rNickText.Text == "昵称" ? rUserNameText.Text : rNickText.Text;

            //检查是否重名
            try
            {
                if (userBll.ExistsUserName(registerUser.UserName))
                {
                    Response.Write("<script>alert('用户名已存在!')</script>");
                }
                else
                {
                    CanRegister = true;
                }
            }
            catch
            {
                Response.Write("检测重名异常");
            }

            finally
            {
            }
            //注册
            if (CanRegister)
            {
                try
                {
                    if (userBll.Add(registerUser) > 0)
                    {
                        Session["CurrentUser"] = registerUser;
                        Response.Redirect("Home.aspx");
                    }
                }
                catch
                {
                    Response.Write("注册异常");
                }
                finally
                {
                }
            }
        }
Beispiel #2
0
        public User CreateUser(string username, string password)
        {
            var userDto = new UserDTO()
            {
                Login = username, Password = password
            };

            return(dbUsers.Add(userDto));
        }
Beispiel #3
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            string telphone = context.Request["telphone"];
            string pwd      = context.Request["pwd"];
            string repwd    = context.Request["repwd"];
            string yan      = context.Request["yan"];
            string code     = context.Session["code"].ToString();

            if (yan != code)
            {
                context.Response.Write("验证码不正确,请重试");
            }
            else
            {
                if (pwd != repwd)
                {
                    context.Response.Write("两次密码不一致,请重试");
                }
                else
                {
                    int isexists = ub.ExistsByLoginId(telphone);
                    if (isexists >= 1)
                    {
                        context.Response.Write("该用户名已被注册,请输入其他用户名");
                    }
                    else
                    {
                        Users u = new Users()
                        {
                            LoginId     = telphone,
                            LoginPwd    = pwd,
                            Name        = telphone,
                            Address     = "",
                            Phone       = telphone,
                            Mail        = "",
                            UserStateId = 1
                        };

                        int r = ub.Add(u);
                        if (r >= 1)
                        {
                            context.Session["user"] = u;
                            //没加密之前的密码
                            context.Session["userpwd"] = pwd;
                            context.Response.Write("ok");
                        }
                    }
                }
            }
        }