public List<Maticsoft.Model.Shop.Products.AttributeValue> DataTableToList(DataTable dt) { List<Maticsoft.Model.Shop.Products.AttributeValue> list = new List<Maticsoft.Model.Shop.Products.AttributeValue>(); int count = dt.Rows.Count; if (count > 0) { for (int i = 0; i < count; i++) { Maticsoft.Model.Shop.Products.AttributeValue item = new Maticsoft.Model.Shop.Products.AttributeValue(); if ((dt.Rows[i]["ValueId"] != null) && (dt.Rows[i]["ValueId"].ToString() != "")) { item.ValueId = long.Parse(dt.Rows[i]["ValueId"].ToString()); } if ((dt.Rows[i]["AttributeId"] != null) && (dt.Rows[i]["AttributeId"].ToString() != "")) { item.AttributeId = long.Parse(dt.Rows[i]["AttributeId"].ToString()); } if ((dt.Rows[i]["DisplaySequence"] != null) && (dt.Rows[i]["DisplaySequence"].ToString() != "")) { item.DisplaySequence = int.Parse(dt.Rows[i]["DisplaySequence"].ToString()); } if ((dt.Rows[i]["ValueStr"] != null) && (dt.Rows[i]["ValueStr"].ToString() != "")) { item.ValueStr = dt.Rows[i]["ValueStr"].ToString(); } if ((dt.Rows[i]["ImageUrl"] != null) && (dt.Rows[i]["ImageUrl"].ToString() != "")) { item.ImageUrl = dt.Rows[i]["ImageUrl"].ToString(); } list.Add(item); } } return list; }
public bool AttributeManage(Maticsoft.Model.Shop.Products.AttributeInfo model, DataProviderAction Action) { int rowsAffected = 0; SqlParameter[] parameters = new SqlParameter[] { new SqlParameter("@Action", SqlDbType.Int), new SqlParameter("@AttributeId", SqlDbType.BigInt), new SqlParameter("@AttributeName", SqlDbType.NVarChar), new SqlParameter("@TypeId", SqlDbType.Int), new SqlParameter("@UsageMode", SqlDbType.Int), new SqlParameter("@UseAttributeImage", SqlDbType.Bit), new SqlParameter("@UserDefinedPic", SqlDbType.Bit), new SqlParameter("@AttributeIdOutPut", SqlDbType.BigInt) }; parameters[0].Value = (int) Action; parameters[1].Value = model.AttributeId; parameters[2].Value = model.AttributeName; parameters[3].Value = model.TypeId; parameters[4].Value = model.UsageMode; parameters[5].Value = model.UseAttributeImage; parameters[6].Value = model.UserDefinedPic; parameters[7].Direction = ParameterDirection.Output; DbHelperSQL.RunProcedure("sp_Shop_AttributesCreateEditDelete", parameters, out rowsAffected); long attributeId = 0L; if (Action == DataProviderAction.Create) { attributeId = Convert.ToInt64(parameters[7].Value); } else { attributeId = model.AttributeId; } if (rowsAffected <= 0) { return false; } Maticsoft.SQLServerDAL.Shop.Products.AttributeValue value2 = new Maticsoft.SQLServerDAL.Shop.Products.AttributeValue(); foreach (string str in model.ValueStr) { Maticsoft.Model.Shop.Products.AttributeValue value3 = new Maticsoft.Model.Shop.Products.AttributeValue { AttributeId = attributeId, ValueStr = str }; value2.AttributeValueManage(value3, DataProviderAction.Create); } return true; }
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; }
protected void btnSave_Click(object sender, EventArgs e) { if (string.IsNullOrWhiteSpace(this.txtAttributeValue.Text.Trim())) { MessageBox.ShowFailTip(this, "扩展属性的值,多个属性值可用“,”号隔开,每个值最多15个字符!"); } else if (((this.ValueId > 0L) && string.IsNullOrWhiteSpace(this.txtAttributeValue.Text.Trim())) && this.txtAttributeValue.Text.Trim().Contains(",")) { MessageBox.ShowFailTip(this, "属性值必须小于15个字符,不能为空,并且不能包含逗号!"); } else { string str = this.txtAttributeValue.Text.Trim(); Maticsoft.Model.Shop.Products.AttributeValue model = new Maticsoft.Model.Shop.Products.AttributeValue(); int num = 0; if ((this.MidValue == 0) && (this.ValueId == 0L)) { string[] strArray = str.Replace("\r\n", "\n").Replace("\n", ",").Replace(",", ",").Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); for (int i = 0; i < strArray.Length; i++) { if (strArray[i].Length <= 100) { string str2 = strArray[i]; if (!string.IsNullOrWhiteSpace(str2)) { model.AttributeId = this.AttributeId; model.ValueStr = str2; num = this.ValueBll.AttributeValueManage(model, DataProviderAction.Create) ? (num + 1) : 0; } } } } else if ((this.MidValue > 0) && (this.ValueId == 0L)) { model.AttributeId = this.AttributeId; model.ValueStr = str; num = this.ValueBll.AttributeValueManage(model, DataProviderAction.Create) ? (num + 1) : 0; } else { model = this.ValueBll.GetModel(this.ValueId); model.ValueStr = str; if (this.ValueBll.Update(model)) { num++; } } if (((num > 0) && (this.AddOrModify > 0)) && (this.MidValue > 0)) { MessageBox.ResponseScript(this, string.Concat(new object[] { "parent.location.href='listV.aspx?tid=", this.ProductTypeId, "&ed=", this.AttributeId, "&a=", this.AddOrModify, "'" })); } else if ((num > 0) && (this.AddOrModify > 0)) { MessageBox.ResponseScript(this, "parent.location.href='Step2.aspx?tid=" + this.ProductTypeId + "'"); } else if ((num > 0) && (this.MidValue == 0)) { MessageBox.ResponseScript(this, string.Concat(new object[] { "parent.location.href='Modify2.aspx?tid=", this.ProductTypeId, "&ed=", this.AttributeId, "'" })); } else if ((num > 0) && (this.MidValue > 0)) { MessageBox.ResponseScript(this, string.Concat(new object[] { "parent.location.href='listV.aspx?tid=", this.ProductTypeId, "&ed=", this.AttributeId, "'" })); } else if ((num > 0) && (this.ValueId > 0L)) { MessageBox.ResponseScript(this, string.Concat(new object[] { "parent.location.href='listV.aspx?tid=", this.ProductTypeId, "&ed=", this.AttributeId, "'" })); } else { this.btnSave.Enabled = false; MessageBox.ShowFailTip(this, "保存失败!"); } } }
public Maticsoft.Model.Shop.Products.AttributeValue GetModel(long ValueId) { StringBuilder builder = new StringBuilder(); builder.Append("SELECT TOP 1 ValueId,AttributeId,DisplaySequence,ValueStr,ImageUrl FROM Shop_AttributeValues "); builder.Append(" WHERE ValueId=@ValueId"); SqlParameter[] cmdParms = new SqlParameter[] { new SqlParameter("@ValueId", SqlDbType.BigInt) }; cmdParms[0].Value = ValueId; Maticsoft.Model.Shop.Products.AttributeValue value2 = new Maticsoft.Model.Shop.Products.AttributeValue(); DataSet set = DbHelperSQL.Query(builder.ToString(), cmdParms); if (set.Tables[0].Rows.Count <= 0) { return null; } if ((set.Tables[0].Rows[0]["ValueId"] != null) && (set.Tables[0].Rows[0]["ValueId"].ToString() != "")) { value2.ValueId = long.Parse(set.Tables[0].Rows[0]["ValueId"].ToString()); } if ((set.Tables[0].Rows[0]["AttributeId"] != null) && (set.Tables[0].Rows[0]["AttributeId"].ToString() != "")) { value2.AttributeId = long.Parse(set.Tables[0].Rows[0]["AttributeId"].ToString()); } if ((set.Tables[0].Rows[0]["DisplaySequence"] != null) && (set.Tables[0].Rows[0]["DisplaySequence"].ToString() != "")) { value2.DisplaySequence = int.Parse(set.Tables[0].Rows[0]["DisplaySequence"].ToString()); } if ((set.Tables[0].Rows[0]["ValueStr"] != null) && (set.Tables[0].Rows[0]["ValueStr"].ToString() != "")) { value2.ValueStr = set.Tables[0].Rows[0]["ValueStr"].ToString(); } if ((set.Tables[0].Rows[0]["ImageUrl"] != null) && (set.Tables[0].Rows[0]["ImageUrl"].ToString() != "")) { value2.ImageUrl = set.Tables[0].Rows[0]["ImageUrl"].ToString(); } return value2; }
protected void btnSave_Click(object sender, EventArgs e) { if (this.IsImg == 0) { if (string.IsNullOrWhiteSpace(this.txtAttributeValue.Text.Trim())) { MessageBox.ShowFailTip(this, "扩展属性的值,多个属性值可用“,”号隔开,每个值最多15个字符!"); return; } } else { if (string.IsNullOrWhiteSpace(this.hfFileUrl.Value)) { MessageBox.ShowFailTip(this, "请选择要上传的图片,仅接受jpg、gif、png、格式的图片!"); return; } if (string.IsNullOrWhiteSpace(this.txtImgTitle.Text.Trim())) { MessageBox.ShowFailTip(this, "请填写图片描述信息!"); return; } } Maticsoft.Model.Shop.Products.AttributeValue model = new Maticsoft.Model.Shop.Products.AttributeValue(); int num = 0; if (this.IsImg == 0) { string[] strArray = this.txtAttributeValue.Text.Trim().Replace("\r\n", "\n").Replace("\n", ",").Replace(",", ",").Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); for (int i = 0; i < strArray.Length; i++) { if (strArray[i].Length <= 100) { string str2 = strArray[i]; if (!string.IsNullOrWhiteSpace(str2)) { model.AttributeId = this.AttributeId; model.ValueStr = str2; num = this.ValueBll.AttributeValueManage(model, DataProviderAction.Create) ? (num + 1) : 0; } } } } else if (this.IsImg == 1) { model.ImageUrl = this.hfFileUrl.Value; model.AttributeId = this.AttributeId; model.ValueStr = this.txtImgTitle.Text; num = this.ValueBll.AttributeValueManage(model, DataProviderAction.Create) ? (num + 1) : 0; } if (((num > 0) && (this.AddOrModify > 0)) && (this.MidValue == 1)) { MessageBox.ResponseScript(this, string.Concat(new object[] { "parent.location.href='ListSpec.aspx?tid=", this.ProductTypeId, "&ed=", this.AttributeId, "&img=", this.IsImg, "&a=", this.AddOrModify, "'" })); } else if (((num > 0) && (this.AddOrModify > 0)) && (this.MidValue == 2)) { MessageBox.ResponseScript(this, "parent.location.href='Step3.aspx?tid=" + this.ProductTypeId + "'"); } else if ((num > 0) && (this.MidValue == 1)) { MessageBox.ResponseScript(this, string.Concat(new object[] { "parent.location.href='ListSpec.aspx?tid=", this.ProductTypeId, "&ed=", this.AttributeId, "&img=", this.IsImg, "'" })); } else if (num > 0) { MessageBox.ResponseScript(this, "parent.location.href='Modify3.aspx?tid=" + this.ProductTypeId + "'"); } else { this.btnSave.Enabled = false; MessageBox.ShowFailTip(this, "保存失败!"); } }
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; }