Ejemplo 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);
            }
        }
Ejemplo n.º 2
0
        private void DeleteImage(HttpContext context)
        {
            string text    = context.Request["PhotoIdStr"];
            int    photoId = 0;
            string text2   = text.Trim();

            if (!string.IsNullOrEmpty(text2))
            {
                string[] array = text2.Split(',');
                foreach (string text3 in array)
                {
                    if (!string.IsNullOrEmpty(text3))
                    {
                        string[] array2 = text3.Split(':');
                        if (int.TryParse(array2[0], out photoId))
                        {
                            StoreHelper.DeleteImage(array2[1]);
                            if (!GalleryHelper.DeletePhoto(photoId))
                            {
                                throw new HidistroAshxException("请至少选择一项");
                            }
                        }
                    }
                }
                base.ReturnResult(context, true, text2, 0, true);
                return;
            }
            throw new HidistroAshxException("请至少选择一项");
        }
Ejemplo n.º 3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            int num;

            if ((!string.IsNullOrEmpty(Request["isCallback"]) && (Request["isCallback"] == "true")) && int.TryParse(Request["ValueId"], out num))
            {
                if (ProductTypeHelper.DeleteAttributeValue(num))
                {
                    if (!string.IsNullOrEmpty(Request["ImageUrl"]))
                    {
                        StoreHelper.DeleteImage(Request["ImageUrl"]);
                        Response.Clear();
                        Response.ContentType = "application/json";
                        Response.Write("{\"Status\":\"true\"}");
                        Response.End();
                    }
                    else
                    {
                        Response.Clear();
                        Response.ContentType = "application/json";
                        Response.Write("{\"Status\":\"true\"}");
                        Response.End();
                    }
                }
                else
                {
                    Response.Clear();
                    Response.ContentType = "application/json";
                    Response.Write("{\"Status\":\"false\"}");
                    Response.End();
                }
            }
            btnFilish.Click += new EventHandler(btnFilish_Click);
        }
Ejemplo n.º 4
0
        private void photoDataList_ItemCommand(object sender, DataListCommandEventArgs e)
        {
            int    photoId   = Convert.ToInt32(this.photoDataList.DataKeys[e.Item.ItemIndex]);
            string photoPath = GalleryHelper.GetPhotoPath(photoId);

            if (GalleryHelper.DeletePhoto(photoId))
            {
                StoreHelper.DeleteImage(photoPath);
                this.ShowMsg("删除图片成功", true);
            }
            this.BindImageData();
        }
Ejemplo n.º 5
0
        protected void Lkdel_Click(object sender, EventArgs e)
        {
            SiteSettings masterSettings = SettingsManager.GetMasterSettings(false);
            string       src            = this.imgqrcode.Src;

            try
            {
                StoreHelper.DeleteImage(src);
            }
            catch
            {
            }
            masterSettings.VipCardQR = string.Empty;
            SettingsManager.Save(masterSettings);
            this.LoadSiteContent(masterSettings);
        }
Ejemplo n.º 6
0
        private void DelImg(HttpContext context)
        {
            string s        = context.Request["PhotoId"];
            string imageUrl = context.Request["PhotoPath"];
            int    photoId  = 0;

            if (int.TryParse(s, out photoId))
            {
                StoreHelper.DeleteImage(imageUrl);
                if (!GalleryHelper.DeletePhoto(photoId))
                {
                    throw new HidistroAshxException("请至少选择一项");
                }
                base.ReturnResult(context, true, "删除成功!", 0, true);
                return;
            }
            throw new HidistroAshxException("操作失败");
        }
Ejemplo n.º 7
0
        protected void btnDeleteLogo_Click(object sender, EventArgs e)
        {
            SiteSettings masterSettings = SettingsManager.GetMasterSettings(false);

            try
            {
                StoreHelper.DeleteImage(masterSettings.LogoUrl);
            }
            catch
            {
            }
            masterSettings.LogoUrl = string.Empty;
            if (ValidationSettings(masterSettings))
            {
                SettingsManager.Save(masterSettings);
                LoadSiteContent(masterSettings);
            }
        }
Ejemplo n.º 8
0
        private void btnPicDelete_Click(object sender, System.EventArgs e)
        {
            FriendlyLinksInfo friendlyLink = StoreHelper.GetFriendlyLink(this.linkId);

            try
            {
                StoreHelper.DeleteImage(friendlyLink.ImageUrl);
            }
            catch
            {
            }
            friendlyLink.ImageUrl = (this.imgPic.ImageUrl = string.Empty);
            if (StoreHelper.UpdateFriendlyLink(friendlyLink))
            {
                this.btnPicDelete.Visible = !string.IsNullOrEmpty(this.imgPic.ImageUrl);
                this.imgPic.Visible       = !string.IsNullOrEmpty(this.imgPic.ImageUrl);
            }
        }
Ejemplo n.º 9
0
 private void btnDeleteLogo_Click(object sender, System.EventArgs e)
 {
     Hidistro.Membership.Context.SiteSettings masterSettings = Hidistro.Membership.Context.SettingsManager.GetMasterSettings(false);
     try
     {
         StoreHelper.DeleteImage(masterSettings.LogoUrl);
     }
     catch
     {
     }
     masterSettings.LogoUrl = string.Empty;
     if (!this.ValidationSettings(masterSettings))
     {
         return;
     }
     Hidistro.Membership.Context.SettingsManager.Save(masterSettings);
     this.LoadSiteContent(masterSettings);
 }
Ejemplo n.º 10
0
        private void btnDelete_Click(object sender, EventArgs e)
        {
            bool flag  = true;
            bool flag2 = true;

            foreach (DataListItem item in this.photoDataList.Controls)
            {
                CheckBox    box   = (CheckBox)item.FindControl("checkboxCol");
                HiddenField field = (HiddenField)item.FindControl("HiddenFieldImag");
                if ((box != null) && box.Checked)
                {
                    flag2 = false;
                    try
                    {
                        int photoId = (int)this.photoDataList.DataKeys[item.ItemIndex];
                        StoreHelper.DeleteImage(field.Value);
                        if (!GalleryHelper.DeletePhoto(photoId))
                        {
                            flag = false;
                        }
                        continue;
                    }
                    catch
                    {
                        this.ShowMsg("删除文件错误", false);
                        this.BindImageData();
                        continue;
                    }
                }
            }
            if (flag2)
            {
                this.ShowMsg("未选择删除的图片", false);
            }
            else
            {
                if (flag)
                {
                    this.ShowMsg("删除图片成功", true);
                }
                this.BindImageData();
            }
        }
Ejemplo n.º 11
0
        private void grdSKU_RowDeleting(object source, System.Web.UI.WebControls.GridViewDeleteEventArgs e)
        {
            int           num       = (int)this.grdSKU.DataKeys[e.RowIndex].Value;
            AttributeInfo attribute = ProductTypeHelper.GetAttribute(num);

            if (ProductTypeHelper.DeleteAttribute(num))
            {
                foreach (AttributeValueInfo current in attribute.AttributeValues)
                {
                    StoreHelper.DeleteImage(current.ImageUrl);
                }
                base.Response.Redirect(System.Web.HttpContext.Current.Request.Url.ToString(), true);
                return;
            }
            this.BindAttribute();
            string str = string.Format("ShowMsg(\"{0}\", {1});", "有商品在使用此规格,无法删除", "false");

            this.Page.ClientScript.RegisterStartupScript(base.GetType(), "ServerMessageScript2", "<script language='JavaScript' defer='defer'>setTimeout(function(){" + str + "},300);</script>");
        }
Ejemplo n.º 12
0
        private void grdAttributeValues_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    attributeValueId        = (int)this.grdAttributeValues.DataKeys[rowIndex].Value;
            int    displaySequence         = int.Parse((this.grdAttributeValues.Rows[rowIndex].FindControl("lblDisplaySequence") as System.Web.UI.WebControls.Literal).Text, System.Globalization.NumberStyles.None);
            string imageUrl                = e.CommandArgument.ToString();
            int    replaceAttributeValueId = 0;
            int    replaceDisplaySequence  = 0;

            if (e.CommandName == "Fall")
            {
                if (rowIndex < this.grdAttributeValues.Rows.Count - 1)
                {
                    replaceAttributeValueId = (int)this.grdAttributeValues.DataKeys[rowIndex + 1].Value;
                    replaceDisplaySequence  = int.Parse((this.grdAttributeValues.Rows[rowIndex + 1].FindControl("lblDisplaySequence") as System.Web.UI.WebControls.Literal).Text, System.Globalization.NumberStyles.None);
                }
            }
            else
            {
                if (e.CommandName == "Rise" && rowIndex > 0)
                {
                    replaceAttributeValueId = (int)this.grdAttributeValues.DataKeys[rowIndex - 1].Value;
                    replaceDisplaySequence  = int.Parse((this.grdAttributeValues.Rows[rowIndex - 1].FindControl("lblDisplaySequence") as System.Web.UI.WebControls.Literal).Text, System.Globalization.NumberStyles.None);
                }
            }
            if (e.CommandName == "dele")
            {
                if (ProductTypeHelper.DeleteAttributeValue(attributeValueId))
                {
                    StoreHelper.DeleteImage(imageUrl);
                }
                else
                {
                    this.ShowMsg("该规格下存在商品", false);
                }
            }
            if (replaceAttributeValueId > 0)
            {
                ProductTypeHelper.SwapAttributeValueSequence(attributeValueId, replaceAttributeValueId, displaySequence, replaceDisplaySequence);
            }
            this.BindData();
        }
Ejemplo n.º 13
0
        private void grdGroupList_RowDeleting(object sender, System.Web.UI.WebControls.GridViewDeleteEventArgs e)
        {
            int linkId = (int)this.grdGroupList.DataKeys[e.RowIndex].Value;
            FriendlyLinksInfo friendlyLink = StoreHelper.GetFriendlyLink(linkId);

            if (StoreHelper.FriendlyLinkDelete(linkId) > 0)
            {
                try
                {
                    StoreHelper.DeleteImage(friendlyLink.ImageUrl);
                }
                catch
                {
                }
                this.BindFriendlyLinks();
                this.ShowMsg("成功删除了选择的友情链接", true);
                return;
            }
            this.ShowMsg("未知错误", false);
        }
Ejemplo n.º 14
0
        /// <summary>
        /// 行删除
        /// </summary>
        /// <param name="source"></param>
        /// <param name="e"></param>
        protected void grdSKU_RowDeleting(object source, GridViewDeleteEventArgs e)
        {
            int           attributeId = (int)grdSKU.DataKeys[e.RowIndex].Value;
            AttributeInfo attribute   = ProductTypeHelper.GetAttribute(attributeId);

            if (ProductTypeHelper.DeleteAttribute(attributeId))
            {
                foreach (AttributeValueInfo info2 in attribute.AttributeValues)
                {
                    StoreHelper.DeleteImage(info2.ImageUrl);
                }
                base.Response.Redirect(HttpContext.Current.Request.Url.ToString(), true);
            }
            else
            {
                BindAttribute();
                string str = string.Format("ShowMsg(\"{0}\", {1});", "有商品在使用此规格,无法删除", "false");
                Page.ClientScript.RegisterStartupScript(base.GetType(), "ServerMessageScript2", "<script language='JavaScript' defer='defer'>setTimeout(function(){" + str + "},300);</script>");
            }
        }
Ejemplo n.º 15
0
        private void grdProductTypes_RowDeleting(object sender, System.Web.UI.WebControls.GridViewDeleteEventArgs e)
        {
            int typeId = (int)this.grdProductTypes.DataKeys[e.RowIndex].Value;

            System.Collections.Generic.IList <AttributeInfo> attributes = ProductTypeHelper.GetAttributes(typeId, AttributeUseageMode.Choose);
            if (ProductTypeHelper.DeleteProductType(typeId))
            {
                foreach (AttributeInfo current in attributes)
                {
                    foreach (AttributeValueInfo current2 in current.AttributeValues)
                    {
                        StoreHelper.DeleteImage(current2.ImageUrl);
                    }
                }
                this.BindTypes();
                this.ShowMsg("成功删除了一个商品类型", true);
                return;
            }
            this.ShowMsg("删除商品类型失败, 可能有商品正在使用该类型", false);
        }
Ejemplo n.º 16
0
        private void btnDelete_Click(object sender, System.EventArgs e)
        {
            bool flag  = true;
            bool flag2 = true;

            foreach (System.Web.UI.WebControls.DataListItem dataListItem in this.photoDataList.Controls)
            {
                System.Web.UI.WebControls.CheckBox    checkBox    = (System.Web.UI.WebControls.CheckBox)dataListItem.FindControl("checkboxCol");
                System.Web.UI.WebControls.HiddenField hiddenField = (System.Web.UI.WebControls.HiddenField)dataListItem.FindControl("HiddenFieldImag");
                if (checkBox != null && checkBox.Checked)
                {
                    flag2 = false;
                    try
                    {
                        int    photoId = (int)this.photoDataList.DataKeys[dataListItem.ItemIndex];
                        string value   = hiddenField.Value;
                        StoreHelper.DeleteImage(value);
                        if (!GalleryHelper.DeletePhoto(photoId))
                        {
                            flag = false;
                        }
                    }
                    catch
                    {
                        this.ShowMsg("删除文件错误", false);
                        this.BindImageData();
                    }
                }
            }
            if (flag2)
            {
                this.ShowMsg("未选择删除的图片", false);
                return;
            }
            if (flag)
            {
                this.ShowMsg("删除图片成功", true);
            }
            this.BindImageData();
        }
Ejemplo n.º 17
0
        private void grdProductTypes_RowDeleting(object sender, GridViewDeleteEventArgs e)
        {
            int typeId = (int)this.grdProductTypes.DataKeys[e.RowIndex].Value;
            IList <AttributeInfo> attributes = ProductTypeHelper.GetAttributes(typeId, AttributeUseageMode.Choose);

            if (ProductTypeHelper.DeleteProductType(typeId))
            {
                foreach (AttributeInfo info in attributes)
                {
                    foreach (AttributeValueInfo info2 in info.AttributeValues)
                    {
                        StoreHelper.DeleteImage(info2.ImageUrl);
                    }
                }
                this.BindTypes();
                this.ShowMsg("成功删除了一个商品类型", true);
            }
            else
            {
                this.ShowMsg("删除商品类型失败, 可能有商品正在使用该类型", false);
            }
        }
Ejemplo n.º 18
0
        private void grdGroupList_RowDeleting(object sender, GridViewDeleteEventArgs e)
        {
            int linkId = (int)grdGroupList.DataKeys[e.RowIndex].Value;
            FriendlyLinksInfo friendlyLink = StoreHelper.GetFriendlyLink(linkId);

            if (StoreHelper.FriendlyLinkDelete(linkId) > 0)
            {
                try
                {
                    StoreHelper.DeleteImage(friendlyLink.ImageUrl);
                }
                catch
                {
                }
                BindFriendlyLinks();
                ShowMsg("成功删除了选择的友情链接", true);
            }
            else
            {
                ShowMsg("未知错误", false);
            }
        }
Ejemplo n.º 19
0
        public void Delete(HttpContext context)
        {
            int value = base.GetIntParam(context, "id", false).Value;

            if (value < 1)
            {
                throw new HidistroAshxException("错误的参数");
            }
            FriendlyLinksInfo friendlyLink = StoreHelper.GetFriendlyLink(value);

            if (StoreHelper.FriendlyLinkDelete(value))
            {
                try
                {
                    StoreHelper.DeleteImage(friendlyLink.ImageUrl);
                }
                catch
                {
                }
                base.ReturnSuccessResult(context, "成功删除了选择的友情链接", 0, true);
                return;
            }
            throw new HidistroAshxException("未知错误");
        }
Ejemplo n.º 20
0
        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();
                }
            }
        }
Ejemplo n.º 21
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")
            {
                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>");
            }
        }
Ejemplo n.º 22
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);
         }
     }
 }
Ejemplo n.º 23
0
        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);
        }
Ejemplo n.º 24
0
        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();
                }
            }
        }