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); } }
/// <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); } } }
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, 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 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); } } }