private void grdAttribute_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 attributeId = (int)this.grdAttribute.DataKeys[rowIndex].Value; int displaySequence = int.Parse((this.grdAttribute.Rows[rowIndex].FindControl("lblDisplaySequence") as System.Web.UI.WebControls.Literal).Text, System.Globalization.NumberStyles.None); int num = 0; int replaceDisplaySequence = 0; if (e.CommandName == "saveAttributeName") { System.Web.UI.WebControls.TextBox textBox = this.grdAttribute.Rows[rowIndex].FindControl("txtAttributeName") as System.Web.UI.WebControls.TextBox; AttributeInfo attribute = ProductTypeHelper.GetAttribute(attributeId); string attributeName = Globals.StripHtmlXmlTags(Globals.StripScriptTags(textBox.Text).Replace("\\", "")); if (string.IsNullOrEmpty(textBox.Text.Trim()) || textBox.Text.Trim().Length > 15) { string str = string.Format("ShowMsg(\"{0}\", {1});", "属性名称限制在1-15个字符以内,不允许包含html字符和\\,系统会自动过滤", "false"); this.Page.ClientScript.RegisterStartupScript(base.GetType(), "ServerMessageScript2", "<script language='JavaScript' defer='defer'>setTimeout(function(){" + str + "},300);</script>"); return; } attribute.AttributeName = attributeName; ProductTypeHelper.UpdateAttributeName(attribute); base.Response.Redirect(System.Web.HttpContext.Current.Request.Url.ToString(), true); } if (e.CommandName == "SetYesOrNo") { AttributeInfo attribute2 = ProductTypeHelper.GetAttribute(attributeId); if (attribute2.IsMultiView) { attribute2.UsageMode = AttributeUseageMode.View; } else { attribute2.UsageMode = AttributeUseageMode.MultiView; } ProductTypeHelper.UpdateAttributeName(attribute2); base.Response.Redirect(System.Web.HttpContext.Current.Request.Url.ToString(), true); } if (e.CommandName == "Fall") { if (rowIndex < this.grdAttribute.Rows.Count - 1) { num = (int)this.grdAttribute.DataKeys[rowIndex + 1].Value; replaceDisplaySequence = int.Parse((this.grdAttribute.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.grdAttribute.DataKeys[rowIndex - 1].Value; replaceDisplaySequence = int.Parse((this.grdAttribute.Rows[rowIndex - 1].FindControl("lblDisplaySequence") as System.Web.UI.WebControls.Literal).Text, System.Globalization.NumberStyles.None); } } if (num > 0) { ProductTypeHelper.SwapAttributeSequence(attributeId, num, displaySequence, replaceDisplaySequence); this.BindAttribute(); } }
private void grdAttribute_RowCommand(object sender, GridViewCommandEventArgs e) { int rowIndex = ((GridViewRow)((Control)e.CommandSource).NamingContainer).RowIndex; int attributeId = (int)this.grdAttribute.DataKeys[rowIndex].Value; int displaySequence = int.Parse((this.grdAttribute.Rows[rowIndex].FindControl("lblDisplaySequence") as Literal).Text, NumberStyles.None); int replaceAttributeId = 0; int replaceDisplaySequence = 0; if (e.CommandName == "saveAttributeName") { TextBox box = this.grdAttribute.Rows[rowIndex].FindControl("txtAttributeName") as TextBox; AttributeInfo attribute = ProductTypeHelper.GetAttribute(attributeId); if (string.IsNullOrEmpty(box.Text.Trim()) || (box.Text.Trim().Length > 15)) { string str = string.Format("ShowMsg(\"{0}\", {1});", "属性名称限制在1-15个字符以内", "false"); this.Page.ClientScript.RegisterStartupScript(base.GetType(), "ServerMessageScript2", "<script language='JavaScript' defer='defer'>setTimeout(function(){" + str + "},300);</script>"); return; } attribute.AttributeName = Globals.HtmlEncode(box.Text); ProductTypeHelper.UpdateAttributeName(attribute); base.Response.Redirect(HttpContext.Current.Request.Url.ToString(), true); } if (e.CommandName == "SetYesOrNo") { AttributeInfo info2 = ProductTypeHelper.GetAttribute(attributeId); if (info2.IsMultiView) { info2.UsageMode = AttributeUseageMode.View; } else { info2.UsageMode = AttributeUseageMode.MultiView; } ProductTypeHelper.UpdateAttributeName(info2); base.Response.Redirect(HttpContext.Current.Request.Url.ToString(), true); } if (e.CommandName == "Fall") { if (rowIndex < (this.grdAttribute.Rows.Count - 1)) { replaceAttributeId = (int)this.grdAttribute.DataKeys[rowIndex + 1].Value; replaceDisplaySequence = int.Parse((this.grdAttribute.Rows[rowIndex + 1].FindControl("lblDisplaySequence") as Literal).Text, NumberStyles.None); } } else if ((e.CommandName == "Rise") && (rowIndex > 0)) { replaceAttributeId = (int)this.grdAttribute.DataKeys[rowIndex - 1].Value; replaceDisplaySequence = int.Parse((this.grdAttribute.Rows[rowIndex - 1].FindControl("lblDisplaySequence") as Literal).Text, NumberStyles.None); } if (replaceAttributeId > 0) { ProductTypeHelper.SwapAttributeSequence(attributeId, replaceAttributeId, displaySequence, replaceDisplaySequence); this.BindAttribute(); } }
private void grdSKU_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 attributeId = System.Convert.ToInt32(this.grdSKU.DataKeys[rowIndex].Value); if (e.CommandName == "saveSKUName") { System.Web.UI.WebControls.TextBox box = this.grdSKU.Rows[rowIndex].Cells[2].FindControl("txtSKUName") as System.Web.UI.WebControls.TextBox; AttributeInfo attribute = new AttributeInfo { AttributeId = attributeId }; if (string.IsNullOrEmpty(box.Text.Trim()) || box.Text.Trim().Length > 30) { string str = string.Format("ShowMsg(\"{0}\", {1});", "规格名称限制在1-30个字符以内", "false"); this.Page.ClientScript.RegisterStartupScript(base.GetType(), "ServerMessageScript2", "<script language='JavaScript' defer='defer'>setTimeout(function(){" + str + "},300);</script>"); return; } attribute.AttributeName = Globals.HtmlEncode(box.Text); attribute.UsageMode = AttributeUseageMode.Choose; ProductTypeHelper.UpdateAttributeName(attribute); base.Response.Redirect(System.Web.HttpContext.Current.Request.Url.ToString(), true); } int displaySequence = int.Parse((this.grdSKU.Rows[rowIndex].FindControl("lblDisplaySequence") as System.Web.UI.WebControls.Literal).Text, System.Globalization.NumberStyles.None); int replaceAttributeId = 0; int replaceDisplaySequence = 0; if (e.CommandName == "Fall") { if (rowIndex < this.grdSKU.Rows.Count - 1) { replaceAttributeId = (int)this.grdSKU.DataKeys[rowIndex + 1].Value; replaceDisplaySequence = int.Parse((this.grdSKU.Rows[rowIndex + 1].FindControl("lblDisplaySequence") as System.Web.UI.WebControls.Literal).Text, System.Globalization.NumberStyles.None); } } else { if (e.CommandName == "Rise" && rowIndex > 0) { replaceAttributeId = (int)this.grdSKU.DataKeys[rowIndex - 1].Value; replaceDisplaySequence = int.Parse((this.grdSKU.Rows[rowIndex - 1].FindControl("lblDisplaySequence") as System.Web.UI.WebControls.Literal).Text, System.Globalization.NumberStyles.None); } } if (replaceAttributeId > 0) { ProductTypeHelper.SwapAttributeSequence(attributeId, replaceAttributeId, displaySequence, replaceDisplaySequence); } this.BindAttribute(); }
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 EditName(HttpContext context) { int value = base.GetIntParam(context, "id", false).Value; if (value < 1) { throw new HidistroAshxException("错误的参数!"); } string parameter = base.GetParameter(context, "name", true); if (string.IsNullOrWhiteSpace(parameter)) { throw new HidistroAshxException("错误的参数!"); } AttributeInfo attribute = ProductTypeHelper.GetAttribute(value); if (attribute == null) { throw new HidistroAshxException("错误的参数!"); } parameter = Globals.StripHtmlXmlTags(Globals.StripScriptTags(parameter)).Replace("\\", "").Trim(); if (string.IsNullOrEmpty(parameter) || parameter.Length > 30) { throw new HidistroAshxException("属性名称限制在1-15个字符以内,不允许包含html字符和\\\\(反斜杠),系统会自动过滤"); } IList <AttributeInfo> attributes = ProductTypeHelper.GetAttributes(attribute.TypeId); foreach (AttributeInfo item in attributes) { if (item.AttributeName.Trim() == parameter && item.AttributeId != value) { throw new HidistroAshxException("同一个类型中不能存相同的规格/属性名称!"); } } attribute.AttributeName = parameter; if (ProductTypeHelper.UpdateAttributeName(attribute)) { base.ReturnSuccessResult(context, "修改成功!", 0, true); return; } throw new HidistroAshxException(" 操作失败!"); }
private void IsMulti(HttpContext context) { int value = base.GetIntParam(context, "id", false).Value; int value2 = base.GetIntParam(context, "typeid", false).Value; AttributeInfo attribute = ProductTypeHelper.GetAttribute(value); if (attribute.IsMultiView) { attribute.UsageMode = AttributeUseageMode.View; } else { attribute.UsageMode = AttributeUseageMode.MultiView; } if (ProductTypeHelper.UpdateAttributeName(attribute)) { base.ReturnSuccessResult(context, "操作成功", 0, true); return; } throw new HidistroAshxException("操作失败"); }