熱點推薦:
您现在的位置: 電腦知識網 >> 編程 >> .NET編程 >> 正文

ASP.NET入門教程 13.3.1 購物對象[3]

2022-06-13   來源: .NET編程 

    ()添加如下代碼創建一個購物車商品對象稱為CartItem

 

Imports MicrosoftVisualBasic

Imports SystemData

Imports SystemDataSqlClient

Imports SystemCollectionsGeneric

 

Namespace WroxCommerce

 

    <Serializable()> _

    Public Class CartItem

        Private _productID As Integer

        Private _productName As String

        Private _productImageUrl As String

        Private _quantity As Integer

        Private _price As Double

        Private _lineTotal As Double

 

        Public Sub New()

        End Sub

 

        Public Sub New(ByVal ProductID As Integer ByVal ProductName As String ByVal ProductImageUrl As String ByVal Quantity As Integer ByVal Price As Double)

 

            _productID = ProductID

            _productName = ProductName

            _productImageUrl = ProductImageUrl

            _quantity = Quantity

            _price = Price

            _lineTotal = Quantity * Price

 

        End Sub

 

        Public Property ProductID() As Integer

            Get

                Return _productID

            End Get

            Set(ByVal value As Integer)

                _productID = value

            End Set

        End Property

 

        Public Property ProductName() As String

            Get

                Return _productName

            End Get

            Set(ByVal value As String)

                _productName = value

            End Set

        End Property

 

        Public Property ProductImageUrl() As String

            Get

                Return _productImageUrl

            End Get

            Set(ByVal value As String)

                _productImageUrl = value

            End Set

        End Property

 

        Public Property Quantity() As Integer

            Get

                Return _quantity

            End Get

            Set(ByVal value As Integer)

                _quantity = value

            End Set

        End Property

 

        Public Property Price() As Double

            Get

                Return _price

            End Get

            Set(ByVal value As Double)

                _price = value

            End Set

        End Property

 

        Public ReadOnly Property LineTotal() As Double

            Get

                Return _quantity * _price

            End Get

        End Property

 

    End Class

[]  []  []  []  []  []  []  []  []  


From:http://tw.wingwit.com/Article/program/net/201311/15597.html
    推薦文章
    Copyright © 2005-2022 電腦知識網 Computer Knowledge   All rights reserved.