/// <summary> /// 创建属性值 /// </summary> public static void CreateAttributeValue(AttributeValueInfo attributeValueInfo) { BrnShop.Data.Categories.CreateAttributeValue(attributeValueInfo); AttributeInfo attributeInfo = GetAttributeById(attributeValueInfo.AttrId); if (attributeInfo.IsFilter == 1) { BrnShop.Core.BSPCache.Remove(CacheKeys.SHOP_CATEGORY_FILTERAANDVLIST + attributeInfo.CateId); } BrnShop.Core.BSPCache.Remove(CacheKeys.SHOP_CATEGORY_AANDVLISTJSONCACHE + attributeInfo.CateId); }
/// <summary> /// 通过IDataReader创建AttributeValueInfo信息 /// </summary> public static AttributeValueInfo BuildAttributeValueFromReader(IDataReader reader) { AttributeValueInfo attributeValueInfo = new AttributeValueInfo(); attributeValueInfo.AttrValueId = TypeHelper.ObjectToInt(reader["attrvalueid"]); attributeValueInfo.AttrValue = reader["attrvalue"].ToString(); attributeValueInfo.IsInput = TypeHelper.ObjectToInt(reader["isinput"]); attributeValueInfo.AttrName = reader["attrname"].ToString(); attributeValueInfo.AttrDisplayOrder = TypeHelper.ObjectToInt(reader["attrdisplayorder"]); attributeValueInfo.AttrShowType = TypeHelper.ObjectToInt(reader["attrshowtype"]); attributeValueInfo.AttrValueDisplayOrder = TypeHelper.ObjectToInt(reader["attrvaluedisplayorder"]); attributeValueInfo.AttrGroupId = TypeHelper.ObjectToInt(reader["attrgroupid"]); attributeValueInfo.AttrGroupName = reader["attrgroupname"].ToString(); attributeValueInfo.AttrGroupDisplayOrder = TypeHelper.ObjectToInt(reader["attrgroupdisplayorder"]); attributeValueInfo.AttrId = TypeHelper.ObjectToInt(reader["attrid"]); return attributeValueInfo; }
public ActionResult AddAttributeValue(AttributeValueModel model, int attrId = -1) { AttributeInfo attributeInfo = AdminCategories.GetAttributeById(attrId); if (attributeInfo == null) ModelState.AddModelError("AttributName", "属性不存在"); if (AdminCategories.GetAttributeValueIdByAttrIdAndValue(attrId, model.AttrValue) > 0) ModelState.AddModelError("AttributName", "值已经存在"); if (ModelState.IsValid) { AttributeGroupInfo attributeGroupInfo = AdminCategories.GetAttributeGroupById(attributeInfo.AttrGroupId); AttributeValueInfo attributeValueInfo = new AttributeValueInfo(); attributeValueInfo.AttrId = attributeInfo.AttrId; attributeValueInfo.AttrName = attributeInfo.Name; attributeValueInfo.AttrDisplayOrder = attributeInfo.DisplayOrder; attributeValueInfo.AttrShowType = attributeInfo.ShowType; attributeValueInfo.AttrGroupId = attributeGroupInfo.AttrGroupId; attributeValueInfo.AttrGroupName = attributeGroupInfo.Name; attributeValueInfo.AttrGroupDisplayOrder = attributeGroupInfo.DisplayOrder; attributeValueInfo.AttrValue = model.AttrValue; attributeValueInfo.IsInput = 0; attributeValueInfo.AttrValueDisplayOrder = model.DisplayOrder; AdminCategories.CreateAttributeValue(attributeValueInfo); AddAdminOperateLog("添加属性值", "添加属性值,属性值为:" + model.AttrValue); return PromptView("属性值添加成功"); } ViewData["attrId"] = attributeInfo.AttrId; ViewData["attributeName"] = attributeInfo.Name; ViewData["referer"] = ShopUtils.GetAdminRefererCookie(); return View(model); }
/// <summary> /// 更新属性值 /// </summary> public static void UpdateAttributeValue(AttributeValueInfo attributeValueInfo) { BrnShop.Core.BSPData.RDBS.UpdateAttributeValue(attributeValueInfo); }
/// <summary> /// 更新属性值 /// </summary> public void UpdateAttributeValue(AttributeValueInfo attributeValueInfo) { DbParameter[] parms = { GenerateInParam("@attrvalue", SqlDbType.NChar,70, attributeValueInfo.AttrValue), GenerateInParam("@isinput", SqlDbType.TinyInt,1, attributeValueInfo.IsInput), GenerateInParam("@attrname", SqlDbType.NChar,30, attributeValueInfo.AttrName), GenerateInParam("@attrdisplayorder", SqlDbType.Int,4, attributeValueInfo.AttrDisplayOrder), GenerateInParam("@attrshowtype", SqlDbType.TinyInt,1, attributeValueInfo.AttrShowType), GenerateInParam("@attrvaluedisplayorder", SqlDbType.Int,4,attributeValueInfo.AttrValueDisplayOrder), GenerateInParam("@attrgroupid", SqlDbType.SmallInt,2, attributeValueInfo.AttrGroupId), GenerateInParam("@attrgroupname", SqlDbType.NChar,20, attributeValueInfo.AttrGroupName), GenerateInParam("@attrgroupdisplayorder", SqlDbType.Int,4, attributeValueInfo.AttrGroupDisplayOrder), GenerateInParam("@attrid", SqlDbType.SmallInt,2,attributeValueInfo.AttrId), GenerateInParam("@attrvalueid", SqlDbType.Int, 4, attributeValueInfo.AttrValueId) }; string commandText = string.Format("UPDATE [{0}attributevalues] SET [attrvalue]=@attrvalue,[isinput]=@isinput,[attrname]=@attrname,[attrdisplayorder]=@attrdisplayorder,[attrshowtype]=@attrshowtype,[attrvaluedisplayorder]=@attrvaluedisplayorder,[attrgroupid]=@attrgroupid,[attrgroupname]=@attrgroupname,[attrgroupdisplayorder]=@attrgroupdisplayorder,[attrid]=@attrid WHERE [attrvalueid]=@attrvalueid", RDBSHelper.RDBSTablePre); RDBSHelper.ExecuteNonQuery(CommandType.Text, commandText, parms); }
/// <summary> /// 创建属性值 /// </summary> public void CreateAttributeValue(AttributeValueInfo attributeValueInfo) { DbParameter[] parms = { GenerateInParam("@attrvalue", SqlDbType.NChar,70, attributeValueInfo.AttrValue), GenerateInParam("@isinput", SqlDbType.TinyInt,1, attributeValueInfo.IsInput), GenerateInParam("@attrname", SqlDbType.NChar,30, attributeValueInfo.AttrName), GenerateInParam("@attrdisplayorder", SqlDbType.Int,4, attributeValueInfo.AttrDisplayOrder), GenerateInParam("@attrshowtype", SqlDbType.TinyInt,1, attributeValueInfo.AttrShowType), GenerateInParam("@attrvaluedisplayorder", SqlDbType.Int,4,attributeValueInfo.AttrValueDisplayOrder), GenerateInParam("@attrgroupid", SqlDbType.SmallInt,2, attributeValueInfo.AttrGroupId), GenerateInParam("@attrgroupname", SqlDbType.NChar,20, attributeValueInfo.AttrGroupName), GenerateInParam("@attrgroupdisplayorder", SqlDbType.Int,4, attributeValueInfo.AttrGroupDisplayOrder), GenerateInParam("@attrid", SqlDbType.SmallInt,2,attributeValueInfo.AttrId) }; string commandText = string.Format("INSERT INTO [{0}attributevalues]([attrvalue],[isinput],[attrname],[attrdisplayorder],[attrshowtype],[attrvaluedisplayorder],[attrgroupid],[attrgroupname],[attrgroupdisplayorder],[attrid]) VALUES(@attrvalue,@isinput,@attrname,@attrdisplayorder,@attrshowtype,@attrvaluedisplayorder,@attrgroupid,@attrgroupname,@attrgroupdisplayorder,@attrid)", RdbsHelper.RdbsTablePre); RdbsHelper.ExecuteNonQuery(CommandType.Text, commandText, parms); }