コード例 #1
0
        public void ProcessRequest(HttpContext context)
        {
            string username        = context.Request["username"];
            string password        = context.Request["password"];
            string confirmPassword = context.Request["confirmPassword"];


            if (password != confirmPassword)
            {
                string createAccountFilePath = context.Server.MapPath("~/CreateAccount.html");
                string html = File.ReadAllText(createAccountFilePath);
                context.Response.Write("<script>alert('請確認密碼和密碼確認是否一樣')</script>");
                context.Response.Write(html);
                return;
            }

            MemberAccountModel memberAccountModel = new MemberAccountModel()
            {
                UserName = username,
                PassWord = password
            };

            if (_memberService.CreateMemberAccount(memberAccountModel))
            {
                context.Response.Write("<script>alert('建立帳號成功,請重新登入!')</script>");
                string html = File.ReadAllText(context.Server.MapPath("~/loginPage.html"));
                context.Response.Write(html);
            }
        }
コード例 #2
0
        public int CreateMemberAccount(MemberAccountModel model)
        {
            string    sql       = @"INSERT INTO dbo.UserAccount  (UserName,[PassWord]) VALUES (@UserName,@PassWord)";
            SqlHelper sqlHelper = new SqlHelper(_conn);

            SqlParameter usernameParameter = new SqlParameter("@UserName", SqlDbType.VarChar, 100)
            {
                Value = model.UserName
            };
            SqlParameter passWordParameter = new SqlParameter("@PassWord", SqlDbType.VarChar, 100)
            {
                Value = model.PassWord
            };

            return(sqlHelper.ExecuteNonQuery(sql, parameters: new[]
            {
                usernameParameter,
                passWordParameter
            }));
        }
コード例 #3
0
 public bool CreateMemberAccount(MemberAccountModel model)
 {
     return(_memberDao.CreateMemberAccount(model) > 0);
 }