public IList <AttributeInfo> GetAttributes(int typeId) { IList <AttributeInfo> list = new List <AttributeInfo>(); DbCommand sqlStringCommand = base.database.GetSqlStringCommand("SELECT * FROM Hishop_Attributes WHERE TypeId = @TypeId ORDER BY DisplaySequence DESC SELECT * FROM Hishop_AttributeValues WHERE AttributeId IN (SELECT AttributeId FROM Hishop_Attributes WHERE TypeId = @TypeId) ORDER BY DisplaySequence DESC"); base.database.AddInParameter(sqlStringCommand, "TypeId", DbType.Int32, typeId); using (DataSet dataSet = base.database.ExecuteDataSet(sqlStringCommand)) { foreach (DataRow row in dataSet.Tables[0].Rows) { AttributeInfo attributeInfo = new AttributeInfo(); attributeInfo.AttributeId = (int)row["AttributeId"]; attributeInfo.AttributeName = (string)row["AttributeName"]; attributeInfo.DisplaySequence = (int)row["DisplaySequence"]; attributeInfo.TypeId = (int)row["TypeId"]; attributeInfo.UsageMode = (AttributeUseageMode)(int)row["UsageMode"]; attributeInfo.UseAttributeImage = (bool)row["UseAttributeImage"]; if (dataSet.Tables[1].Rows.Count > 0) { DataRow[] array = dataSet.Tables[1].Select("AttributeId=" + attributeInfo.AttributeId.ToString()); DataRow[] array2 = array; foreach (DataRow dataRow2 in array2) { AttributeValueInfo attributeValueInfo = new AttributeValueInfo(); attributeValueInfo.ValueId = (int)dataRow2["ValueId"]; attributeValueInfo.AttributeId = attributeInfo.AttributeId; attributeValueInfo.ValueStr = (string)dataRow2["ValueStr"]; attributeInfo.AttributeValues.Add(attributeValueInfo); } } list.Add(attributeInfo); } } return(list); }
public ActionResult EditAttributeValue(int attrValueId = -1) { AttributeValueInfo attributeValueInfo = AdminCategories.GetAttributeValueById(attrValueId); if (attributeValueInfo == null) { return(PromptView("属性值不存在")); } if (attributeValueInfo.IsInput == 1) { return(PromptView("输入型属性值不能修改")); } AttributeValueModel model = new AttributeValueModel(); model.AttrValue = attributeValueInfo.AttrValue; model.DisplayOrder = attributeValueInfo.AttrValueDisplayOrder; AttributeInfo attributeInfo = Categories.GetAttributeById(attributeValueInfo.AttrId); ViewData["attrId"] = attributeInfo.AttrId; ViewData["attributeName"] = attributeInfo.Name; ViewData["referer"] = ShopUtils.GetAdminRefererCookie(); return(View(model)); }
private void AddValue(HttpContext context) { IList <AttributeValueInfo> list = new List <AttributeValueInfo>(); int value = base.GetIntParam(context, "typeId", false).Value; int value2 = base.GetIntParam(context, "id", false).Value; string parameter = base.GetParameter(context, "contents", false); parameter = Globals.StripHtmlXmlTags(Globals.StripScriptTags(parameter.Trim()).Replace(",", ",").Replace("\\", "") .Replace("+", "")); string[] array = parameter.Split(','); for (int i = 0; i < array.Length && array[i].Trim().Length <= 100; i++) { AttributeValueInfo attributeValueInfo = new AttributeValueInfo(); if (array[i].Trim().Length > 15) { throw new HidistroAshxException("属性值不合规范"); } attributeValueInfo.ValueStr = array[i].Trim(); attributeValueInfo.ValueStr = attributeValueInfo.ValueStr.Replace("+", "").Replace("\\", "").Replace("/", ""); attributeValueInfo.AttributeId = value2; list.Add(attributeValueInfo); } foreach (AttributeValueInfo item in list) { ProductTypeHelper.AddAttributeValue(item); } base.ReturnSuccessResult(context, "添加值成功!", 0, true); }
public static int AddAttributeValue(AttributeValueInfo attributeValue) { AttributeValueDao attributeValueDao = new AttributeValueDao(); attributeValue.DisplaySequence = attributeValueDao.GetMaxDisplaySequence <AttributeValueInfo>(); return((int)new AttributeValueDao().Add(attributeValue, null)); }
/// <summary> /// 删除属性值 /// </summary> /// <param name="attrValueId">属性值id</param> /// <returns>-2代表此属性值不存在,-1代表此属性值为输入属性值,0代表此属性值下还有商品未删除,1代表删除成功</returns> public static int DeleteAttributeValueById(int attrValueId) { AttributeValueInfo attributeValueInfo = GetAttributeValueById(attrValueId); if (attributeValueInfo == null) { return(-2); } if (attributeValueInfo.IsInput == 1) { return(-1); } if (AdminProducts.AdminGetAttrValueProductCount(attrValueId) > 0) { return(0); } AttributeInfo attributeInfo = GetAttributeById(attributeValueInfo.AttrId); BrnMall.Data.Categories.DeleteAttributeValueById(attrValueId); if (attributeInfo.IsFilter == 1) { BrnMall.Core.BMACache.Remove(CacheKeys.MALL_CATEGORY_FILTERAANDVLIST + attributeInfo.CateId); } BrnMall.Core.BMACache.Remove(CacheKeys.MALL_CATEGORY_AANDVLISTJSONCACHE + attributeInfo.CateId); return(1); }
public IList <AttributeInfo> GetAttributes(AttributeUseageMode attributeUseageMode) { IList <AttributeInfo> list = new List <AttributeInfo>(); string text = (attributeUseageMode != AttributeUseageMode.Choose) ? "UsageMode <> 2" : "UsageMode = 2"; DbCommand sqlStringCommand = base.database.GetSqlStringCommand("SELECT * FROM Hishop_Attributes WHERE " + text + " ORDER BY DisplaySequence Desc SELECT * FROM Hishop_AttributeValues WHERE AttributeId IN (SELECT AttributeId FROM Hishop_Attributes Where " + text + " ) ORDER BY DisplaySequence Desc"); using (DataSet dataSet = base.database.ExecuteDataSet(sqlStringCommand)) { foreach (DataRow row in dataSet.Tables[0].Rows) { AttributeInfo attributeInfo = new AttributeInfo(); attributeInfo.AttributeId = (int)row["AttributeId"]; attributeInfo.AttributeName = (string)row["AttributeName"]; attributeInfo.DisplaySequence = (int)row["DisplaySequence"]; attributeInfo.TypeId = (int)row["TypeId"]; attributeInfo.UsageMode = (AttributeUseageMode)(int)row["UsageMode"]; attributeInfo.UseAttributeImage = (bool)row["UseAttributeImage"]; if (dataSet.Tables[1].Rows.Count > 0) { DataRow[] array = dataSet.Tables[1].Select("AttributeId=" + attributeInfo.AttributeId.ToString()); DataRow[] array2 = array; foreach (DataRow dataRow2 in array2) { AttributeValueInfo attributeValueInfo = new AttributeValueInfo(); attributeValueInfo.ValueId = (int)dataRow2["ValueId"]; attributeValueInfo.AttributeId = attributeInfo.AttributeId; attributeValueInfo.ValueStr = (string)dataRow2["ValueStr"]; attributeInfo.AttributeValues.Add(attributeValueInfo); } } list.Add(attributeInfo); } } return(list); }
/// <summary> /// 获取当前属性下的属性值列表 /// </summary> public List <AttributeValueInfo> GetAttributeValueInfos(int attrid) { using (brnshopEntities context = new brnshopEntities()) { try { List <AttributeValueInfo> result = new List <AttributeValueInfo>(); var attributevaluess = context.bsp_attributevalues.Where(t => t.attrid == attrid).ToList(); foreach (var attrvalue in attributevaluess) { AttributeValueInfo newattrvalue = new AttributeValueInfo() { attrvalueid = attrvalue.attrvalueid, attrvalue = attrvalue.attrvalue, attrname = attrvalue.attrname, }; result.Add(newattrvalue); } return(result); } catch (Exception ex) { Logger._.Error(ex); return(null); } } }
protected void Page_Load(object sender, EventArgs e) { if (!base.IsPostBack) { if (string.IsNullOrEmpty(this.Page.Request.QueryString["action"].ToString().Trim())) { base.GotoResourceNotFound(); return; } string a = this.Page.Request.QueryString["action"].ToString().Trim(); if (a == "add") { if (!int.TryParse(this.Page.Request.QueryString["attributeId"], out this.attributeId)) { base.GotoResourceNotFound(); return; } } else { if (!int.TryParse(this.Page.Request.QueryString["valueId"], out this.valueId)) { base.GotoResourceNotFound(); return; } AttributeValueInfo attributeValueInfo = ProductTypeHelper.GetAttributeValueInfo(this.valueId); this.attributeId = attributeValueInfo.AttributeId; this.txtValueStr.Text = Globals.HtmlDecode(attributeValueInfo.ValueStr); } this.currentAttributeId.Value = this.attributeId.ToString(); } this.btnCreateValue.Click += this.btnCreateValue_Click; }
private void btnCreateValueAdd_Click(object sender, EventArgs e) { AttributeValueInfo info = new AttributeValueInfo(); IList <AttributeValueInfo> list = new List <AttributeValueInfo>(); int num = int.Parse(this.currentAttributeId.Value); info.AttributeId = num; if (!string.IsNullOrEmpty(this.txtValueStr.Text.Trim())) { string[] strArray = this.txtValueStr.Text.Trim().Replace(",", ",").Split(new char[] { ',' }); for (int i = 0; i < strArray.Length; i++) { if (strArray[i].Trim().Length > 100) { break; } AttributeValueInfo item = new AttributeValueInfo(); if (strArray[i].Trim().Length > 50) { string str2 = string.Format("ShowMsg(\"{0}\", {1});", "属性值限制在50个字符以内", "false"); this.Page.ClientScript.RegisterStartupScript(base.GetType(), "ServerMessageScript2", "<script language='JavaScript' defer='defer'>setTimeout(function(){" + str2 + "},300);</script>"); return; } item.ValueStr = Globals.HtmlEncode(strArray[i].Trim()).Replace("+", ""); item.AttributeId = num; list.Add(item); } foreach (AttributeValueInfo info3 in list) { ProductTypeHelper.AddAttributeValue(info3); } this.txtValueStr.Text = string.Empty; base.Response.Redirect(HttpContext.Current.Request.Url.ToString(), true); } }
private void btnUpdate_Click(object sender, EventArgs e) { AttributeValueInfo attributeValueInfo = ProductTypeHelper.GetAttributeValueInfo(Convert.ToInt32(currentAttributeId.Value)); if (ProductTypeHelper.GetAttribute(attributeValueInfo.AttributeId).UseAttributeImage) { if (!string.IsNullOrEmpty(txtValueDec1.Text)) { attributeValueInfo.ValueStr = Globals.HtmlEncode(txtValueDec1.Text); } } else if (!string.IsNullOrEmpty(txtValueStr1.Text)) { attributeValueInfo.ValueStr = Globals.HtmlEncode(txtValueStr1.Text); } if (fileUpload1.HasFile) { try { StoreHelper.DeleteImage(attributeValueInfo.ImageUrl); attributeValueInfo.ImageUrl = ProductTypeHelper.UploadSKUImage(fileUpload1.PostedFile); } catch { } } if (ProductTypeHelper.UpdateSku(attributeValueInfo)) { txtValueStr1.Text = string.Empty; txtValueDec1.Text = string.Empty; base.Response.Redirect(HttpContext.Current.Request.Url.ToString(), true); } }
private void ProcessingAttrUpdate(ProductTypeInfo model) { AttributeValueInfo list = null; ProductTypeInfo productTypeInfo = this.context.ProductTypeInfo.FindById <ProductTypeInfo>(model.Id); foreach (AttributeInfo attributeInfo in model.AttributeInfo.ToList <AttributeInfo>()) { if (productTypeInfo.AttributeInfo.Any <AttributeInfo>((AttributeInfo a) => (!a.Id.Equals(attributeInfo.Id) ? false : attributeInfo.Id != (long)0))) { AttributeInfo name = productTypeInfo.AttributeInfo.FirstOrDefault <AttributeInfo>((AttributeInfo a) => a.Id.Equals(attributeInfo.Id)); name.Name = attributeInfo.Name; name.IsMulti = attributeInfo.IsMulti; IEnumerable <AttributeValueInfo> attributeValueInfos = name.AttributeValueInfo.Except <AttributeValueInfo>(attributeInfo.AttributeValueInfo, new AttrValueComparer()); if ((attributeValueInfos == null ? false : 0 < attributeValueInfos.Count <AttributeValueInfo>())) { foreach (AttributeValueInfo list2 in attributeValueInfos.ToList <AttributeValueInfo>()) { this.context.AttributeValueInfo.Remove(list2); } } IEnumerable <AttributeValueInfo> attributeValueInfos1 = attributeInfo.AttributeValueInfo.Except <AttributeValueInfo>(name.AttributeValueInfo, new AttrValueComparer()); if ((attributeValueInfos1 == null ? false : 0 < attributeValueInfos1.Count <AttributeValueInfo>())) { foreach (AttributeValueInfo id in attributeValueInfos1.ToList <AttributeValueInfo>()) { id.AttributeId = attributeInfo.Id; this.context.AttributeValueInfo.Add(id); } } } } }
public ActionResult EditAttributeValue(AttributeValueModel model, int attrValueId = 0) { AttributeValueInfo attributeValueInfo = AdminCategories.GetAttributeValueById(attrValueId); if (attributeValueInfo == null) { return(PromptView("属性值不存在")); } //if (attributeValueInfo.IsInput == 1) // return PromptView("输入型属性值不能修改"); int attrValueId2 = AdminCategories.GetAttributeValueIdByAttrIdAndValue(attributeValueInfo.AttrId, model.AttrValue); if (attrValueId2 > 0 && attrValueId2 != attrValueId) { ModelState.AddModelError("AttrValue", "值已经存在"); } if (ModelState.IsValid) { attributeValueInfo.AttrValue = model.AttrValue; attributeValueInfo.AttrValueDisplayOrder = model.DisplayOrder; AdminCategories.UpdateAttributeValue(attributeValueInfo); AddMallAdminLog("修改属性值", "修改属性值,属性值ID为:" + attrValueId); return(PromptView("属性值修改成功")); } AttributeInfo attributeInfo = Categories.GetAttributeById(attributeValueInfo.AttrId); ViewData["attrId"] = attributeInfo.AttrId; ViewData["attributeName"] = attributeInfo.Name; ViewData["referer"] = MallUtils.GetMallAdminRefererCookie(); return(View(model)); }
public IList <AttributeInfo> GetAttributes(int typeId) { IList <AttributeInfo> list = new List <AttributeInfo>(); DbCommand sqlStringCommand = this.database.GetSqlStringCommand("SELECT * FROM Hishop_Attributes WHERE TypeId = @TypeId ORDER BY DisplaySequence DESC SELECT * FROM Hishop_AttributeValues WHERE AttributeId IN (SELECT AttributeId FROM Hishop_Attributes WHERE TypeId = @TypeId) ORDER BY DisplaySequence DESC"); this.database.AddInParameter(sqlStringCommand, "TypeId", DbType.Int32, typeId); using (DataSet set = this.database.ExecuteDataSet(sqlStringCommand)) { foreach (DataRow row in set.Tables[0].Rows) { AttributeInfo item = new AttributeInfo { AttributeId = (int)row["AttributeId"], AttributeName = (string)row["AttributeName"], DisplaySequence = (int)row["DisplaySequence"], TypeId = (int)row["TypeId"], UsageMode = (AttributeUseageMode)((int)row["UsageMode"]), UseAttributeImage = (bool)row["UseAttributeImage"] }; if (set.Tables[1].Rows.Count > 0) { foreach (DataRow row2 in set.Tables[1].Select("AttributeId=" + item.AttributeId.ToString())) { AttributeValueInfo info2 = new AttributeValueInfo { ValueId = (int)row2["ValueId"], AttributeId = item.AttributeId, ValueStr = (string)row2["ValueStr"] }; item.AttributeValues.Add(info2); } } list.Add(item); } } return(list); }
/// <summary> /// 创建规格值 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnCreateValue_Click(object sender, EventArgs e) { AttributeValueInfo attributeValue = new AttributeValueInfo(); IList <AttributeValueInfo> list = new List <AttributeValueInfo>(); int num = int.Parse(currentAttributeId.Value); attributeValue.AttributeId = num; if (!string.IsNullOrEmpty(txtValueStr.Text.Trim())) { string[] strArray = txtValueStr.Text.Trim().Split(new char[] { ',' }); for (int i = 0; i < strArray.Length; i++) { if (strArray[i].Length > 100) { break; } AttributeValueInfo item = new AttributeValueInfo(); if (strArray[i].Length > 15) { string str = string.Format("ShowMsg(\"{0}\", {1});", "属性值限制在15个字符以内", "false"); Page.ClientScript.RegisterStartupScript(base.GetType(), "ServerMessageScript2", "<script language='JavaScript' defer='defer'>setTimeout(function(){" + str + "},300);</script>"); return; } item.ValueStr = Globals.HtmlEncode(strArray[i]); item.AttributeId = num; list.Add(item); } foreach (AttributeValueInfo info3 in list) { ProductTypeHelper.AddAttributeValue(info3); } txtValueStr.Text = string.Empty; base.Response.Redirect(HttpContext.Current.Request.Url.ToString(), true); } if (fileUpload.HasFile) { try { attributeValue.ImageUrl = ProductTypeHelper.UploadSKUImage(fileUpload.PostedFile); // if (!string.IsNullOrEmpty(attributeValue.ValueStr)) //{ attributeValue.ValueStr = Globals.HtmlEncode(txtValueDec.Text); ////} ////else ////{ //// throw new Exception("测试抛出的错误:ValueStr为NULL!"); ////} } catch { } if (ProductTypeHelper.AddAttributeValue(attributeValue)) { txtValueStr.Text = string.Empty; base.Response.Redirect(HttpContext.Current.Request.Url.ToString(), true); } } }
private void btnCreate_Click(object sender, EventArgs e) { if (this.txtName.Text.Trim().Length > 15) { string str = string.Format("ShowMsg(\"{0}\", {1});", "属性名称限制在15个字符以内", "false"); this.Page.ClientScript.RegisterStartupScript(base.GetType(), "ServerMessageScript2", "<script language='JavaScript' defer='defer'>setTimeout(function(){" + str + "},300);</script>"); } else { AttributeInfo target = new AttributeInfo { TypeId = this.typeId, AttributeName = Globals.HtmlEncode(this.txtName.Text.Trim()) }; if (this.chkMulti.Checked) { target.UsageMode = AttributeUseageMode.MultiView; } else { target.UsageMode = AttributeUseageMode.View; } if (!string.IsNullOrEmpty(this.txtValues.Text.Trim())) { string[] strArray = this.txtValues.Text.Trim().Replace(",", ",").Split(new char[] { ',' }); for (int i = 0; i < strArray.Length; i++) { if (strArray[i].Length > 100) { break; } AttributeValueInfo item = new AttributeValueInfo(); if (strArray[i].Length > 15) { string str3 = string.Format("ShowMsg(\"{0}\", {1});", "扩展属性的值,每个值的字符数最多15个字符", "false"); this.Page.ClientScript.RegisterStartupScript(base.GetType(), "ServerMessageScript2", "<script language='JavaScript' defer='defer'>setTimeout(function(){" + str3 + "},300);</script>"); return; } item.ValueStr = Globals.HtmlEncode(strArray[i]); target.AttributeValues.Add(item); } } ValidationResults results = Hishop.Components.Validation.Validation.Validate <AttributeInfo>(target, new string[] { "ValAttribute" }); string str4 = string.Empty; if (!results.IsValid) { foreach (ValidationResult result in (IEnumerable <ValidationResult>)results) { str4 = str4 + Formatter.FormatErrorMessage(result.Message); } } else if (ProductTypeHelper.AddAttribute(target)) { this.txtName.Text = string.Empty; this.txtValues.Text = string.Empty; base.Response.Redirect(HttpContext.Current.Request.Url.ToString(), true); } } }
public bool UpdateAttributeValue(AttributeValueInfo attributeValue) { System.Data.Common.DbCommand sqlStringCommand = this.database.GetSqlStringCommand("UPDATE Hishop_AttributeValues SET ValueStr=@ValueStr, ImageUrl=@ImageUrl WHERE ValueId=@valueId"); this.database.AddInParameter(sqlStringCommand, "ValueStr", System.Data.DbType.String, attributeValue.ValueStr); this.database.AddInParameter(sqlStringCommand, "ValueId", System.Data.DbType.Int32, attributeValue.ValueId); this.database.AddInParameter(sqlStringCommand, "ImageUrl", System.Data.DbType.String, attributeValue.ImageUrl); return(this.database.ExecuteNonQuery(sqlStringCommand) > 0); }
public IList <AttributeInfo> GetAttributes(int typeId, AttributeUseageMode attributeUseageMode) { IList <AttributeInfo> list = new List <AttributeInfo>(); string text; if (attributeUseageMode == AttributeUseageMode.Choose) { text = "UsageMode = 2"; } else { text = "UsageMode <> 2"; } DbCommand sqlStringCommand = this.database.GetSqlStringCommand(string.Concat(new string[] { "SELECT * FROM Ecshop_Attributes WHERE TypeId = @TypeId AND ", text, " ORDER BY DisplaySequence Desc SELECT * FROM Ecshop_AttributeValues WHERE AttributeId IN (SELECT AttributeId FROM Ecshop_Attributes WHERE TypeId = @TypeId AND ", text, " ) ORDER BY DisplaySequence Desc" })); this.database.AddInParameter(sqlStringCommand, "TypeId", DbType.Int32, typeId); using (DataSet dataSet = this.database.ExecuteDataSet(sqlStringCommand)) { foreach (DataRow dataRow in dataSet.Tables[0].Rows) { AttributeInfo attributeInfo = new AttributeInfo(); attributeInfo.AttributeId = (int)dataRow["AttributeId"]; attributeInfo.AttributeName = (string)dataRow["AttributeName"]; attributeInfo.DisplaySequence = (int)dataRow["DisplaySequence"]; attributeInfo.TypeId = (int)dataRow["TypeId"]; attributeInfo.UsageMode = (AttributeUseageMode)((int)dataRow["UsageMode"]); attributeInfo.UseAttributeImage = (bool)dataRow["UseAttributeImage"]; if (dataSet.Tables[1].Rows.Count > 0) { DataRow[] array = dataSet.Tables[1].Select("AttributeId=" + attributeInfo.AttributeId.ToString()); DataRow[] array2 = array; for (int i = 0; i < array2.Length; i++) { DataRow dataRow2 = array2[i]; AttributeValueInfo attributeValueInfo = new AttributeValueInfo(); attributeValueInfo.ValueId = (int)dataRow2["ValueId"]; attributeValueInfo.AttributeId = attributeInfo.AttributeId; if (dataRow2["ImageUrl"] != DBNull.Value) { attributeValueInfo.ImageUrl = (string)dataRow2["ImageUrl"]; } attributeValueInfo.ValueStr = (string)dataRow2["ValueStr"]; attributeInfo.AttributeValues.Add(attributeValueInfo); } } list.Add(attributeInfo); } } return(list); }
/// <summary> /// 更新属性值 /// </summary> public static void UpdateAttributeValue(AttributeValueInfo attributeValueInfo) { NStore.Data.Categories.UpdateAttributeValue(attributeValueInfo); //AttributeInfo attributeInfo = GetAttributeById(attributeValueInfo.AttrId); //if (attributeInfo.IsFilter == 1) //{ // NStore.Core.BMACache.Remove(CacheKeys.MALL_CATEGORY_FILTERAANDVLIST + attributeInfo.CateId); //} NStore.Core.BMACache.Remove(CacheKeys.MALL_CATEGORY_AANDVLISTJSONCACHE); }
/// <summary> /// 设置AttributeValueInfo值 /// </summary> /// <param name="dr"></param> /// <returns></returns> private AttributeValueInfo SetAttributeValueModel(DataRow dr) { AttributeValueInfo attributeInfo = new AttributeValueInfo(); attributeInfo.ID = string.IsNullOrEmpty(dr["ID"].ToString()) ? 0 : int.Parse(dr["ID"].ToString()); attributeInfo.AttributeID = string.IsNullOrEmpty(dr["AttributeID"].ToString()) ? 0 : int.Parse(dr["AttributeID"].ToString()); attributeInfo.StockID = string.IsNullOrEmpty(dr["StockID"].ToString()) ? 0 : int.Parse(dr["StockID"].ToString()); attributeInfo.Values = dr["Values"].ToString(); return(attributeInfo); }
private void btnCreate_Click(object sender, EventArgs e) { if (this.txtName.Text.Trim().Length > 15) { string str = string.Format("ShowMsg(\"{0}\", {1});", "属性名称不合规范", "false"); this.Page.ClientScript.RegisterStartupScript(base.GetType(), "ServerMessageScript2", "<script language='JavaScript' defer='defer'>setTimeout(function(){" + str + "},300);</script>"); } else { AttributeInfo attributeInfo = new AttributeInfo(); attributeInfo.TypeId = this.typeId; attributeInfo.AttributeName = Globals.HtmlEncode(Globals.StripScriptTags(this.txtName.Text.Trim()).Replace("\\", "")); if (this.chkMulti.Checked) { attributeInfo.UsageMode = AttributeUseageMode.MultiView; } else { attributeInfo.UsageMode = AttributeUseageMode.View; } if (!string.IsNullOrEmpty(this.txtValues.Text.Trim())) { string text = Globals.StripHtmlXmlTags(Globals.StripScriptTags(this.txtValues.Text.Trim()).Replace(",", ",").Replace("\\", "")); string[] array = text.Split(','); for (int i = 0; i < array.Length && array[i].Length <= 100; i++) { AttributeValueInfo attributeValueInfo = new AttributeValueInfo(); if (array[i].Length > 15) { string str2 = string.Format("ShowMsg(\"{0}\", {1});", "属性值不合规范", "false"); this.Page.ClientScript.RegisterStartupScript(base.GetType(), "ServerMessageScript2", "<script language='JavaScript' defer='defer'>setTimeout(function(){" + str2 + "},300);</script>"); return; } attributeValueInfo.ValueStr = array[i]; attributeInfo.AttributeValues.Add(attributeValueInfo); } } ValidationResults validationResults = Validation.Validate(attributeInfo, "ValAttribute"); string str3 = string.Empty; if (!validationResults.IsValid) { foreach (ValidationResult item in (IEnumerable <ValidationResult>)validationResults) { str3 += Formatter.FormatErrorMessage(item.Message); } } else if (ProductTypeHelper.AddAttribute(attributeInfo)) { this.txtName.Text = string.Empty; this.txtValues.Text = string.Empty; base.Response.Redirect(HttpContext.Current.Request.Url.ToString(), true); } } }
/// <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> /// 更新属性值 /// </summary> public static void UpdateAttributeValue(AttributeValueInfo attributeValueInfo) { BrnMall.Data.Categories.UpdateAttributeValue(attributeValueInfo); AttributeInfo attributeInfo = GetAttributeById(attributeValueInfo.AttrId); if (attributeInfo.IsFilter == 1) { BrnMall.Core.BMACache.Remove(CacheKeys.MALL_CATEGORY_FILTERAANDVLIST + attributeInfo.CateId); } BrnMall.Core.BMACache.Remove(CacheKeys.MALL_CATEGORY_AANDVLISTJSONCACHE + attributeInfo.CateId); }
public AttributeValueInfo GetAttributeValueInfo(int valueId) { AttributeValueInfo result = null; System.Data.Common.DbCommand sqlStringCommand = this.database.GetSqlStringCommand("SELECT * FROM Hishop_AttributeValues WHERE ValueId=@ValueId"); this.database.AddInParameter(sqlStringCommand, "ValueId", System.Data.DbType.Int32, valueId); using (System.Data.IDataReader dataReader = this.database.ExecuteReader(sqlStringCommand)) { result = ReaderConvert.ReaderToModel <AttributeValueInfo>(dataReader); } return(result); }
/// <summary> /// 添加自定义属性信息 /// </summary> /// <param name="model">自定义属性实体</param> /// <returns></returns> public int AddAttributeValues(AttributeValueInfo model) { SqlParameter[] param = new SqlParameter[] { new SqlParameter("@attributeID", SqlDbType.Int), new SqlParameter("@stockID", SqlDbType.Int), new SqlParameter("@values", SqlDbType.NVarChar, 200) }; param[0].Value = model.AttributeID; param[1].Value = model.StockID; param[2].Value = model.Values; return(Convert.ToInt32(SqlHelper.RunProcedure("attribute_value_info_add", param, true))); }
/// <summary> /// 获得属性值列表 /// </summary> /// <param name="attrId">属性id</param> /// <returns></returns> public static List <AttributeValueInfo> GetAttributeValueListByAttrId(int attrId) { List <AttributeValueInfo> attributeValueList = new List <AttributeValueInfo>(); IDataReader reader = NStore.Core.BMAData.RDBS.GetAttributeValueListByAttrId(attrId); while (reader.Read()) { AttributeValueInfo attributeValueInfo = BuildAttributeValueFromReader(reader); attributeValueList.Add(attributeValueInfo); } reader.Close(); return(attributeValueList); }
public static int GetSpecificationValueId(int attributeId, string valueStr) { int specificationValueId = new AttributeValueDao().GetSpecificationValueId(attributeId, valueStr); if (specificationValueId > 0) { return specificationValueId; } AttributeValueInfo attributeValue = new AttributeValueInfo { AttributeId = attributeId, ValueStr = valueStr }; return new AttributeValueDao().AddAttributeValue(attributeValue); }
/// <summary> /// 获得属性值 /// </summary> /// <param name="attrValueId">属性值id</param> /// <returns></returns> public static AttributeValueInfo GetAttributeValueById(int attrValueId) { AttributeValueInfo attributeValueInfo = null; IDataReader reader = NStore.Core.BMAData.RDBS.GetAttributeValueById(attrValueId); if (reader.Read()) { attributeValueInfo = BuildAttributeValueFromReader(reader); } reader.Close(); return(attributeValueInfo); }
public static int GetSpecificationValueId(int attributeId, string valueStr) { int specificationValueId = ProductProvider.Instance().GetSpecificationValueId(attributeId, valueStr); if (specificationValueId > 0) { return(specificationValueId); } AttributeValueInfo attributeValue = new AttributeValueInfo(); attributeValue.AttributeId = attributeId; attributeValue.ValueStr = valueStr; return(ProductProvider.Instance().AddAttributeValue(attributeValue)); }
public IList <AttributeInfo> GetAttributes(int typeId, AttributeUseageMode attributeUseageMode) { string str; IList <AttributeInfo> list = new List <AttributeInfo>(); if (attributeUseageMode == AttributeUseageMode.Choose) { str = "UsageMode = 2"; } else { str = "UsageMode <> 2"; } DbCommand sqlStringCommand = this.database.GetSqlStringCommand("SELECT * FROM Hishop_Attributes WHERE TypeId = @TypeId AND " + str + " ORDER BY DisplaySequence Desc SELECT * FROM Hishop_AttributeValues WHERE AttributeId IN (SELECT AttributeId FROM Hishop_Attributes WHERE TypeId = @TypeId AND " + str + " ) ORDER BY DisplaySequence Desc"); this.database.AddInParameter(sqlStringCommand, "TypeId", DbType.Int32, typeId); using (DataSet set = this.database.ExecuteDataSet(sqlStringCommand)) { foreach (DataRow row in set.Tables[0].Rows) { AttributeInfo item = new AttributeInfo { AttributeId = (int)row["AttributeId"], AttributeName = (string)row["AttributeName"], DisplaySequence = (int)row["DisplaySequence"], TypeId = (int)row["TypeId"], UsageMode = (AttributeUseageMode)((int)row["UsageMode"]), UseAttributeImage = (bool)row["UseAttributeImage"] }; if (set.Tables[1].Rows.Count > 0) { DataRow[] rowArray = set.Tables[1].Select("AttributeId=" + item.AttributeId.ToString()); foreach (DataRow row2 in rowArray) { AttributeValueInfo info2 = new AttributeValueInfo { ValueId = (int)row2["ValueId"], AttributeId = item.AttributeId }; if (row2["ImageUrl"] != DBNull.Value) { info2.ImageUrl = (string)row2["ImageUrl"]; } info2.ValueStr = (string)row2["ValueStr"]; item.AttributeValues.Add(info2); } } list.Add(item); } } return(list); }
public override IList <AttributeInfo> GetAttributeInfoByCategoryId(int categoryId, int maxNum) { IList <AttributeInfo> list = new List <AttributeInfo>(); DbCommand sqlStringCommand = this.database.GetSqlStringCommand("SELECT * FROM Hishop_AttributeValues WHERE AttributeId IN (SELECT AttributeId FROM Hishop_Attributes WHERE TypeId=(SELECT AssociatedProductType FROM distro_Categories WHERE CategoryId=@CategoryId AND DistributorUserId = @DistributorUserId) AND UsageMode <> 2) AND ValueId IN (SELECT ValueId FROM Hishop_ProductAttributes WHERE ProductId IN (SELECT ProductId FROM distro_Products WHERE DistributorUserId = @DistributorUserId)) ORDER BY DisplaySequence DESC;" + string.Format(" SELECT TOP {0} * FROM Hishop_Attributes ", maxNum) + " WHERE TypeId=(SELECT AssociatedProductType FROM distro_Categories WHERE CategoryId=@CategoryId AND DistributorUserId = @DistributorUserId) AND UsageMode <> 2 AND AttributeId IN (SELECT AttributeId FROM Hishop_ProductAttributes WHERE ProductId IN (SELECT ProductId FROM distro_Products WHERE DistributorUserId = @DistributorUserId)) ORDER BY DisplaySequence DESC"); this.database.AddInParameter(sqlStringCommand, "CategoryId", DbType.Int32, categoryId); this.database.AddInParameter(sqlStringCommand, "DistributorUserId", DbType.Int32, HiContext.Current.SiteSettings.UserId.Value); using (IDataReader reader = this.database.ExecuteReader(sqlStringCommand)) { IList <AttributeValueInfo> list2 = new List <AttributeValueInfo>(); while (reader.Read()) { AttributeValueInfo item = new AttributeValueInfo(); item.ValueId = (int)reader["ValueId"]; item.AttributeId = (int)reader["AttributeId"]; item.DisplaySequence = (int)reader["DisplaySequence"]; item.ValueStr = (string)reader["ValueStr"]; if (reader["ImageUrl"] != DBNull.Value) { item.ImageUrl = (string)reader["ImageUrl"]; } list2.Add(item); } if (!reader.NextResult()) { return(list); } while (reader.Read()) { AttributeInfo info2 = new AttributeInfo(); info2.AttributeId = (int)reader["AttributeId"]; info2.AttributeName = (string)reader["AttributeName"]; info2.DisplaySequence = (int)reader["DisplaySequence"]; info2.TypeId = (int)reader["TypeId"]; info2.UsageMode = (AttributeUseageMode)((int)reader["UsageMode"]); info2.UseAttributeImage = (bool)reader["UseAttributeImage"]; foreach (AttributeValueInfo info3 in list2) { if (info2.AttributeId == info3.AttributeId) { info2.AttributeValues.Add(info3); } } list.Add(info2); } } return(list); }