Imports System.Data Imports OakLeaf.MM.Main.Business Imports OakLeaf.MM.Main.Windows.Forms Imports TSG.StellarVisiTrak.Business Public Class VisitorTypeForm Inherits OakLeaf.MM.Main.Windows.Forms.mmBusinessForm ' Declare class variables to use for busness objects and datasets Private oVisitorType As VisitorType Private dsVisitorType As VisitorTypeDataset #Region " Windows Form Designer generated code " Public Sub New() MyBase.New() 'Instantiate and register business objects with the form Me.oVisitorType = CType(Me.RegisterPrimaryBizObj(New VisitorType), VisitorType) ' Register children of the primary business object ' Not applicable - no children 'This call is required by the Windows Form Designer. InitializeComponent() 'Add any initialization after the InitializeComponent() call ' Retrieve all Visitor Types Me.oVisitorType.GetAllVisitorTypes() End SubOn the form designer I dragged a dataset and configured it as a typed dataset.
Public Class ABusinessObject Inherits mmBusinessObject Public Sub New() Me.DatabaseKey = "StellarVisiTrak" Me.RetrieveAutoIncrementPK = True End Sub End ClassMy Custom Data Adapter code:
Imports System.Data Imports OakLeaf.MM.Main.Data Public Class VisitorTypeDataAccessSQL Inherits mmDataAccessSql #Region " Component Designer generated code " Public Sub New(ByVal Container As System.ComponentModel.IContainer) MyClass.New() 'Required for Windows.Forms Class Composition Designer support Container.Add(Me) End Sub Public Sub New() MyBase.New() 'This call is required by the Component Designer. InitializeComponent() 'Add any initialization after the InitializeComponent() call End Sub 'Component overrides dispose to clean up the component list. Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean) ...(normal dispose code)... End Sub 'Required by the Component Designer Private components As System.ComponentModel.IContainer 'NOTE: The following procedure is required by the Component Designer 'It can be modified using the Component Designer. 'Do not modify it using the code editor. Friend WithEvents daVisitorTypeSqlDataAdapter As System.Data.SqlClient.SqlDataAdapter Friend WithEvents cmdVisitorTypeSqlSelectCommand As System.Data.SqlClient.SqlCommand Friend WithEvents cmdVisitorTypeSqlInsertCommand As System.Data.SqlClient.SqlCommand Friend WithEvents cmdVisitorTypeSqlUpdateCommand As System.Data.SqlClient.SqlCommand Friend WithEvents cmdVisitorTypeSqlDeleteCommand As System.Data.SqlClient.SqlCommand ...(Details of commands here).... #End Region Public Overloads Overrides Function CreateDataAdapter() As IDataAdapter Return Me.daVisitorTypeSqlDataAdapter End Function End ClassMy Business Object code:
Imports System Imports System.Data Imports OakLeaf.MM.Main.Data Public Class VisitorType Inherits ABusinessObject Public Sub New() Me.TableName = "VisitorTypes" Me.PrimaryKey = "VisitorTypeId" End Sub Protected Overrides Function CreateDataAccessObject(ByVal dataAccessClassName As String) As mmDataAccessBase Return New VisitorTypeDataAccessSQL End Function Protected Overrides Function CreateDataSet() As OakLeaf.MM.Main.Data.mmDataSet Return New VisitorTypeDataset End Function ' Returns a DataSet containing all VisitorTypes Public Function GetAllVisitorTypes() As DataSet ' Get a reference to the data access object Dim dao As mmDataAccessBase = Me.GetDataAccessObject() ' Create and configure parameter objects ' Get a DataSet filled with the result set Dim dsVisitorTypes As DataSet = _ Me.GetDataSet( _ "SELECT * FROM VisitorTypes") Return dsVisitorTypes End Function End Class