private void btnCreate_Click(object sender, EventArgs e) { AttributeInfo target = new AttributeInfo { TypeId = this.typeId, AttributeName = Globals.HtmlEncode(this.txtName.Text).Replace(",", ","), UsageMode = AttributeUseageMode.Choose, UseAttributeImage = this.radIsImage.SelectedValue }; ValidationResults results = Hishop.Components.Validation.Validation.Validate<AttributeInfo>(target, new string[] { "ValAttribute" }); string str = string.Empty; if (!results.IsValid) { foreach (ValidationResult result in (IEnumerable<ValidationResult>) results) { str = str + Formatter.FormatErrorMessage(result.Message); } } else { ProductTypeHelper.GetAttributes(this.typeId, AttributeUseageMode.Choose); if (ProductTypeHelper.AddAttributeName(target)) { base.Response.Redirect(HttpContext.Current.Request.Url.ToString(), true); } } }
public override bool AddAttributeName(AttributeInfo attribute) { DbCommand sqlStringCommand = database.GetSqlStringCommand("DECLARE @DisplaySequence AS INT SELECT @DisplaySequence = (CASE WHEN MAX(DisplaySequence) IS NULL THEN 1 ELSE MAX(DisplaySequence) + 1 END) FROM Hishop_Attributes; INSERT INTO Hishop_Attributes(AttributeName, DisplaySequence, TypeId, UsageMode, UseAttributeImage) VALUES(@AttributeName, @DisplaySequence, @TypeId, @UsageMode, @UseAttributeImage);"); database.AddInParameter(sqlStringCommand, "AttributeName", DbType.String, attribute.AttributeName); database.AddInParameter(sqlStringCommand, "TypeId", DbType.Int32, attribute.TypeId); database.AddInParameter(sqlStringCommand, "UsageMode", DbType.Int32, (int)attribute.UsageMode); database.AddInParameter(sqlStringCommand, "UseAttributeImage", DbType.Boolean, attribute.UseAttributeImage); return (database.ExecuteNonQuery(sqlStringCommand) > 0); }
public AttributeInfo GetAttribute(int attributeId) { AttributeInfo info = new AttributeInfo(); DbCommand sqlStringCommand = this.database.GetSqlStringCommand("SELECT * FROM Hishop_AttributeValues WHERE AttributeId = @AttributeId ORDER BY DisplaySequence DESC; SELECT * FROM Hishop_Attributes WHERE AttributeId = @AttributeId;"); this.database.AddInParameter(sqlStringCommand, "AttributeId", DbType.Int32, attributeId); using (IDataReader reader = this.database.ExecuteReader(sqlStringCommand)) { IList<AttributeValueInfo> list = ReaderConvert.ReaderToList<AttributeValueInfo>(reader); reader.NextResult(); info = ReaderConvert.ReaderToModel<AttributeInfo>(reader); info.AttributeValues = list; } return info; }
public int AddAttributeName(AttributeInfo attribute) { int num = 0; DbCommand sqlStringCommand = this.database.GetSqlStringCommand("DECLARE @DisplaySequence AS INT SELECT @DisplaySequence = (CASE WHEN MAX(DisplaySequence) IS NULL THEN 1 ELSE MAX(DisplaySequence) + 1 END) FROM Hishop_Attributes; INSERT INTO Hishop_Attributes(AttributeName, DisplaySequence, TypeId, UsageMode, UseAttributeImage) VALUES(@AttributeName, @DisplaySequence, @TypeId, @UsageMode, @UseAttributeImage); SELECT @@IDENTITY"); this.database.AddInParameter(sqlStringCommand, "AttributeName", DbType.String, attribute.AttributeName); this.database.AddInParameter(sqlStringCommand, "TypeId", DbType.Int32, attribute.TypeId); this.database.AddInParameter(sqlStringCommand, "UsageMode", DbType.Int32, (int) attribute.UsageMode); this.database.AddInParameter(sqlStringCommand, "UseAttributeImage", DbType.Boolean, attribute.UseAttributeImage); object obj2 = this.database.ExecuteScalar(sqlStringCommand); if (obj2 != null) { num = Convert.ToInt32(obj2); } return num; }
public override IList<AttributeInfo> GetAttributeInfoByCategoryId(int categoryId) { 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 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; SELECT * FROM Hishop_Attributes WHERE TypeId=(SELECT AssociatedProductType FROM distro_Categories WHERE CategoryId=@CategoryId) 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; }
public bool AddAttribute(AttributeInfo attribute) { DbCommand sqlStringCommand = this.database.GetSqlStringCommand("DECLARE @DisplaySequence AS INT SELECT @DisplaySequence = (CASE WHEN MAX(DisplaySequence) IS NULL THEN 1 ELSE MAX(DisplaySequence) + 1 END) FROM Hishop_Attributes; INSERT INTO Hishop_Attributes(AttributeName, DisplaySequence, TypeId, UsageMode, UseAttributeImage) VALUES(@AttributeName, @DisplaySequence, @TypeId, @UsageMode, @UseAttributeImage); SELECT @@IDENTITY"); this.database.AddInParameter(sqlStringCommand, "AttributeName", DbType.String, attribute.AttributeName); this.database.AddInParameter(sqlStringCommand, "TypeId", DbType.Int32, attribute.TypeId); this.database.AddInParameter(sqlStringCommand, "UsageMode", DbType.Int32, (int) attribute.UsageMode); this.database.AddInParameter(sqlStringCommand, "UseAttributeImage", DbType.Boolean, attribute.UseAttributeImage); object obj2 = this.database.ExecuteScalar(sqlStringCommand); if ((attribute.AttributeValues.Count != 0) && (obj2 != null)) { int num = Convert.ToInt32(obj2); foreach (AttributeValueInfo info in attribute.AttributeValues) { DbCommand command = this.database.GetSqlStringCommand("DECLARE @DisplaySequence AS INT SELECT @DisplaySequence = (CASE WHEN MAX(DisplaySequence) IS NULL THEN 1 ELSE MAX(DisplaySequence) + 1 END) FROM Hishop_AttributeValues; INSERT INTO Hishop_AttributeValues(AttributeId, DisplaySequence, ValueStr, ImageUrl) VALUES(@AttributeId, @DisplaySequence, @ValueStr, @ImageUrl)"); this.database.AddInParameter(command, "AttributeId", DbType.Int32, num); this.database.AddInParameter(command, "ValueStr", DbType.String, info.ValueStr); this.database.AddInParameter(command, "ImageUrl", DbType.String, info.ImageUrl); this.database.ExecuteNonQuery(command); } } return (obj2 != null); }
public bool UpdateAttributeName(AttributeInfo attribute) { DbCommand sqlStringCommand = this.database.GetSqlStringCommand("UPDATE Hishop_Attributes SET AttributeName = @AttributeName, UsageMode = @UsageMode WHERE AttributeId = @AttributeId;"); this.database.AddInParameter(sqlStringCommand, "AttributeId", DbType.Int32, attribute.AttributeId); this.database.AddInParameter(sqlStringCommand, "AttributeName", DbType.String, attribute.AttributeName); this.database.AddInParameter(sqlStringCommand, "UsageMode", DbType.Int32, (int) attribute.UsageMode); return (this.database.ExecuteNonQuery(sqlStringCommand) > 0); }
public bool UpdateAttribute(AttributeInfo attribute) { DbCommand sqlStringCommand = this.database.GetSqlStringCommand("UPDATE Hishop_Attributes SET AttributeName = @AttributeName, TypeId = @TypeId, UseAttributeImage = @UseAttributeImage WHERE AttributeId = @AttributeId; DELETE FROM Hishop_AttributeValues WHERE AttributeId = @AttributeId;"); this.database.AddInParameter(sqlStringCommand, "AttributeId", DbType.Int32, attribute.AttributeId); this.database.AddInParameter(sqlStringCommand, "AttributeName", DbType.String, attribute.AttributeName); this.database.AddInParameter(sqlStringCommand, "TypeId", DbType.Int32, attribute.TypeId); this.database.AddInParameter(sqlStringCommand, "UseAttributeImage", DbType.Boolean, attribute.UseAttributeImage); bool flag = this.database.ExecuteNonQuery(sqlStringCommand) > 0; if (flag && (attribute.AttributeValues.Count != 0)) { foreach (AttributeValueInfo info in attribute.AttributeValues) { DbCommand command = this.database.GetSqlStringCommand("DECLARE @DisplaySequence AS INT SELECT @DisplaySequence = (CASE WHEN MAX(DisplaySequence) IS NULL THEN 1 ELSE MAX(DisplaySequence) + 1 END) FROM Hishop_AttributeValues; INSERT INTO Hishop_AttributeValues(AttributeId, DisplaySequence, ValueStr, ImageUrl) VALUES(@AttributeId, @DisplaySequence, @ValueStr, @ImageUrl)"); this.database.AddInParameter(command, "AttributeId", DbType.Int32, attribute.AttributeId); this.database.AddInParameter(command, "ValueStr", DbType.String, info.ValueStr); this.database.AddInParameter(command, "ImageUrl", DbType.String, info.ImageUrl); this.database.ExecuteNonQuery(command); } } return flag; }
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 static bool AddAttributeName(AttributeInfo attribute) { return ProductProvider.Instance().AddAttributeName(attribute); }
public static bool UpdateSpecification(AttributeInfo attribute) { return ProductProvider.Instance().UpdateSpecification(attribute); }
public static bool UpdateAttribute(AttributeInfo attribute) { return ProductProvider.Instance().UpdateAttribute(attribute); }
public abstract bool UpdateSpecification(AttributeInfo attribute);
public abstract bool AddAttributeName(AttributeInfo attribute);
public override bool UpdateSpecification(AttributeInfo attribute) { DbCommand sqlStringCommand = database.GetSqlStringCommand("UPDATE Hishop_Attributes SET AttributeName = @AttributeName, UseAttributeImage = @UseAttributeImage WHERE AttributeId = @AttributeId"); database.AddInParameter(sqlStringCommand, "AttributeId", DbType.Int32, attribute.AttributeId); database.AddInParameter(sqlStringCommand, "AttributeName", DbType.String, attribute.AttributeName); database.AddInParameter(sqlStringCommand, "UseAttributeImage", DbType.Boolean, attribute.UseAttributeImage); return (database.ExecuteNonQuery(sqlStringCommand) > 0); }
public static bool AddAttributeName(AttributeInfo attribute) { return (new AttributeDao().AddAttributeName(attribute) > 0); }
public static bool AddAttribute(AttributeInfo attribute) { return new AttributeDao().AddAttribute(attribute); }
public static bool UpdateAttributeName(AttributeInfo attribute) { return new AttributeDao().UpdateAttributeName(attribute); }
public static int GetSpecificationId(int typeId, string specificationName) { int specificationId = new AttributeDao().GetSpecificationId(typeId, specificationName); if (specificationId > 0) { return specificationId; } AttributeInfo attribute = new AttributeInfo { TypeId = typeId, UsageMode = AttributeUseageMode.Choose, UseAttributeImage = false, AttributeName = specificationName }; return new AttributeDao().AddAttributeName(attribute); }
public override AttributeInfo GetAttribute(int attributeId) { AttributeInfo info = new AttributeInfo(); DbCommand sqlStringCommand = database.GetSqlStringCommand("SELECT * FROM Hishop_AttributeValues WHERE AttributeId = @AttributeId ORDER BY DisplaySequence DESC; SELECT * FROM Hishop_Attributes WHERE AttributeId = @AttributeId;"); database.AddInParameter(sqlStringCommand, "AttributeId", DbType.Int32, attributeId); using (IDataReader reader = database.ExecuteReader(sqlStringCommand)) { IList<AttributeValueInfo> list = 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"]; } list.Add(item); } if (!reader.NextResult()) { return info; } if (reader.Read()) { info.AttributeId = (int)reader["AttributeId"]; info.AttributeName = (string)reader["AttributeName"]; info.DisplaySequence = (int)reader["DisplaySequence"]; info.TypeId = (int)reader["TypeId"]; info.UsageMode = (AttributeUseageMode)((int)reader["UsageMode"]); info.UseAttributeImage = (bool)reader["UseAttributeImage"]; info.AttributeValues = list; } } return info; }
/// <summary> /// 创建产品规格 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnCreate_Click(object sender, EventArgs e) { AttributeInfo attrInfo = new AttributeInfo(); attrInfo.TypeId = typeId; attrInfo.AttributeName = Globals.HtmlEncode(txtName.Text); attrInfo.UsageMode = AttributeUseageMode.Choose; attrInfo.UseAttributeImage = radIsImage.SelectedValue; ValidationResults results = Hishop.Components.Validation.Validation.Validate<AttributeInfo>(attrInfo, new string[] { "ValAttribute" }); string str = string.Empty; if (!results.IsValid) { foreach (ValidationResult result in (IEnumerable<ValidationResult>)results) { str = str + Formatter.FormatErrorMessage(result.Message); } } else { ProductTypeHelper.GetAttributes(typeId, AttributeUseageMode.Choose); if (ProductTypeHelper.AddAttributeName(attrInfo)) { Response.Redirect(HttpContext.Current.Request.Url.ToString(), true); } } }
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) { 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, ValueStr = (string) row2["ValueStr"] }; item.AttributeValues.Add(info2); } } list.Add(item); } } return list; }
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 info3 = new AttributeInfo(); info3.TypeId = this.typeId; info3.AttributeName = Globals.HtmlEncode(this.txtName.Text.Trim()); AttributeInfo target = info3; 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().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 str2 = string.Format("ShowMsg(\"{0}\", {1});", "属性值限制在15个字符以内", "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]); target.AttributeValues.Add(item); } } ValidationResults results = Hishop.Components.Validation.Validation.Validate<AttributeInfo>(target, new string[] { "ValAttribute" }); string str3 = string.Empty; if (!results.IsValid) { foreach (ValidationResult result in (IEnumerable<ValidationResult>)results) { str3 = str3 + 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); } } }
private void grdSKU_RowCommand(object sender, GridViewCommandEventArgs e) { int rowIndex = ((GridViewRow) ((Control) e.CommandSource).NamingContainer).RowIndex; int attributeId = Convert.ToInt32(this.grdSKU.DataKeys[rowIndex].Value); if (e.CommandName == "saveSKUName") { TextBox box = this.grdSKU.Rows[rowIndex].Cells[2].FindControl("txtSKUName") as TextBox; AttributeInfo attribute = new AttributeInfo { AttributeId = attributeId }; if (string.IsNullOrEmpty(box.Text.Trim()) || (box.Text.Trim().Length > 30)) { string str = string.Format("ShowMsg(\"{0}\", {1});", "规格名称限制在1-30个字符以内", "false"); this.Page.ClientScript.RegisterStartupScript(base.GetType(), "ServerMessageScript2", "<script language='JavaScript' defer='defer'>setTimeout(function(){" + str + "},300);</script>"); return; } attribute.AttributeName = Globals.HtmlEncode(box.Text); attribute.UsageMode = AttributeUseageMode.Choose; ProductTypeHelper.UpdateAttributeName(attribute); base.Response.Redirect(HttpContext.Current.Request.Url.ToString(), true); } int displaySequence = int.Parse((this.grdSKU.Rows[rowIndex].FindControl("lblDisplaySequence") as Literal).Text, NumberStyles.None); int replaceAttributeId = 0; int replaceDisplaySequence = 0; if (e.CommandName == "Fall") { if (rowIndex < (this.grdSKU.Rows.Count - 1)) { replaceAttributeId = (int) this.grdSKU.DataKeys[rowIndex + 1].Value; replaceDisplaySequence = int.Parse((this.grdSKU.Rows[rowIndex + 1].FindControl("lblDisplaySequence") as Literal).Text, NumberStyles.None); } } else if ((e.CommandName == "Rise") && (rowIndex > 0)) { replaceAttributeId = (int) this.grdSKU.DataKeys[rowIndex - 1].Value; replaceDisplaySequence = int.Parse((this.grdSKU.Rows[rowIndex - 1].FindControl("lblDisplaySequence") as Literal).Text, NumberStyles.None); } if (replaceAttributeId > 0) { ProductTypeHelper.SwapAttributeSequence(attributeId, replaceAttributeId, displaySequence, replaceDisplaySequence); } this.BindAttribute(); }
public abstract bool UpdateAttributeName(AttributeInfo attribute);