private void btnAddProductType_Click(object sender, System.EventArgs e) { ProductTypeInfo productTypeInfo = new ProductTypeInfo(); productTypeInfo.TypeName = Globals.StripHtmlXmlTags(Globals.StripScriptTags(this.txtTypeName.Text).Replace(",", ",").Replace("\\", "")); if (string.IsNullOrEmpty(productTypeInfo.TypeName)) { this.ShowMsg("类型名称不能为空,不允许包含脚本标签、HTML标签和\\,系统会自动过滤", false); return; } productTypeInfo.Remark = this.txtRemark.Text; System.Collections.Generic.IList <int> list = new System.Collections.Generic.List <int>(); foreach (System.Web.UI.WebControls.ListItem listItem in this.chlistBrand.Items) { if (listItem.Selected) { list.Add(int.Parse(listItem.Value)); } } productTypeInfo.Brands = list; if (!this.ValidationProductType(productTypeInfo)) { return; } int num = ProductTypeHelper.AddProductType(productTypeInfo); if (num > 0) { base.Response.Redirect(Globals.GetAdminAbsolutePath("/product/AddAttribute.aspx?typeId=" + num), true); return; } this.ShowMsg("添加商品类型失败", false); }
private void btnAddProductType_Click(object sender, EventArgs e) { ProductTypeInfo productType = new ProductTypeInfo(); productType.TypeName = this.txtTypeName.Text.Trim(); productType.Remark = this.txtRemark.Text; IList <int> list = new List <int>(); foreach (ListItem item in this.chlistBrand.Items) { if (item.Selected) { list.Add(int.Parse(item.Value)); } } productType.Brands = list; if (this.ValidationProductType(productType)) { int num = ProductTypeHelper.AddProductType(productType); if (num > 0) { base.Response.Redirect(Globals.GetAdminAbsolutePath("/product/AddAttribute.aspx?typeId=" + num), true); } else { this.ShowMsg("添加商品类型失败", false); } } }
private void BindData() { AttributeInfo attribute = ProductTypeHelper.GetAttribute(attributeId); grdAttributeValues.DataSource = attribute.AttributeValues; grdAttributeValues.DataBind(); }
/// <summary> /// Builds this instance and returns the underlying instrument associated with the controller /// </summary> /// <returns></returns> public PropertyTransaction Build() { //var equity = UnderlyingEquity.(); var buyerPartyReference = PartyReferenceHelper.Parse(BuyerReference); var sellerPartyReference = PartyReferenceHelper.Parse(SellerReference); var productType = new object[] { ProductTypeHelper.Create("PropertyTransaction") }; //var productId = new ProductId {Value = "BondTransaction"}; var itemName = new[] { ItemsChoiceType2.productType }; //TODO extend this //var productIds = new[] {productId}; var property = XmlSerializerHelper.Clone(PropertyInfo); var purchasePrice = XmlSerializerHelper.Clone(PurchasePrice); var propertyTransaction = new PropertyTransaction { buyerPartyReference = buyerPartyReference, sellerPartyReference = sellerPartyReference, id = Id, //productId = productIds, Items = productType, ItemsElementName = itemName, purchasePrice = purchasePrice, property = property }; return(propertyTransaction); }
private void btnEditProductType_Click(object sender, System.EventArgs e) { ProductTypeInfo productTypeInfo = new ProductTypeInfo(); productTypeInfo.TypeId = this.typeId; productTypeInfo.TypeName = this.txtTypeName.Text; productTypeInfo.Remark = this.txtRemark.Text; System.Collections.Generic.IList <int> list = new System.Collections.Generic.List <int>(); foreach (System.Web.UI.WebControls.ListItem listItem in this.chlistBrand.Items) { if (listItem.Selected) { list.Add(int.Parse(listItem.Value)); } } productTypeInfo.Brands = list; if (!this.ValidationProductType(productTypeInfo)) { return; } if (ProductTypeHelper.UpdateProductType(productTypeInfo)) { this.ShowMsg("修改成功", true); } }
private void grdAttributeValues_RowCommand(object sender, GridViewCommandEventArgs e) { int rowIndex = ((GridViewRow)((Control)e.CommandSource).NamingContainer).RowIndex; int attributeValueId = (int)this.grdAttributeValues.DataKeys[rowIndex].Value; int displaySequence = int.Parse((this.grdAttributeValues.Rows[rowIndex].FindControl("lblDisplaySequence") as Literal).Text, NumberStyles.None); int replaceAttributeValueId = 0; int replaceDisplaySequence = 0; if (e.CommandName == "Fall") { if (rowIndex < (this.grdAttributeValues.Rows.Count - 1)) { replaceAttributeValueId = (int)this.grdAttributeValues.DataKeys[rowIndex + 1].Value; replaceDisplaySequence = int.Parse((this.grdAttributeValues.Rows[rowIndex + 1].FindControl("lblDisplaySequence") as Literal).Text, NumberStyles.None); } } else if ((e.CommandName == "Rise") && (rowIndex > 0)) { replaceAttributeValueId = (int)this.grdAttributeValues.DataKeys[rowIndex - 1].Value; replaceDisplaySequence = int.Parse((this.grdAttributeValues.Rows[rowIndex - 1].FindControl("lblDisplaySequence") as Literal).Text, NumberStyles.None); } if (replaceAttributeValueId > 0) { ProductTypeHelper.SwapAttributeValueSequence(attributeValueId, replaceAttributeValueId, displaySequence, replaceDisplaySequence); this.BindData(); } }
private void btnCreate_Click(object sender, System.EventArgs e) { AttributeInfo attributeInfo = new AttributeInfo(); attributeInfo.TypeId = this.typeId; attributeInfo.AttributeName = Globals.StripHtmlXmlTags(Globals.StripScriptTags(this.txtName.Text).Replace(",", ",").Replace("\\", "")); if (string.IsNullOrEmpty(attributeInfo.AttributeName)) { string str = string.Format("ShowMsg(\"{0}\", {1});", "规格名称限制在1-30个字符以内,不允许包含脚本标签、HTML标签和\\,系统会自动过滤", "false"); this.Page.ClientScript.RegisterStartupScript(base.GetType(), "ServerMessageScript2", "<script language='JavaScript' defer='defer'>setTimeout(function(){" + str + "},300);</script>"); return; } attributeInfo.UsageMode = AttributeUseageMode.Choose; attributeInfo.UseAttributeImage = this.radIsImage.SelectedValue; ValidationResults validationResults = Validation.Validate <AttributeInfo>(attributeInfo, new string[] { "ValAttribute" }); string str2 = string.Empty; if (!validationResults.IsValid) { foreach (ValidationResult current in (System.Collections.Generic.IEnumerable <ValidationResult>)validationResults) { str2 += Formatter.FormatErrorMessage(current.Message); } return; } ProductTypeHelper.GetAttributes(this.typeId, AttributeUseageMode.Choose); if (ProductTypeHelper.AddAttributeName(attributeInfo)) { base.Response.Redirect(System.Web.HttpContext.Current.Request.Url.ToString(), true); } }
private void grdAttributeValues_RowCommand(object sender, System.Web.UI.WebControls.GridViewCommandEventArgs e) { int rowIndex = ((System.Web.UI.WebControls.GridViewRow)((System.Web.UI.Control)e.CommandSource).NamingContainer).RowIndex; int attributeValueId = (int)this.grdAttributeValues.DataKeys[rowIndex].Value; int displaySequence = int.Parse((this.grdAttributeValues.Rows[rowIndex].FindControl("lblDisplaySequence") as System.Web.UI.WebControls.Literal).Text, System.Globalization.NumberStyles.None); int num = 0; int replaceDisplaySequence = 0; if (e.CommandName == "Fall") { if (rowIndex < this.grdAttributeValues.Rows.Count - 1) { num = (int)this.grdAttributeValues.DataKeys[rowIndex + 1].Value; replaceDisplaySequence = int.Parse((this.grdAttributeValues.Rows[rowIndex + 1].FindControl("lblDisplaySequence") as System.Web.UI.WebControls.Literal).Text, System.Globalization.NumberStyles.None); } } else { if (e.CommandName == "Rise" && rowIndex > 0) { num = (int)this.grdAttributeValues.DataKeys[rowIndex - 1].Value; replaceDisplaySequence = int.Parse((this.grdAttributeValues.Rows[rowIndex - 1].FindControl("lblDisplaySequence") as System.Web.UI.WebControls.Literal).Text, System.Globalization.NumberStyles.None); } } if (num > 0) { ProductTypeHelper.SwapAttributeValueSequence(attributeValueId, num, displaySequence, replaceDisplaySequence); this.BindData(); } }
private void btnEditProductType_Click(object sender, System.EventArgs e) { ProductTypeInfo productType = new ProductTypeInfo { TypeId = this.typeId, TypeName = this.txtTypeName.Text, Remark = this.txtRemark.Text }; System.Collections.Generic.IList <int> list = new System.Collections.Generic.List <int>(); if (CustomConfigHelper.Instance.BrandShow) { chlistBrand.Visible = false; } foreach (System.Web.UI.WebControls.ListItem item in this.chlistBrand.Items) { if (item.Selected) { list.Add(int.Parse(item.Value)); } } productType.Brands = list; if (this.ValidationProductType(productType) && ProductTypeHelper.UpdateProductType(productType)) { this.ShowMsg("修改成功", true); } }
private string GetSimpleProductView() { string text = ""; string text2 = ""; string productBrand = this.GetProductBrand(); string categorys = this.GetCategorys(); string productTags = this.GetProductTags(); System.Collections.Generic.IList <ProductTypeInfo> productTypeList = this.GetProductTypeList(); System.Collections.Generic.IList <AttributeInfo> attributes = ProductTypeHelper.GetAttributes(AttributeUseageMode.MultiView); if (productTypeList != null) { text = JavaScriptConvert.SerializeObject(productTypeList); } if (attributes.Count > 0) { text2 = JavaScriptConvert.SerializeObject(attributes); } return(string.Concat(new string[] { "{\"Categorys\":", categorys, ",\"Brands\":", productBrand, ",\"Tags\":", productTags, ",\"ProductTypes\":", text, ",\"Attributes\":", text2, "}" })); }
private string GetSimpleProductView() { string productBrand = ""; string categorys = ""; string productTags = ""; IList <ProductTypeInfo> productTypeList = null; string str4 = ""; IList <AttributeInfo> attributes = null; string str5 = ""; productBrand = this.GetProductBrand(); categorys = this.GetCategorys(); productTags = this.GetProductTags(); productTypeList = this.GetProductTypeList(); attributes = ProductTypeHelper.GetAttributes(AttributeUseageMode.MultiView); if (productTypeList != null) { str4 = JavaScriptConvert.SerializeObject(productTypeList); } if (attributes.Count > 0) { str5 = JavaScriptConvert.SerializeObject(attributes); } return("{\"Categorys\":" + categorys + ",\"Brands\":" + productBrand + ",\"Tags\":" + productTags + ",\"ProductTypes\":" + str4 + ",\"Attributes\":" + str5 + "}"); }
private void btnEditProductType_Click(object sender, EventArgs e) { ProductTypeInfo productTypeInfo = new ProductTypeInfo(); productTypeInfo.TypeId = this.typeId; productTypeInfo.TypeName = Globals.StripHtmlXmlTags(Globals.StripScriptTags(this.txtTypeName.Text).Replace(",", ",").Replace("\\", "")); if (string.IsNullOrEmpty(productTypeInfo.TypeName)) { this.ShowMsg("类型名称不能为空,不允许包含脚本标签、HTML标签和\\\\(反斜杠),系统会自动过滤", false); } else if (ProductTypeHelper.HasSameProductTypeName(productTypeInfo.TypeName, this.typeId)) { this.ShowMsg("不能有重复的类型名称", false); } else { productTypeInfo.Remark = this.txtRemark.Text; IList <int> list = new List <int>(); foreach (ListItem item in this.chlistBrand.Items) { if (item.Selected) { list.Add(int.Parse(item.Value)); } } productTypeInfo.Brands = list; if (this.ValidationProductType(productTypeInfo) && ProductTypeHelper.UpdateProductType(productTypeInfo)) { this.ShowMsg("修改成功", true); } } }
private string GetSimpleProductView() { string text = ""; string text2 = ""; string text3 = ""; IList <ProductTypeInfo> list = null; string text4 = "[]"; IList <AttributeInfo> list2 = null; string text5 = "[]"; text = this.GetProductBrand(); text2 = this.GetCategorys(); text3 = this.GetProductTags(); list = this.GetProductTypeList(); list2 = ProductTypeHelper.GetAttributes(AttributeUseageMode.MultiView); if (list != null) { text4 = JsonConvert.SerializeObject(list); } if (list2.Count > 0) { text5 = JsonConvert.SerializeObject(list2); } return("{\"Categorys\":" + text2 + ",\"Brands\":" + text + ",\"Tags\":" + text3 + ",\"ProductTypes\":" + text4 + ",\"Attributes\":" + text5 + "}"); }
private void IsUplod(HttpContext context) { int value = base.GetIntParam(context, "AttributeId", false).Value; bool value2 = base.GetBoolParam(context, "UseAttributeImage", false).Value; int value3 = base.GetIntParam(context, "typeId", false).Value; AttributeInfo attributeInfo = new AttributeInfo(); attributeInfo.AttributeId = value; bool flag = false; if (value2) { flag = false; } else { flag = true; if (ProductTypeHelper.HasSetUseImg(value3) > 0) { throw new HidistroAshxException("已有其他规格可上传图片,最多只有一个规格允许上传商品规格图!"); } } attributeInfo.UseAttributeImage = flag; if (ProductTypeHelper.UpdateIsUseAttribute(attributeInfo)) { base.ReturnSuccessResult(context, "", 0, true); } }
protected void Page_Load(object sender, EventArgs e) { int num; if ((!string.IsNullOrEmpty(Request["isCallback"]) && (Request["isCallback"] == "true")) && int.TryParse(Request["ValueId"], out num)) { if (ProductTypeHelper.DeleteAttributeValue(num)) { if (!string.IsNullOrEmpty(Request["ImageUrl"])) { StoreHelper.DeleteImage(Request["ImageUrl"]); Response.Clear(); Response.ContentType = "application/json"; Response.Write("{\"Status\":\"true\"}"); Response.End(); } else { Response.Clear(); Response.ContentType = "application/json"; Response.Write("{\"Status\":\"true\"}"); Response.End(); } } else { Response.Clear(); Response.ContentType = "application/json"; Response.Write("{\"Status\":\"false\"}"); Response.End(); } } btnFilish.Click += new EventHandler(btnFilish_Click); }
private void DoCallback() { base.Response.Clear(); base.Response.ContentType = "text/xml"; string a = base.Request.QueryString["action"]; if (a == "getAttributes") { System.Collections.Generic.IList <AttributeInfo> attributes = ProductTypeHelper.GetAttributes(int.Parse(base.Request.QueryString["typeId"])); System.Text.StringBuilder stringBuilder = new System.Text.StringBuilder(); stringBuilder.Append("<xml><attributes>"); foreach (AttributeInfo current in attributes) { stringBuilder.Append("<item attributeId=\"").Append(current.AttributeId.ToString(System.Globalization.CultureInfo.InvariantCulture)).Append("\" attributeName=\"").Append(current.AttributeName).Append("\" typeId=\"").Append(current.TypeId.ToString(System.Globalization.CultureInfo.InvariantCulture)).Append("\" />"); } stringBuilder.Append("</attributes></xml>"); base.Response.Write(stringBuilder.ToString()); } if (a == "getValues") { AttributeInfo attribute = ProductTypeHelper.GetAttribute(int.Parse(base.Request.QueryString["attributeId"])); System.Text.StringBuilder stringBuilder2 = new System.Text.StringBuilder(); stringBuilder2.Append("<xml><values>"); if (attribute != null && attribute.AttributeValues.Count > 0) { foreach (AttributeValueInfo current2 in attribute.AttributeValues) { stringBuilder2.Append("<item valueId=\"").Append(current2.ValueId.ToString(System.Globalization.CultureInfo.InvariantCulture)).Append("\" valueStr=\"").Append(current2.ValueStr).Append("\" attributeId=\"").Append(current2.AttributeId.ToString(System.Globalization.CultureInfo.InvariantCulture)).Append("\" />"); } } stringBuilder2.Append("</values></xml>"); base.Response.Write(stringBuilder2.ToString()); } base.Response.End(); }
private void btnEditProductType_Click(object sender, System.EventArgs e) { ProductTypeInfo productTypeInfo = new ProductTypeInfo(); productTypeInfo.TypeId = this.typeId; productTypeInfo.TypeName = Globals.StripHtmlXmlTags(Globals.StripScriptTags(this.txtTypeName.Text).Replace(",", ",").Replace("\\", "")); if (string.IsNullOrEmpty(productTypeInfo.TypeName)) { this.ShowMsg("类型名称不能为空,不允许包含脚本标签、HTML标签和\\,系统会自动过滤", false); return; } productTypeInfo.Remark = this.txtRemark.Text; System.Collections.Generic.IList <int> list = new System.Collections.Generic.List <int>(); foreach (System.Web.UI.WebControls.ListItem listItem in this.chlistBrand.Items) { if (listItem.Selected) { list.Add(int.Parse(listItem.Value)); } } productTypeInfo.Brands = list; if (!this.ValidationProductType(productTypeInfo)) { return; } if (ProductTypeHelper.UpdateProductType(productTypeInfo)) { this.ShowMsg("修改成功", true); } }
protected void Page_Load(object sender, System.EventArgs e) { if (!string.IsNullOrEmpty(this.Page.Request.QueryString["typeId"])) { int.TryParse(this.Page.Request.QueryString["typeId"], out this.typeId); } this.btnEditProductType.Click += new System.EventHandler(this.btnEditProductType_Click); if (!this.Page.IsPostBack) { this.chlistBrand.DataBind(); ProductTypeInfo productType = ProductTypeHelper.GetProductType(this.typeId); if (productType == null) { base.GotoResourceNotFound(); return; } this.txtTypeName.Text = productType.TypeName; this.txtRemark.Text = productType.Remark; foreach (System.Web.UI.WebControls.ListItem listItem in this.chlistBrand.Items) { if (productType.Brands.Contains(int.Parse(listItem.Value))) { listItem.Selected = true; } } } }
private void btnAddProductType_Click(object sender, System.EventArgs e) { ProductTypeInfo productTypeInfo = new ProductTypeInfo(); productTypeInfo.TypeName = this.txtTypeName.Text.Trim(); productTypeInfo.Remark = this.txtRemark.Text; System.Collections.Generic.IList <int> list = new System.Collections.Generic.List <int>(); foreach (System.Web.UI.WebControls.ListItem listItem in this.chlistBrand.Items) { if (listItem.Selected) { list.Add(int.Parse(listItem.Value)); } } productTypeInfo.Brands = list; if (!this.ValidationProductType(productTypeInfo)) { return; } int num = ProductTypeHelper.AddProductType(productTypeInfo); if (num > 0) { base.Response.Redirect(Globals.GetAdminAbsolutePath("/goods/AddAttribute.aspx?typeId=" + num), true); return; } this.ShowMsg("添加商品类型失败", false); }
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); } } }
protected void Page_Load(object sender, System.EventArgs e) { if (!this.Page.IsPostBack) { this.cboxCategory.DataSource = CategoryBrowser.GetAllCategories(); this.cboxCategory.DataTextField = "Name"; this.cboxCategory.DataValueField = "CategoryId"; this.cboxCategory.DataBind(); this.cboxBrand.DataSource = CategoryBrowser.GetBrandCategories(); this.cboxBrand.DataTextField = "BrandName"; this.cboxBrand.DataValueField = "BrandId"; this.cboxBrand.DataBind(); this.cboxType.DataSource = ProductTypeHelper.GetProductTypes(); this.cboxType.DataTextField = "TypeName"; this.cboxType.DataValueField = "TypeId"; this.cboxType.DataBind(); DataTable dtData = DistributorsBrower.GetDistributorProductRangeByUserid(int.Parse(Request.QueryString["UserID"])); if (dtData.Rows.Count > 0) { string strs = string.Empty; if (dtData.Rows[0]["ProductRange1"] != DBNull.Value) { strs = "," + dtData.Rows[0]["ProductRange1"].ToString().Trim() + ","; foreach (ListItem li in this.cboxCategory.Items) { if (strs.IndexOf(li.Value) > -1) { li.Selected = true; } } } if (dtData.Rows[0]["ProductRange2"] != DBNull.Value) { strs = "," + dtData.Rows[0]["ProductRange2"].ToString().Trim() + ","; foreach (ListItem li in this.cboxBrand.Items) { if (strs.IndexOf(li.Value) > -1) { li.Selected = true; } } } if (dtData.Rows[0]["ProductRange3"] != DBNull.Value) { strs = "," + dtData.Rows[0]["ProductRange3"].ToString().Trim() + ","; foreach (ListItem li in this.cboxType.Items) { if (strs.IndexOf(li.Value) > -1) { li.Selected = true; } } } } ViewState["dtData"] = dtData; } }
protected void Page_Load(object sender, EventArgs e) { if (!string.IsNullOrEmpty(Page.Request.QueryString["typeId"])) { int.TryParse(Page.Request.QueryString["typeId"], out typeId); } btnEditProductType.Click += new EventHandler(btnEditProductType_Click); if (!Page.IsPostBack) { chlistBrand.DataBind(); ProductTypeInfo productType = ProductTypeHelper.GetProductType(typeId); if (productType == null) { base.GotoResourceNotFound(); } else { txtTypeName.Text = productType.TypeName; txtRemark.Text = productType.Remark; foreach (ListItem item in chlistBrand.Items) { if (productType.Brands.Contains(int.Parse(item.Value))) { item.Selected = true; } } } } }
/// <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); } } }
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); } }
public void DataBindByTypeId(int?typeId) { this.Items.Clear(); if (this.AllowNull) { base.Items.Add(new ListItem(this.NullToDisplay, string.Empty)); } DataTable dataTable = new DataTable(); if (typeId != null) { dataTable = ProductTypeHelper.GetBrandCategoriesByTypeId((int)typeId); if (dataTable.Rows.Count == 0) { dataTable = ControlProvider.Instance().GetBrandCategories(); } } else { dataTable = ControlProvider.Instance().GetBrandCategories(); } foreach (DataRow dataRow in dataTable.Rows) { this.Items.Add(new ListItem((string)dataRow["BrandName"], ((int)dataRow["BrandId"]).ToString(CultureInfo.InvariantCulture))); } }
private void btnCreate_Click(object sender, System.EventArgs e) { AttributeInfo attributeInfo = new AttributeInfo(); attributeInfo.TypeId = this.typeId; attributeInfo.AttributeName = Globals.HtmlEncode(this.txtName.Text).Replace(",", ","); attributeInfo.UsageMode = AttributeUseageMode.Choose; attributeInfo.UseAttributeImage = this.radIsImage.SelectedValue; ValidationResults validationResults = Validation.Validate <AttributeInfo>(attributeInfo, new string[] { "ValAttribute" }); string str = string.Empty; if (!validationResults.IsValid) { foreach (ValidationResult current in ((System.Collections.Generic.IEnumerable <ValidationResult>)validationResults)) { str += Formatter.FormatErrorMessage(current.Message); } return; } ProductTypeHelper.GetAttributes(this.typeId, AttributeUseageMode.Choose); if (ProductTypeHelper.AddAttributeName(attributeInfo)) { base.Response.Redirect(System.Web.HttpContext.Current.Request.Url.ToString(), true); } }
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); }
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); } }
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 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); } } }