protected void btnSave_Click(object sender, EventArgs e) { if (string.IsNullOrWhiteSpace(this.txtAttributeName.Text.Trim())) { MessageBox.ShowFailTip(this, "扩展属性名称不能为空,长度限制在1-15个字符之间!"); } else { string text = this.txtAttributeName.Text; this.txtAttributeValue.Text.Trim(); Maticsoft.Model.Shop.Products.AttributeInfo model = new Maticsoft.Model.Shop.Products.AttributeInfo { UsageMode = 3 }; if (this.rbPic.Checked) { model.UseAttributeImage = true; } else { model.UseAttributeImage = false; } List<string> list = new List<string>(); model.ValueStr = list; model.AttributeName = text; model.TypeId = this.ProductTypeId; model.UserDefinedPic = this.chbDefinePic.Checked; if (this.bll.AttributeManage(model, DataProviderAction.Create)) { if (this.Action == 0) { MessageBox.ResponseScript(this, "parent.location.href='Step3.aspx?tid=" + this.ProductTypeId + "'"); } else { MessageBox.ResponseScript(this, string.Concat(new object[] { "parent.location.href='Modify3.aspx?tid=", this.ProductTypeId, "&ed=", this.Action, "'" })); } } else { this.btnSave.Enabled = false; MessageBox.ShowFailTip(this, "保存失败!", "Step2.aspx"); } } }
private Maticsoft.Model.Shop.Products.AttributeInfo GetAttributeInfo4Obj(JsonData jsonData) { Maticsoft.Model.Shop.Products.AttributeInfo info = null; if (!jsonData.IsObject) { return null; } info = new Maticsoft.Model.Shop.Products.AttributeInfo { AttributeId = Globals.SafeInt(jsonData["AttributeId"].ToString(), -1) }; string str = jsonData["AttributeMode"].ToString(); ProductAttributeModel model = (ProductAttributeModel) Enum.Parse(typeof(ProductAttributeModel), str); info.UsageMode = (int) model; switch (model) { case ProductAttributeModel.One: { Maticsoft.Model.Shop.Products.AttributeValue item = new Maticsoft.Model.Shop.Products.AttributeValue { AttributeId = info.AttributeId, ValueId = Globals.SafeInt(jsonData["ValueItem"].ToString(), -1) }; info.AttributeValues.Add(item); return info; } case ProductAttributeModel.Any: foreach (JsonData data in (IEnumerable) jsonData["ValueItem"]) { Maticsoft.Model.Shop.Products.AttributeValue value2 = new Maticsoft.Model.Shop.Products.AttributeValue { AttributeId = info.AttributeId, ValueId = Globals.SafeInt(data.ToString(), -1) }; info.AttributeValues.Add(value2); } return info; case ProductAttributeModel.Input: { Maticsoft.Model.Shop.Products.AttributeValue value4 = new Maticsoft.Model.Shop.Products.AttributeValue { AttributeId = info.AttributeId, ValueStr = jsonData["ValueItem"].ToString() }; info.AttributeValues.Add(value4); return info; } } return info; }
public ProductSKUModel GetProductSKUInfoByProductId(long productId) { ProductSKUModel productSKUModel = new ProductSKUModel { ListSKUInfos = this.GetProductSkuInfo(productId) }; if ((productSKUModel.ListSKUInfos != null) && (productSKUModel.ListSKUInfos.Count >= 1)) { productSKUModel.ListSKUItems = this.GetSKUItemsByProductId(productId); if ((productSKUModel.ListSKUItems == null) || (productSKUModel.ListSKUItems.Count < 1)) { return productSKUModel; } productSKUModel.ListSKUInfos.ForEach(delegate (Maticsoft.Model.Shop.Products.SKUInfo skuInfo) { if (skuInfo.Upselling) { foreach (Maticsoft.Model.Shop.Products.SKUItem item in productSKUModel.ListSKUItems) { if (item.SkuId == skuInfo.SkuId) { if (skuInfo.SkuItems == null) { skuInfo.SkuItems = new List<Maticsoft.Model.Shop.Products.SKUItem>(); } this.MergeSKUItem4AV(item); Maticsoft.Model.Shop.Products.AttributeInfo key = new Maticsoft.Model.Shop.Products.AttributeInfo { AttributeId = item.AttributeId, AttributeName = item.AttributeName, DisplaySequence = item.AB_DisplaySequence, UsageMode = item.UsageMode, UseAttributeImage = item.UseAttributeImage, UserDefinedPic = item.UserDefinedPic }; productSKUModel.ListAttrSKUItems.Add(key, item); skuInfo.SkuItems.Add(item); } } } }); } return productSKUModel; }
public Maticsoft.Model.Shop.Products.AttributeInfo GetModel(long AttributeId) { StringBuilder builder = new StringBuilder(); builder.Append("SELECT TOP 1 AttributeId,AttributeName,DisplaySequence,TypeId,UsageMode,UseAttributeImage FROM Shop_Attributes "); builder.Append(" WHERE AttributeId=@AttributeId"); SqlParameter[] cmdParms = new SqlParameter[] { new SqlParameter("@AttributeId", SqlDbType.BigInt) }; cmdParms[0].Value = AttributeId; Maticsoft.Model.Shop.Products.AttributeInfo info = new Maticsoft.Model.Shop.Products.AttributeInfo(); DataSet set = DbHelperSQL.Query(builder.ToString(), cmdParms); if (set.Tables[0].Rows.Count <= 0) { return null; } if ((set.Tables[0].Rows[0]["AttributeId"] != null) && (set.Tables[0].Rows[0]["AttributeId"].ToString() != "")) { info.AttributeId = long.Parse(set.Tables[0].Rows[0]["AttributeId"].ToString()); } if ((set.Tables[0].Rows[0]["AttributeName"] != null) && (set.Tables[0].Rows[0]["AttributeName"].ToString() != "")) { info.AttributeName = set.Tables[0].Rows[0]["AttributeName"].ToString(); } if ((set.Tables[0].Rows[0]["DisplaySequence"] != null) && (set.Tables[0].Rows[0]["DisplaySequence"].ToString() != "")) { info.DisplaySequence = int.Parse(set.Tables[0].Rows[0]["DisplaySequence"].ToString()); } if ((set.Tables[0].Rows[0]["TypeId"] != null) && (set.Tables[0].Rows[0]["TypeId"].ToString() != "")) { info.TypeId = int.Parse(set.Tables[0].Rows[0]["TypeId"].ToString()); } if ((set.Tables[0].Rows[0]["UsageMode"] != null) && (set.Tables[0].Rows[0]["UsageMode"].ToString() != "")) { info.UsageMode = int.Parse(set.Tables[0].Rows[0]["UsageMode"].ToString()); } if ((set.Tables[0].Rows[0]["UseAttributeImage"] != null) && (set.Tables[0].Rows[0]["UseAttributeImage"].ToString() != "")) { if ((set.Tables[0].Rows[0]["UseAttributeImage"].ToString() == "1") || (set.Tables[0].Rows[0]["UseAttributeImage"].ToString().ToLower() == "true")) { info.UseAttributeImage = true; return info; } info.UseAttributeImage = false; } return info; }
private List<Maticsoft.Model.Shop.Products.AttributeInfo> FillAttributeInfos(DataSet ds) { List<Maticsoft.Model.Shop.Products.AttributeInfo> list = new List<Maticsoft.Model.Shop.Products.AttributeInfo>(); using (IEnumerator enumerator = ds.Tables[0].Rows.GetEnumerator()) { Predicate<Maticsoft.Model.Shop.Products.AttributeInfo> match = null; DataRow dataRow; while (enumerator.MoveNext()) { dataRow = (DataRow) enumerator.Current; if (match == null) { match = info => info.AttributeId.ToString(CultureInfo.InvariantCulture) == dataRow["AttributeId"].ToString(); } Maticsoft.Model.Shop.Products.AttributeInfo item = list.Find(match); if (item == null) { int num = (int) dataRow["UsageMode"]; if ((num != 2) && (dataRow["ValueId"] == DBNull.Value)) { continue; } item = new Maticsoft.Model.Shop.Products.AttributeInfo { AttributeId = (long) dataRow["AttributeId"], AttributeName = dataRow["AttributeName"].ToString(), DisplaySequence = (int) dataRow["AttributeDisplaySequence"], TypeId = (int) dataRow["TypeId"], UsageMode = num, UseAttributeImage = (bool) dataRow["UseAttributeImage"], UserDefinedPic = (bool) dataRow["UserDefinedPic"] }; list.Add(item); } if (dataRow["ValueId"] != DBNull.Value) { Maticsoft.Model.Shop.Products.AttributeValue value2 = new Maticsoft.Model.Shop.Products.AttributeValue { ValueId = (long) dataRow["ValueId"], AttributeId = (long) dataRow["AttributeId"], DisplaySequence = (int) dataRow["ValueDisplaySequence"], ValueStr = (dataRow["ValueStr"] != DBNull.Value) ? dataRow["ValueStr"].ToString() : string.Empty, ImageUrl = (dataRow["ImageUrl"] != DBNull.Value) ? dataRow["ImageUrl"].ToString() : string.Empty }; item.AttributeValues.Add(value2); item.ValueStr.Add(dataRow.Field<string>("ValueStr")); } } } return list; }