private void btnDeleteLogo_Click(object sender, EventArgs e) { string filename = HttpContext.Current.Request.MapPath(Globals.ApplicationPath + string.Format("/Templates/sites/{0}/{1}/ProductSubjects.xml", HiContext.Current.User.UserId, themName)); XmlDocument document = new XmlDocument(); document.Load(filename); XmlNode entity = document.SelectSingleNode("root/Subject[SubjectId='" + subjectId + "']"); try { if (!((entity.SelectSingleNode("SubjectImg") == null) || string.IsNullOrEmpty(entity.SelectSingleNode("SubjectImg").InnerText))) { ResourcesHelper.DeleteImage(entity.SelectSingleNode("SubjectImg").InnerText); } entity.SelectSingleNode("SubjectImg").InnerText = ""; ViewState["Logo"] = null; Globals.EntityCoding(entity, true); document.Save(filename); HiCache.Remove("ProductSubjectFileCache-Admin"); } catch { ShowMsg("删除失败", false); return; } BindControl(entity); }
private void btnUpoad_Click(object sender, EventArgs e) { string filename = HttpContext.Current.Request.MapPath(Globals.ApplicationPath + string.Format("/Templates/sites/{0}/{1}/ProductSubjects.xml", HiContext.Current.User.UserId, themName)); XmlDocument document = new XmlDocument(); document.Load(filename); XmlNode entity = document.SelectSingleNode("root/Subject[SubjectId='" + subjectId + "']"); if (fileUpload.HasFile && (entity != null)) { try { if (entity.SelectSingleNode("SubjectImg").InnerText != "") { ResourcesHelper.DeleteImage(entity.SelectSingleNode("SubjectImg").InnerText); } entity.SelectSingleNode("SubjectImg").InnerText = UploadSubjectImg(fileUpload.PostedFile); ViewState["Logo"] = entity.SelectSingleNode("SubjectImg").InnerText; } catch { ShowMsg("图片上传失败,您选择的不是图片类型的文件,或者网站的虚拟目录没有写入文件的权限", false); return; } Globals.EntityCoding(entity, true); document.Save(filename); HiCache.Remove("ProductSubjectFileCache-Admin"); } BindControl(entity); }
private void grdArticleCategories_RowCommand(object sender, GridViewCommandEventArgs e) { int rowIndex = ((GridViewRow)((Control)e.CommandSource).NamingContainer).RowIndex; int categoryId = (int)this.grdArticleCategories.DataKeys[rowIndex].Value; int displaySequence = int.Parse((this.grdArticleCategories.Rows[rowIndex].FindControl("lblDisplaySequence") as Literal).Text); int replaceCategoryId = 0; int replaceDisplaySequence = 0; if (e.CommandName == "Fall") { if (rowIndex < (this.grdArticleCategories.Rows.Count - 1)) { replaceCategoryId = (int)this.grdArticleCategories.DataKeys[rowIndex + 1].Value; replaceDisplaySequence = int.Parse((this.grdArticleCategories.Rows[rowIndex + 1].FindControl("lblDisplaySequence") as Literal).Text); } } else if ((e.CommandName == "Rise") && (rowIndex > 0)) { replaceCategoryId = (int)this.grdArticleCategories.DataKeys[rowIndex - 1].Value; replaceDisplaySequence = int.Parse((this.grdArticleCategories.Rows[rowIndex - 1].FindControl("lblDisplaySequence") as Literal).Text); } if (replaceCategoryId > 0) { ArticleHelper.SwapArticleCategorySequence(categoryId, replaceCategoryId, displaySequence, replaceDisplaySequence); } if (e.CommandName == "Delete") { ArticleCategoryInfo articleCategory = ArticleHelper.GetArticleCategory(categoryId); if (ArticleHelper.DeleteArticleCategory(categoryId)) { ResourcesHelper.DeleteImage(articleCategory.IconUrl); } } base.Response.Redirect(HttpContext.Current.Request.Url.ToString(), true); }
private void btnAddArticle_Click(object sender, System.EventArgs e) { if (!this.dropArticleCategory.SelectedValue.HasValue) { this.ShowMsg("请选择文章分类", false); return; } ArticleInfo article = ArticleHelper.GetArticle(this.articleId); if (this.fileUpload.HasFile) { try { ResourcesHelper.DeleteImage(article.IconUrl); article.IconUrl = ArticleHelper.UploadArticleImage(this.fileUpload.PostedFile); this.imgPic.ImageUrl = article.IconUrl; } catch { this.ShowMsg("图片上传失败,您选择的不是图片类型的文件,或者网站的虚拟目录没有写入文件的权限", false); return; } } article.ArticleId = this.articleId; article.CategoryId = this.dropArticleCategory.SelectedValue.Value; article.Title = this.txtArticleTitle.Text.Trim(); article.MetaDescription = this.txtMetaDescription.Text.Trim(); article.MetaKeywords = this.txtMetaKeywords.Text.Trim(); article.Description = this.txtShortDesc.Text.Trim(); article.Content = this.fcContent.Text; article.AddedDate = System.DateTime.Now; article.IsRelease = this.ckrrelease.Checked; ValidationResults validationResults = Validation.Validate <ArticleInfo>(article, new string[] { "ValArticleInfo" }); string text = string.Empty; if (!validationResults.IsValid) { foreach (ValidationResult current in (System.Collections.Generic.IEnumerable <ValidationResult>)validationResults) { text += Formatter.FormatErrorMessage(current.Message); } this.ShowMsg(text, false); } else { if (ArticleHelper.UpdateArticle(article)) { this.ShowMsg("已经成功修改当前文章", true); return; } this.ShowMsg("修改文章失败", false); return; } }
protected void btnUpdateTopic_Click(object sender, System.EventArgs e) { TopicInfo topic = VShopHelper.Gettopic(this.topicId); if (topic.Keys != this.txtKeys.Text.Trim() && ReplyHelper.HasReplyKey(this.txtKeys.Text.Trim())) { this.ShowMsg("关键字重复!", false); } else { if (this.fileUpload.HasFile) { try { ResourcesHelper.DeleteImage(topic.IconUrl); topic.IconUrl = VShopHelper.UploadTopicImage(this.fileUpload.PostedFile); this.imgPic.ImageUrl = topic.IconUrl; } catch { this.ShowMsg("图片上传失败,您选择的不是图片类型的文件,或者网站的虚拟目录没有写入文件的权限", false); return; } } topic.TopicId = this.topicId; topic.Title = this.txtTopicTitle.Text.Trim(); topic.Keys = this.txtKeys.Text.Trim(); topic.IconUrl = topic.IconUrl; topic.Content = this.fcContent.Text; topic.AddedDate = System.DateTime.Now; topic.IsRelease = true; ValidationResults results = Validation.Validate <TopicInfo>(topic, new string[] { "ValTopicInfo" }); string msg = string.Empty; if (results.IsValid) { if (VShopHelper.Updatetopic(topic)) { this.ShowMsg("已经成功修改当前专题", true); } else { this.ShowMsg("修改专题失败", false); } } else { foreach (ValidationResult result in (System.Collections.Generic.IEnumerable <ValidationResult>)results) { msg += Formatter.FormatErrorMessage(result.Message); } this.ShowMsg(msg, false); } } }
private void btnAddArticle_Click(object sender, EventArgs e) { if (!dropArticleCategory.SelectedValue.HasValue) { ShowMsg("请选择文章分类", false); } else { ArticleInfo article = ArticleHelper.GetArticle(articleId); if (fileUpload.HasFile) { try { ResourcesHelper.DeleteImage(article.IconUrl); article.IconUrl = ArticleHelper.UploadArticleImage(fileUpload.PostedFile); imgPic.ImageUrl = article.IconUrl; } catch { ShowMsg("图片上传失败,您选择的不是图片类型的文件,或者网站的虚拟目录没有写入文件的权限", false); return; } } article.ArticleId = articleId; article.CategoryId = dropArticleCategory.SelectedValue.Value; article.Title = txtArticleTitle.Text.Trim(); article.MetaDescription = txtMetaDescription.Text.Trim(); article.MetaKeywords = txtMetaKeywords.Text.Trim(); article.Description = txtShortDesc.Text.Trim(); article.Content = fcContent.Text; article.AddedDate = DateTime.Now; article.IsRelease = ckrrelease.Checked; ValidationResults results = Hishop.Components.Validation.Validation.Validate <ArticleInfo>(article, new string[] { "ValArticleInfo" }); string msg = string.Empty; if (results.IsValid) { if (ArticleHelper.UpdateArticle(article)) { ShowMsg("已经成功修改当前文章", true); } else { ShowMsg("修改文章失败", false); } } else { foreach (ValidationResult result in (IEnumerable <ValidationResult>)results) { msg = msg + Formatter.FormatErrorMessage(result.Message); } ShowMsg(msg, false); } } }
private void btnPicDelete_Click(object sender, System.EventArgs e) { SiteSettings masterSettings = SettingsManager.GetMasterSettings(false); if (!string.IsNullOrEmpty(masterSettings.WeiXinCodeImageUrl)) { ResourcesHelper.DeleteImage(masterSettings.WeiXinCodeImageUrl); this.btnPicDelete.Visible = false; masterSettings.WeiXinCodeImageUrl = (this.imgPic.ImageUrl = string.Empty); SettingsManager.Save(masterSettings); } }
protected void btnPicDelete_Click(object sender, System.EventArgs e) { try { ResourcesHelper.DeleteImage(this.imgPic.ImageUrl); this.imgPic.ImageUrl = ""; this.btnPicDelete.Visible = !string.IsNullOrEmpty(this.imgPic.ImageUrl); this.imgPic.Visible = !string.IsNullOrEmpty(this.imgPic.ImageUrl); } catch { } }
private void Delete(HttpContext context) { int num = context.Request["ids"].ToInt(0); ArticleCategoryInfo articleCategory = ArticleHelper.GetArticleCategory(num); if (ArticleHelper.DeleteCategorys(new List <int> { num }) > 0) { ResourcesHelper.DeleteImage(articleCategory.IconUrl); base.ReturnSuccessResult(context, "成功删除分类!", 0, true); } }
private void btnPicDelete_Click(object sender, EventArgs e) { SiteSettings masterSettings = SettingsManager.GetMasterSettings(); if (!string.IsNullOrEmpty(masterSettings.WeiXinCodeImageUrl)) { ResourcesHelper.DeleteImage(masterSettings.WeiXinCodeImageUrl); this.btnPicDelete.Visible = false; SiteSettings siteSettings = masterSettings; HiImage hiImage = this.imgPic; string text2 = siteSettings.WeiXinCodeImageUrl = (hiImage.ImageUrl = string.Empty); SettingsManager.Save(masterSettings); } }
private void grdArticleCategories_RowDeleting(object sender, System.Web.UI.WebControls.GridViewDeleteEventArgs e) { int categoryId = (int)this.grdArticleCategories.DataKeys[e.RowIndex].Value; ArticleCategoryInfo articleCategory = SubsiteCommentsHelper.GetArticleCategory(categoryId); if (SubsiteCommentsHelper.DeleteArticleCategory(categoryId)) { ResourcesHelper.DeleteImage(articleCategory.IconUrl); this.ShowMsg("成功删除了指定的文章分类", true); } else { this.ShowMsg("未知错误", false); } this.BindArticleCategory(); }
private void grdArticleCategories_RowDeleting(object sender, GridViewDeleteEventArgs e) { int categoryId = (int)grdArticleCategories.DataKeys[e.RowIndex].Value; ArticleCategoryInfo articleCategory = ArticleHelper.GetArticleCategory(categoryId); if (ArticleHelper.DeleteArticleCategory(categoryId)) { ResourcesHelper.DeleteImage(articleCategory.IconUrl); ShowMsg("成功删除了指定的文章分类", true); } else { ShowMsg("未知错误", false); } BindArticleCategory(); }
private void btnSubmitHelpCategory_Click(object sender, System.EventArgs e) { string text = string.Empty; text = ArticleHelper.GetHelpCategory(this.categoryId).IconUrl; if (this.fileUpload.HasFile) { try { if (!string.IsNullOrEmpty(text)) { ResourcesHelper.DeleteImage(text); } text = ArticleHelper.UploadHelpImage(this.fileUpload.PostedFile); } catch { this.ShowMsg("图片上传失败,您选择的不是图片类型的文件,或者网站的虚拟目录没有写入文件的权限", false); return; } } HelpCategoryInfo helpCategoryInfo = new HelpCategoryInfo(); helpCategoryInfo.CategoryId = new int?(this.categoryId); helpCategoryInfo.Name = this.txtHelpCategoryName.Text.Trim(); helpCategoryInfo.IconUrl = text; helpCategoryInfo.Description = this.txtHelpCategoryDesc.Text.Trim(); helpCategoryInfo.IsShowFooter = this.radioShowFooter.SelectedValue; ValidationResults validationResults = Validation.Validate <HelpCategoryInfo>(helpCategoryInfo, new string[] { "ValHelpCategoryInfo" }); string text2 = string.Empty; if (validationResults.IsValid) { this.UpdateCategory(helpCategoryInfo); return; } foreach (ValidationResult current in (System.Collections.Generic.IEnumerable <ValidationResult>)validationResults) { text2 += Formatter.FormatErrorMessage(current.Message); } this.ShowMsg(text2, false); }
private void btnSubmitHelpCategory_Click(object sender, EventArgs e) { string iconUrl = string.Empty; iconUrl = SubsiteCommentsHelper.GetHelpCategory(this.categoryId).IconUrl; if (this.fileUpload.HasFile) { try { if (!string.IsNullOrEmpty(iconUrl)) { ResourcesHelper.DeleteImage(iconUrl); } iconUrl = SubsiteCommentsHelper.UploadHelpImage(this.fileUpload.PostedFile); } catch { this.ShowMsg("图片上传失败,您选择的不是图片类型的文件,或者网站的虚拟目录没有写入文件的权限", false); return; } } HelpCategoryInfo info2 = new HelpCategoryInfo(); info2.CategoryId = new int?(this.categoryId); info2.Name = this.txtHelpCategoryName.Text.Trim(); info2.IconUrl = iconUrl; info2.Description = this.txtHelpCategoryDesc.Text.Trim(); info2.IsShowFooter = this.radioShowFooter.SelectedValue; HelpCategoryInfo target = info2; ValidationResults results = Hishop.Components.Validation.Validation.Validate <HelpCategoryInfo>(target, new string[] { "ValHelpCategoryInfo" }); string msg = string.Empty; if (results.IsValid) { this.UpdateCategory(target); } else { foreach (ValidationResult result in (IEnumerable <ValidationResult>)results) { msg = msg + Formatter.FormatErrorMessage(result.Message); } this.ShowMsg(msg, false); } }
protected void btnPicDelete_Click(object sender, System.EventArgs e) { TopicInfo topicInfo = VShopHelper.Gettopic(this.topicId); try { ResourcesHelper.DeleteImage(topicInfo.IconUrl); } catch { } topicInfo.IconUrl = (this.imgPic.ImageUrl = null); if (VShopHelper.Updatetopic(topicInfo)) { this.btnPicDelete.Visible = !string.IsNullOrEmpty(this.imgPic.ImageUrl); this.imgPic.Visible = !string.IsNullOrEmpty(this.imgPic.ImageUrl); } }
private void btnPicDelete_Click(object sender, System.EventArgs e) { ArticleInfo article = SubsiteCommentsHelper.GetArticle(this.articleId); try { ResourcesHelper.DeleteImage(article.IconUrl); } catch { } article.IconUrl = (this.imgPic.ImageUrl = null); if (SubsiteCommentsHelper.UpdateArticle(article)) { this.btnPicDelete.Visible = !string.IsNullOrEmpty(this.imgPic.ImageUrl); this.imgPic.Visible = !string.IsNullOrEmpty(this.imgPic.ImageUrl); } }
private void btnPicDelete_Click(object sender, System.EventArgs e) { CategoryInfo category = SubsiteCatalogHelper.GetCategory(this.categoryId); try { ResourcesHelper.DeleteImage(category.Icon); } catch { } category.Icon = (this.imgPic.ImageUrl = null); if (SubsiteCatalogHelper.UpdateCategory(category) == CategoryActionStatus.Success) { this.btnPicDelete.Visible = !string.IsNullOrEmpty(this.imgPic.ImageUrl); this.imgPic.Visible = !string.IsNullOrEmpty(this.imgPic.ImageUrl); } }
private void btnDeleteLogo_Click(object sender, System.EventArgs e) { BrandCategoryInfo brandCategoryInfo = this.GetBrandCategoryInfo(); try { ResourcesHelper.DeleteImage(brandCategoryInfo.Logo); brandCategoryInfo.Logo = null; this.ViewState["Logo"] = null; CatalogHelper.UpdateBrandCategory(brandCategoryInfo); } catch { this.ShowMsg("删除失败", false); return; } this.loadData(); }
private void btnPicDelete_Click(object sender, System.EventArgs e) { ArticleCategoryInfo articleCategory = ArticleHelper.GetArticleCategory(this.categoryId); try { ResourcesHelper.DeleteImage(articleCategory.IconUrl); } catch { } articleCategory.IconUrl = (this.imgPic.ImageUrl = null); if (ArticleHelper.UpdateArticleCategory(articleCategory)) { this.btnPicDelete.Visible = !string.IsNullOrEmpty(this.imgPic.ImageUrl); this.imgPic.Visible = !string.IsNullOrEmpty(this.imgPic.ImageUrl); } }
private void btnPicDelete_Click(object sender, EventArgs e) { ArticleInfo article = ArticleHelper.GetArticle(articleId); try { ResourcesHelper.DeleteImage(article.IconUrl); } catch { } article.IconUrl = (string)(imgPic.ImageUrl = null); if (ArticleHelper.UpdateArticle(article)) { btnPicDelete.Visible = !string.IsNullOrEmpty(imgPic.ImageUrl); imgPic.Visible = !string.IsNullOrEmpty(imgPic.ImageUrl); } }
private void btnPicDelete_Click(object sender, EventArgs e) { HelpCategoryInfo helpCategory = ArticleHelper.GetHelpCategory(this.categoryId); try { ResourcesHelper.DeleteImage(helpCategory.IconUrl); } catch { } helpCategory.IconUrl = this.imgPic.ImageUrl = string.Empty; if (ArticleHelper.UpdateHelpCategory(helpCategory)) { this.btnPicDelete.Visible = !string.IsNullOrEmpty(this.imgPic.ImageUrl); this.imgPic.Visible = !string.IsNullOrEmpty(this.imgPic.ImageUrl); } }
private void btnUpoad_Click(object sender, System.EventArgs e) { BrandCategoryInfo brandCategoryInfo = this.GetBrandCategoryInfo(); try { ResourcesHelper.DeleteImage(brandCategoryInfo.Logo); brandCategoryInfo.Logo = CatalogHelper.UploadBrandCategorieImage(this.fileUpload.PostedFile); this.ViewState["Logo"] = brandCategoryInfo.Logo; } catch { this.ShowMsg("图片上传失败,您选择的不是图片类型的文件,或者网站的虚拟目录没有写入文件的权限", false); return; } CatalogHelper.UpdateBrandCategory(brandCategoryInfo); this.loadData(); }
private void btnSubmitArticleCategory_Click(object sender, System.EventArgs e) { ArticleCategoryInfo articleCategory = ArticleHelper.GetArticleCategory(this.categoryId); if (articleCategory == null) { return; } if (this.fileUpload.HasFile) { try { ResourcesHelper.DeleteImage(articleCategory.IconUrl); articleCategory.IconUrl = ArticleHelper.UploadArticleImage(this.fileUpload.PostedFile); } catch { this.ShowMsg("图片上传失败,您选择的不是图片类型的文件,或者网站的虚拟目录没有写入文件的权限", false); return; } } articleCategory.Name = this.txtArticleCategoryiesName.Text.Trim(); articleCategory.Description = this.txtArticleCategoryiesDesc.Text.Trim(); ValidationResults validationResults = Validation.Validate <ArticleCategoryInfo>(articleCategory, new string[] { "ValArticleCategoryInfo" }); string text = string.Empty; if (validationResults.IsValid) { this.UpdateCategory(articleCategory); return; } foreach (ValidationResult current in (System.Collections.Generic.IEnumerable <ValidationResult>)validationResults) { text += Formatter.FormatErrorMessage(current.Message); } this.ShowMsg(text, false); }
private void btnUpoad_Click(object sender, System.EventArgs e) { SiteSettings masterSettings = SettingsManager.GetMasterSettings(false); if (this.fileUpload.HasFile) { try { if (!string.IsNullOrEmpty(masterSettings.WeiXinCodeImageUrl)) { ResourcesHelper.DeleteImage(masterSettings.WeiXinCodeImageUrl); } this.imgPic.ImageUrl = (masterSettings.WeiXinCodeImageUrl = VShopHelper.UploadWeiXinCodeImage(this.fileUpload.PostedFile)); this.btnPicDelete.Visible = true; SettingsManager.Save(masterSettings); } catch { this.ShowMsg("图片上传失败,您选择的不是图片类型的文件,或者网站的虚拟目录没有写入文件的权限", false); } } }
private void btnSubmitArticleCategory_Click(object sender, EventArgs e) { ArticleCategoryInfo articleCategory = ArticleHelper.GetArticleCategory(categoryId); if (articleCategory != null) { if (fileUpload.HasFile) { try { ResourcesHelper.DeleteImage(articleCategory.IconUrl); articleCategory.IconUrl = ArticleHelper.UploadArticleImage(fileUpload.PostedFile); } catch { ShowMsg("图片上传失败,您选择的不是图片类型的文件,或者网站的虚拟目录没有写入文件的权限", false); return; } } articleCategory.Name = txtArticleCategoryiesName.Text.Trim(); articleCategory.Description = txtArticleCategoryiesDesc.Text.Trim(); ValidationResults results = Hishop.Components.Validation.Validation.Validate <ArticleCategoryInfo>(articleCategory, new string[] { "ValArticleCategoryInfo" }); string msg = string.Empty; if (results.IsValid) { UpdateCategory(articleCategory); } else { foreach (ValidationResult result in (IEnumerable <ValidationResult>)results) { msg = msg + Formatter.FormatErrorMessage(result.Message); } ShowMsg(msg, false); } } }
private void btnSaveCategory_Click(object sender, System.EventArgs e) { CategoryInfo category = CatalogHelper.GetCategory(this.categoryId); if (category == null) { this.ShowMsg("编缉商品分类错误,未知", false); return; } if (this.fileUpload.HasFile) { try { ResourcesHelper.DeleteImage(category.Icon); category.IconUrl = CatalogHelper.UploadCategoryIcon(this.fileUpload.PostedFile); } catch { this.ShowMsg("图片上传失败,您选择的不是图片类型的文件,或者网站的虚拟目录没有写入文件的权限", false); return; } } else { category.IconUrl = category.Icon; } category.Name = this.txtCategoryName.Text; category.SKUPrefix = this.txtSKUPrefix.Text; category.RewriteName = this.txtRewriteName.Text; category.MetaTitle = this.txtPageKeyTitle.Text; category.MetaKeywords = this.txtPageKeyWords.Text; category.MetaDescription = this.txtPageDesc.Text; category.AssociatedProductType = this.dropProductTypes.SelectedValue; category.Notes1 = this.fckNotes1.Text; //category.TaxRateId = this.dropTaxRate.SelectedValue; category.CategoryType = (CategoryType)System.Enum.Parse(typeof(CategoryType), this.ddlType.SelectedValue); int isIdsadble = 0; int.TryParse(this.radioButton.SelectedValue, out isIdsadble); category.IsDisable = isIdsadble; category.Notes2 = this.fckNotes2.Text; category.Notes3 = this.fckNotes3.Text; if (category.Depth > 1) { CategoryInfo category2 = CatalogHelper.GetCategory(category.ParentCategoryId.Value); if (string.IsNullOrEmpty(category.Notes1)) { category.Notes1 = category2.Notes1; } if (string.IsNullOrEmpty(category.Notes2)) { category.Notes2 = category2.Notes2; } if (string.IsNullOrEmpty(category.Notes3)) { category.Notes3 = category2.Notes3; } } ValidationResults validationResults = Validation.Validate <CategoryInfo>(category, new string[] { "ValCategory" }); string text = string.Empty; if (!validationResults.IsValid) { foreach (ValidationResult current in (System.Collections.Generic.IEnumerable <ValidationResult>)validationResults) { text += Formatter.FormatErrorMessage(current.Message); } this.ShowMsg(text, false); } else { CategoryActionStatus categoryActionStatus = CatalogHelper.UpdateCategory(category); if (categoryActionStatus == CategoryActionStatus.Success) { base.Response.Redirect(Globals.GetAdminAbsolutePath("/product/ManageCategories.aspx"), true); return; } if (categoryActionStatus == CategoryActionStatus.UpdateParentError) { this.ShowMsg("不能自己成为自己的上级分类", false); return; } this.ShowMsg("编缉商品分类错误,未知", false); return; } }
private void btnEditVote_Click(object sender, EventArgs e) { if (StoreHelper.GetVoteCounts(this.voteId) > 0) { this.ShowMsg("投票已经开始,不能再对投票选项进行任何操作", false); } else { VoteInfo voteById = StoreHelper.GetVoteById(this.voteId); if ((voteById.Keys != this.txtKeys.Text.Trim()) && ReplyHelper.HasReplyKey(this.txtKeys.Text.Trim())) { this.ShowMsg("关键字重复!", false); } else { if (this.fileUpload.HasFile) { try { ResourcesHelper.DeleteImage(voteById.ImageUrl); this.imgPic.ImageUrl = voteById.ImageUrl = StoreHelper.UploadVoteImage(this.fileUpload.PostedFile); } catch { this.ShowMsg("图片上传失败,您选择的不是图片类型的文件,或者网站的虚拟目录没有写入文件的权限", false); return; } } voteById.VoteName = Globals.HtmlEncode(this.txtAddVoteName.Text.Trim()); voteById.Keys = this.txtKeys.Text.Trim(); int result = 1; if (int.TryParse(this.txtMaxCheck.Text.Trim(), out result)) { voteById.MaxCheck = result; } voteById.StartDate = this.calendarStartDate.SelectedDate.Value; voteById.EndDate = this.calendarEndDate.SelectedDate.Value; IList <VoteItemInfo> list = null; if (!string.IsNullOrEmpty(this.txtValues.Text.Trim())) { list = new List <VoteItemInfo>(); string[] strArray = this.txtValues.Text.Trim().Replace("\r\n", "\n").Replace("\n", "*").Split(new char[] { '*' }); for (int i = 0; i < strArray.Length; i++) { VoteItemInfo item = new VoteItemInfo(); if (strArray[i].Length > 60) { this.ShowMsg("投票选项长度限制在60个字符以内", false); return; } item.VoteItemName = Globals.HtmlEncode(strArray[i]); list.Add(item); } } else { this.ShowMsg("投票选项不能为空", false); return; } voteById.VoteItems = list; if (this.ValidationVote(voteById)) { if (StoreHelper.UpdateVote(voteById)) { this.ShowMsg("修改投票成功", true); } else { this.ShowMsg("修改投票失败", false); } } } } }
protected void btnPicDelete_Click(object sender, System.EventArgs e) { TopicInfo topicInfo = VShopHelper.Gettopic(this.topicId); ImageLinkButton button = sender as ImageLinkButton; string arg = string.Empty; if (button != null) { arg = button.CommandArgument; } switch (arg) { case "pic": try { ResourcesHelper.DeleteImage(topicInfo.IconUrl); } catch { } topicInfo.IconUrl = (this.imgPic.ImageUrl = null); if (VShopHelper.Updatetopic(topicInfo)) { this.btnPicDelete.Visible = !string.IsNullOrEmpty(this.imgPic.ImageUrl); this.imgPic.Visible = !string.IsNullOrEmpty(this.imgPic.ImageUrl); } break; case "mobile_list": try { ResourcesHelper.DeleteImage(topicInfo.MobileListImageUrl); } catch { } topicInfo.MobileListImageUrl = (this.imgMobileList.ImageUrl = null); if (VShopHelper.Updatetopic(topicInfo)) { this.btnDeleteMobileListImg.Visible = !string.IsNullOrEmpty(this.imgMobileList.ImageUrl); this.imgMobileList.Visible = !string.IsNullOrEmpty(this.imgMobileList.ImageUrl); } break; case "mobile_banner": try { ResourcesHelper.DeleteImage(topicInfo.MobileBannerImageUrl); } catch { } topicInfo.MobileBannerImageUrl = (this.imgMobileBanner.ImageUrl = null); if (VShopHelper.Updatetopic(topicInfo)) { this.btnDeleteMobileBannerImg.Visible = !string.IsNullOrEmpty(this.imgMobileBanner.ImageUrl); this.imgMobileBanner.Visible = !string.IsNullOrEmpty(this.imgMobileBanner.ImageUrl); } break; case "pc_list": try { ResourcesHelper.DeleteImage(topicInfo.PCListImageUrl); } catch { } topicInfo.PCListImageUrl = (this.imgPcList.ImageUrl = null); if (VShopHelper.Updatetopic(topicInfo)) { this.btnDeletePcBannerImg.Visible = !string.IsNullOrEmpty(this.imgPcList.ImageUrl); this.imgPcList.Visible = !string.IsNullOrEmpty(this.imgPcList.ImageUrl); } break; case "pc_banner": try { ResourcesHelper.DeleteImage(topicInfo.PCBannerImageUrl); } catch { } topicInfo.PCBannerImageUrl = (this.imgPcBanner.ImageUrl = null); if (VShopHelper.Updatetopic(topicInfo)) { this.btnDeletePcBannerImg.Visible = !string.IsNullOrEmpty(this.imgPcBanner.ImageUrl); this.imgPcBanner.Visible = !string.IsNullOrEmpty(this.imgPcBanner.ImageUrl); } break; default: break; } }
protected void btnUpdateTopic_Click(object sender, System.EventArgs e) { TopicInfo topicInfo = VShopHelper.Gettopic(this.topicId); if (this.fileUpload.HasFile) { try { ResourcesHelper.DeleteImage(topicInfo.IconUrl); topicInfo.IconUrl = VShopHelper.UploadTopicImage(this.fileUpload.PostedFile); this.imgPic.ImageUrl = topicInfo.IconUrl; } catch { this.ShowMsg("图片上传失败,您选择的不是图片类型的文件,或者网站的虚拟目录没有写入文件的权限", false); return; } } if (this.fileUploadMobileListImg.HasFile) { try { ResourcesHelper.DeleteImage(topicInfo.MobileListImageUrl); topicInfo.MobileListImageUrl = VShopHelper.UploadTopicImage(this.fileUploadMobileListImg.PostedFile); this.imgMobileList.ImageUrl = topicInfo.MobileListImageUrl; } catch { this.ShowMsg("移动端列表图片上传失败,您选择的不是图片类型的文件,或者网站的虚拟目录没有写入文件的权限", false); return; } } if (this.fileUploadMobileBannerImg.HasFile) { try { ResourcesHelper.DeleteImage(topicInfo.MobileBannerImageUrl); topicInfo.MobileBannerImageUrl = VShopHelper.UploadTopicImage(this.fileUploadMobileBannerImg.PostedFile); this.imgMobileList.ImageUrl = topicInfo.MobileBannerImageUrl; } catch { this.ShowMsg("移动端Banner图片上传失败,您选择的不是图片类型的文件,或者网站的虚拟目录没有写入文件的权限", false); return; } } if (this.fileUploadPCListImg.HasFile) { try { ResourcesHelper.DeleteImage(topicInfo.PCListImageUrl); topicInfo.PCListImageUrl = VShopHelper.UploadTopicImage(this.fileUploadPCListImg.PostedFile); this.imgPcList.ImageUrl = topicInfo.PCListImageUrl; } catch { this.ShowMsg("PC端列表图片上传失败,您选择的不是图片类型的文件,或者网站的虚拟目录没有写入文件的权限", false); return; } } if (this.fileUploadPCBannerImg.HasFile) { try { ResourcesHelper.DeleteImage(topicInfo.PCBannerImageUrl); topicInfo.PCBannerImageUrl = VShopHelper.UploadTopicImage(this.fileUploadPCBannerImg.PostedFile); this.imgPcBanner.ImageUrl = topicInfo.PCBannerImageUrl; } catch { this.ShowMsg("PC端Banner图片上传失败,您选择的不是图片类型的文件,或者网站的虚拟目录没有写入文件的权限", false); return; } } topicInfo.TopicId = this.topicId; topicInfo.Title = this.txtTopicTitle.Text.Trim(); topicInfo.Keys = ""; //topicInfo.IconUrl = topicInfo.IconUrl; topicInfo.Content = this.fcContent.Text; topicInfo.AddedDate = System.DateTime.Now; topicInfo.IsRelease = true; ValidationResults validationResults = Validation.Validate <TopicInfo>(topicInfo, new string[] { "ValTopicInfo" }); string text = string.Empty; if (!validationResults.IsValid) { foreach (ValidationResult current in (System.Collections.Generic.IEnumerable <ValidationResult>)validationResults) { text += Formatter.FormatErrorMessage(current.Message); } this.ShowMsg(text, false); } else { if (VShopHelper.Updatetopic(topicInfo)) { this.ShowMsg("已经成功修改当前专题", true); return; } this.ShowMsg("修改专题失败", false); return; } }
private static void DeleteProductImage(ProductInfo product) { if (product != null) { if (!string.IsNullOrEmpty(product.ImageUrl1)) { ResourcesHelper.DeleteImage(product.ImageUrl1); ResourcesHelper.DeleteImage(product.ImageUrl1.Replace("/Storage/master/product/images/", "/Storage/master/product/thumbs40/40_")); ResourcesHelper.DeleteImage(product.ImageUrl1.Replace("/Storage/master/product/images/", "/Storage/master/product/thumbs60/60_")); ResourcesHelper.DeleteImage(product.ImageUrl1.Replace("/Storage/master/product/images/", "/Storage/master/product/thumbs100/100_")); ResourcesHelper.DeleteImage(product.ImageUrl1.Replace("/Storage/master/product/images/", "/Storage/master/product/thumbs160/160_")); ResourcesHelper.DeleteImage(product.ImageUrl1.Replace("/Storage/master/product/images/", "/Storage/master/product/thumbs180/180_")); ResourcesHelper.DeleteImage(product.ImageUrl1.Replace("/Storage/master/product/images/", "/Storage/master/product/thumbs220/220_")); ResourcesHelper.DeleteImage(product.ImageUrl1.Replace("/Storage/master/product/images/", "/Storage/master/product/thumbs310/310_")); ResourcesHelper.DeleteImage(product.ImageUrl1.Replace("/Storage/master/product/images/", "/Storage/master/product/thumbs410/410_")); } if (!string.IsNullOrEmpty(product.ImageUrl2)) { ResourcesHelper.DeleteImage(product.ImageUrl2); ResourcesHelper.DeleteImage(product.ImageUrl2.Replace("/Storage/master/product/images/", "/Storage/master/product/thumbs40/40_")); ResourcesHelper.DeleteImage(product.ImageUrl2.Replace("/Storage/master/product/images/", "/Storage/master/product/thumbs60/60_")); ResourcesHelper.DeleteImage(product.ImageUrl2.Replace("/Storage/master/product/images/", "/Storage/master/product/thumbs100/100_")); ResourcesHelper.DeleteImage(product.ImageUrl2.Replace("/Storage/master/product/images/", "/Storage/master/product/thumbs160/160_")); ResourcesHelper.DeleteImage(product.ImageUrl2.Replace("/Storage/master/product/images/", "/Storage/master/product/thumbs180/180_")); ResourcesHelper.DeleteImage(product.ImageUrl2.Replace("/Storage/master/product/images/", "/Storage/master/product/thumbs220/220_")); ResourcesHelper.DeleteImage(product.ImageUrl2.Replace("/Storage/master/product/images/", "/Storage/master/product/thumbs310/310_")); ResourcesHelper.DeleteImage(product.ImageUrl2.Replace("/Storage/master/product/images/", "/Storage/master/product/thumbs410/410_")); } if (!string.IsNullOrEmpty(product.ImageUrl3)) { ResourcesHelper.DeleteImage(product.ImageUrl3); ResourcesHelper.DeleteImage(product.ImageUrl3.Replace("/Storage/master/product/images/", "/Storage/master/product/thumbs40/40_")); ResourcesHelper.DeleteImage(product.ImageUrl3.Replace("/Storage/master/product/images/", "/Storage/master/product/thumbs60/60_")); ResourcesHelper.DeleteImage(product.ImageUrl3.Replace("/Storage/master/product/images/", "/Storage/master/product/thumbs100/100_")); ResourcesHelper.DeleteImage(product.ImageUrl3.Replace("/Storage/master/product/images/", "/Storage/master/product/thumbs160/160_")); ResourcesHelper.DeleteImage(product.ImageUrl3.Replace("/Storage/master/product/images/", "/Storage/master/product/thumbs180/180_")); ResourcesHelper.DeleteImage(product.ImageUrl3.Replace("/Storage/master/product/images/", "/Storage/master/product/thumbs220/220_")); ResourcesHelper.DeleteImage(product.ImageUrl3.Replace("/Storage/master/product/images/", "/Storage/master/product/thumbs310/310_")); ResourcesHelper.DeleteImage(product.ImageUrl3.Replace("/Storage/master/product/images/", "/Storage/master/product/thumbs410/410_")); } if (!string.IsNullOrEmpty(product.ImageUrl4)) { ResourcesHelper.DeleteImage(product.ImageUrl4); ResourcesHelper.DeleteImage(product.ImageUrl4.Replace("/Storage/master/product/images/", "/Storage/master/product/thumbs40/40_")); ResourcesHelper.DeleteImage(product.ImageUrl4.Replace("/Storage/master/product/images/", "/Storage/master/product/thumbs60/60_")); ResourcesHelper.DeleteImage(product.ImageUrl4.Replace("/Storage/master/product/images/", "/Storage/master/product/thumbs100/100_")); ResourcesHelper.DeleteImage(product.ImageUrl4.Replace("/Storage/master/product/images/", "/Storage/master/product/thumbs160/160_")); ResourcesHelper.DeleteImage(product.ImageUrl4.Replace("/Storage/master/product/images/", "/Storage/master/product/thumbs180/180_")); ResourcesHelper.DeleteImage(product.ImageUrl4.Replace("/Storage/master/product/images/", "/Storage/master/product/thumbs220/220_")); ResourcesHelper.DeleteImage(product.ImageUrl4.Replace("/Storage/master/product/images/", "/Storage/master/product/thumbs310/310_")); ResourcesHelper.DeleteImage(product.ImageUrl4.Replace("/Storage/master/product/images/", "/Storage/master/product/thumbs410/410_")); } if (!string.IsNullOrEmpty(product.ImageUrl5)) { ResourcesHelper.DeleteImage(product.ImageUrl5); ResourcesHelper.DeleteImage(product.ImageUrl5.Replace("/Storage/master/product/images/", "/Storage/master/product/thumbs40/40_")); ResourcesHelper.DeleteImage(product.ImageUrl5.Replace("/Storage/master/product/images/", "/Storage/master/product/thumbs60/60_")); ResourcesHelper.DeleteImage(product.ImageUrl5.Replace("/Storage/master/product/images/", "/Storage/master/product/thumbs100/100_")); ResourcesHelper.DeleteImage(product.ImageUrl5.Replace("/Storage/master/product/images/", "/Storage/master/product/thumbs160/160_")); ResourcesHelper.DeleteImage(product.ImageUrl5.Replace("/Storage/master/product/images/", "/Storage/master/product/thumbs180/180_")); ResourcesHelper.DeleteImage(product.ImageUrl5.Replace("/Storage/master/product/images/", "/Storage/master/product/thumbs220/220_")); ResourcesHelper.DeleteImage(product.ImageUrl5.Replace("/Storage/master/product/images/", "/Storage/master/product/thumbs310/310_")); ResourcesHelper.DeleteImage(product.ImageUrl5.Replace("/Storage/master/product/images/", "/Storage/master/product/thumbs410/410_")); } } }