Object-Oriented Report Development using Crystal Reports and ASP.NET 2.0 - Developing classes to hold information from the database
(Page 3 of 4 )
Information from the database must be contained in an object. Using the "Solution Explorer," add a new class named "Order.vb". This class is used to hold the information based on the fields selected.
The code for the "Order" class is as follows:
Imports Microsoft.VisualBasic
Public Class Order
Private _OrderID As Int32
Private _CustomerName As String
Private _EmployeeName As String
Private _OrderDate As Date
Private _OrderValue As Double
Public Property OrderID() As Int32
Get
Return _OrderID
End Get
Set(ByVal value As Int32)
_OrderID = value
End Set
End Property
Public Property CustomerName() As String
Get
Return _CustomerName
End Get
Set(ByVal value As String)
_CustomerName = value
End Set
End Property
Public Property EmployeeName() As String
Get
Return _EmployeeName
End Get
Set(ByVal value As String)
_EmployeeName = value
End Set
End Property
Public Property OrderDate() As Date
Get
Return _OrderDate
End Get
Set(ByVal value As Date)
_OrderDate = value
End Set
End Property
Public Property OrderValue() As Double
Get
Return _OrderValue
End Get
Set(ByVal value As Double)
_OrderValue = value
End Set
End Property
Public Sub New(ByVal oID As String, ByVal oCustomer As String, ByVal oEmployee As String, ByVal oOrderDate As String, ByVal oOrderValue As String)
Me.OrderID = oID
Me.CustomerName = oCustomer
Me.EmployeeName = oEmployee
Me.OrderDate = oOrderDate
Me.OrderValue = oOrderValue
End Sub
End Class
Add one more class (OrderCollection.vb), which holds a set of objects (collection) based on the above class. The code for the class is as follows:
Imports Microsoft.VisualBasic
Imports System.Collections.Generic
Public Class OrderCollection
Inherits List(Of Order)
End Class
You need not write any code for the above class as it deals with generics in .NET 2.0.
Next: Adding a Factory class to populate object collection >>
More ASP.NET Articles
More By Jagadish Chaterjee