예제 #1
0
        protected void btnSave_Click(object sender, System.EventArgs e)
        {
            string text = this.txtUserName.Text.Trim();

            if (text.Length > 20 || text.Length < 3)
            {
                this.ShowMsg("3-20个字符,支持汉字、字母、数字等组合", false);
                return;
            }
            if (this.txtPassword.Text.Length > 20 || this.txtPassword.Text.Length < 6)
            {
                this.ShowMsg("密码为6-20个字符,可由英文‘数字及符号组成", false);
                return;
            }
            if (string.Compare(this.txtPassword.Text, this.txtPasswordagain.Text) != 0)
            {
                this.ShowMsg("请确保两次输入的密码相同", false);
                return;
            }
            if (string.Compare(this.txtPassword.Text, this.txtPasswordagain.Text) != 0)
            {
                this.ShowMsg("请确保两次输入的密码相同", false);
                return;
            }
            string text2 = this.txtEmail.Text.Trim();

            if (!System.Text.RegularExpressions.Regex.IsMatch(text2, "^(\\w)+(\\.\\w+)*@(\\w)+((\\.\\w+)+)$"))
            {
                this.ShowMsg("请输入有效的邮箱地址,长度在256个字符以内", false);
                return;
            }
            int num = 0;

            int.TryParse(this.dropRole.SelectedValue.ToString(), out num);
            if (num == 0)
            {
                this.ShowMsg("所属部门没有选择,请选择", false);
                return;
            }
            ManagerInfo manager = ManagerHelper.GetManager(this.txtUserName.Text.Trim());

            if (manager != null)
            {
                this.ShowMsg("用户名已存在", false);
                return;
            }
            if (ManagerHelper.Create(new ManagerInfo
            {
                RoleId = num,
                UserName = text,
                Email = text2,
                Password = HiCryptographer.Md5Encrypt(this.txtPassword.Text.Trim()),
                SiteId = siteid
            }))
            {
                this.txtEmail.Text    = string.Empty;
                this.txtUserName.Text = string.Empty;
                this.ShowMsg("成功添加了一个管理员", true);
            }
        }
예제 #2
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()
                };
                if (ManagerHelper.Create(manager))
                {
                    this.txtEmail.Text    = string.Empty;
                    this.txtUserName.Text = string.Empty;
                    this.ShowMsg("成功添加了一个管理员", true);

                    //跳转地址
                    if (clientUserId > 0)
                    {
                        base.Response.Redirect(Globals.GetAdminAbsolutePath("/distributor/DistributorList.aspx"), true);
                    }
                }
                else
                {
                    this.ShowMsg("添加失败!", false);
                }
            }
        }
        protected void btnSave_Click(object sender, EventArgs e)
        {
            string str = this.txtUserName.Text.Trim();

            if ((str.Length > 20) || (str.Length < 3))
            {
                this.ShowMsg("3-20个字符,支持汉字、字母、数字等组合", false);
            }
            else if ((this.txtPassword.Text.Length > 20) || (this.txtPassword.Text.Length < 6))
            {
                this.ShowMsg("密码为6-20个字符,可由英文‘数字及符号组成", false);
            }
            else if (string.Compare(this.txtPassword.Text, this.txtPasswordagain.Text) != 0)
            {
                this.ShowMsg("请确保两次输入的密码相同", false);
            }
            else if (string.Compare(this.txtPassword.Text, this.txtPasswordagain.Text) != 0)
            {
                this.ShowMsg("请确保两次输入的密码相同", false);
            }
            else
            {
                string input = this.txtEmail.Text.Trim();
                if (!Regex.IsMatch(input, @"^(\w)+(\.\w+)*@(\w)+((\.\w+)+)$"))
                {
                    this.ShowMsg("请输入有效的邮箱地址,长度在256个字符以内", false);
                }
                else
                {
                    int result = 0;
                    int.TryParse(this.dropRole.SelectedValue.ToString(), out result);
                    if (result == 0)
                    {
                        this.ShowMsg("所属部门没有选择,请选择", false);
                    }
                    else if (ManagerHelper.GetManager(this.txtUserName.Text.Trim()) != null)
                    {
                        this.ShowMsg("用户名已存在", false);
                    }
                    else
                    {
                        ManagerInfo manager = new ManagerInfo
                        {
                            RoleId   = result,
                            UserName = str,
                            Email    = input,
                            Password = HiCryptographer.Md5Encrypt(this.txtPassword.Text.Trim())
                        };
                        if (ManagerHelper.Create(manager))
                        {
                            this.txtEmail.Text    = string.Empty;
                            this.txtUserName.Text = string.Empty;
                            this.ShowMsg("成功添加了一个管理员", true);
                        }
                    }
                }
            }
        }
예제 #4
0
 private void btnCreate_Click(object sender, 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())
         };
         if (ManagerHelper.Create(manager))
         {
             this.txtEmail.Text    = string.Empty;
             this.txtUserName.Text = string.Empty;
             this.ShowMsg("成功添加了一个管理员", true);
         }
     }
 }
예제 #5
0
        private void btnCreate_Click(object sender, EventArgs e)
        {
            ManagerInfo managerInfo = null;

            if (string.Compare(this.txtPassword.Text, this.txtPasswordagain.Text) != 0)
            {
                this.ShowMsg("请确保两次输入的密码相同", false);
            }
            else
            {
                managerInfo = ManagerHelper.FindManagerByUsername(this.txtUserName.Text.Trim());
                if (managerInfo != null)
                {
                    this.ShowMsg("输入的管理员账户已存在,请重新输入!", false);
                }
                else
                {
                    managerInfo          = new ManagerInfo();
                    managerInfo.Password = this.txtPassword.Text.Trim();
                    managerInfo.RoleId   = this.dropRole.SelectedValue;
                    managerInfo.UserName = this.txtUserName.Text.Trim();
                    string pass = this.txtPassword.Text.Trim();
                    managerInfo.CreateDate = DateTime.Now;
                    string text = Globals.RndStr(128, true);
                    pass = (managerInfo.Password = Users.EncodePassword(pass, text));
                    managerInfo.PasswordSalt = text;
                    if (ManagerHelper.Create(managerInfo) > 0)
                    {
                        this.txtUserName.Text = string.Empty;
                        this.ShowMsg("成功添加了一个管理员", true);
                    }
                    else
                    {
                        this.ShowMsg("添加了一个管理员失败", false);
                    }
                }
            }
        }
예제 #6
0
        private void btnCreate_Click(object sender, System.EventArgs e)
        {
            Hidistro.Membership.Core.Enums.CreateUserStatus createUserStatus = Hidistro.Membership.Core.Enums.CreateUserStatus.UnknownFailure;
            Hidistro.Membership.Context.SiteManager         siteManager      = new Hidistro.Membership.Context.SiteManager();
            siteManager.IsApproved     = true;
            siteManager.Username       = this.txtUserName.Text.Trim();
            siteManager.Email          = "supplier_" + System.DateTime.Now.Ticks.ToString() + "@tom.com";
            siteManager.Password       = this.txtPassword.Text.Trim();
            siteManager.PasswordFormat = System.Web.Security.MembershipPasswordFormat.Hashed;
            siteManager.Comment        = this.fkRemark.Text;
            if (string.Compare(this.txtPassword.Text, this.txtPasswordagain.Text) != 0)
            {
                this.ShowMsg("请确保两次输入的密码相同", false);
                return;
            }
            if (string.IsNullOrEmpty(this.drpSupplierGrades.SelectedValue))
            {
                this.ShowMsg("错误:供应商等级必选", false);
                return;
            }
            if (!this.ValidationAddManager(siteManager))
            {
                return;
            }
            try
            {
                createUserStatus = ManagerHelper.Create(siteManager, "供应商");
            }
            catch (Hidistro.Membership.Core.CreateUserException ex)
            {
                createUserStatus = ex.CreateUserStatus;
            }
            switch (createUserStatus)
            {
            case Hidistro.Membership.Core.Enums.CreateUserStatus.UnknownFailure:
                this.ShowMsg("未知错误", false);
                return;

            case Hidistro.Membership.Core.Enums.CreateUserStatus.Created:
                Methods.Supplier_SupUpdate(siteManager.UserId, this.fkRemark.Text, int.Parse(this.drpSupplierGrades.SelectedValue));
                this.txtEmail.Text    = string.Empty;
                this.txtUserName.Text = string.Empty;
                this.fkRemark.Text    = string.Empty;
                this.ShowMsg("成功添加了一个供应商", true);
                break;

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

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

            case Hidistro.Membership.Core.Enums.CreateUserStatus.InvalidFirstCharacter:
            case Hidistro.Membership.Core.Enums.CreateUserStatus.Updated:
            case Hidistro.Membership.Core.Enums.CreateUserStatus.Deleted:
            case Hidistro.Membership.Core.Enums.CreateUserStatus.InvalidQuestionAnswer:
                break;

            case Hidistro.Membership.Core.Enums.CreateUserStatus.DisallowedUsername:
                this.ShowMsg("用户名被禁止注册", false);
                return;

            case Hidistro.Membership.Core.Enums.CreateUserStatus.InvalidPassword:
                this.ShowMsg("无效的密码", false);
                return;

            case Hidistro.Membership.Core.Enums.CreateUserStatus.InvalidEmail:
                this.ShowMsg("无效的电子邮件地址", false);
                return;

            default:
                return;
            }
        }
예제 #7
0
        private void btnCreate_Click(object sender, System.EventArgs e)
        {
            CreateUserStatus createUserStatus = CreateUserStatus.UnknownFailure;
            SiteManager      siteManager      = new SiteManager();

            siteManager.IsApproved = true;
            siteManager.Username   = this.txtUserName.Text.Trim();
            siteManager.Email      = this.txtEmail.Text.Trim();
            siteManager.Password   = this.txtPassword.Text.Trim();
            siteManager.Name       = this.txtName.Text.Trim();

            if (!string.IsNullOrEmpty(this.Page.Request.QueryString["SupplierId"]))
            {
                int supplierId = 0;
                if (int.TryParse(this.Page.Request.QueryString["SupplierId"], out supplierId))
                {
                    siteManager.SupplierId = supplierId;
                }
            }

            if (!string.IsNullOrEmpty(this.Page.Request.QueryString["StoreId"]))
            {
                int storeId = 0;
                if (int.TryParse(this.Page.Request.QueryString["StoreId"], out storeId))
                {
                    siteManager.StoreId = storeId;
                }
            }

            siteManager.PasswordFormat = System.Web.Security.MembershipPasswordFormat.Hashed;

            if (string.Compare(this.txtPassword.Text, this.txtPasswordagain.Text) != 0)
            {
                this.ShowMsg("请确保两次输入的密码相同", false);
                return;
            }

            if (!this.ValidationAddManager(siteManager))
            {
                return;
            }
            try
            {
                string text = this.dropRole.SelectedItem.Text;
                if (string.Compare(text, "超级管理员") == 0)
                {
                    text = "SystemAdministrator";
                }
                createUserStatus = ManagerHelper.Create(siteManager, text);
            }
            catch (CreateUserException ex)
            {
                createUserStatus = ex.CreateUserStatus;
            }
            switch (createUserStatus)
            {
            case CreateUserStatus.UnknownFailure:
                this.ShowMsg("未知错误", false);
                return;

            case CreateUserStatus.Created:
                this.txtEmail.Text    = string.Empty;
                this.txtUserName.Text = string.Empty;
                this.txtName.Text     = string.Empty;
                this.ShowMsg("成功添加了一个管理员", true);
                break;

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

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

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

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

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

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

            default:
                return;
            }
        }
예제 #8
0
        private void btnCreate_Click(object sender, EventArgs e)
        {
            CreateUserStatus unknownFailure = CreateUserStatus.UnknownFailure;
            SiteManager      siteManager    = new SiteManager();

            siteManager.IsApproved     = true;
            siteManager.Username       = this.txtUserName.Text.Trim();
            siteManager.Email          = this.txtEmail.Text.Trim();
            siteManager.Password       = this.txtPassword.Text.Trim();
            siteManager.PasswordFormat = MembershipPasswordFormat.Hashed;
            if (string.Compare(this.txtPassword.Text, this.txtPasswordagain.Text) != 0)
            {
                this.ShowMsg("请确保两次输入的密码相同", false);
            }
            else if (this.ValidationAddManager(siteManager))
            {
                try
                {
                    string text = this.dropRole.SelectedItem.Text;
                    if (string.Compare(text, "超级管理员") == 0)
                    {
                        text = "SystemAdministrator";
                    }
                    unknownFailure = ManagerHelper.Create(siteManager, text);
                }
                catch (CreateUserException exception)
                {
                    unknownFailure = exception.CreateUserStatus;
                }
                switch (unknownFailure)
                {
                case CreateUserStatus.UnknownFailure:
                    this.ShowMsg("未知错误", false);
                    return;

                case CreateUserStatus.Created:
                    this.txtEmail.Text    = string.Empty;
                    this.txtUserName.Text = string.Empty;
                    this.ShowMsg("成功添加了一个管理员", true);
                    return;

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

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

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

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

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

                case CreateUserStatus.InvalidEmail:
                    this.ShowMsg("无效的电子邮件地址", false);
                    return;
                }
            }
        }
예제 #9
0
        private void btnCreate_Click(object sender, System.EventArgs e)
        {
            Hidistro.Membership.Core.Enums.CreateUserStatus createUserStatus = Hidistro.Membership.Core.Enums.CreateUserStatus.UnknownFailure;
            Hidistro.Membership.Context.SiteManager         siteManager      = new Hidistro.Membership.Context.SiteManager();
            siteManager.IsApproved     = true;
            siteManager.Username       = this.txtUserName.Text.Trim();
            siteManager.Email          = "supplier_" + System.DateTime.Now.Ticks.ToString() + "@tom.com";
            siteManager.Password       = this.txtPassword.Text.Trim();
            siteManager.PasswordFormat = System.Web.Security.MembershipPasswordFormat.Hashed;
            siteManager.Comment        = this.fkRemark.Text;
            if (string.Compare(this.txtPassword.Text, this.txtPasswordagain.Text) != 0)
            {
                this.ShowMsg("请确保两次输入的密码相同", false);
                return;
            }
            if (!this.ValidationAddManager(siteManager))
            {
                return;
            }
            if (!this.rsddlRegion.GetSelectedRegionId().HasValue || string.IsNullOrEmpty(this.txtRealName.Text.Trim()) || string.IsNullOrEmpty(this.txtAddress.Text.Trim()) || string.IsNullOrEmpty(this.txtZip.Text.Trim()) || string.IsNullOrEmpty(this.txtCellPhone.Text.Trim()))
            {
                this.ShowMsg("错误:收货人、所在区域、具体地址、邮编、手机必填", false);
                return;
            }
            int    value           = this.rsddlRegion.GetSelectedRegionId().Value;
            string selectedRegions = this.rsddlRegion.SelectedRegions;

            string[] array = selectedRegions.Split(",".ToCharArray());
            if (array.Length == 1 && RegionHelper.GetCitys(value).Count > 0)
            {
                this.ShowMsg("所在区域必填填写完整", false);
                return;
            }
            if (array.Length == 2 && RegionHelper.GetCountys(value).Count > 0)
            {
                this.ShowMsg("所在区域必填填写完整", false);
                return;
            }
            try
            {
                createUserStatus = ManagerHelper.Create(siteManager, "区域发货点");
            }
            catch (Hidistro.Membership.Core.CreateUserException ex)
            {
                createUserStatus = ex.CreateUserStatus;
            }
            switch (createUserStatus)
            {
            case Hidistro.Membership.Core.Enums.CreateUserStatus.UnknownFailure:
                this.ShowMsg("未知错误", false);
                return;

            case Hidistro.Membership.Core.Enums.CreateUserStatus.Created:
                Methods.Supplier_ShipPointUpdate(siteManager.UserId, this.fkRemark.Text, new int?(value), selectedRegions, this.txtRealName.Text.Trim(), this.txtAddress.Text.Trim(), this.txtZip.Text.Trim(), this.txtCellPhone.Text.Trim(), this.txtPhone.Text.Trim());
                this.Page.ClientScript.RegisterClientScriptBlock(base.GetType(), "sucess", string.Format("<script language=\"javascript\" >alert('添加成功');window.location.href=\"{0}\"</script>", System.Web.HttpContext.Current.Request.RawUrl));
                break;

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

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

            case Hidistro.Membership.Core.Enums.CreateUserStatus.InvalidFirstCharacter:
            case Hidistro.Membership.Core.Enums.CreateUserStatus.Updated:
            case Hidistro.Membership.Core.Enums.CreateUserStatus.Deleted:
            case Hidistro.Membership.Core.Enums.CreateUserStatus.InvalidQuestionAnswer:
                break;

            case Hidistro.Membership.Core.Enums.CreateUserStatus.DisallowedUsername:
                this.ShowMsg("用户名被禁止注册", false);
                return;

            case Hidistro.Membership.Core.Enums.CreateUserStatus.InvalidPassword:
                this.ShowMsg("无效的密码", false);
                return;

            case Hidistro.Membership.Core.Enums.CreateUserStatus.InvalidEmail:
                this.ShowMsg("无效的电子邮件地址", false);
                return;

            default:
                return;
            }
        }
예제 #10
0
        private void SaveSupplier(out int userId)
        {
            userId = 0;
            SupplierInfo supplierInfo = new SupplierInfo();
            string       userName     = DataHelper.CleanSearchString(this.txtUserName.Text.Trim());
            string       supplierName = Globals.StripAllTags(this.txtSupplierName.Text.Trim());
            string       address      = Globals.StripAllTags(this.txtAddress.Text);
            string       text         = this.txtTel.Text;
            string       text2        = Globals.StripAllTags(this.txtContactMan.Text);

            if (SupplierHelper.ExistSupplierName(0, supplierName))
            {
                this.ShowMsg("供应商名称已经存在,请重新输入!", false);
            }
            else if (!this.dropRegion.GetSelectedRegionId().HasValue)
            {
                this.ShowMsg("请选择供应商所在区域!", false);
            }
            else if (text2.Length > 8 || text2.Length < 2)
            {
                this.ShowMsg("请输入联系人,联系人长度必须是2-8位!", false);
            }
            else if (address.Length > 50 || address.Length < 2)
            {
                this.ShowMsg("请输入地址,长度必须为2-50个字符!", false);
            }
            else if (text == "" || !DataHelper.IsTel(text))
            {
                this.ShowMsg("请输入正确的联系电话(手机或者固定电话)!", false);
            }
            else if (ManagerHelper.FindManagerByUsername(userName) != null)
            {
                this.ShowMsg("用户名已经存在,请重新输入!", false);
            }
            else if (this.txtUserPwd.Text.Length < 6 || this.txtUserPwd.Text.Length > 20)
            {
                this.ShowMsg("密码不能为空,用户密码长度必须为6-20个字符!", false);
            }
            else if (string.Compare(this.txtUserPwd.Text, this.txtUserRePwd.Text) != 0)
            {
                this.ShowMsg("请确保两次输入的密码相同", false);
            }
            else
            {
                supplierInfo.Introduce    = this.editDescription.Text;
                supplierInfo.SupplierName = supplierName;
                supplierInfo.Picture      = this.UploadImage();
                supplierInfo.Status       = 1;
                supplierInfo.RegionId     = this.dropRegion.GetSelectedRegionId().Value;
                supplierInfo.Tel          = text;
                List <string> list = RegionHelper.GetFullRegion(this.dropRegion.GetSelectedRegionId().Value, ",", true, 0).Split(',').Take(3)
                                     .ToList();
                list.ForEach(delegate(string c)
                {
                    address = address.Replace(c, string.Empty);
                });
                supplierInfo.Address        = address;
                supplierInfo.ContactMan     = text2;
                supplierInfo.FullRegionPath = RegionHelper.GetFullPath(supplierInfo.RegionId, true);
                int num = SupplierHelper.AddSupplier(supplierInfo);
                if (num > 0)
                {
                    ManagerInfo managerInfo = new ManagerInfo();
                    managerInfo.RoleId   = -2;
                    managerInfo.UserName = this.txtUserName.Text.Trim();
                    string text3 = this.txtUserPwd.Text;
                    managerInfo.CreateDate = DateTime.Now;
                    string text4 = Globals.RndStr(128, true);
                    text3 = (managerInfo.Password = Users.EncodePassword(text3, text4));
                    managerInfo.PasswordSalt = text4;
                    managerInfo.StoreId      = num;
                    userId = ManagerHelper.Create(managerInfo);
                }
            }
        }