protected void Page_Load(object sender, EventArgs e) { btnSubmitArticleCategory.Click += new EventHandler(btnSubmitArticleCategory_Click); btnPicDelete.Click += new EventHandler(btnPicDelete_Click); if (!int.TryParse(base.Request.QueryString["CategoryId"], out categoryId)) { base.GotoResourceNotFound(); } else if (!base.IsPostBack) { ArticleCategoryInfo articleCategory = ArticleHelper.GetArticleCategory(categoryId); if (articleCategory == null) { base.GotoResourceNotFound(); } else { Globals.EntityCoding(articleCategory, false); txtArticleCategoryiesName.Text = articleCategory.Name; txtArticleCategoryiesDesc.Text = articleCategory.Description; imgPic.ImageUrl = articleCategory.IconUrl; btnPicDelete.Visible = !string.IsNullOrEmpty(imgPic.ImageUrl); imgPic.Visible = !string.IsNullOrEmpty(imgPic.ImageUrl); } } }
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 btnSubmitArticleCategory_Click(object sender, EventArgs e) { ArticleCategoryInfo articleCategory = ArticleHelper.GetArticleCategory(this.categoryId); if (articleCategory != null) { string text2 = articleCategory.IconUrl = this.UploadImage(); articleCategory.Name = this.txtArticleCategoryiesName.Text.Trim(); articleCategory.Description = this.txtArticleCategoryiesDesc.Text.Trim(); ValidationResults validationResults = Validation.Validate(articleCategory, "ValArticleCategoryInfo"); string text3 = string.Empty; if (!validationResults.IsValid) { foreach (ValidationResult item in (IEnumerable <ValidationResult>)validationResults) { text3 += Formatter.FormatErrorMessage(item.Message); } this.ShowMsg(text3, false); } else { this.UpdateCategory(articleCategory); } } }
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 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 btnPicDelete_Click(object sender, EventArgs e) { ArticleCategoryInfo articleCategory = ArticleHelper.GetArticleCategory(categoryId); try { ResourcesHelper.DeleteImage(articleCategory.IconUrl); } catch { } articleCategory.IconUrl = (string)(imgPic.ImageUrl = null); if (ArticleHelper.UpdateArticleCategory(articleCategory)) { btnPicDelete.Visible = !string.IsNullOrEmpty(imgPic.ImageUrl); imgPic.Visible = !string.IsNullOrEmpty(imgPic.ImageUrl); } }
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); }
protected void Page_Load(object sender, EventArgs e) { this.btnSubmitArticleCategory.Click += this.btnSubmitArticleCategory_Click; if (!int.TryParse(base.Request.QueryString["CategoryId"], out this.categoryId)) { base.GotoResourceNotFound(); } else if (!base.IsPostBack) { ArticleCategoryInfo articleCategory = ArticleHelper.GetArticleCategory(this.categoryId); if (articleCategory == null) { base.GotoResourceNotFound(); } else { Globals.EntityCoding(articleCategory, false); this.txtArticleCategoryiesName.Text = articleCategory.Name; this.txtArticleCategoryiesDesc.Text = articleCategory.Description; this.hidOldImages.Value = articleCategory.IconUrl; } } }
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); } } }