private bool ValidationDistributorRequest(Hidistro.Membership.Context.Distributor distributor) { ValidationResults validationResults = Validation.Validate <Hidistro.Membership.Context.Distributor>(distributor, new string[] { "ValDistributor" }); string text = string.Empty; if (!validationResults.IsValid) { foreach (ValidationResult current in (System.Collections.Generic.IEnumerable <ValidationResult>)validationResults) { text += Formatter.FormatErrorMessage(current.Message); } this.ShowMessage(text, false); } return(validationResults.IsValid); }
private void btnOK_Click(object sender, System.EventArgs e) { if (this.ValidationInput()) { int?selectedRegionId = this.dropRegion.GetSelectedRegionId(); Hidistro.Membership.Core.HiMembershipUser membershipUser = new Hidistro.Membership.Core.HiMembershipUser(false, Hidistro.Membership.Core.Enums.UserRole.Distributor); Hidistro.Membership.Context.Distributor distributor = new Hidistro.Membership.Context.Distributor(membershipUser); distributor.IsApproved = false; distributor.Username = this.txtUserName.Text; distributor.Email = this.txtEmail.Text; distributor.Password = this.txtPasswordCompare.Text; if (!string.IsNullOrEmpty(this.txtTransactionPasswordCompare.Text)) { distributor.TradePassword = this.txtTransactionPasswordCompare.Text; } else { distributor.TradePassword = distributor.Password; } distributor.RealName = this.txtRealName.Text; distributor.CompanyName = this.txtCompanyName.Text; if (selectedRegionId.HasValue) { distributor.RegionId = selectedRegionId.Value; distributor.TopRegionId = RegionHelper.GetTopRegionId(distributor.RegionId); } distributor.Address = this.txtAddress.Text; distributor.Zipcode = this.txtZipcode.Text; distributor.QQ = this.txtQQ.Text; distributor.Wangwang = this.txtWangwang.Text; distributor.MSN = this.txtMSN.Text; distributor.TelPhone = this.txtTelPhone.Text; distributor.CellPhone = this.txtCellPhone.Text; distributor.Remark = string.Empty; if (this.ValidationDistributorRequest(distributor)) { switch (SubsiteStoreHelper.CreateDistributor(distributor)) { case Hidistro.Membership.Core.Enums.CreateUserStatus.UnknownFailure: this.ShowMessage("未知错误", false); break; case Hidistro.Membership.Core.Enums.CreateUserStatus.Created: distributor.ChangePasswordQuestionAndAnswer(null, this.txtPasswordQuestion.Text, this.txtPasswordAnswer.Text); Messenger.UserRegister(distributor, this.txtPasswordCompare.Text); distributor.OnRegister(new Hidistro.Membership.Context.UserEventArgs(distributor.Username, this.txtPasswordCompare.Text, null)); this.Page.Response.Redirect(Globals.ApplicationPath + "/Shopadmin/DistributorsRegisterComplete.aspx"); break; case Hidistro.Membership.Core.Enums.CreateUserStatus.DuplicateUsername: this.ShowMessage("您输入的用户名已经被注册使用", false); break; case Hidistro.Membership.Core.Enums.CreateUserStatus.DuplicateEmailAddress: this.ShowMessage("您输入的电子邮件地址已经被注册使用", false); break; case Hidistro.Membership.Core.Enums.CreateUserStatus.DisallowedUsername: this.ShowMessage("用户名被禁止注册", false); break; case Hidistro.Membership.Core.Enums.CreateUserStatus.InvalidPassword: this.ShowMessage("无效的密码", false); break; case Hidistro.Membership.Core.Enums.CreateUserStatus.InvalidEmail: this.ShowMessage("无效的电子邮件地址", false); break; } } } }