コード例 #1
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            string text  = Globals.StripAllTags(this.txtImageName.Text);
            string text2 = Globals.StripAllTags(this.txtDescription.Text);
            string value = this.hidOldImages.Value;
            int    num   = this.hidImageId.Value.ToInt(0);

            if (text.Trim() == "" || text.Length > 20)
            {
                this.ShowMsg("请输入图库名称,并且图库名称长度不能大于20个字符", false);
            }
            else if (text2.Trim() != "" && text2.Length > 100)
            {
                this.ShowMsg("使用说明长度不能大于100个字符", false);
            }
            else
            {
                MarketingImagesInfo marketingImagesInfo = new MarketingImagesInfo();
                if (num > 0)
                {
                    marketingImagesInfo = MarketingImagesHelper.GetMarketingImagesInfo(num);
                    if (marketingImagesInfo == null)
                    {
                        this.ShowMsg("错误的营销图库ID", false);
                        return;
                    }
                }
                marketingImagesInfo.ImageName   = text;
                marketingImagesInfo.Description = text2;
                if (this.hidOldImages.Value != this.hidUploadImages.Value)
                {
                    marketingImagesInfo.ImageUrl = base.UploadImage(this.hidUploadImages.Value, "depot");
                    this.hidOldImages.Value      = marketingImagesInfo.ImageUrl;
                }
                else
                {
                    marketingImagesInfo.ImageUrl = this.hidOldImages.Value;
                }
                if (marketingImagesInfo.ImageUrl.Trim() == "")
                {
                    this.ShowMsg("请上传图库图片", false);
                }
                else
                {
                    bool flag = false;
                    if ((num <= 0) ? (MarketingImagesHelper.AddMarketingImages(marketingImagesInfo) > 0) : MarketingImagesHelper.UpdateMarketingImages(marketingImagesInfo))
                    {
                        base.CloseWindow(num);
                        this.ShowMsgCloseWindow("营销图库" + ((num > 0) ? "编辑" : "添加") + "成功", true);
                    }
                    else
                    {
                        this.ShowMsg("营销图库" + ((num > 0) ? "编辑" : "添加") + "失败", false);
                    }
                }
            }
        }
コード例 #2
0
 protected override void AttachChildControls()
 {
     this.imgMarketing = (HtmlImage)this.FindControl("imgMarketing");
     int.TryParse(this.Page.Request.QueryString["storeId"], out this.storeId);
     int.TryParse(this.Page.Request.QueryString["imageId"], out this.imageId);
     if (this.storeId > 0 && this.imageId > 0)
     {
         MarketingImagesInfo marketingImagesInfo = MarketingImagesHelper.GetMarketingImagesInfo(this.imageId);
         if (marketingImagesInfo != null)
         {
             this.imgMarketing.Src = marketingImagesInfo.ImageUrl;
         }
     }
     PageTitle.AddSiteNameTitle("门店营销");
 }
コード例 #3
0
        private void bindImageInfo(int imageId)
        {
            MarketingImagesInfo marketingImagesInfo = MarketingImagesHelper.GetMarketingImagesInfo(imageId);

            if (marketingImagesInfo == null)
            {
                this.hidImageId.Value = "0";
            }
            else
            {
                this.btnSave.Text        = "保存";
                this.txtDescription.Text = marketingImagesInfo.Description;
                this.txtImageName.Text   = marketingImagesInfo.ImageName;
                this.hidOldImages.Value  = marketingImagesInfo.ImageUrl;
            }
        }
コード例 #4
0
 protected void Page_Load(object sender, EventArgs e)
 {
     try
     {
         int imageId = base.Request.QueryString["ImageId"].ToInt(0);
         int storeId = HiContext.Current.Manager.StoreId;
         MarketingImagesInfo marketingImagesInfo = MarketingImagesHelper.GetMarketingImagesInfo(imageId);
         if (marketingImagesInfo != null)
         {
             StoreMarketingImagesInfo      storeMarketingImages = MarketingImagesHelper.GetStoreMarketingImages(storeId, imageId);
             IList <StoreProductBaseModel> list = null;
             if (storeMarketingImages != null)
             {
                 string safeIDList = Globals.GetSafeIDList(storeMarketingImages.ProductIds, ',', true);
                 if (safeIDList != "")
                 {
                     list = StoresHelper.GetStoreProductBaseInfo(storeMarketingImages.ProductIds, storeId);
                 }
             }
             if (list == null)
             {
                 list = new List <StoreProductBaseModel>();
             }
             StringBuilder stringBuilder = new StringBuilder();
             for (int i = 0; i < list.Count; i++)
             {
                 if (stringBuilder.Length > 0)
                 {
                     stringBuilder.Insert(0, list[i].ProductId + "|||" + list[i].ProductName + ",,,");
                 }
                 else
                 {
                     stringBuilder.Append(list[i].ProductId + "|||" + list[i].ProductName);
                 }
             }
             this.hidSelectProducts.Value = stringBuilder.ToString();
             this.txtImageName.Value      = marketingImagesInfo.ImageName;
             this.txtDescription.Value    = marketingImagesInfo.Description;
             this.txtImageName.Disabled   = true;
             this.txtDescription.Disabled = true;
         }
     }
     catch (Exception ex)
     {
         base.Response.Write(ex.Message);
     }
 }
コード例 #5
0
        public void Delete(HttpContext context)
        {
            string text = context.Request.Form["ids"];

            if (string.IsNullOrEmpty(text))
            {
                throw new HidistroAshxException("请选择要删除的数据");
            }
            string[] array = text.Split(',');
            foreach (string obj in array)
            {
                MarketingImagesInfo marketingImagesInfo = MarketingImagesHelper.GetMarketingImagesInfo(obj.ToInt(0));
                if (marketingImagesInfo != null)
                {
                    string text2 = marketingImagesInfo.ImageUrl.ToNullString().ToLower();
                    if (!text2.StartsWith("http://") && !text2.StartsWith("https://") && File.Exists(context.Server.MapPath(marketingImagesInfo.ImageUrl)))
                    {
                        File.Delete(context.Server.MapPath(marketingImagesInfo.ImageUrl));
                    }
                    MarketingImagesHelper.DeleteMarketingImages(obj.ToInt(0));
                }
            }
            base.ReturnSuccessResult(context, "删除成功!", 0, true);
        }
コード例 #6
0
 public override void OnLoad(HttpContext context)
 {
     base.OnLoad(context);
     if (context.Request["flag"] == "Select")
     {
         int storeId = base.CurrentManager.StoreId;
         int num     = context.Request["pageIndex"].ToInt(0);
         if (num <= 0)
         {
             num = 1;
         }
         int num2 = context.Request["pageSize"].ToInt(0);
         if (num2 < 1)
         {
             num2 = 10;
         }
         MarketingImagesQuery marketingImagesQuery = new MarketingImagesQuery();
         marketingImagesQuery.PageIndex = num;
         marketingImagesQuery.PageSize  = num2;
         marketingImagesQuery.SortOrder = SortAction.Desc;
         marketingImagesQuery.SortBy    = "ImageId";
         PageModel <MarketingImagesInfo> marketingImages = MarketingImagesHelper.GetMarketingImages(marketingImagesQuery);
         string s = JsonConvert.SerializeObject(new
         {
             Result = new
             {
                 RecordCount = marketingImages.Total,
                 List        = from i in marketingImages.Models
                               select new
                 {
                     ImageId     = i.ImageId,
                     ImageName   = i.ImageName,
                     ImageUrl    = this.GetImageFullPath(i.ImageUrl),
                     Description = i.Description
                 }
             }
         });
         context.Response.Write(s);
         context.Response.End();
     }
     if (context.Request["flag"] == "Mdy")
     {
         int    storeId2 = base.CurrentManager.StoreId;
         int    imageId  = context.Request["ImageId"].ToInt(0);
         string idList   = context.Request["ProductIds"].ToNullString();
         MarketingImagesInfo marketingImagesInfo = MarketingImagesHelper.GetMarketingImagesInfo(imageId);
         if (marketingImagesInfo == null)
         {
             context.Response.Write(this.GetErrorJosn(701, ((Enum)(object)ApiErrorCode.ImageIdNotExists_Error).ToDescription()));
         }
         else
         {
             idList = Globals.GetSafeIDList(idList, ',', true);
             if (string.IsNullOrEmpty(idList))
             {
                 context.Response.Write(this.GetErrorJosn(101, ((Enum)(object)ApiErrorCode.Paramter_Error).ToDescription()));
             }
             else
             {
                 StoreMarketingImagesInfo storeMarketingImagesInfo = MarketingImagesHelper.GetStoreMarketingImages(storeId2, imageId);
                 string text = "";
                 if (storeMarketingImagesInfo != null)
                 {
                     string safeIDList = Globals.GetSafeIDList(storeMarketingImagesInfo.ProductIds, ',', true);
                     if (safeIDList != "")
                     {
                         string[] array = idList.Split(',');
                         foreach (string str in array)
                         {
                             if (!("," + safeIDList + ",").Contains("," + str + ","))
                             {
                                 text = text + str + ",";
                             }
                         }
                     }
                 }
                 else
                 {
                     storeMarketingImagesInfo         = new StoreMarketingImagesInfo();
                     storeMarketingImagesInfo.StoreId = storeId2;
                     storeMarketingImagesInfo.ImageId = imageId;
                 }
                 if (!string.IsNullOrEmpty(text))
                 {
                     StoreMarketingImagesInfo storeMarketingImagesInfo2 = storeMarketingImagesInfo;
                     storeMarketingImagesInfo2.ProductIds += ("," + text).TrimEnd(',');
                 }
                 else
                 {
                     storeMarketingImagesInfo.ProductIds = idList.TrimEnd(',');
                 }
                 MarketingImagesHelper.UpdateStoreMarketingImages(storeMarketingImagesInfo);
                 string s2 = JsonConvert.SerializeObject(new
                 {
                     Result = new
                     {
                         Success = new
                         {
                             Status = true,
                             Msg    = string.Empty
                         }
                     }
                 });
                 context.Response.Write(s2);
                 context.Response.End();
             }
         }
     }
 }
コード例 #7
0
 public static int AddMarketingImages(MarketingImagesInfo model)
 {
     return(new MarketingImagesDao().Add(model, null).ToInt(0));
 }
コード例 #8
0
 public static bool UpdateMarketingImages(MarketingImagesInfo model)
 {
     return(new MarketingImagesDao().Update(model, null));
 }