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 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); } } }
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); } }
/// <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 AddSku(HttpContext context) { int value = base.GetIntParam(context, "typeId", false).Value; bool value2 = base.GetBoolParam(context, "UseAttributeImage", false).Value; string parameter = base.GetParameter(context, "SkuName", false); AttributeInfo attributeInfo = new AttributeInfo(); attributeInfo.TypeId = value; attributeInfo.AttributeName = Globals.StripHtmlXmlTags(Globals.StripScriptTags(parameter).Replace(",", ",").Replace("\\", "")).Trim(); if (string.IsNullOrEmpty(attributeInfo.AttributeName)) { throw new HidistroAshxException("规格名称限制在1-30个字符以内,不允许包含脚本标签、HTML标签和\\\\(反斜杠),系统会自动过滤!"); } if (ProductTypeHelper.HasSetUseImg(value) > 0 && value2) { throw new HidistroAshxException("已有其他规格可上传图片,最多只有一个规格允许上传商品规格图!"); } IList <AttributeInfo> attributes = ProductTypeHelper.GetAttributes(attributeInfo.TypeId); foreach (AttributeInfo item in attributes) { if (item.AttributeName.Trim() == attributeInfo.AttributeName) { throw new HidistroAshxException("同一个类型中不能存相同的规格/属性名称!"); } } attributeInfo.UsageMode = AttributeUseageMode.Choose; attributeInfo.UseAttributeImage = value2; ValidationResults validationResults = Validation.Validate(attributeInfo, "ValAttribute"); string str = string.Empty; if (!validationResults.IsValid) { foreach (ValidationResult item2 in (IEnumerable <ValidationResult>)validationResults) { str += item2.Message; } } else { IList <AttributeInfo> attributes2 = ProductTypeHelper.GetAttributes(value, AttributeUseageMode.Choose); if (ProductTypeHelper.AddAttributeName(attributeInfo)) { base.ReturnSuccessResult(context, "添加成功!", 0, true); } } }