private void btnEditProductType_Click(object sender, EventArgs e)
        {
            ProductTypeInfo productTypeInfo = new ProductTypeInfo();

            productTypeInfo.TypeId   = this.typeId;
            productTypeInfo.TypeName = Globals.StripHtmlXmlTags(Globals.StripScriptTags(this.txtTypeName.Text).Replace(",", ",").Replace("\\", ""));
            if (string.IsNullOrEmpty(productTypeInfo.TypeName))
            {
                this.ShowMsg("类型名称不能为空,不允许包含脚本标签、HTML标签和\\\\(反斜杠),系统会自动过滤", false);
            }
            else if (ProductTypeHelper.HasSameProductTypeName(productTypeInfo.TypeName, this.typeId))
            {
                this.ShowMsg("不能有重复的类型名称", false);
            }
            else
            {
                productTypeInfo.Remark = this.txtRemark.Text;
                IList <int> list = new List <int>();
                foreach (ListItem item in this.chlistBrand.Items)
                {
                    if (item.Selected)
                    {
                        list.Add(int.Parse(item.Value));
                    }
                }
                productTypeInfo.Brands = list;
                if (this.ValidationProductType(productTypeInfo) && ProductTypeHelper.UpdateProductType(productTypeInfo))
                {
                    this.ShowMsg("修改成功", true);
                }
            }
        }
Example #2
0
        private void btnAddProductType_Click(object sender, EventArgs e)
        {
            ProductTypeInfo productTypeInfo = new ProductTypeInfo();

            productTypeInfo.TypeName = Globals.StripHtmlXmlTags(Globals.StripScriptTags(this.txtTypeName.Text).Replace(",", ",").Replace("\\", ""));
            if (string.IsNullOrEmpty(productTypeInfo.TypeName))
            {
                this.ShowMsg("类型名称不能为空,不允许包含脚本标签、HTML标签和\\,系统会自动过滤", false);
            }
            else if (ProductTypeHelper.HasSameProductTypeName(productTypeInfo.TypeName, 0))
            {
                this.ShowMsg("不能有重复的类型名称", false);
            }
            else
            {
                productTypeInfo.Remark = this.txtRemark.Text;
                IList <int> list = new List <int>();
                foreach (ListItem item in this.chlistBrand.Items)
                {
                    if (item.Selected)
                    {
                        list.Add(int.Parse(item.Value));
                    }
                }
                productTypeInfo.Brands = list;
                if (this.ValidationProductType(productTypeInfo))
                {
                    int num = ProductTypeHelper.AddProductType(productTypeInfo);
                    if (num > 0)
                    {
                        base.Response.Redirect(Globals.GetAdminAbsolutePath("/product/AddAttribute.aspx?typeId=" + num), true);
                    }
                    else
                    {
                        this.ShowMsg("添加商品类型失败", false);
                    }
                }
            }
        }