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); } }
private void EditSku(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; if (value < 1) { throw new HidistroAshxException("请选择要修改的规格,或刷新页面重试!"); } int num = ProductTypeHelper.HasSetUseImg(value3); if (num > 0 && (num != value & value2)) { throw new HidistroAshxException("已有其他规格可上传图片,最多只有一个规格允许上传商品规格图!"); } string parameter = base.GetParameter(context, "SkuName", false); AttributeInfo attribute = ProductTypeHelper.GetAttribute(value); if (attribute == null) { throw new HidistroAshxException("规格不存在,请刷新页面重试!"); } string text = Globals.StripHtmlXmlTags(Globals.StripScriptTags(parameter)).Replace("\\", "").Trim(); if (string.IsNullOrEmpty(text) || text.Length > 30) { throw new HidistroAshxException("规格名称限制在1-30个字符以内,不允许包含脚本标签、HTML标签和\\\\(反斜杠),系统会自动过滤!"); } IList <AttributeInfo> attributes = ProductTypeHelper.GetAttributes(attribute.TypeId); foreach (AttributeInfo item in attributes) { if (item.AttributeName.Trim() == text && item.AttributeId != value) { throw new HidistroAshxException("同一个类型中不能存相同的规格/属性名称!"); } } attribute.AttributeName = text; attribute.UsageMode = AttributeUseageMode.Choose; attribute.UseAttributeImage = value2; if (ProductTypeHelper.UpdateAttributeName(attribute)) { base.ReturnSuccessResult(context, "修改成功!", 0, true); return; } throw new HidistroAshxException(" 修改规格错误!"); }
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); } } }