public ActionResult AddAttribute(string productCateID, string productAttrName, string inputType, string dataType, int length) { try { if (string.IsNullOrEmpty(productCateID) || string.IsNullOrEmpty(productAttrName)) { return Content("2"); } var attr = new Product_Attribute { ProductCategoryID = Convert.ToInt32(productCateID), AttributeName = productAttrName, InputType = inputType, DataType = dataType, DataLength = length }; this.ProductAttributeService.AddProductAttribute(attr); return Content("1"); } catch (Exception exception) { throw new Exception(exception.Message, exception); } }
/// <summary> /// 添加商品属性. /// </summary> /// <param name="productAttribute"> /// 商品属性实体 /// </param> /// <returns> /// 添加记录的主键值. /// </returns> public int Insert(Product_Attribute productAttribute) { if (productAttribute == null) { throw new ArgumentNullException("productAttribute"); } var parameters = new List<SqlParameter> { this.SqlServer.CreateSqlParameter( "ProductCategoryID", SqlDbType.NVarChar, productAttribute.ProductCategoryID, ParameterDirection.Input), this.SqlServer.CreateSqlParameter( "AttributeName", SqlDbType.NVarChar, productAttribute.AttributeName, ParameterDirection.Input), this.SqlServer.CreateSqlParameter( "DataType", SqlDbType.NVarChar, productAttribute.DataType, ParameterDirection.Input), this.SqlServer.CreateSqlParameter( "DataLength", SqlDbType.Int, productAttribute.DataLength, ParameterDirection.Input), this.sqlServer.CreateSqlParameter( "InputType", SqlDbType.NVarChar, productAttribute.InputType, ParameterDirection.Input ), this.SqlServer.CreateSqlParameter( "ReferenceID", SqlDbType.Int, null, ParameterDirection.Output) }; try { this.SqlServer.ExecuteNonQuery(CommandType.StoredProcedure, "sp_Product_Attribute_Insert", parameters, null); return (int)parameters.Find(parameter => parameter.ParameterName == "ReferenceID").Value; } catch (Exception exception) { throw new Exception("Exception - ProductAttributeDA - Insert", exception); } }
/// <summary> /// The modify product attribute. /// </summary> /// <param name="productAttribute"> /// The product attribute. /// </param> public void ModifyProductAttribute(Product_Attribute productAttribute) { this.productAttributeDA.Update(productAttribute); }
/// <summary> /// 修改图片信息. /// </summary> /// <param name="productAttribute"> /// 图片实体. /// </param> public void Update(Product_Attribute productAttribute) { if (productAttribute == null) { throw new ArgumentNullException("productAttribute"); } var parameters = new List<SqlParameter> { this.SqlServer.CreateSqlParameter( "ID", SqlDbType.Int, productAttribute.ID, ParameterDirection.Input), this.SqlServer.CreateSqlParameter( "AttributeName", SqlDbType.NVarChar, productAttribute.AttributeName, ParameterDirection.Input), this.SqlServer.CreateSqlParameter( "Sorting", SqlDbType.Int, productAttribute.Sorting, ParameterDirection.Input), this.SqlServer.CreateSqlParameter( "DataLength", SqlDbType.Int, productAttribute.DataLength, ParameterDirection.Input), this.sqlServer.CreateSqlParameter( "InputType", SqlDbType.NVarChar, productAttribute.InputType, ParameterDirection.Input ), this.SqlServer.CreateSqlParameter( "DataType", SqlDbType.NVarChar, productAttribute.DataType, ParameterDirection.Input ) }; try { this.SqlServer.ExecuteNonQuery(CommandType.StoredProcedure, "sp_Product_Attribute_Update", parameters, null); } catch (Exception exception) { throw new Exception("Exception - ProductAttributeDA - Update", exception); } }
/// <summary> /// The add product attribute. /// </summary> /// <param name="productAttribute"> /// The product attribute. /// </param> /// <returns> /// The <see cref="int"/>. /// </returns> public int AddProductAttribute(Product_Attribute productAttribute) { return this.productAttributeDA.Insert(productAttribute); }