Exemplo n.º 1
0
        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);
            }
        }
Exemplo n.º 2
0
 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);
         }
     }
 }