private void btnSubmitArticleCategory_Click(object sender, EventArgs e) { string str = string.Empty; if (this.fileUpload.HasFile) { try { str = SubsiteCommentsHelper.UploadArticleImage(this.fileUpload.PostedFile); } catch { this.ShowMsg("图片上传失败,您选择的不是图片类型的文件,或者网站的虚拟目录没有写入文件的权限", false); return; } } ArticleCategoryInfo info2 = new ArticleCategoryInfo(); info2.Name = this.txtArticleCategoryiesName.Text.Trim(); info2.IconUrl = str; info2.Description = this.txtArticleCategoryiesDesc.Text.Trim(); ArticleCategoryInfo target = info2; ValidationResults results = Hishop.Components.Validation.Validation.Validate<ArticleCategoryInfo>(target, new string[] { "ValArticleCategoryInfo" }); string msg = string.Empty; if (results.IsValid) { this.AddNewCategory(target); } else { foreach (ValidationResult result in (IEnumerable<ValidationResult>) results) { msg = msg + Formatter.FormatErrorMessage(result.Message); } this.ShowMsg(msg, false); } }
public static bool CreateArticleCategory(ArticleCategoryInfo articleCategory) { if (null == articleCategory) { return false; } Globals.EntityCoding(articleCategory, true); return CommentsProvider.Instance().CreateUpdateDeleteArticleCategory(articleCategory, DataProviderAction.Create); }
private void AddNewCategory(ArticleCategoryInfo category) { if (SubsiteCommentsHelper.CreateArticleCategory(category)) { this.Reset(); this.ShowMsg("成功添加了一个文章分类", true); } else { this.ShowMsg("未知错误", false); } }
private void AddNewCategory(ArticleCategoryInfo category) { if (ArticleHelper.CreateArticleCategory(category)) { Reset(); ShowMsg("成功添加了一个文章分类", true); } else { ShowMsg("未知错误", false); } }
public override bool CreateUpdateDeleteArticleCategory(ArticleCategoryInfo articleCategory, DataProviderAction action) { if (null == articleCategory) { return false; } DbCommand storedProcCommand = database.GetStoredProcCommand("cp_ArticleCategory_CreateUpdateDelete"); database.AddInParameter(storedProcCommand, "Action", DbType.Int32, (int)action); database.AddOutParameter(storedProcCommand, "Status", DbType.Int32, 4); if (action != DataProviderAction.Create) { database.AddInParameter(storedProcCommand, "CategoryId", DbType.Int32, articleCategory.CategoryId); } if (action != DataProviderAction.Delete) { database.AddInParameter(storedProcCommand, "Name", DbType.String, articleCategory.Name); database.AddInParameter(storedProcCommand, "IconUrl", DbType.String, articleCategory.IconUrl); database.AddInParameter(storedProcCommand, "Description", DbType.String, articleCategory.Description); } database.ExecuteNonQuery(storedProcCommand); return (((int)database.GetParameterValue(storedProcCommand, "Status")) == 0); }
public static ArticleCategoryInfo PopulateArticleCategory(IDataRecord reader) { if (null == reader) { return null; } ArticleCategoryInfo info = new ArticleCategoryInfo(); info.CategoryId = (int) reader["CategoryId"]; info.Name = (string) reader["Name"]; info.DisplaySequence = (int) reader["DisplaySequence"]; if (reader["IconUrl"] != DBNull.Value) { info.IconUrl = (string) reader["IconUrl"]; } if (reader["Description"] != DBNull.Value) { info.Description = (string) reader["Description"]; } return info; }
public static bool DeleteArticleCategory(int categoryId) { ArticleCategoryInfo articleCategory = new ArticleCategoryInfo(); articleCategory.CategoryId = categoryId; return CommentsProvider.Instance().CreateUpdateDeleteArticleCategory(articleCategory, DataProviderAction.Delete); }
public abstract bool CreateUpdateDeleteArticleCategory(ArticleCategoryInfo articleCategory, DataProviderAction action);
private void UpdateCategory(ArticleCategoryInfo category) { if (SubsiteCommentsHelper.UpdateArticleCategory(category)) { this.imgPic.ImageUrl = null; this.ShowMsg("成功修改了文章分类", true); } else { this.ShowMsg("未知错误", false); } this.btnPicDelete.Visible = !string.IsNullOrEmpty(this.imgPic.ImageUrl); this.imgPic.Visible = !string.IsNullOrEmpty(this.imgPic.ImageUrl); }
private void UpdateCategory(ArticleCategoryInfo category) { if (ArticleHelper.UpdateArticleCategory(category)) { imgPic.ImageUrl = null; ShowMsg("成功修改了文章分类", true); } else { ShowMsg("未知错误", false); } btnPicDelete.Visible = !string.IsNullOrEmpty(imgPic.ImageUrl); imgPic.Visible = !string.IsNullOrEmpty(imgPic.ImageUrl); }