Пример #1
0
 /// <summary>
 /// 创建商品属性
 /// </summary>
 public static bool CreateProductAttribute(ProductAttributeInfo productAttributeInfo)
 {
     return BrnShop.Data.Products.CreateProductAttribute(productAttributeInfo);
 }
Пример #2
0
 /// <summary>
 /// 更新商品属性
 /// </summary>
 public static bool UpdateProductAttribute(ProductAttributeInfo productAttributeInfo)
 {
     if (productAttributeInfo.Pid < 1 || productAttributeInfo.AttrId < 1 || productAttributeInfo.AttrValueId < 0 || (productAttributeInfo.AttrValueId == 0 && string.IsNullOrWhiteSpace(productAttributeInfo.InputValue)))
         return false;
     return BrnShop.Data.Products.UpdateProductAttribute(productAttributeInfo);
 }
Пример #3
0
 /// <summary>
 /// 更新商品属性
 /// </summary>
 public bool UpdateProductAttribute(ProductAttributeInfo productAttributeInfo)
 {
     DbParameter[] parms =  {
                              GenerateInParam("@pid", SqlDbType.Int, 4, productAttributeInfo.Pid),
                              GenerateInParam("@attrid", SqlDbType.SmallInt, 2, productAttributeInfo.AttrId),
                              GenerateInParam("@attrvalueid", SqlDbType.Int, 4, productAttributeInfo.AttrValueId),
                              GenerateInParam("@inputvalue", SqlDbType.NVarChar, 100, productAttributeInfo.InputValue),
                              GenerateInParam("@recordid", SqlDbType.Int, 4, productAttributeInfo.RecordId)
                            };
     string commandText = string.Format("UPDATE [{0}productattributes] SET [pid]=@pid,[attrid]=@attrid,[attrvalueid]=@attrvalueid,[inputvalue]=@inputvalue WHERE [recordid]=@recordid",
                                         RDBSHelper.RDBSTablePre);
     return TypeHelper.ObjectToInt(RDBSHelper.ExecuteNonQuery(CommandType.Text, commandText, parms)) > 0;
 }
Пример #4
0
 /// <summary>
 /// 创建商品属性
 /// </summary>
 public bool CreateProductAttribute(ProductAttributeInfo productAttributeInfo)
 {
     DbParameter[] parms =  {
                              GenerateInParam("@pid", SqlDbType.Int, 4, productAttributeInfo.Pid),
                              GenerateInParam("@attrid", SqlDbType.SmallInt, 2, productAttributeInfo.AttrId),
                              GenerateInParam("@attrvalueid", SqlDbType.Int, 4, productAttributeInfo.AttrValueId),
                              GenerateInParam("@inputvalue", SqlDbType.NVarChar, 100, productAttributeInfo.InputValue)
                            };
     string commandText = string.Format("INSERT INTO [{0}productattributes]([pid],[attrid],[attrvalueid],[inputvalue]) VALUES(@pid,@attrid,@attrvalueid,@inputvalue)",
                                         RDBSHelper.RDBSTablePre);
     return RDBSHelper.ExecuteNonQuery(CommandType.Text, commandText, parms) > 0;
 }
Пример #5
0
 /// <summary>
 /// 创建商品属性
 /// </summary>
 public static bool CreateProductAttribute(ProductAttributeInfo productAttributeInfo)
 {
     bool result = BrnShop.Core.BSPData.RDBS.CreateProductAttribute(productAttributeInfo);
     if (_productnosql != null)
         _productnosql.ClearProductAttribute(productAttributeInfo.Pid);
     return result;
 }
Пример #6
0
        /// <summary>
        /// 从IDataReader创建ProductAttributeInfo
        /// </summary>
        public static ProductAttributeInfo BuildProductAttributeFromReader(IDataReader reader)
        {
            ProductAttributeInfo productAttributeInfo = new ProductAttributeInfo();

            productAttributeInfo.RecordId = TypeHelper.ObjectToInt(reader["recordid"]);
            productAttributeInfo.Pid = TypeHelper.ObjectToInt(reader["pid"]);
            productAttributeInfo.AttrId = TypeHelper.ObjectToInt(reader["attrid"]);
            productAttributeInfo.AttrValueId = TypeHelper.ObjectToInt(reader["attrvalueid"]);
            productAttributeInfo.InputValue = reader["inputvalue"].ToString();

            return productAttributeInfo;
        }
Пример #7
0
        /// <summary>
        /// 更新商品属性
        /// </summary>
        /// <param name="pid">商品id</param>
        /// <param name="attrId">属性id</param>
        /// <param name="attrValueId">属性值id</param>
        /// <param name="inputValue">输入值</param>
        /// <param name="type">更新类型</param>
        /// <returns></returns>
        public ActionResult UpdateProductAttribute(int pid = -1, int attrId = -1, int attrValueId = -1, string inputValue = "", int type = -1)
        {
            bool result = false;
            ProductAttributeInfo productAttributeInfo = AdminProducts.GetProductAttributeByPidAndAttrId(pid, attrId);
            if (productAttributeInfo == null)
            {
                productAttributeInfo = new ProductAttributeInfo();

                productAttributeInfo.Pid = pid;
                productAttributeInfo.AttrId = attrId;
                productAttributeInfo.AttrValueId = attrValueId;
                if (AdminCategories.GetAttributeValueById(attrValueId).IsInput == 0 || string.IsNullOrWhiteSpace(inputValue))
                    productAttributeInfo.InputValue = "";
                else
                    productAttributeInfo.InputValue = inputValue;

                result = AdminProducts.CreateProductAttribute(productAttributeInfo);
            }
            else
            {
                if (type == 1)
                {
                    productAttributeInfo.AttrValueId = attrValueId;
                    productAttributeInfo.InputValue = inputValue;
                    result = AdminProducts.UpdateProductAttribute(productAttributeInfo);
                }
                else if (type == 0)
                {
                    productAttributeInfo.AttrValueId = attrValueId;
                    productAttributeInfo.InputValue = "";
                    result = AdminProducts.UpdateProductAttribute(productAttributeInfo);
                }
            }
            if (result)
            {
                AddAdminOperateLog("修改商品属性", "修改商品属性,商品属性ID:" + pid + "_" + attrId);
                return Content("1");
            }
            else
            {
                return Content("0");
            }
        }