예제 #1
0
        private void btnCreate_Click(object sender, System.EventArgs e)
        {
            if (string.Compare(this.txtPassword.Text, this.txtPasswordagain.Text) != 0)
            {
                this.ShowMsg("请确保两次输入的密码相同", false);
            }
            else
            {
                ManagerInfo manager = new ManagerInfo
                {
                    RoleId       = this.dropRole.SelectedValue,
                    UserName     = this.txtUserName.Text.Trim(),
                    Email        = this.txtEmail.Text.Trim(),
                    Password     = HiCryptographer.Md5Encrypt(this.txtPassword.Text.Trim()),
                    ClientUserId = clientUserId > 0 ? clientUserId : 0,
                    AgentName    = this.txtAgentName.Text.Trim(),
                    State        = 1 //通过此页面注册的后台代理商账号默认值都为1:未激活
                };

                if (ManagerHelper.CreateAgent(manager))
                {
                    //如果创建成功了账号,同时还要保存地址信息,
                    ShippingAddressInfo shippingAddress = new ShippingAddressInfo
                    {
                        Address   = this.txtAddress.Text,
                        CellPhone = this.txtCellPhone.Text,
                        ShipTo    = this.txtShipName.Text,
                        Zipcode   = "",
                        IsDefault = true,
                        UserId    = Convert.ToInt32("99999" + ManagerHelper.GetManager(this.txtUserName.Text.Trim()).UserId.ToString()),
                        RegionId  = Convert.ToInt32(this.dropRegion.GetSelectedRegionId())
                    };
                    Hidistro.SaleSystem.Vshop.MemberProcessor.AddAgentShippingAddress(shippingAddress);

                    this.txtEmail.Text    = string.Empty;
                    this.txtUserName.Text = string.Empty;
                    this.ShowMsgAndReUrl("成功添加了一个代理商,请联系超级管理员激活该账号", true, "login.aspx");
                }
                else
                {
                    this.ShowMsg("添加失败!", false);
                }
            }
        }