/// <summary> /// The modify product category. /// </summary> /// <param name="category"> /// The category. /// </param> public void ModifyProductCategory(Product_Category category) { this.productCategoryDA.Update(category); }
/// <summary> /// 添加类别 /// </summary> /// <param name="category"> /// 商品类别实体 /// </param> /// <returns> /// 新增记录主键值 /// </returns> public int Insert(Product_Category category) { if (category == null) { throw new ArgumentNullException("category"); } var parameters = new List<SqlParameter> { this.SqlServer.CreateSqlParameter( "@ParentID", SqlDbType.Int, category.ParentID, ParameterDirection.Input), this.SqlServer.CreateSqlParameter( "@CategoryName", SqlDbType.NVarChar, category.CategoryName, ParameterDirection.Input), this.SqlServer.CreateSqlParameter( "@CategoryNameSpell", SqlDbType.NVarChar, category.CategoryNameSpell ?? string.Empty, ParameterDirection.Input), this.SqlServer.CreateSqlParameter( "@CategoryNameEnglish", SqlDbType.NVarChar, category.CategoryNameEnglish ?? string.Empty, ParameterDirection.Input), this.SqlServer.CreateSqlParameter( "@SEOKeywords", SqlDbType.NVarChar, category.SEOKeywords ?? string.Empty, ParameterDirection.Input), this.SqlServer.CreateSqlParameter( "@SEODescription", SqlDbType.NVarChar, category.SEODescription ?? string.Empty, ParameterDirection.Input), this.SqlServer.CreateSqlParameter( "@IsGjw", SqlDbType.Bit, category.IsGjw, ParameterDirection.Input), this.SqlServer.CreateSqlParameter( "@IsDisplay", SqlDbType.Bit, category.IsDisplay, ParameterDirection.Input), this.SqlServer.CreateSqlParameter( "@Layer", SqlDbType.Int, category.Layer, ParameterDirection.Input), this.SqlServer.CreateSqlParameter( "@CreateTime", SqlDbType.DateTime, category.CreateTime, ParameterDirection.Input), this.SqlServer.CreateSqlParameter( "@ReferenceID", SqlDbType.Int, null, ParameterDirection.Output), this.SqlServer.CreateSqlParameter( "@SEOTitle", SqlDbType.NVarChar, category.SEOTitle, ParameterDirection.Input ) }; var SqlString = new StringBuilder(); SqlString.Append("Insert Into Product_Category([ParentID],[CategoryName],[CategoryNameSpell],[CategoryNameEnglish],[SEOKeywords],[SEODescription],[IsGjw],[IsDisplay],[Layer],[Sorting],[CreateTime],[SEOTitle]) "); SqlString.Append( "Values (@ParentID,@CategoryName,@CategoryNameSpell,@CategoryNameEnglish,@SEOKeywords,@SEODescription,@IsGjw,@IsDisplay,@Layer,null,@CreateTime,@SEOTitle) "); SqlString.Append("set @ReferenceID = @@IDENTITY"); this.SqlServer.ExecuteNonQuery(CommandType.Text, SqlString.ToString(), parameters, null); return (int)parameters.Find(parameter => parameter.ParameterName == "@ReferenceID").Value; }
/// <summary> /// The add product category. /// </summary> /// <param name="product"> /// The product. /// </param> /// <returns> /// The <see cref="int"/>. /// </returns> public int AddProductCategory(Product_Category product) { return this.productCategoryDA.Insert(product); }
/// <summary> /// 修改类别信息. /// </summary> /// <param name="category"> /// 类别实体. /// </param> public void Update(Product_Category category) { if (category == null) { throw new ArgumentNullException("category"); } var parameters = new List<SqlParameter> { this.SqlServer.CreateSqlParameter( "ID", SqlDbType.Int, category.ID, ParameterDirection.Input), this.SqlServer.CreateSqlParameter( "ParentID", SqlDbType.Int, category.ParentID, ParameterDirection.Input), this.SqlServer.CreateSqlParameter( "CategoryName", SqlDbType.NVarChar, category.CategoryName, ParameterDirection.Input), this.SqlServer.CreateSqlParameter( "CategoryNameSpell", SqlDbType.NVarChar, category.CategoryNameSpell??string.Empty, ParameterDirection.Input), this.SqlServer.CreateSqlParameter( "CategoryNameEnglish", SqlDbType.NVarChar, category.CategoryNameEnglish, ParameterDirection.Input), this.SqlServer.CreateSqlParameter( "SEOKeywords", SqlDbType.NVarChar, category.SEOKeywords, ParameterDirection.Input), this.SqlServer.CreateSqlParameter( "SEODescription", SqlDbType.NVarChar, category.SEODescription, ParameterDirection.Input), this.SqlServer.CreateSqlParameter( "IsDisplay", SqlDbType.Bit, category.IsDisplay, ParameterDirection.Input), this.SqlServer.CreateSqlParameter( "Sorting", SqlDbType.Int, category.Sorting, ParameterDirection.Input), this.SqlServer.CreateSqlParameter( "SEOTitle", SqlDbType.NVarChar, category.SEOTitle??string.Empty, ParameterDirection.Input ) }; string sqlString = "Update Product_Category Set [ParentID] = @ParentID,[CategoryName] = @CategoryName,[CategoryNameSpell] = @CategoryNameSpell,[CategoryNameEnglish] = @CategoryNameEnglish,[SEOKeywords] = @SEOKeywords,[SEODescription] = @SEODescription,[IsDisplay] = @IsDisplay,[Sorting] = @Sorting,[SEOTitle]=@SEOTitle Where [ID] = @ID"; try { this.SqlServer.ExecuteNonQuery(CommandType.Text, sqlString, parameters, null); } catch (Exception exception) { throw new Exception("Exception - ProductCategpryDA - Update", exception); } }