예제 #1
0
 private void btnConfirm_Click(object sender, EventArgs e)
 {
     if (string.IsNullOrEmpty(this.txtPassword.Value))
     {
         this.message.Text = "密码不能为空";
     }
     else if (this.txtPassword.Value != this.txtPassword2.Value)
     {
         this.message.Text = "两次密码输入不一致,请重新输入";
     }
     else
     {
         MemberDao  memberDao  = new MemberDao();
         bool       flag       = true;
         MemberInfo memberInfo = memberDao.FindMemberByCellphone(this.username);
         if (memberInfo == null)
         {
             memberInfo = memberDao.FindMemberByEmail(this.username);
         }
         if (DataHelper.IsEmail(this.username))
         {
             flag = false;
         }
         if (memberInfo != null)
         {
             string value = this.txtNumber.Value;
             string text  = "验证码错误";
             if ((flag && HiContext.Current.CheckPhoneVerifyCode(value, memberInfo.CellPhone, out text)) || (!flag && HiContext.Current.CheckVerifyCode(value, "")))
             {
                 if (MemberProcessor.ChangePassword(memberInfo, this.txtPassword2.Value))
                 {
                     Messenger.UserPasswordChanged(memberInfo, this.txtPassword2.Value);
                     Users.SetCurrentUser(memberInfo.UserId, 1, true, false);
                     ShoppingCartInfo cookieShoppingCart = ShoppingCartProcessor.GetCookieShoppingCart();
                     if (cookieShoppingCart != null)
                     {
                         ShoppingCartProcessor.ConvertShoppingCartToDataBase(cookieShoppingCart);
                         ShoppingCartProcessor.ClearCookieShoppingCart();
                     }
                     this.Page.Response.Redirect("MemberCenter.aspx", true);
                 }
             }
             else
             {
                 this.message.Text = text;
             }
         }
         else
         {
             this.message.Text = "密码修改失败,错误的用户名";
         }
     }
 }