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); } }
/// <summary> /// 创建规格值 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnCreateValue_Click(object sender, EventArgs e) { AttributeValueInfo attributeValue = new AttributeValueInfo(); IList <AttributeValueInfo> list = new List <AttributeValueInfo>(); int num = int.Parse(currentAttributeId.Value); attributeValue.AttributeId = num; if (!string.IsNullOrEmpty(txtValueStr.Text.Trim())) { string[] strArray = txtValueStr.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 str = string.Format("ShowMsg(\"{0}\", {1});", "属性值限制在15个字符以内", "false"); Page.ClientScript.RegisterStartupScript(base.GetType(), "ServerMessageScript2", "<script language='JavaScript' defer='defer'>setTimeout(function(){" + str + "},300);</script>"); return; } item.ValueStr = Globals.HtmlEncode(strArray[i]); item.AttributeId = num; list.Add(item); } foreach (AttributeValueInfo info3 in list) { ProductTypeHelper.AddAttributeValue(info3); } txtValueStr.Text = string.Empty; base.Response.Redirect(HttpContext.Current.Request.Url.ToString(), true); } if (fileUpload.HasFile) { try { attributeValue.ImageUrl = ProductTypeHelper.UploadSKUImage(fileUpload.PostedFile); // if (!string.IsNullOrEmpty(attributeValue.ValueStr)) //{ attributeValue.ValueStr = Globals.HtmlEncode(txtValueDec.Text); ////} ////else ////{ //// throw new Exception("测试抛出的错误:ValueStr为NULL!"); ////} } catch { } if (ProductTypeHelper.AddAttributeValue(attributeValue)) { txtValueStr.Text = string.Empty; base.Response.Redirect(HttpContext.Current.Request.Url.ToString(), true); } } }
private void btnAdd_Click(object sender, System.EventArgs e) { AttributeValueInfo attributeValueInfo = new AttributeValueInfo(); if (this.txtValue.Text.Trim().Length <= 15 && this.txtValue.Text.Trim().Length != 0) { attributeValueInfo.ValueStr = this.txtValue.Text.Trim().Replace("+", ""); attributeValueInfo.AttributeId = this.attributeId; if (ProductTypeHelper.AddAttributeValue(attributeValueInfo) > 0) { this.BindData(); this.ShowMsg("添加成功", true); } return; } this.ShowMsg("属性值必须小于15个字符,不能为空", false); }
private void AddValue(HttpContext context) { int value = base.GetIntParam(context, "attributeId", false).Value; string parameter = base.GetParameter(context, "Value", false); AttributeValueInfo attributeValueInfo = new AttributeValueInfo(); string text = Globals.StripHtmlXmlTags(Globals.StripScriptTags(parameter.Trim().Replace("+", "").Replace("\\", ""))); if (text.Length > 15 || text.Length == 0) { throw new HidistroAshxException("属性值必须小于15个字符,不能为空,且不能包含脚本标签、HTML标签、XML标签以及\\+!"); } attributeValueInfo.ValueStr = text; attributeValueInfo.AttributeId = value; if (ProductTypeHelper.AddAttributeValue(attributeValueInfo) > 0) { base.ReturnSuccessResult(context, "添加成功!", 0, true); } }
private void btnAdd_Click(object sender, System.EventArgs e) { AttributeValueInfo attributeValueInfo = new AttributeValueInfo(); string text = Globals.StripHtmlXmlTags(Globals.StripScriptTags(this.txtValue.Text.Trim().Replace("+", "").Replace("\\", ""))); if (text.Length > 15 || text.Length == 0) { this.ShowMsg("属性值必须小于15个字符,不能为空,且不能包含脚本标签、HTML标签、XML标签以及\\+", false); return; } attributeValueInfo.ValueStr = text; attributeValueInfo.AttributeId = this.attributeId; if (ProductTypeHelper.AddAttributeValue(attributeValueInfo) > 0) { this.BindData(); this.ShowMsg("添加成功", true); } }
private void btnAdd_Click(object sender, EventArgs e) { AttributeValueInfo attributeValue = new AttributeValueInfo(); if ((this.txtValue.Text.Trim().Length > 15) || (this.txtValue.Text.Trim().Length == 0)) { this.ShowMsg("属性值必须小于15个字符,不能为空", false); } else { attributeValue.ValueStr = this.txtValue.Text.Trim().Replace("+", ""); attributeValue.AttributeId = this.attributeId; if (ProductTypeHelper.AddAttributeValue(attributeValue) > 0) { this.BindData(); this.ShowMsg("添加成功", true); } } }
private void btnAdd_Click(object sender, EventArgs e) { AttributeValueInfo attributeValue = new AttributeValueInfo(); if (((txtValue.Text.Trim().Length > 15) || (txtValue.Text.Trim().IndexOf(",") != -1)) || (txtValue.Text.Trim().Length == 0)) { ShowMsg("属性值必须小于15个字符,不能为空,并且不能包含逗号", false); } else { attributeValue.ValueStr = txtValue.Text.Trim().Replace("+", ""); attributeValue.AttributeId = attributeId; if (ProductTypeHelper.AddAttributeValue(attributeValue)) { BindData(); ShowMsg("添加成功", true); } } }
private void btnCreateValueAdd_Click(object sender, System.EventArgs e) { AttributeValueInfo attributeValueInfo = new AttributeValueInfo(); System.Collections.Generic.IList <AttributeValueInfo> list = new System.Collections.Generic.List <AttributeValueInfo>(); int attributeId = int.Parse(this.currentAttributeId.Value); attributeValueInfo.AttributeId = attributeId; if (!string.IsNullOrEmpty(this.txtValueStr.Text.Trim())) { string text = Globals.StripHtmlXmlTags(Globals.StripScriptTags(this.txtValueStr.Text.Trim()).Replace(",", ",").Replace("\\", "").Replace("+", "")); string[] array = text.Split(new char[] { ',' }); int num = 0; while (num < array.Length && array[num].Trim().Length <= 100) { AttributeValueInfo attributeValueInfo2 = new AttributeValueInfo(); if (array[num].Trim().Length > 15) { string str = string.Format("ShowMsg(\"{0}\", {1});", "属性值限制在15个字符以内,不允许包含脚本标签,HTML标签和\\,系统会自动过滤", "false"); this.Page.ClientScript.RegisterStartupScript(base.GetType(), "ServerMessageScript2", "<script language='JavaScript' defer='defer'>setTimeout(function(){" + str + "},300);</script>"); return; } attributeValueInfo2.ValueStr = array[num].Trim().Replace("+", ""); attributeValueInfo2.ValueStr = attributeValueInfo2.ValueStr.Replace("\\", ""); attributeValueInfo2.ValueStr = attributeValueInfo2.ValueStr.Replace("/", ""); attributeValueInfo2.AttributeId = attributeId; list.Add(attributeValueInfo2); num++; } foreach (AttributeValueInfo current in list) { ProductTypeHelper.AddAttributeValue(current); } this.txtValueStr.Text = string.Empty; base.Response.Redirect(System.Web.HttpContext.Current.Request.Url.ToString(), true); } }
protected void btnCreateValue_Click(object sender, EventArgs e) { AttributeValueInfo attributeValue = new AttributeValueInfo(); IList <AttributeValueInfo> list = new List <AttributeValueInfo>(); int num = int.Parse(this.currentAttributeId.Value); attributeValue.AttributeId = num; if (this.Page.Request.QueryString["action"].ToString().Trim() == "add") { if (!string.IsNullOrEmpty(this.txtValueStr.Text.Trim())) { string[] strArray = this.txtValueStr.Text.Trim().Split(new char[] { ',' }); for (int i = 0; i < strArray.Length; i++) { if (strArray[i].Trim().Length <= 100) { AttributeValueInfo item = new AttributeValueInfo(); if (strArray[i].Trim().Length > 50) { this.ShowMsgToTarget("属性值限制在50个字符以内", false, "parent"); return; } item.ValueStr = Globals.HtmlEncode(strArray[i].Trim()); item.AttributeId = num; list.Add(item); } else { this.ShowMsgToTarget("[" + strArray[i].Trim() + "]属性值超出了50个字符", false, "parent"); return; } } foreach (AttributeValueInfo info3 in list) { ProductTypeHelper.AddAttributeValue(info3); } base.ClientScript.RegisterStartupScript(base.ClientScript.GetType(), "myscript", "<script>window.parent.closeModal(getParam('action'));</script>"); this.txtValueStr.Text = ""; } if (this.fileUpload.HasFile) { try { attributeValue.ImageUrl = ProductTypeHelper.UploadSKUImage(this.fileUpload.PostedFile); attributeValue.ValueStr = Globals.HtmlEncode(this.txtValueDec.Text); } catch { } if (ProductTypeHelper.AddAttributeValue(attributeValue) <= 0) { } } } else { this.valueId = int.Parse(this.Page.Request.QueryString["valueId"]); attributeValue = ProductTypeHelper.GetAttributeValueInfo(this.valueId); if (ProductTypeHelper.GetAttribute(attributeValue.AttributeId).UseAttributeImage) { if (!string.IsNullOrEmpty(this.txtValueDec.Text)) { attributeValue.ValueStr = Globals.HtmlEncode(this.txtValueDec.Text); } } else if (!string.IsNullOrEmpty(this.txtValueStr.Text)) { attributeValue.ValueStr = Globals.HtmlEncode(this.txtValueStr.Text); } if (this.fileUpload.HasFile) { try { StoreHelper.DeleteImage(attributeValue.ImageUrl); attributeValue.ImageUrl = ProductTypeHelper.UploadSKUImage(this.fileUpload.PostedFile); } catch { } } ProductTypeHelper.UpdateAttributeValue(attributeValue); base.ClientScript.RegisterStartupScript(base.ClientScript.GetType(), "myscript", "<script>window.parent.closeModal(getParam('action'));</script>"); } }
protected void btnCreateValue_Click(object sender, EventArgs e) { AttributeValueInfo attributeValue = new AttributeValueInfo(); IList <AttributeValueInfo> list = new List <AttributeValueInfo>(); int num = int.Parse(this.currentAttributeId.Value); attributeValue.AttributeId = num; string a = this.Page.Request.QueryString["action"].ToString().Trim(); if (a == "add") { if (!string.IsNullOrEmpty(this.txtValueStr.Text.Trim())) { string content = this.txtValueStr.Text.Trim(); content = Globals.StripHtmlXmlTags(Globals.StripScriptTags(content)).Replace(",", ",").Replace("\\", "") .Replace("/", ""); string[] array = content.Split(','); for (int i = 0; i < array.Length && array[i].Trim().Length <= 100; i++) { AttributeValueInfo attributeValueInfo = new AttributeValueInfo(); if (array[i].Trim().Length > 50) { this.ShowMsg("属性值限制在50个字符以内", false); return; } attributeValueInfo.ValueStr = Globals.HtmlEncode(array[i].Trim()); attributeValueInfo.AttributeId = num; list.Add(attributeValueInfo); } foreach (AttributeValueInfo item in list) { IList <AttributeValueInfo> attributeValues = ProductTypeHelper.GetAttribute(item.AttributeId).AttributeValues; if ((from c in attributeValues where c.ValueStr == item.ValueStr select c).Count() > 0) { this.ShowMsg("规格值不能重复", false); return; } ProductTypeHelper.AddAttributeValue(item); } base.CloseWindow(null); } } else { this.valueId = int.Parse(this.Page.Request.QueryString["valueId"]); attributeValue = ProductTypeHelper.GetAttributeValueInfo(this.valueId); AttributeInfo attribute = ProductTypeHelper.GetAttribute(attributeValue.AttributeId); if (!string.IsNullOrEmpty(this.txtValueStr.Text)) { attributeValue.ValueStr = Globals.StripHtmlXmlTags(Globals.StripScriptTags(this.txtValueStr.Text)).Replace(",", ",").Replace("\\", "") .Replace("/", ""); } IList <AttributeValueInfo> attributeValues2 = ProductTypeHelper.GetAttribute(attributeValue.AttributeId).AttributeValues; if ((from c in attributeValues2 where c.ValueId != attributeValue.ValueId && c.ValueStr == attributeValue.ValueStr select c).Count() > 0) { this.ShowMsg("规格值不能重复", false); } else if (ProductTypeHelper.UpdateAttributeValue(attributeValue)) { base.CloseWindow(null); } } }
protected void Page_Load(object sender, EventArgs e) { int num; if ((!string.IsNullOrEmpty(base.Request["isCallback"]) && (base.Request["isCallback"] == "true")) && int.TryParse(base.Request["ValueId"], out num)) { if (ProductTypeHelper.DeleteAttributeValue(num)) { if (!string.IsNullOrEmpty(base.Request["ImageUrl"])) { StoreHelper.DeleteImage(base.Request["ImageUrl"]); base.Response.Clear(); base.Response.ContentType = "application/json"; base.Response.Write("{\"Status\":\"true\"}"); base.Response.End(); } else { base.Response.Clear(); base.Response.ContentType = "application/json"; base.Response.Write("{\"Status\":\"true\"}"); base.Response.End(); } } else { base.Response.Clear(); base.Response.ContentType = "application/json"; base.Response.Write("{\"Status\":\"false\"}"); base.Response.End(); } } if (!string.IsNullOrEmpty(base.Request["isAjax"]) && (base.Request["isAjax"] == "true")) { string str = base.Request["Mode"].ToString(); string str2 = ""; string str3 = "false"; string str6 = str; if (str6 != null) { int num2; if (!(str6 == "Add")) { if (str6 == "AddSkuItemValue") { str2 = "参数缺少"; if (int.TryParse(base.Request["AttributeId"], out num2)) { string str5 = ""; str2 = "规格值名不允许为空!"; if (!string.IsNullOrEmpty(base.Request["ValueName"].ToString())) { str5 = Globals.HtmlEncode(base.Request["ValueName"].ToString().Replace("+", "").Replace(",", "")); str2 = "规格值名长度不允许超过15个字符"; if (str5.Length < 15) { AttributeValueInfo attributeValue = new AttributeValueInfo { ValueStr = str5, AttributeId = num2 }; int num4 = 0; str2 = "添加规格值失败"; num4 = ProductTypeHelper.AddAttributeValue(attributeValue); if (num4 > 0) { str2 = num4.ToString(); str3 = "true"; } } } } base.Response.Clear(); base.Response.ContentType = "application/json"; base.Response.Write("{\"Status\":\"" + str3 + "\",\"msg\":\"" + str2 + "\"}"); base.Response.End(); } } else { num2 = 0; str2 = "参数缺少"; if (int.TryParse(base.Request["AttributeId"], out num2)) { string str4 = ""; str2 = "属性名称不允许为空!"; if (!string.IsNullOrEmpty(base.Request["ValueName"].ToString())) { str4 = Globals.HtmlEncode(base.Request["ValueName"].ToString()); AttributeValueInfo info = new AttributeValueInfo { ValueStr = str4, AttributeId = num2 }; int num3 = 0; str2 = "添加属性值失败"; num3 = ProductTypeHelper.AddAttributeValue(info); if (num3 > 0) { str2 = num3.ToString(); str3 = "true"; } } } base.Response.Clear(); base.Response.ContentType = "application/json"; base.Response.Write("{\"Status\":\"" + str3 + "\",\"msg\":\"" + str2 + "\"}"); base.Response.End(); } } } this.btnFilish.Click += new EventHandler(this.btnFilish_Click); }
protected void Page_Load(object sender, System.EventArgs e) { bool flag = !string.IsNullOrEmpty(base.Request["isCallback"]) && base.Request["isCallback"] == "true"; int attributeValueId; if (flag && int.TryParse(base.Request["ValueId"], out attributeValueId)) { if (ProductTypeHelper.DeleteAttributeValue(attributeValueId)) { if (!string.IsNullOrEmpty(base.Request["ImageUrl"])) { StoreHelper.DeleteImage(base.Request["ImageUrl"]); base.Response.Clear(); base.Response.ContentType = "application/json"; base.Response.Write("{\"Status\":\"true\"}"); base.Response.End(); } else { base.Response.Clear(); base.Response.ContentType = "application/json"; base.Response.Write("{\"Status\":\"true\"}"); base.Response.End(); } } else { base.Response.Clear(); base.Response.ContentType = "application/json"; base.Response.Write("{\"Status\":\"false\"}"); base.Response.End(); } } if (!string.IsNullOrEmpty(base.Request["isAjax"]) && base.Request["isAjax"] == "true") { string text = base.Request["Mode"].ToString(); string text2 = "false"; string a; if ((a = text) != null) { int attributeId; string text3; if (a == "Add") { attributeId = 0; text3 = "参数缺少"; if (int.TryParse(base.Request["AttributeId"], out attributeId)) { text3 = "属性名称不允许为空!"; if (!string.IsNullOrEmpty(base.Request["ValueName"].ToString())) { string valueStr = Globals.HtmlEncode(base.Request["ValueName"].ToString()); AttributeValueInfo attributeValueInfo = new AttributeValueInfo(); attributeValueInfo.ValueStr = valueStr; attributeValueInfo.AttributeId = attributeId; text3 = "添加属性值失败"; int num = ProductTypeHelper.AddAttributeValue(attributeValueInfo); if (num > 0) { text3 = num.ToString(); text2 = "true"; } } } base.Response.Clear(); base.Response.ContentType = "application/json"; base.Response.Write(string.Concat(new string[] { "{\"Status\":\"", text2, "\",\"msg\":\"", text3, "\"}" })); base.Response.End(); return; } if (!(a == "AddSkuItemValue")) { return; } text3 = "参数缺少"; if (int.TryParse(base.Request["AttributeId"], out attributeId)) { text3 = "规格值名不允许为空!"; if (!string.IsNullOrEmpty(base.Request["ValueName"].ToString())) { string text4 = Globals.HtmlEncode(base.Request["ValueName"].ToString().Replace("+", "").Replace(",", "")); text3 = "规格值名长度不允许超过50个字符"; if (text4.Length < 50) { AttributeValueInfo attributeValueInfo2 = new AttributeValueInfo(); attributeValueInfo2.ValueStr = text4; attributeValueInfo2.AttributeId = attributeId; text3 = "添加规格值失败"; int num2 = ProductTypeHelper.AddAttributeValue(attributeValueInfo2); if (num2 > 0) { text3 = num2.ToString(); text2 = "true"; } } } } base.Response.Clear(); base.Response.ContentType = "application/json"; base.Response.Write(string.Concat(new string[] { "{\"Status\":\"", text2, "\",\"msg\":\"", text3, "\"}" })); base.Response.End(); } } }
protected void btnCreateValue_Click(object sender, System.EventArgs e) { AttributeValueInfo attributeValueInfo = new AttributeValueInfo(); System.Collections.Generic.IList <AttributeValueInfo> list = new System.Collections.Generic.List <AttributeValueInfo>(); int num = int.Parse(this.currentAttributeId.Value); attributeValueInfo.AttributeId = num; string a = this.Page.Request.QueryString["action"].ToString().Trim(); if (a == "add") { if (!string.IsNullOrEmpty(this.txtValueStr.Text.Trim())) { string text = this.txtValueStr.Text.Trim(); text = Globals.StripHtmlXmlTags(Globals.StripScriptTags(text)).Replace(",", ",").Replace("\\", "").Replace("/", ""); string[] array = text.Split(new char[] { ',' }); int num2 = 0; while (num2 < array.Length && array[num2].Trim().Length <= 100) { AttributeValueInfo attributeValueInfo2 = new AttributeValueInfo(); if (array[num2].Trim().Length > 15) { this.ShowMsg("属性值限制在15个字符以内", false); return; } attributeValueInfo2.ValueStr = Globals.HtmlEncode(array[num2].Trim()); attributeValueInfo2.AttributeId = num; list.Add(attributeValueInfo2); num2++; } foreach (AttributeValueInfo current in list) { ProductTypeHelper.AddAttributeValue(current); } this.CloseWindow(); } if (!this.fileUpload.HasFile) { this.ShowMsg("属性值限制在15个字符以内", false); return; } try { attributeValueInfo.ImageUrl = ProductTypeHelper.UploadSKUImage(this.fileUpload.PostedFile); attributeValueInfo.ValueStr = Globals.HtmlEncode(this.txtValueDec.Text); } catch { } if (ProductTypeHelper.AddAttributeValue(attributeValueInfo) > 0) { this.CloseWindow(); return; } } else { this.valueId = int.Parse(this.Page.Request.QueryString["valueId"]); attributeValueInfo = ProductTypeHelper.GetAttributeValueInfo(this.valueId); AttributeInfo attribute = ProductTypeHelper.GetAttribute(attributeValueInfo.AttributeId); if (attribute.UseAttributeImage) { if (!string.IsNullOrEmpty(this.txtValueDec.Text)) { attributeValueInfo.ValueStr = Globals.StripHtmlXmlTags(Globals.StripScriptTags(this.txtValueDec.Text)).Replace(",", ",").Replace("\\", "").Replace("/", ""); } } else { if (!string.IsNullOrEmpty(this.txtValueStr.Text)) { attributeValueInfo.ValueStr = Globals.StripHtmlXmlTags(Globals.StripScriptTags(this.txtValueStr.Text)).Replace(",", ",").Replace("\\", "").Replace("/", ""); } } if (this.fileUpload.HasFile) { try { StoreHelper.DeleteImage(attributeValueInfo.ImageUrl); attributeValueInfo.ImageUrl = ProductTypeHelper.UploadSKUImage(this.fileUpload.PostedFile); } catch { } } if (ProductTypeHelper.UpdateAttributeValue(attributeValueInfo)) { this.CloseWindow(); } } }
protected void Page_Load(object sender, EventArgs e) { bool flag = !string.IsNullOrEmpty(base.Request["isCallback"]) && base.Request["isCallback"] == "true"; this.btnFilish.Click += this.btnFilish_Click; int attributeValueId = default(int); if (flag && int.TryParse(base.Request["ValueId"], out attributeValueId)) { if (ProductTypeHelper.DeleteAttributeValue(attributeValueId)) { base.Response.Clear(); base.Response.ContentType = "application/json"; base.Response.Write("{\"Status\":\"true\"}"); base.Response.End(); } else { base.Response.Clear(); base.Response.ContentType = "application/json"; base.Response.Write("{\"Status\":\"false\"}"); base.Response.End(); } } if (!string.IsNullOrEmpty(base.Request["isAjax"]) && base.Request["isAjax"] == "true") { string text = base.Request["Mode"].ToString(); string text2 = ""; string text3 = "false"; string a = text; int attributeId = default(int); if (!(a == "Add")) { if (a == "AddSkuItemValue") { text2 = "参数缺少"; if (int.TryParse(base.Request["AttributeId"], out attributeId)) { string text4 = ""; text2 = "规格值名不允许为空!"; if (!string.IsNullOrEmpty(base.Request["ValueName"].ToString())) { text4 = Globals.StripHtmlXmlTags(Globals.StripScriptTags(base.Request["ValueName"].ToString().Replace("+", "").Replace(",", ""))); text2 = "规格值名长度不允许超过15个字符"; if (text4.Length < 15) { AttributeValueInfo attributeValueInfo = new AttributeValueInfo(); attributeValueInfo.ValueStr = text4; attributeValueInfo.AttributeId = attributeId; int num = 0; text2 = "添加规格值失败"; num = ProductTypeHelper.AddAttributeValue(attributeValueInfo); if (num > 0) { text2 = num.ToString(); text3 = "true"; } } } } base.Response.Clear(); base.Response.ContentType = "application/json"; base.Response.Write("{\"Status\":\"" + text3 + "\",\"msg\":\"" + text2 + "\"}"); base.Response.End(); } } else { attributeId = 0; text2 = "参数缺少"; if (int.TryParse(base.Request["AttributeId"], out attributeId)) { string text5 = ""; text2 = "属性名称不允许为空!"; if (!string.IsNullOrEmpty(base.Request["ValueName"].ToString())) { text5 = Globals.HtmlEncode(base.Request["ValueName"].ToString()); AttributeValueInfo attributeValueInfo2 = new AttributeValueInfo(); attributeValueInfo2.ValueStr = text5; attributeValueInfo2.AttributeId = attributeId; int num2 = 0; text2 = "添加属性值失败"; num2 = ProductTypeHelper.AddAttributeValue(attributeValueInfo2); if (num2 > 0) { text2 = num2.ToString(); text3 = "true"; } } } base.Response.Clear(); base.Response.ContentType = "application/json"; base.Response.Write("{\"Status\":\"" + text3 + "\",\"msg\":\"" + text2 + "\"}"); base.Response.End(); } } }
protected void btnCreateValue_Click(object sender, EventArgs e) { AttributeValueInfo attributeValue = new AttributeValueInfo(); IList<AttributeValueInfo> list = new List<AttributeValueInfo>(); int num = int.Parse(this.currentAttributeId.Value); attributeValue.AttributeId = num; if (!(this.Page.Request.QueryString["action"].ToString().Trim() == "add")) { this.valueId = int.Parse(this.Page.Request.QueryString["valueId"]); attributeValue = ProductTypeHelper.GetAttributeValueInfo(this.valueId); if (ProductTypeHelper.GetAttribute(attributeValue.AttributeId).UseAttributeImage) { if (!string.IsNullOrEmpty(this.txtValueDec.Text)) { attributeValue.ValueStr = Globals.HtmlEncode(this.txtValueDec.Text); } } else if (!string.IsNullOrEmpty(this.txtValueStr.Text)) { attributeValue.ValueStr = Globals.HtmlEncode(this.txtValueStr.Text); } if (this.fileUpload.HasFile) { try { StoreHelper.DeleteImage(attributeValue.ImageUrl); attributeValue.ImageUrl = ProductTypeHelper.UploadSKUImage(this.fileUpload.PostedFile); } catch { } } if (ProductTypeHelper.UpdateSku(attributeValue)) { this.CloseWindow(); } } else { if (!string.IsNullOrEmpty(this.txtValueStr.Text.Trim())) { string[] strArray = this.txtValueStr.Text.Trim().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 > 15) { this.ShowMsg("属性值限制在15个字符以内", false); return; } item.ValueStr = Globals.HtmlEncode(strArray[i].Trim()); item.AttributeId = num; list.Add(item); } foreach (AttributeValueInfo info3 in list) { ProductTypeHelper.AddAttributeValue(info3); } this.CloseWindow(); } if (this.fileUpload.HasFile) { try { attributeValue.ImageUrl = ProductTypeHelper.UploadSKUImage(this.fileUpload.PostedFile); attributeValue.ValueStr = Globals.HtmlEncode(this.txtValueDec.Text); } catch { } if (ProductTypeHelper.AddAttributeValue(attributeValue) > 0) { this.CloseWindow(); } } else { this.ShowMsg("属性值限制在15个字符以内", false); } } }