Exemplo n.º 1
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, "绑定失败!");
            }
        }