/// <summary> /// 增加主题分类 /// </summary> /// <param name="category">主题分类实体</param> public bool AddCategory(ThemeCategory category) { string cmdText = @" insert into ThemeCategory (CategoryName,ParentId,CategoryIcon,SortNumber,BindTagCategories) values (@CategoryName,@ParentId,@CategoryIcon,@SortNumber,@BindTagCategories);SELECT @@IDENTITY "; SqlParameter[] parameters = new SqlParameter[] { SqlParameterHelper.BuildInputParameter("@CategoryName",SqlDbType.NVarChar, 300, category.CategoryName), SqlParameterHelper.BuildInputParameter("@ParentId",SqlDbType.Int, 4, category.ParentId), SqlParameterHelper.BuildInputParameter("@CategoryIcon",SqlDbType.NVarChar, 300, category.CategoryIcon), SqlParameterHelper.BuildInputParameter("@SortNumber",SqlDbType.Int, 4, category.SortNumber), SqlParameterHelper.BuildInputParameter("@BindTagCategories",SqlDbType.NVarChar, 500, category.BindTagCategories) }; category.CategoryId = Convert.ToInt32(SqlHelper.ExecuteScalar(_connectionProvider.GetWriteConnectionString(), CommandType.Text, cmdText, parameters)); return category.CategoryId > 0; }
} /// <summary> /// 更新主题分类 /// </summary> /// <param name="category">主题分类实体</param> public bool UpdateCategory(ThemeCategory category) { string cmdText = @" update ThemeCategory set CategoryName=@CategoryName, ParentId=@ParentId, CategoryIcon=@CategoryIcon, SortNumber=@SortNumber, BindTagCategories=@BindTagCategories where CategoryId=@CategoryId "; SqlParameter[] parameters = new SqlParameter[] { SqlParameterHelper.BuildInputParameter("@CategoryId", SqlDbType.Int, 4, category.CategoryId), SqlParameterHelper.BuildInputParameter("@CategoryName", SqlDbType.NVarChar, 300, category.CategoryName), SqlParameterHelper.BuildInputParameter("@ParentId", SqlDbType.Int, 4, category.ParentId), SqlParameterHelper.BuildInputParameter("@CategoryIcon", SqlDbType.NVarChar, 300, category.CategoryIcon), SqlParameterHelper.BuildInputParameter("@SortNumber", SqlDbType.Int, 4, category.SortNumber), SqlParameterHelper.BuildInputParameter("@BindTagCategories", SqlDbType.NVarChar, 500, category.BindTagCategories) };