📄 productcontroller.vb
字号:
db.AddInParameter(dbCommand, "@DescriptorID", DbType.Int32, DescriptorID)
db.AddInParameter(dbCommand, "@ProductID", DbType.Int32, productDescriptorInfo.ProductID)
db.AddInParameter(dbCommand, "@Title", DbType.String, productDescriptorInfo.Title)
db.AddInParameter(dbCommand, "@Descriptor", DbType.String, productDescriptorInfo.Descriptor)
db.AddInParameter(dbCommand, "@IsBulletedList", DbType.Boolean, productDescriptorInfo.IsBulletedList)
db.AddInParameter(dbCommand, "@ItemOrder ", DbType.Int32, productDescriptorInfo.ItemOrder)
db.AddInParameter(dbCommand, "@IsValid", DbType.Boolean, productDescriptorInfo.IsValid)
db.ExecuteNonQuery(dbCommand)
Return DescriptorID
End Function
Public Shared Sub AddProductCategory(ByVal productID As String, ByVal categoryID As Integer)
Dim db As Database = DatabaseFactory.CreateDatabase
Dim dbCommand As DbCommand = db.GetStoredProcCommand("nsf_Product_AddProductCategory")
db.AddInParameter(dbCommand, "@CategoryID", DbType.Int32, categoryID)
db.AddInParameter(dbCommand, "@ProductID", DbType.Int32, productID)
db.ExecuteNonQuery(dbCommand)
End Sub
Public Shared Function AddProduct(ByVal product As ProductInfo) As Integer
Dim db As Database = DatabaseFactory.CreateDatabase()
Dim sqlCommand As String = "nsf_Product_AddProduct"
Dim dbCommand As DbCommand = db.GetStoredProcCommand(sqlCommand)
Dim ProductID As Integer = GetKeys("ProductID")
db.AddInParameter(dbCommand, "@ProductID", DbType.Int32, ProductID)
db.AddInParameter(dbCommand, "@ProductCode", DbType.String, product.ProductCode)
db.AddInParameter(dbCommand, "@ProductName", DbType.String, product.ProductName)
db.AddInParameter(dbCommand, "@ProductType", DbType.Int32, product.ProductType)
db.AddInParameter(dbCommand, "@CategoryID", DbType.Int32, product.CategoryID)
db.AddInParameter(dbCommand, "@Description", DbType.String, product.Description)
db.AddInParameter(dbCommand, "@Unit", DbType.String, product.Unit)
db.AddInParameter(dbCommand, "@Price", DbType.Decimal, product.Price)
db.AddInParameter(dbCommand, "@ListPrice", DbType.Decimal, product.ListPrice)
db.AddInParameter(dbCommand, "@StorageQty", DbType.Int32, product.StorageQty)
db.AddInParameter(dbCommand, "@StorageQtyLimit", DbType.Int32, product.StorageQtyLimit)
db.AddInParameter(dbCommand, "@MinOrderAmount", DbType.Int32, product.MinOrderAmount)
db.AddInParameter(dbCommand, "@Weight", DbType.Decimal, product.Weight)
' db.AddInParameter(dbCommand, "@AttributeXML", DbType.String, product.AttributeXML)
db.AddInParameter(dbCommand, "@IsStorageAlert", DbType.Boolean, product.IsStorageAlert)
db.AddInParameter(dbCommand, "@IsFreeshipping", DbType.Boolean, product.IsFreeshipping)
db.AddInParameter(dbCommand, "@IsSpecialOffer", DbType.Boolean, product.IsSpecialOffer)
db.AddInParameter(dbCommand, "@IsSellWell", DbType.Boolean, product.IsSellWell)
db.AddInParameter(dbCommand, "@IsValid", DbType.Boolean, product.IsValid)
db.AddInParameter(dbCommand, "@IsNewArrival", DbType.Boolean, product.IsNewArrival)
db.AddInParameter(dbCommand, "@IsGlobalDiscounts", DbType.Boolean, product.IsGlobalDiscounts)
db.AddInParameter(dbCommand, "@FeatureGroupID", DbType.Int32, product.FeatureGroupID)
db.AddInParameter(dbCommand, "@ManufacturerID", DbType.Int32, product.ManufacturerID)
' db.AddInParameter(dbCommand, "@ImagePath", DbType.String, product.ImagePath)
db.AddInParameter(dbCommand, "@IsCommend", DbType.Boolean, product.IsCommend)
db.ExecuteNonQuery(dbCommand)
Return ProductID
End Function
Public Shared Function UpdateProduct(ByVal product As ProductInfo) As Integer
Dim db As Database = DatabaseFactory.CreateDatabase()
Dim sqlCommand As String = "nsf_Product_UpdateProduct"
Dim dbCommand As DbCommand = db.GetStoredProcCommand(sqlCommand)
db.AddInParameter(dbCommand, "@ProductID", DbType.Int32, product.ProductID)
db.AddInParameter(dbCommand, "@ProductCode", DbType.String, product.ProductCode)
db.AddInParameter(dbCommand, "@ProductName", DbType.String, product.ProductName)
db.AddInParameter(dbCommand, "@ProductType", DbType.Int32, product.ProductType)
db.AddInParameter(dbCommand, "@CategoryID", DbType.String, product.CategoryID)
db.AddInParameter(dbCommand, "@Description", DbType.String, product.Description)
db.AddInParameter(dbCommand, "@Unit", DbType.String, product.Unit)
db.AddInParameter(dbCommand, "@Price", DbType.Decimal, product.Price)
db.AddInParameter(dbCommand, "@ListPrice", DbType.Decimal, product.ListPrice)
db.AddInParameter(dbCommand, "@StorageQty", DbType.Int32, product.StorageQty)
db.AddInParameter(dbCommand, "@StorageQtyLimit", DbType.Int32, product.StorageQtyLimit)
db.AddInParameter(dbCommand, "@MinOrderAmount", DbType.Int32, product.MinOrderAmount)
db.AddInParameter(dbCommand, "@Weight", DbType.Decimal, product.Weight)
' db.AddInParameter(dbCommand, "@AttributeXML", DbType.String, product.AttributeXML)
db.AddInParameter(dbCommand, "@IsStorageAlert", DbType.Boolean, product.IsStorageAlert)
db.AddInParameter(dbCommand, "@IsFreeshipping", DbType.Boolean, product.IsFreeshipping)
db.AddInParameter(dbCommand, "@IsSpecialOffer", DbType.Boolean, product.IsSpecialOffer)
db.AddInParameter(dbCommand, "@IsSellWell", DbType.Boolean, product.IsSellWell)
db.AddInParameter(dbCommand, "@IsValid", DbType.Boolean, product.IsValid)
db.AddInParameter(dbCommand, "@IsNewArrival", DbType.Boolean, product.IsNewArrival)
db.AddInParameter(dbCommand, "@IsGlobalDiscounts", DbType.Boolean, product.IsGlobalDiscounts)
db.AddInParameter(dbCommand, "@FeatureGroupID", DbType.Int32, product.FeatureGroupID)
db.AddInParameter(dbCommand, "@ManufacturerID", DbType.Int32, product.ManufacturerID)
' db.AddInParameter(dbCommand, "@ImagePath", DbType.String, product.ImagePath)
db.AddInParameter(dbCommand, "@IsCommend", DbType.Boolean, product.IsCommend)
db.ExecuteNonQuery(dbCommand)
End Function
Public Shared Sub DeleteProduct(ByVal productID As Integer)
Dim db As Database = DatabaseFactory.CreateDatabase()
Dim sqlCommand As String = "nsf_Product_DeleteProduct"
Dim dbCommand As DbCommand = db.GetStoredProcCommand(sqlCommand)
db.AddInParameter(dbCommand, "@ProductID", DbType.Int32, productID)
db.ExecuteNonQuery(dbCommand)
End Sub
Public Shared Sub DeleteProductLinks(ByVal productLinksID As Integer)
Dim db As Database = DatabaseFactory.CreateDatabase()
Dim sqlCommand As String = "nsf_Product_DeleteProductLinks"
Dim dbCommand As DbCommand = db.GetStoredProcCommand(sqlCommand)
db.AddInParameter(dbCommand, "@productLinksID", DbType.Int32, productLinksID)
db.ExecuteNonQuery(dbCommand)
End Sub
Public Shared Sub UpdataProductQuick(ByVal productID As Integer, ByVal price As Decimal, ByVal storageQty As Integer, ByVal isSpecialOffer As Boolean, ByVal isSellWell As Boolean, ByVal isValid As Boolean, ByVal isNewArrival As Boolean, ByVal isCommend As Boolean, ByVal ItemOrder As Integer)
Dim db As Database = DatabaseFactory.CreateDatabase()
Dim sqlCommand As String = "nsf_Product_UpdateProductQuick"
Dim dbCommand As DbCommand = db.GetStoredProcCommand(sqlCommand)
' Add paramters
' Input parameters can specify the input value
db.AddInParameter(dbCommand, "@ProductID", DbType.Int32, productID)
db.AddInParameter(dbCommand, "@Price", DbType.Decimal, price)
db.AddInParameter(dbCommand, "@StorageQty", DbType.Int32, storageQty)
db.AddInParameter(dbCommand, "@IsSpecialOffer", DbType.Boolean, isSpecialOffer)
db.AddInParameter(dbCommand, "@IsSellWell", DbType.Boolean, isSellWell)
db.AddInParameter(dbCommand, "@IsValid", DbType.Boolean, isValid)
db.AddInParameter(dbCommand, "@IsNewArrival", DbType.Boolean, isNewArrival)
db.AddInParameter(dbCommand, "@IsCommend", DbType.Boolean, isCommend)
db.AddInParameter(dbCommand, "@ItemOrder", DbType.Int32, ItemOrder)
' Output parameters specify the size of the return data
db.ExecuteNonQuery(dbCommand)
End Sub
#Region "---Private Method---"
Private Shared Function FillProductInfo(ByVal dr As IDataReader) As ProductInfo
Dim objProduct As New ProductInfo
objProduct.ProductID = dr.Item("ProductID")
objProduct.ProductCode = dr.Item("ProductCode")
objProduct.ProductName = dr.Item("ProductName")
objProduct.CategoryID = dr.Item("CategoryID")
objProduct.Description = dr.Item("Description")
objProduct.Unit = dr.Item("Unit")
objProduct.Price = dr.Item("Price")
objProduct.ListPrice = dr.Item("ListPrice")
objProduct.StorageQty = dr.Item("StorageQty")
objProduct.StorageQtyLimit = dr.Item("StorageQtyLimit")
objProduct.MinOrderAmount = dr.Item("MinOrderAmount")
objProduct.IsFreeshipping = dr.Item("IsFreeshipping")
objProduct.IsSpecialOffer = dr.Item("IsSpecialOffer")
objProduct.IsStorageAlert = dr.Item("IsStorageAlert")
objProduct.IsSellWell = dr.Item("IsSellWell")
objProduct.IsValid = dr.Item("IsValid")
objProduct.IsGlobalDiscounts = dr.Item("IsGlobalDiscounts")
objProduct.ImagePath = dr.Item("ImagePath")
objProduct.AttributeXML = dr.Item("AttributeXML")
objProduct.IsNewArrival = dr.Item("IsNewArrival")
objProduct.IsStorageAlert = dr.Item("IsStorageAlert")
objProduct.ProductType = CInt(dr.Item("ProductType"))
objProduct.ManufacturerID = dr.Item("ManufacturerID")
objProduct.IsCommend = dr.Item("IsCommend")
objProduct.ItemOrder = dr.Item("ItemOrder")
Return objProduct
End Function
Private Shared Function FillProductDescriptorInfo(ByVal reader As IDataReader) As ProductDescriptorInfo
Dim desprictor As New ProductDescriptorInfo
desprictor.ProductID = CInt(reader("productID"))
desprictor.DescriptorID = CInt(reader("DescriptorID"))
desprictor.Descriptor = reader("Descriptor").ToString
desprictor.IsBulletedList = CBool(reader("IsBulletedList"))
desprictor.IsValid = CBool(reader("IsValid"))
desprictor.ItemOrder = CInt(reader("ItemOrder"))
desprictor.Title = reader("Title").ToString
Return desprictor
End Function
Private Shared Function FillProductLinksInfo(ByVal reader As IDataReader) As ProductLiksInfo
Dim links As New ProductLiksInfo
links.ProductLinksID = CInt(reader("ProductLinksID").ToString)
links.LinkType = CInt(reader("LinkType"))
links.ProductID = CInt(reader("ProductID"))
links.ProductName = reader("ProductName")
links.ImagePath = reader("ImagePath")
links.Price = reader("Price")
Return links
End Function
#End Region
End Class
End Namespace
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -