예제 #1
0
        /// <summary>
        /// 提交按钮点击方法
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void SubmitButton_Click(object sender, EventArgs e)
        {
            #region
            //添加属性组,即产品类型
            int             productTypeID = 0;
            ProductTypeInfo productType   = new ProductTypeInfo();
            productType.Id   = RequestHelper.GetQueryString <int>("ID");
            productType.Name = Name.Text;
            //productType.BrandIds = RequestHelper.GetForm<string>("proBrand").Replace(",",";");
            productType.BrandIds = RequestHelper.GetForm <string>("choosedBrnadIds").Replace(";;", ";");

            string alertMessage = ShopLanguage.ReadLanguage("AddOK");
            if (productType.Id == int.MinValue)
            {
                CheckAdminPower("AddProductType", PowerCheckType.Single);
                productTypeID = ProductTypeBLL.Add(productType);
                AdminLogBLL.Add(ShopLanguage.ReadLanguage("AddRecord"), ShopLanguage.ReadLanguage("ProductType"), productTypeID);

                #region
                //添加相关属性
                string[] namelist  = RequestHelper.GetForm <string>("NameList").Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
                string[] valuelist = RequestHelper.GetForm <string>("ValueList").Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
                string[] typelist  = RequestHelper.GetForm <string>("TypeList").Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);

                if (namelist.Length > 0)
                {
                    for (int t = 0; t < namelist.Length; t++)
                    {
                        ProductTypeAttributeInfo attribute = new ProductTypeAttributeInfo();
                        attribute.Name = namelist[t];
                        var _attribute = ProductTypeAttributeBLL.Read(attribute.Name, productTypeID);
                        if (_attribute.Id > 0)
                        {
                            ScriptHelper.Alert("该属性已存在,请重新输入", RequestHelper.RawUrl);
                        }
                        else
                        {
                            attribute.ProductTypeId = productTypeID;
                            int typeNum = 0;
                            int.TryParse(typelist[t], out typeNum);

                            attribute.InputType  = typeNum;
                            attribute.InputValue = valuelist[t].Replace('|', ';');
                            attribute.OrderId    = 0;

                            ProductTypeAttributeBLL.Add(attribute);
                        }
                    }
                }
                #endregion
                #region
                //添加相关规格
                string[] snamelist  = RequestHelper.GetForm <string>("SNameList").Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
                string[] svaluelist = RequestHelper.GetForm <string>("SValueList").Split(',');
                string[] stypelist  = RequestHelper.GetForm <string>("STypeList").Split(',');
                if (snamelist.Length > 0)
                {
                    for (int t = 0; t < snamelist.Length; t++)
                    {
                        ProductTypeStandardInfo standard = new ProductTypeStandardInfo();
                        standard.Name = snamelist[t];
                        var _standard = ProductTypeStandardBLL.Read(standard.Name, productTypeID);
                        if (_standard.Id > 0)
                        {
                            ScriptHelper.Alert("该规格已存在,请重新输入", RequestHelper.RawUrl);
                        }
                        else
                        {
                            standard.ProductTypeId = productTypeID;
                            int typeNum = 0;
                            int.TryParse(stypelist[t], out typeNum);

                            standard.ValueList = svaluelist[t].Replace('|', ';');

                            ProductTypeStandardBLL.Add(standard);
                        }
                    }
                }
                #endregion
            }
            else
            {
                CheckAdminPower("UpdateProductType", PowerCheckType.Single);
                ProductTypeBLL.Update(productType);
                AdminLogBLL.Add(ShopLanguage.ReadLanguage("UpdateRecord"), ShopLanguage.ReadLanguage("ProductType"), productType.Id);
                alertMessage = ShopLanguage.ReadLanguage("UpdateOK");

                #region
                //删除原有属性
                //ProductTypeAttributeBLL.DeleteList(productType.Id);

                //添加相关属性
                string[] namelist  = RequestHelper.GetForm <string>("NameList").Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
                string[] valuelist = RequestHelper.GetForm <string>("ValueList").Split(',');
                string[] typelist  = RequestHelper.GetForm <string>("TypeList").Split(',');
                string[] idList    = RequestHelper.GetForm <string>("IdList").Split(',');

                if (namelist.Length > 0)
                {
                    List <ProductTypeAttributeInfo> productTypeAttrList = ProductTypeAttributeBLL.ReadList(productType.Id);
                    for (int t = 0; t < namelist.Length; t++)
                    {
                        if (idList[t] != "0")
                        {
                            ProductTypeAttributeInfo attribute = ProductTypeAttributeBLL.Read(Convert.ToInt32(idList[t]));
                            attribute.Name = namelist[t];
                            var _attribute = ProductTypeAttributeBLL.Read(attribute.Name, productType.Id);
                            if (_attribute.Id != attribute.Id && _attribute.Id > 0)
                            {
                                ScriptHelper.Alert("该属性已存在,请重新输入", RequestHelper.RawUrl);
                            }
                            else
                            {
                                attribute.ProductTypeId = productType.Id;
                                int typeNum = 0;
                                int.TryParse(typelist[t], out typeNum);

                                attribute.InputType  = typeNum;
                                attribute.InputValue = valuelist[t].Replace('|', ';');
                                attribute.OrderId    = 0;

                                ProductTypeAttributeBLL.Update(attribute);
                            }
                        }
                        else
                        {
                            ProductTypeAttributeInfo attribute = new ProductTypeAttributeInfo();
                            attribute.Name = namelist[t];
                            var _attribute = ProductTypeAttributeBLL.Read(attribute.Name, productType.Id);
                            if (_attribute.Id > 0)
                            {
                                ScriptHelper.Alert("该属性已存在,请重新输入", RequestHelper.RawUrl);
                            }
                            else
                            {
                                attribute.ProductTypeId = productType.Id;
                                int typeNum = 0;
                                int.TryParse(typelist[t], out typeNum);

                                attribute.InputType  = typeNum;
                                attribute.InputValue = valuelist[t].Replace('|', ';');
                                attribute.OrderId    = 0;

                                ProductTypeAttributeBLL.Add(attribute);
                            }
                        }
                    }
                }
                #endregion
                #region
                //删除原有规格
                //ProductTypeStandardBLL.DeleteList(productType.Id);
                //添加相关规格
                string[] snamelist  = RequestHelper.GetForm <string>("SNameList").Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
                string[] svaluelist = RequestHelper.GetForm <string>("SValueList").Split(',');
                string[] stypelist  = RequestHelper.GetForm <string>("STypeList").Split(',');
                string[] sidList    = RequestHelper.GetForm <string>("SIdList").Split(',');

                if (snamelist.Length > 0)
                {
                    List <ProductTypeStandardInfo> productTypeStandardList = ProductTypeStandardBLL.ReadList(productType.Id);
                    for (int t = 0; t < snamelist.Length; t++)
                    {
                        if (sidList[t] != "0")
                        {
                            ProductTypeStandardInfo standard = ProductTypeStandardBLL.Read(Convert.ToInt32(sidList[t]));
                            standard.Name = snamelist[t];
                            var _standard = ProductTypeStandardBLL.Read(standard.Name, productType.Id);
                            if (_standard.Id != standard.Id && _standard.Id > 0)
                            {
                                ScriptHelper.Alert("该规格已存在,请重新输入", RequestHelper.RawUrl);
                            }
                            else
                            {
                                standard.ProductTypeId = productType.Id;
                                standard.ValueList     = svaluelist[t].Replace('|', ';');

                                ProductTypeStandardBLL.Update(standard);
                            }
                        }
                        else
                        {
                            ProductTypeStandardInfo standard = new ProductTypeStandardInfo();
                            standard.Name = snamelist[t];
                            var _standard = ProductTypeStandardBLL.Read(standard.Name, productType.Id);
                            if (_standard.Id > 0)
                            {
                                ScriptHelper.Alert("该规格已存在,请重新输入", RequestHelper.RawUrl);
                            }
                            else
                            {
                                standard.ProductTypeId = productType.Id;
                                standard.ValueList     = svaluelist[t].Replace('|', ';');

                                ProductTypeStandardBLL.Add(standard);
                            }
                        }
                    }
                }
                #endregion
            }
            #endregion


            ScriptHelper.Alert(alertMessage, RequestHelper.RawUrl);
        }
예제 #2
0
        public int Put([FromBody] ProductType parameter)
        {
            ProductTypeBLL bll = new ProductTypeBLL();

            return(bll.Update(parameter));
        }