Example #1
0
    //修改密码
    protected void Button2_Click(object sender, EventArgs e)
    {
        string userPassword = "";

        try
        {
            userPassword = UserAccess.GetUserPasswordById(userId);
        }
        catch
        {
            Utility.Alert(this, "修改失败!");
            return;
        }

        string oldPassword = this.UserPassword.Text.Trim();

        if (oldPassword == "")
        {
            this.Label2.Text = "旧密码未填写!";
            return;
        }
        else
        {
            if (oldPassword != userPassword)
            {
                this.Label2.Text = "旧密码不正确!";
                return;
            }
        }

        string newPassword  = this.NewPassword.Text.Trim();
        string newPassword2 = this.NewPassword2.Text.Trim();

        if (!ValidHelper.CheckLength(newPassword, 2))
        {
            this.Label1.Text = "新密码填写错误!";
            return;
        }
        if (newPassword != newPassword2)
        {
            this.Label4.Text = "两次新密码不一致!";
            return;
        }

        bool success = UserAccess.UpdateUserPassword(userId, newPassword);

        if (success)
        {
            Utility.Alert(this, "修改成功。", "UserLogout.aspx");
        }
        else
        {
            Utility.Alert(this, "修改失败!");
        }
    }
    //绑定已有帐号
    protected void BoundButton_Click(object sender, EventArgs e)
    {
        string userName = this.UserNameBound.Text.Trim();

        if (!ValidHelper.CheckLength(userName, 2))
        {
            Utility.Alert(this, "用户名填写错误!");
            return;
        }

        string userPassword = this.UserPasswordBound.Text.Trim();

        if (!ValidHelper.CheckLength(userPassword, 2))
        {
            Utility.Alert(this, "密码填写错误!");
            return;
        }

        int  newUserId = 0;
        bool success   = UserAccess.CheckUserLogin(userName, userPassword, out newUserId);

        if (success)
        {
            UserEntity user = UserAccess.GetUserById(newUserId);
            success = OAuthAccess.OAuthBoundUser(userId, user.UserID);
            if (success)
            {
                Session["UserID"]       = userId = user.UserID;
                Session["UserName"]     = user.UserName;
                Session["UserNickName"] = user.UserNickName;
                Session["UserTheme"]    = user.UserTheme;
                Session["UserLevel"]    = user.UserLevel.ToString();
                Session["UserFrom"]     = user.UserFrom;
                Session["UserWorkDay"]  = user.UserWorkDay;
                Session["UserFunction"] = user.UserFunction;
                Session["CategoryRate"] = user.CategoryRate;

                Response.Cookies["ThemeCookie"].Value   = user.UserTheme;
                Response.Cookies["ThemeCookie"].Expires = DateTime.MaxValue;

                PopulateControls();
                Utility.Alert(this, "绑定成功。", "UserBoundAdmin.aspx");
            }
            else
            {
                Utility.Alert(this, "绑定失败!");
            }
        }
        else
        {
            Utility.Alert(this, "登录失败!");
        }
    }
Example #3
0
        //绑定已有帐号
        protected void BoundButton_Click(object sender, EventArgs e)
        {
            string userName     = this.UserNameBound.Text.Trim();
            string userPassword = this.UserPasswordBound.Text.Trim();

            if (!ValidHelper.CheckLength(userName, 2))
            {
                Utility.Alert(this, "用户名填写错误!");
                return;
            }

            if (!ValidHelper.CheckLength(userPassword, 2))
            {
                Utility.Alert(this, "密码填写错误!");
                return;
            }

            bool success = user_bll.UserLogin(userName, userPassword);

            if (!success)
            {
                Utility.Alert(this, "登录失败!");
                return;
            }

            UserInfo user = user_bll.GetUserByUserPassword(userName, userPassword);

            using (TransactionScope ts = new TransactionScope())
            {
                success = bll.OAuthBoundOldUser(userId, user.UserID);
                bool succ = item_bll.UpdateItemToUser(userId, user.UserID);

                ts.Complete();
            }

            if (success)
            {
                UserHelper.SaveSession(user);

                Response.Cookies["ThemeCookie"].Value   = user.UserTheme;
                Response.Cookies["ThemeCookie"].Expires = DateTime.MaxValue;

                Utility.Alert(this, "绑定成功。", "UserBoundAdmin.aspx");
            }
            else
            {
                Utility.Alert(this, "绑定失败!");
            }
        }
Example #4
0
        //绑定新帐号
        protected void NewButton_Click(object sender, EventArgs e)
        {
            string userName     = this.UserNameNew.Text.Trim();
            string userPassword = this.UserPasswordNew.Text.Trim();

            if (!ValidHelper.CheckLength(userName, 2))
            {
                Utility.Alert(this, "用户名填写错误!");
                return;
            }

            bool success = user_bll.UserExists(userName);

            if (success)
            {
                Utility.Alert(this, "用户名重复!");
                return;
            }

            if (!ValidHelper.CheckLength(userPassword, 2))
            {
                Utility.Alert(this, "密码填写错误!");
                return;
            }

            UserInfo user = user_bll.GetUserByUserId(userId);

            user.UserName     = userName;
            user.UserPassword = userPassword;

            using (TransactionScope ts = new TransactionScope())
            {
                success = user_bll.UpdateUser(user);
                success = bll.OAuthBoundNewUser(userId);

                ts.Complete();
            }

            if (success)
            {
                Utility.Alert(this, "绑定成功。", "UserBoundAdmin.aspx");
            }
            else
            {
                Utility.Alert(this, "绑定失败!");
            }
        }
Example #5
0
    //修改密码
    protected void Button2_Click(object sender, EventArgs e)
    {
        string userPassword = user.UserPassword;//旧版此处用了try,不明原因
        string oldPassword  = this.UserPassword.Text.Trim();
        string newPassword  = this.NewPassword.Text.Trim();
        string newPassword2 = this.NewPassword2.Text.Trim();

        if (oldPassword == "")
        {
            this.Label2.Text = "旧密码未填写!";
            return;
        }
        if (oldPassword != userPassword)
        {
            this.Label2.Text = "旧密码不正确!";
            return;
        }

        if (!ValidHelper.CheckLength(newPassword, 2))
        {
            this.Label1.Text = "新密码填写错误!";
            return;
        }
        if (newPassword != newPassword2)
        {
            this.Label4.Text = "两次新密码不一致!";
            return;
        }

        user.UserPassword = newPassword;
        user.Synchronize  = 1;
        user.ModifyDate   = DateTime.Now;

        bool success = bll.UpdateUser(user);

        if (success)
        {
            Utility.Alert(this, "修改成功。", "UserLogout.aspx");
        }
        else
        {
            Utility.Alert(this, "修改失败!");
        }
    }
    //绑定新帐号
    protected void NewButton_Click(object sender, EventArgs e)
    {
        string userName = this.UserNameNew.Text.Trim();

        if (!ValidHelper.CheckLength(userName, 2))
        {
            Utility.Alert(this, "用户名填写错误!");
            return;
        }

        bool repeat = UserAccess.CheckUserRepeat(userName);

        if (repeat)
        {
            Utility.Alert(this, "用户名重复!");
            return;
        }

        string userPassword = this.UserPasswordNew.Text.Trim();

        if (!ValidHelper.CheckLength(userPassword, 2))
        {
            Utility.Alert(this, "密码填写错误!");
            return;
        }

        bool success = OAuthAccess.OAuthBoundNew(userId, userName, userPassword);

        if (success)
        {
            PopulateControls();
            Utility.Alert(this, "绑定成功。", "UserBoundAdmin.aspx");
        }
        else
        {
            Utility.Alert(this, "绑定失败!");
        }
    }
Example #7
0
    //注册按钮
    protected void SubmitButtom_Click(object sender, EventArgs e)
    {
        string userName      = this.UserName.Text.Trim();
        string userPassword  = this.UserPassword.Text.Trim();
        string userPassword2 = this.UserPassword2.Text.Trim();
        string userNickName  = this.UserNickName.Text.Trim();
        string userEmail     = this.UserEmail.Text.Trim();
        string userTheme     = "main";
        string userWorkDay   = this.UserWorkDay.SelectedValue;

        if (!ValidHelper.CheckLength(userName, 2))
        {
            Utility.Alert(this, "用户名填写错误!");
            return;
        }

        bool success = bll.UserExists(userName);

        if (success)
        {
            Utility.Alert(this, "用户名重复!");
            return;
        }

        if (!ValidHelper.CheckLength(userPassword, 2))
        {
            Utility.Alert(this, "密码填写错误!");
            return;
        }

        if (userPassword2 == "")
        {
            Utility.Alert(this, "重复密码未填写!");
            return;
        }

        if (userPassword != userPassword2)
        {
            Utility.Alert(this, "两次密码不一致!");
            return;
        }

        if (userEmail != "")
        {
            if (!ValidHelper.CheckEmail(userEmail))
            {
                Utility.Alert(this, "邮箱格式填写错误!");
                return;
            }
        }

        if (Request.Cookies["ThemeCookie"] != null)
        {
            userTheme = Request.Cookies["ThemeCookie"].Value;
        }

        UserInfo user = new UserInfo();

        user.UserName     = userName;
        user.UserPassword = userPassword;
        user.UserNickName = userNickName;
        user.UserEmail    = userEmail;
        user.UserWorkDay  = userWorkDay;
        user.UserTheme    = userTheme;
        user.IsUpdate     = 1;

        success = bll.InsertUser(user);
        if (success)
        {
            Session["TodayDate"] = DateTime.Now.ToString("yyyy-MM-dd");

            UserInfo newUser = bll.GetUserByUserPassword(userName, userPassword);
            UserHelper.SaveSession(newUser);

            Utility.Alert(this, "注册成功。", "Default.aspx");
        }
        else
        {
            Utility.Alert(this, "注册失败!");
        }
    }
Example #8
0
    protected void SubmitButtom_Click(object sender, EventArgs e)
    {
        string userName      = this.UserName.Text.Trim();
        string userPassword  = this.UserPassword.Text.Trim();
        string userPassword2 = this.UserPassword2.Text.Trim();
        string userNickName  = this.UserNickName.Text.Trim();
        string userEmail     = this.UserEmail.Text.Trim();
        string userTheme     = "main";
        string userWorkDay   = this.UserWorkDay.SelectedValue;

        if (!ValidHelper.CheckLength(userName, 2))
        {
            Utility.Alert(this, "用户名填写错误!");
            return;
        }

        bool repeat = UserAccess.CheckUserRepeat(userName);

        if (repeat)
        {
            Utility.Alert(this, "用户名重复!");
            return;
        }

        if (!ValidHelper.CheckLength(userPassword, 2))
        {
            Utility.Alert(this, "密码填写错误!");
            return;
        }

        if (userPassword2 == "")
        {
            Utility.Alert(this, "重复密码未填写!");
            return;
        }

        if (userPassword != userPassword2)
        {
            Utility.Alert(this, "两次密码不一致!");
            return;
        }

        if (userEmail != "")
        {
            if (!ValidHelper.CheckEmail(userEmail))
            {
                Utility.Alert(this, "邮箱格式填写错误!");
                return;
            }
        }

        if (Request.Cookies["ThemeCookie"] != null)
        {
            userTheme = Request.Cookies["ThemeCookie"].Value;
        }

        UserEntity user = new UserEntity();

        user.UserName     = userName;
        user.UserPassword = userPassword;
        user.UserNickName = userNickName;
        user.UserImage    = "none.gif";
        user.UserEmail    = userEmail;
        user.UserWorkDay  = userWorkDay;
        user.UserTheme    = userTheme;
        user.UserFrom     = "web";
        user.UserPhone    = "";
        user.UserMoney    = 0;
        user.CategoryRate = 90;

        int  userId  = 0;
        bool success = UserAccess.InsertUser(user, out userId);

        if (success)
        {
            Session["TodayDate"] = DateTime.Now.ToString("yyyy-MM-dd");

            UserEntity newUser = UserAccess.GetUserById(userId);
            Session["UserID"]       = newUser.UserID;
            Session["UserName"]     = newUser.UserName;
            Session["UserNickName"] = newUser.UserNickName;
            Session["UserTheme"]    = newUser.UserTheme;
            Session["UserLevel"]    = newUser.UserLevel.ToString();
            Session["UserFrom"]     = newUser.UserFrom;
            Session["UserWorkDay"]  = newUser.UserWorkDay;
            Session["UserFunction"] = newUser.UserFunction;
            Session["CategoryRate"] = user.CategoryRate;

            Utility.Alert(this, "注册成功。", "Default.aspx");
        }
        else
        {
            Utility.Alert(this, "注册失败!");
        }
    }