This application requires the use of several classes, which will be added to the single ASP.NET application instead of being placed in a separate project. The first class is the Database class, which you've used in previous projects. Because the code for this class has been covered in previous chapters, we'll omit the listing here. If you need to refer to the code, look at Listing 12.2.
The second class is called MyStockData and this class will be used in conjunction with the stock information service that the application uses. The code for this class is shown in Listing 15.4.
Listing 15.4. MyStockData.vb—The Class for the Stock Information Service
Imports WS_Ch15.StockService
Public Class MyStockData
Private _CompanyName As String
Private _LastTradeAmount As Decimal
Private _StockChange As Decimal
Private _ChangePercent As String
Private _LastTradeDateTime As DateTime
Private _StockSymbol As String
Public Sub New(ByVal QD As QuoteData)
_CompanyName = QD.CompanyName
_LastTradeAmount = QD.LastTradeAmount
_StockChange = QD.StockChange
_ChangePercent = QD.ChangePercent
_LastTradeDateTime = QD.LastTradeDateTime
_StockSymbol = QD.StockSymbol
End Sub
Public ReadOnly Property CompanyName() As String
Get
Return _CompanyName
End Get
End Property
Public ReadOnly Property LastTradeAmount() As String
Get
Return _LastTradeAmount.ToString()
End Get
End Property
Public ReadOnly Property StockChange() As String
Get
Return _StockChange.ToString()
End Get
End Property
Public ReadOnly Property ChangePercent() As String
Get
Return _ChangePercent
End Get
End Property
Public ReadOnly Property LastTradeDateTime() As String
Get
Return _LastTradeDateTime.ToString("MM/dd/yyyy hh:mm tt")
End Get
End Property
Public ReadOnly Property StockSymbol() As String
Get
Return _StockSymbol
End Get
End Property
End Class
This object really has one function—to take the data from the QuoteData object passed into it and to store the data in private member variables. When the data is shown in a control that supports data binding, the properties on the object will return the actual data. For binding purposes, if the object you're using does not have properties, the binding will not work properly. You'll see more how to use this later in the application.