Ejemplo n.º 1
0
        private void CheckSupplierName(HttpContext context)
        {
            int    supplierId   = context.Request["supplierId"].ToInt(0);
            string supplierName = Globals.StripAllTags(context.Request["supplierName"]);
            string empty        = string.Empty;

            empty = ((!SupplierHelper.ExistSupplierName(supplierId, supplierName)) ? "{\"success\":\"true\",\"msg\":\"\"}" : "{\"success\":\"false\",\"msg\":\"供应商名称已经存在,请重新输入!\"}");
            this.ResponseEnd(empty);
        }
Ejemplo n.º 2
0
        private void UpdateSupplier()
        {
            SupplierInfo supplierById = SupplierHelper.GetSupplierById(this.supplierId);
            ManagerInfo  managerInfo  = ManagerHelper.FindManagerByStoreId(this.supplierId, SystemRoles.SupplierAdmin);

            if (managerInfo == null || supplierById == null)
            {
                base.Response.Redirect("SupplierList.aspx");
            }
            string supplierName = Globals.StripAllTags(this.txtSupplierName.Text.Trim());
            string text         = Globals.StripAllTags(this.txtAddress.Text);
            string text2        = this.txtTel.Text;
            string text3        = Globals.StripAllTags(this.txtContactMan.Text);

            if (SupplierHelper.ExistSupplierName(this.supplierId, supplierName))
            {
                this.ShowMsg("供应商名称已经存在,请重新输入!", false);
            }
            else if (!this.dropRegion.GetSelectedRegionId().HasValue)
            {
                this.ShowMsg("请选择供应商所在区域!", false);
            }
            else if (text3.Length > 8 || text3.Length < 2)
            {
                this.ShowMsg("请输入联系人,联系人长度必须是2-8位!", false);
            }
            else if (text.Length > 50 || text.Length < 2)
            {
                this.ShowMsg("请输入地址,长度必须为2-50个字符!", false);
            }
            else if (text2 == "" || !DataHelper.IsTel(text2))
            {
                this.ShowMsg("请输入正确的联系电话(手机或者固定电话)!", false);
            }
            else
            {
                int value = this.dropRegion.GetSelectedRegionId().Value;
                supplierById.SupplierName   = supplierName;
                supplierById.Picture        = this.UploadImage();
                supplierById.Tel            = text2;
                supplierById.Address        = text;
                supplierById.ContactMan     = text3;
                supplierById.RegionId       = value;
                supplierById.FullRegionPath = RegionHelper.GetFullPath(value, true);
                supplierById.Introduce      = this.editDescription.Text;
                SupplierHelper.UpdateSupplier(supplierById);
            }
        }
Ejemplo n.º 3
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);
                }
            }
        }