Exemple #1
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            if (this.ValidationInput())
            {
                int?selectedRegionId            = this.dropRegion.GetSelectedRegionId();
                HiMembershipUser membershipUser = new HiMembershipUser(false, UserRole.Distributor);
                Distributor      distributor    = new 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 CreateUserStatus.UnknownFailure:
                        this.ShowMessage("未知错误", false);
                        return;

                    case CreateUserStatus.Created:
                        distributor.ChangePasswordQuestionAndAnswer(null, this.txtPasswordQuestion.Text, this.txtPasswordAnswer.Text);
                        Messenger.UserRegister(distributor, this.txtPasswordCompare.Text);
                        distributor.OnRegister(new UserEventArgs(distributor.Username, this.txtPasswordCompare.Text, null));
                        this.Page.Response.Redirect(Globals.ApplicationPath + "/Shopadmin/DistributorsRegisterComplete.aspx");
                        return;

                    case CreateUserStatus.DuplicateUsername:
                        this.ShowMessage("您输入的用户名已经被注册使用", false);
                        return;

                    case CreateUserStatus.DuplicateEmailAddress:
                        this.ShowMessage("您输入的电子邮件地址已经被注册使用", false);
                        return;

                    case CreateUserStatus.InvalidFirstCharacter:
                    case CreateUserStatus.Updated:
                    case CreateUserStatus.Deleted:
                    case CreateUserStatus.InvalidQuestionAnswer:
                        return;

                    case CreateUserStatus.DisallowedUsername:
                        this.ShowMessage("用户名被禁止注册", false);
                        return;

                    case CreateUserStatus.InvalidPassword:
                        this.ShowMessage("无效的密码", false);
                        return;

                    case CreateUserStatus.InvalidEmail:
                        this.ShowMessage("无效的电子邮件地址", false);
                        return;
                    }
                }
            }
        }