protected void Submit() { string userName = StringHelper.AddSafe(RequestHelper.GetForm <string>("UserName")); CurrentUser.Email = StringHelper.AddSafe(RequestHelper.GetForm <string>("Email")); CurrentUser.Tel = StringHelper.AddSafe(RequestHelper.GetForm <string>("Tel")); string photo = StringHelper.AddSafe(RequestHelper.GetForm <string>("Photo")); if (!string.IsNullOrEmpty(userName)) { int firstCharIsNumber = 0; int.TryParse(userName.Substring(0, 1), out firstCharIsNumber); if (firstCharIsNumber > 0) { ResponseHelper.Write("error|用户名不能以数字开头"); ResponseHelper.End(); } if (!UserBLL.UniqueUser(userName, base.UserId)) { ResponseHelper.Write("error|用户名已被占用"); ResponseHelper.End(); } if (OrderBLL.ReadCount(base.UserId) > 0) { ResponseHelper.Write("error|用户名更新失败"); ResponseHelper.End(); } CurrentUser.UserName = userName; } if (!string.IsNullOrEmpty(photo)) { CurrentUser.Photo = photo; CookiesHelper.AddCookie("UserPhoto", photo); } else { CurrentUser.Photo = UserBLL.ReadUserPhoto(); } CookiesHelper.AddCookie("UserEmail", CurrentUser.Email); if (CurrentUser.UserType == (int)UserType.Provider) { CurrentUser.ProviderName = StringHelper.AddSafe(RequestHelper.GetForm <string>("ProviderName")); CurrentUser.ProviderBankNo = StringHelper.AddSafe(RequestHelper.GetForm <string>("ProviderBankNo")); CurrentUser.ProviderTaxRegistration = StringHelper.AddSafe(RequestHelper.GetForm <string>("ProviderTaxRegistration")); CurrentUser.ProviderCorporate = StringHelper.AddSafe(RequestHelper.GetForm <string>("ProviderCorporate")); CurrentUser.ProviderLinkerTel = StringHelper.AddSafe(RequestHelper.GetForm <string>("ProviderLinkerTel")); CurrentUser.ProviderFax = StringHelper.AddSafe(RequestHelper.GetForm <string>("ProviderFax")); CurrentUser.ProviderAddress = StringHelper.AddSafe(RequestHelper.GetForm <string>("ProviderAddress")); CurrentUser.RegionId = regionId.ClassID; } UserBLL.Update(CurrentUser); //修改用户名,更新cookie if (!string.IsNullOrEmpty(userName)) { base.UserName = userName; UserBLL.AddUserCookie(CurrentUser); } ResponseHelper.Write("ok|更新成功"); ResponseHelper.End(); }
/// <summary> /// 提交数据 /// </summary> protected override void PostBack() { redirectUrl = HttpUtility.UrlDecode(RequestHelper.GetForm <string>("RedirectUrl")); if (redirectUrl == string.Empty) { redirectUrl = RequestHelper.GetQueryString <string>("RedirectUrl"); } string userName = StringHelper.AddSafe(RequestHelper.GetForm <string>("UserName")); string userPassword = StringHelper.Password(RequestHelper.GetForm <string>("UserPassword"), (PasswordType)ShopConfig.ReadConfigInfo().PasswordType); string autoLogin = StringHelper.SearchSafe(RequestHelper.GetForm <string>("autoLogin")); UserInfo user = UserBLL.Read(userName, userPassword); if (user.Id > 0) { switch (user.Status) { case (int)UserStatus.NoCheck: result = "该用户未激活"; break; case (int)UserStatus.Frozen: result = "该用户已冻结"; break; case (int)UserStatus.Normal: user = UserBLL.ReadUserMore(user.Id); UserBLL.UserLoginInit(user); //如果设置了自动登录则保存COOKIES一周 if (string.Equals(autoLogin, "1")) { UserBLL.AddUserCookieWeekly(user); } //否则不保存(关闭浏览器即失效) else { UserBLL.AddUserCookie(user); } if (redirectUrl != string.Empty) { ResponseHelper.Redirect(redirectUrl); } else { ResponseHelper.Redirect("/User/Index.html"); } break; default: break; } } else { result = "用户名或者密码错误"; } string url = "/User/Login.html?Message=" + result; if (redirectUrl != string.Empty) { url += "&RedirectUrl=" + redirectUrl; } ResponseHelper.Redirect(url); }