How to Create 3 Tier Vb.Net Desktop Application - Part 2 BLL Code
Hi Everyone I hope you enjoyed Lots with Our How to Create 3 Tier Vb.Net Desktop Application Article Part 1. Now Lets Continue with Part 2 that will show you how you can build up BLL (Business Logic Code).
BLL Code
ScheduleMaster.Vb Code
'********* Function Class **********************
#Region " Data Access <<Imported NameSpaces>> "
Imports DLL.Kcon.Practices.PrivateLibrary.DataLib
Imports System.Data.Common
#End Region
#Region " <<Namespace, Class and Functions>> "
Namespace Kcon.Practices.PrivateLibrary
Public Class Schedule_Master
#Region " Variable Declaration "
Private objDAL As New DataAccess
#End Region
#Region " Stored Procedures Names "
Private PRCINS As String = "Schedule_MasterIns"
Private PRCUPD As String = "Schedule_MasterUpd"
Private PRCDEL As String = "Schedule_MasterDel"
Private PRCGETBYID As String = "Schedule_MasterGetByID"
Private PRCGETBYPARAM As String = "Schedule_MasterGetByParam"
Private PRCGETFORSEARCH As String = "Schedule_MasterGetforSearch"
#End Region
#Region " Functions "
Public Function Insert(ByVal objProp As Schedule_MasterProperty) As Int64
Dim parameterInformation As Request.ParameterInformation = Nothing
Dim parameterRequest As Request = Nothing
Try
objDAL.BeginTransaction(IsolationLevel.ReadCommitted)
parameterRequest = New Request
parameterRequest.CommandText = PRCINS
parameterRequest.CommandType = CommandType.StoredProcedure
parameterInformation = New Request.ParameterInformation
parameterInformation.ParameterDirection = ParameterDirection.Input
parameterInformation.ParameterName = "@Schedule_Type_Id"
parameterInformation.ParameterType = DbType.Int32
parameterInformation.ParameterValue = objProp.Schedule_Type_Id
parameterRequest.Parameters.Add(parameterInformation)
parameterInformation = Nothing
parameterInformation = New Request.ParameterInformation
parameterInformation.ParameterDirection = ParameterDirection.Input
parameterInformation.ParameterName = "@Schedule"
parameterInformation.ParameterType = DbType.string
parameterInformation.ParameterValue = objProp.Schedule
parameterRequest.Parameters.Add(parameterInformation)
parameterInformation = Nothing
parameterInformation = New Request.ParameterInformation
parameterInformation.ParameterDirection = ParameterDirection.Input
parameterInformation.ParameterName = "@Annex_Code"
parameterInformation.ParameterType = DbType.string
parameterInformation.ParameterValue = objProp.Annex_Code
parameterRequest.Parameters.Add(parameterInformation)
parameterInformation = Nothing
parameterInformation = New Request.ParameterInformation
parameterInformation.ParameterDirection = ParameterDirection.Input
parameterInformation.ParameterName = "@Schedule_Order"
parameterInformation.ParameterType = DbType.Int32
parameterInformation.ParameterValue = objProp.Schedule_Order
parameterRequest.Parameters.Add(parameterInformation)
parameterInformation = Nothing
parameterInformation = New Request.ParameterInformation
parameterInformation.ParameterDirection = ParameterDirection.Input
parameterInformation.ParameterName = "@Remark"
parameterInformation.ParameterType = DbType.string
parameterInformation.ParameterValue = objProp.Remark
parameterRequest.Parameters.Add(parameterInformation)
parameterInformation = Nothing
parameterInformation = New Request.ParameterInformation
parameterInformation.ParameterDirection = ParameterDirection.Input
parameterInformation.ParameterName = "@Record_Id"
parameterInformation.ParameterType = DbType.Int32
parameterInformation.ParameterValue = objProp.Record_Id
parameterRequest.Parameters.Add(parameterInformation)
parameterInformation = Nothing
parameterInformation = New Request.ParameterInformation
parameterInformation.ParameterDirection = ParameterDirection.Output
parameterInformation.ParameterName = "@ReturnValue"
parameterInformation.ParameterType = DbType.Int64
parameterRequest.Parameters.Add(parameterInformation)
parameterInformation = Nothing
Dim arrayReturnValues As ArrayList = objDAL.ExecuteNonQueryReturnValues(parameterRequest)
Dim returnValue As Int64
returnValue = CType(arrayReturnValues.Item(0), Int64)
objDAL.CommitTransaction()
Return returnValue
Catch ex As Exception
Throw ex
Finally
If Not parameterInformation Is Nothing Then
parameterInformation = Nothing
End If
If Not parameterRequest Is Nothing Then
parameterRequest = Nothing
End If
End Try
End Function
Public Function Update(ByVal objProp As Schedule_MasterProperty) As Int64
Dim parameterInformation As Request.ParameterInformation = Nothing
Dim parameterRequest As Request = Nothing
Try
objDAL.BeginTransaction(IsolationLevel.ReadCommitted)
parameterRequest = New Request
parameterRequest.CommandText = PRCUPD
parameterRequest.CommandType = CommandType.StoredProcedure
parameterInformation = New Request.ParameterInformation
parameterInformation.ParameterDirection = ParameterDirection.Input
parameterInformation.ParameterName = "@Schedule_Id"
parameterInformation.ParameterType = DbType.Int32
parameterInformation.ParameterValue = objProp.Schedule_Id
parameterRequest.Parameters.Add(parameterInformation)
parameterInformation = Nothing
parameterInformation = New Request.ParameterInformation
parameterInformation.ParameterDirection = ParameterDirection.Input
parameterInformation.ParameterName = "@Schedule_Type_Id"
parameterInformation.ParameterType = DbType.Int32
parameterInformation.ParameterValue = objProp.Schedule_Type_Id
parameterRequest.Parameters.Add(parameterInformation)
parameterInformation = Nothing
parameterInformation = New Request.ParameterInformation
parameterInformation.ParameterDirection = ParameterDirection.Input
parameterInformation.ParameterName = "@Schedule"
parameterInformation.ParameterType = DbType.string
parameterInformation.ParameterValue = objProp.Schedule
parameterRequest.Parameters.Add(parameterInformation)
parameterInformation = Nothing
parameterInformation = New Request.ParameterInformation
parameterInformation.ParameterDirection = ParameterDirection.Input
parameterInformation.ParameterName = "@Annex_Code"
parameterInformation.ParameterType = DbType.string
parameterInformation.ParameterValue = objProp.Annex_Code
parameterRequest.Parameters.Add(parameterInformation)
parameterInformation = Nothing
parameterInformation = New Request.ParameterInformation
parameterInformation.ParameterDirection = ParameterDirection.Input
parameterInformation.ParameterName = "@Schedule_Order"
parameterInformation.ParameterType = DbType.Int32
parameterInformation.ParameterValue = objProp.Schedule_Order
parameterRequest.Parameters.Add(parameterInformation)
parameterInformation = Nothing
parameterInformation = New Request.ParameterInformation
parameterInformation.ParameterDirection = ParameterDirection.Input
parameterInformation.ParameterName = "@Remark"
parameterInformation.ParameterType = DbType.string
parameterInformation.ParameterValue = objProp.Remark
parameterRequest.Parameters.Add(parameterInformation)
parameterInformation = Nothing
parameterInformation = New Request.ParameterInformation
parameterInformation.ParameterDirection = ParameterDirection.Input
parameterInformation.ParameterName = "@Record_Id"
parameterInformation.ParameterType = DbType.Int32
parameterInformation.ParameterValue = objProp.Record_Id
parameterRequest.Parameters.Add(parameterInformation)
parameterInformation = Nothing
parameterInformation = New Request.ParameterInformation
parameterInformation.ParameterDirection = ParameterDirection.Output
parameterInformation.ParameterName = "@ReturnValue"
parameterInformation.ParameterType = DbType.Int64
parameterRequest.Parameters.Add(parameterInformation)
parameterInformation = Nothing
Dim arrayReturnValues As ArrayList = objDAL.ExecuteNonQueryReturnValues(parameterRequest)
Dim returnValue As Int64
returnValue = CType(arrayReturnValues.Item(0), Int64)
objDAL.CommitTransaction()
Return returnValue
Catch ex As Exception
Throw ex
Finally
If Not parameterInformation Is Nothing Then
parameterInformation = Nothing
End If
If Not parameterRequest Is Nothing Then
parameterRequest = Nothing
End If
End Try
End Function
Public Function Delete(ByVal PKID As Int64) As Int16
Dim parameterRequest As Request = Nothing
Dim parameterInformation As Request.ParameterInformation = Nothing
Try
objDAL.BeginTransaction(IsolationLevel.ReadCommitted)
parameterRequest = New Request
parameterRequest.CommandText = PRCDEL
parameterRequest.CommandType = CommandType.StoredProcedure
parameterInformation = New Request.ParameterInformation
parameterInformation.ParameterDirection = ParameterDirection.Input
parameterInformation.ParameterName = "@Schedule_Id"
parameterInformation.ParameterType = DbType.Int32
parameterInformation.ParameterValue = PKID
parameterRequest.Parameters.Add(parameterInformation)
parameterInformation = Nothing
parameterInformation = New Request.ParameterInformation
parameterInformation.ParameterDirection = ParameterDirection.Output
parameterInformation.ParameterName = "@ReturnValue"
parameterInformation.ParameterType = DbType.Int64
parameterRequest.Parameters.Add(parameterInformation)
parameterInformation = Nothing
Dim arrayReturnValues As ArrayList = objDAL.ExecuteNonQueryReturnValues(parameterRequest)
Dim returnValue As Integer
returnValue = CType(arrayReturnValues.Item(0), Integer)
objDAL.CommitTransaction()
Return returnValue
Catch ex As Exception
Throw ex
Finally
If Not parameterInformation Is Nothing Then
parameterInformation = Nothing
End If
If Not parameterRequest Is Nothing Then
parameterRequest = Nothing
End If
End Try
End Function
Public Function GetDataByPK(ByVal PKID As Int64) As Schedule_MasterProperty
Dim parameterRequest As Request = Nothing
Dim parameterInformation As Request.ParameterInformation = Nothing
Dim objReader As DbDataReader = Nothing
Dim objProp As New Schedule_MasterProperty
Try
parameterRequest = New Request
parameterRequest.CommandText = PRCGETBYID
parameterRequest.CommandType = CommandType.StoredProcedure
parameterInformation = New Request.ParameterInformation
parameterInformation.ParameterDirection = ParameterDirection.Input
parameterInformation.ParameterName = "@Schedule_Id"
parameterInformation.ParameterType = DbType.Int32
parameterInformation.ParameterValue = PKID
parameterRequest.Parameters.Add(parameterInformation)
parameterInformation = Nothing
objReader = objDAL.ExecuteDataReader(parameterRequest)
If objReader.HasRows Then
objReader.Read()
objProp.Schedule_Id = CType(IIf(IsDBNull(objReader.Item("Schedule_Id")), 0, objReader.Item("Schedule_Id")), Int32)
objProp.Schedule_Type_Id = CType(IIf(IsDBNull(objReader.Item("Schedule_Type_Id")), 0, objReader.Item("Schedule_Type_Id")), Int32)
objProp.Schedule = CType(IIf(IsDBNull(objReader.Item("Schedule")), String.Empty, objReader.Item("Schedule")), String)
objProp.Annex_Code = CType(IIf(IsDBNull(objReader.Item("Annex_Code")), String.Empty, objReader.Item("Annex_Code")), String)
objProp.Schedule_Order = CType(IIf(IsDBNull(objReader.Item("Schedule_Order")), 0, objReader.Item("Schedule_Order")), Int32)
objProp.Remark = CType(IIf(IsDBNull(objReader.Item("Remark")), String.Empty, objReader.Item("Remark")), String)
objProp.Record_Id = CType(IIf(IsDBNull(objReader.Item("Record_Id")), 0, objReader.Item("Record_Id")), Int32)
End If
objReader.Close()
Return objProp
Catch ex As Exception
Throw ex
Finally
If Not parameterInformation Is Nothing Then
parameterInformation = Nothing
End If
If Not parameterRequest Is Nothing Then
parameterRequest = Nothing
End If
End Try
End Function
Public Function GetData(ByVal SearchCriteria As String) As DataTable
Dim databaseReader As DbDataReader = Nothing
Dim parameterRequest As Request = Nothing
Dim parameterInformation As Request.ParameterInformation = Nothing
Try
parameterRequest = New Request
parameterRequest.CommandText = PRCGETBYPARAM
parameterRequest.CommandType = CommandType.StoredProcedure
parameterInformation = New Request.ParameterInformation
parameterInformation.ParameterDirection = ParameterDirection.Input
parameterInformation.ParameterName = "@SearchParam"
parameterInformation.ParameterType = DbType.String
parameterInformation.ParameterValue = SearchCriteria
parameterRequest.Parameters.Add(parameterInformation)
databaseReader = objDAL.ExecuteDataReader(parameterRequest)
Dim dtTable As New DataTable
dtTable.Load(databaseReader)
Return dtTable
Catch ex As Exception
Throw ex
Finally
If Not databaseReader Is Nothing Then
databaseReader.Close()
databaseReader = Nothing
End If
If Not parameterInformation Is Nothing Then
parameterInformation = Nothing
End If
If Not parameterRequest Is Nothing Then
parameterRequest = Nothing
End If
End Try
End Function
Public Function GetDataSearch(ByVal SearchCriteria As String) As DataTable
Dim databaseReader As DbDataReader = Nothing
Dim parameterRequest As Request = Nothing
Dim parameterInformation As Request.ParameterInformation = Nothing
Try
parameterRequest = New Request
parameterRequest.CommandText = PRCGETFORSEARCH
parameterRequest.CommandType = CommandType.StoredProcedure
parameterInformation = New Request.ParameterInformation
parameterInformation.ParameterDirection = ParameterDirection.Input
parameterInformation.ParameterName = "@SearchParam"
parameterInformation.ParameterType = DbType.String
parameterInformation.ParameterValue = SearchCriteria
parameterRequest.Parameters.Add(parameterInformation)
databaseReader = objDAL.ExecuteDataReader(parameterRequest)
Dim dtTable As New DataTable
dtTable.Load(databaseReader)
Return dtTable
Catch ex As Exception
Throw ex
Finally
If Not databaseReader Is Nothing Then
databaseReader.Close()
databaseReader = Nothing
End If
If Not parameterInformation Is Nothing Then
parameterInformation = Nothing
End If
If Not parameterRequest Is Nothing Then
parameterRequest = Nothing
End If
End Try
End Function
#End Region
End Class
End Namespace
#End Region
''********** END Function Class *****************
ScheduleMasterProperty.Vb Code
'' ************ Property Class **********
#Region " Data Access <<Imported NameSpaces>> "
Imports DLL.Kcon.Practices.PrivateLibrary.DataLib
#End Region
Namespace Kcon.Practices.PrivateLibrary
Public Class Schedule_MasterProperty
#Region " Private variables "
Private _Schedule_Id As Int32
Private _Schedule_Type_Id As Int32
Private _Schedule As String
Private _Annex_Code As String
Private _Schedule_Order As Int32
Private _Remark As String
Private _Record_Id As Int32
#End Region
#Region " Properties "
Public Property Schedule_Id() As Int32
Get
Return _Schedule_Id
End Get
Set(ByVal Value As Int32)
_Schedule_Id = Value
End Set
End Property
Public Property Schedule_Type_Id() As Int32
Get
Return _Schedule_Type_Id
End Get
Set(ByVal Value As Int32)
_Schedule_Type_Id = Value
End Set
End Property
Public Property Schedule() As String
Get
Return _Schedule
End Get
Set(ByVal Value As String)
_Schedule = Value
End Set
End Property
Public Property Annex_Code() As String
Get
Return _Annex_Code
End Get
Set(ByVal Value As String)
_Annex_Code = Value
End Set
End Property
Public Property Schedule_Order() As Int32
Get
Return _Schedule_Order
End Get
Set(ByVal Value As Int32)
_Schedule_Order = Value
End Set
End Property
Public Property Remark() As String
Get
Return _Remark
End Get
Set(ByVal Value As String)
_Remark = Value
End Set
End Property
Public Property Record_Id() As Int32
Get
Return _Record_Id
End Get
Set(ByVal Value As Int32)
_Record_Id = Value
End Set
End Property
#End Region
#Region " Initialize Variables "
Public Sub New()
_Schedule_Id = 0
_Schedule_Type_Id = 0
_Schedule = String.Empty
_Annex_Code = String.Empty
_Schedule_Order = 0
_Remark = String.Empty
_Record_Id = 0
End Sub
#End Region
End Class
End Namespace
BLL Code
ScheduleMaster.Vb Code
'********* Function Class **********************
#Region " Data Access <<Imported NameSpaces>> "
Imports DLL.Kcon.Practices.PrivateLibrary.DataLib
Imports System.Data.Common
#End Region
#Region " <<Namespace, Class and Functions>> "
Namespace Kcon.Practices.PrivateLibrary
Public Class Schedule_Master
#Region " Variable Declaration "
Private objDAL As New DataAccess
#End Region
#Region " Stored Procedures Names "
Private PRCINS As String = "Schedule_MasterIns"
Private PRCUPD As String = "Schedule_MasterUpd"
Private PRCDEL As String = "Schedule_MasterDel"
Private PRCGETBYID As String = "Schedule_MasterGetByID"
Private PRCGETBYPARAM As String = "Schedule_MasterGetByParam"
Private PRCGETFORSEARCH As String = "Schedule_MasterGetforSearch"
#End Region
#Region " Functions "
Public Function Insert(ByVal objProp As Schedule_MasterProperty) As Int64
Dim parameterInformation As Request.ParameterInformation = Nothing
Dim parameterRequest As Request = Nothing
Try
objDAL.BeginTransaction(IsolationLevel.ReadCommitted)
parameterRequest = New Request
parameterRequest.CommandText = PRCINS
parameterRequest.CommandType = CommandType.StoredProcedure
parameterInformation = New Request.ParameterInformation
parameterInformation.ParameterDirection = ParameterDirection.Input
parameterInformation.ParameterName = "@Schedule_Type_Id"
parameterInformation.ParameterType = DbType.Int32
parameterInformation.ParameterValue = objProp.Schedule_Type_Id
parameterRequest.Parameters.Add(parameterInformation)
parameterInformation = Nothing
parameterInformation = New Request.ParameterInformation
parameterInformation.ParameterDirection = ParameterDirection.Input
parameterInformation.ParameterName = "@Schedule"
parameterInformation.ParameterType = DbType.string
parameterInformation.ParameterValue = objProp.Schedule
parameterRequest.Parameters.Add(parameterInformation)
parameterInformation = Nothing
parameterInformation = New Request.ParameterInformation
parameterInformation.ParameterDirection = ParameterDirection.Input
parameterInformation.ParameterName = "@Annex_Code"
parameterInformation.ParameterType = DbType.string
parameterInformation.ParameterValue = objProp.Annex_Code
parameterRequest.Parameters.Add(parameterInformation)
parameterInformation = Nothing
parameterInformation = New Request.ParameterInformation
parameterInformation.ParameterDirection = ParameterDirection.Input
parameterInformation.ParameterName = "@Schedule_Order"
parameterInformation.ParameterType = DbType.Int32
parameterInformation.ParameterValue = objProp.Schedule_Order
parameterRequest.Parameters.Add(parameterInformation)
parameterInformation = Nothing
parameterInformation = New Request.ParameterInformation
parameterInformation.ParameterDirection = ParameterDirection.Input
parameterInformation.ParameterName = "@Remark"
parameterInformation.ParameterType = DbType.string
parameterInformation.ParameterValue = objProp.Remark
parameterRequest.Parameters.Add(parameterInformation)
parameterInformation = Nothing
parameterInformation = New Request.ParameterInformation
parameterInformation.ParameterDirection = ParameterDirection.Input
parameterInformation.ParameterName = "@Record_Id"
parameterInformation.ParameterType = DbType.Int32
parameterInformation.ParameterValue = objProp.Record_Id
parameterRequest.Parameters.Add(parameterInformation)
parameterInformation = Nothing
parameterInformation = New Request.ParameterInformation
parameterInformation.ParameterDirection = ParameterDirection.Output
parameterInformation.ParameterName = "@ReturnValue"
parameterInformation.ParameterType = DbType.Int64
parameterRequest.Parameters.Add(parameterInformation)
parameterInformation = Nothing
Dim arrayReturnValues As ArrayList = objDAL.ExecuteNonQueryReturnValues(parameterRequest)
Dim returnValue As Int64
returnValue = CType(arrayReturnValues.Item(0), Int64)
objDAL.CommitTransaction()
Return returnValue
Catch ex As Exception
Throw ex
Finally
If Not parameterInformation Is Nothing Then
parameterInformation = Nothing
End If
If Not parameterRequest Is Nothing Then
parameterRequest = Nothing
End If
End Try
End Function
Public Function Update(ByVal objProp As Schedule_MasterProperty) As Int64
Dim parameterInformation As Request.ParameterInformation = Nothing
Dim parameterRequest As Request = Nothing
Try
objDAL.BeginTransaction(IsolationLevel.ReadCommitted)
parameterRequest = New Request
parameterRequest.CommandText = PRCUPD
parameterRequest.CommandType = CommandType.StoredProcedure
parameterInformation = New Request.ParameterInformation
parameterInformation.ParameterDirection = ParameterDirection.Input
parameterInformation.ParameterName = "@Schedule_Id"
parameterInformation.ParameterType = DbType.Int32
parameterInformation.ParameterValue = objProp.Schedule_Id
parameterRequest.Parameters.Add(parameterInformation)
parameterInformation = Nothing
parameterInformation = New Request.ParameterInformation
parameterInformation.ParameterDirection = ParameterDirection.Input
parameterInformation.ParameterName = "@Schedule_Type_Id"
parameterInformation.ParameterType = DbType.Int32
parameterInformation.ParameterValue = objProp.Schedule_Type_Id
parameterRequest.Parameters.Add(parameterInformation)
parameterInformation = Nothing
parameterInformation = New Request.ParameterInformation
parameterInformation.ParameterDirection = ParameterDirection.Input
parameterInformation.ParameterName = "@Schedule"
parameterInformation.ParameterType = DbType.string
parameterInformation.ParameterValue = objProp.Schedule
parameterRequest.Parameters.Add(parameterInformation)
parameterInformation = Nothing
parameterInformation = New Request.ParameterInformation
parameterInformation.ParameterDirection = ParameterDirection.Input
parameterInformation.ParameterName = "@Annex_Code"
parameterInformation.ParameterType = DbType.string
parameterInformation.ParameterValue = objProp.Annex_Code
parameterRequest.Parameters.Add(parameterInformation)
parameterInformation = Nothing
parameterInformation = New Request.ParameterInformation
parameterInformation.ParameterDirection = ParameterDirection.Input
parameterInformation.ParameterName = "@Schedule_Order"
parameterInformation.ParameterType = DbType.Int32
parameterInformation.ParameterValue = objProp.Schedule_Order
parameterRequest.Parameters.Add(parameterInformation)
parameterInformation = Nothing
parameterInformation = New Request.ParameterInformation
parameterInformation.ParameterDirection = ParameterDirection.Input
parameterInformation.ParameterName = "@Remark"
parameterInformation.ParameterType = DbType.string
parameterInformation.ParameterValue = objProp.Remark
parameterRequest.Parameters.Add(parameterInformation)
parameterInformation = Nothing
parameterInformation = New Request.ParameterInformation
parameterInformation.ParameterDirection = ParameterDirection.Input
parameterInformation.ParameterName = "@Record_Id"
parameterInformation.ParameterType = DbType.Int32
parameterInformation.ParameterValue = objProp.Record_Id
parameterRequest.Parameters.Add(parameterInformation)
parameterInformation = Nothing
parameterInformation = New Request.ParameterInformation
parameterInformation.ParameterDirection = ParameterDirection.Output
parameterInformation.ParameterName = "@ReturnValue"
parameterInformation.ParameterType = DbType.Int64
parameterRequest.Parameters.Add(parameterInformation)
parameterInformation = Nothing
Dim arrayReturnValues As ArrayList = objDAL.ExecuteNonQueryReturnValues(parameterRequest)
Dim returnValue As Int64
returnValue = CType(arrayReturnValues.Item(0), Int64)
objDAL.CommitTransaction()
Return returnValue
Catch ex As Exception
Throw ex
Finally
If Not parameterInformation Is Nothing Then
parameterInformation = Nothing
End If
If Not parameterRequest Is Nothing Then
parameterRequest = Nothing
End If
End Try
End Function
Public Function Delete(ByVal PKID As Int64) As Int16
Dim parameterRequest As Request = Nothing
Dim parameterInformation As Request.ParameterInformation = Nothing
Try
objDAL.BeginTransaction(IsolationLevel.ReadCommitted)
parameterRequest = New Request
parameterRequest.CommandText = PRCDEL
parameterRequest.CommandType = CommandType.StoredProcedure
parameterInformation = New Request.ParameterInformation
parameterInformation.ParameterDirection = ParameterDirection.Input
parameterInformation.ParameterName = "@Schedule_Id"
parameterInformation.ParameterType = DbType.Int32
parameterInformation.ParameterValue = PKID
parameterRequest.Parameters.Add(parameterInformation)
parameterInformation = Nothing
parameterInformation = New Request.ParameterInformation
parameterInformation.ParameterDirection = ParameterDirection.Output
parameterInformation.ParameterName = "@ReturnValue"
parameterInformation.ParameterType = DbType.Int64
parameterRequest.Parameters.Add(parameterInformation)
parameterInformation = Nothing
Dim arrayReturnValues As ArrayList = objDAL.ExecuteNonQueryReturnValues(parameterRequest)
Dim returnValue As Integer
returnValue = CType(arrayReturnValues.Item(0), Integer)
objDAL.CommitTransaction()
Return returnValue
Catch ex As Exception
Throw ex
Finally
If Not parameterInformation Is Nothing Then
parameterInformation = Nothing
End If
If Not parameterRequest Is Nothing Then
parameterRequest = Nothing
End If
End Try
End Function
Public Function GetDataByPK(ByVal PKID As Int64) As Schedule_MasterProperty
Dim parameterRequest As Request = Nothing
Dim parameterInformation As Request.ParameterInformation = Nothing
Dim objReader As DbDataReader = Nothing
Dim objProp As New Schedule_MasterProperty
Try
parameterRequest = New Request
parameterRequest.CommandText = PRCGETBYID
parameterRequest.CommandType = CommandType.StoredProcedure
parameterInformation = New Request.ParameterInformation
parameterInformation.ParameterDirection = ParameterDirection.Input
parameterInformation.ParameterName = "@Schedule_Id"
parameterInformation.ParameterType = DbType.Int32
parameterInformation.ParameterValue = PKID
parameterRequest.Parameters.Add(parameterInformation)
parameterInformation = Nothing
objReader = objDAL.ExecuteDataReader(parameterRequest)
If objReader.HasRows Then
objReader.Read()
objProp.Schedule_Id = CType(IIf(IsDBNull(objReader.Item("Schedule_Id")), 0, objReader.Item("Schedule_Id")), Int32)
objProp.Schedule_Type_Id = CType(IIf(IsDBNull(objReader.Item("Schedule_Type_Id")), 0, objReader.Item("Schedule_Type_Id")), Int32)
objProp.Schedule = CType(IIf(IsDBNull(objReader.Item("Schedule")), String.Empty, objReader.Item("Schedule")), String)
objProp.Annex_Code = CType(IIf(IsDBNull(objReader.Item("Annex_Code")), String.Empty, objReader.Item("Annex_Code")), String)
objProp.Schedule_Order = CType(IIf(IsDBNull(objReader.Item("Schedule_Order")), 0, objReader.Item("Schedule_Order")), Int32)
objProp.Remark = CType(IIf(IsDBNull(objReader.Item("Remark")), String.Empty, objReader.Item("Remark")), String)
objProp.Record_Id = CType(IIf(IsDBNull(objReader.Item("Record_Id")), 0, objReader.Item("Record_Id")), Int32)
End If
objReader.Close()
Return objProp
Catch ex As Exception
Throw ex
Finally
If Not parameterInformation Is Nothing Then
parameterInformation = Nothing
End If
If Not parameterRequest Is Nothing Then
parameterRequest = Nothing
End If
End Try
End Function
Public Function GetData(ByVal SearchCriteria As String) As DataTable
Dim databaseReader As DbDataReader = Nothing
Dim parameterRequest As Request = Nothing
Dim parameterInformation As Request.ParameterInformation = Nothing
Try
parameterRequest = New Request
parameterRequest.CommandText = PRCGETBYPARAM
parameterRequest.CommandType = CommandType.StoredProcedure
parameterInformation = New Request.ParameterInformation
parameterInformation.ParameterDirection = ParameterDirection.Input
parameterInformation.ParameterName = "@SearchParam"
parameterInformation.ParameterType = DbType.String
parameterInformation.ParameterValue = SearchCriteria
parameterRequest.Parameters.Add(parameterInformation)
databaseReader = objDAL.ExecuteDataReader(parameterRequest)
Dim dtTable As New DataTable
dtTable.Load(databaseReader)
Return dtTable
Catch ex As Exception
Throw ex
Finally
If Not databaseReader Is Nothing Then
databaseReader.Close()
databaseReader = Nothing
End If
If Not parameterInformation Is Nothing Then
parameterInformation = Nothing
End If
If Not parameterRequest Is Nothing Then
parameterRequest = Nothing
End If
End Try
End Function
Public Function GetDataSearch(ByVal SearchCriteria As String) As DataTable
Dim databaseReader As DbDataReader = Nothing
Dim parameterRequest As Request = Nothing
Dim parameterInformation As Request.ParameterInformation = Nothing
Try
parameterRequest = New Request
parameterRequest.CommandText = PRCGETFORSEARCH
parameterRequest.CommandType = CommandType.StoredProcedure
parameterInformation = New Request.ParameterInformation
parameterInformation.ParameterDirection = ParameterDirection.Input
parameterInformation.ParameterName = "@SearchParam"
parameterInformation.ParameterType = DbType.String
parameterInformation.ParameterValue = SearchCriteria
parameterRequest.Parameters.Add(parameterInformation)
databaseReader = objDAL.ExecuteDataReader(parameterRequest)
Dim dtTable As New DataTable
dtTable.Load(databaseReader)
Return dtTable
Catch ex As Exception
Throw ex
Finally
If Not databaseReader Is Nothing Then
databaseReader.Close()
databaseReader = Nothing
End If
If Not parameterInformation Is Nothing Then
parameterInformation = Nothing
End If
If Not parameterRequest Is Nothing Then
parameterRequest = Nothing
End If
End Try
End Function
#End Region
End Class
End Namespace
#End Region
''********** END Function Class *****************
ScheduleMasterProperty.Vb Code
'' ************ Property Class **********
#Region " Data Access <<Imported NameSpaces>> "
Imports DLL.Kcon.Practices.PrivateLibrary.DataLib
#End Region
Namespace Kcon.Practices.PrivateLibrary
Public Class Schedule_MasterProperty
#Region " Private variables "
Private _Schedule_Id As Int32
Private _Schedule_Type_Id As Int32
Private _Schedule As String
Private _Annex_Code As String
Private _Schedule_Order As Int32
Private _Remark As String
Private _Record_Id As Int32
#End Region
#Region " Properties "
Public Property Schedule_Id() As Int32
Get
Return _Schedule_Id
End Get
Set(ByVal Value As Int32)
_Schedule_Id = Value
End Set
End Property
Public Property Schedule_Type_Id() As Int32
Get
Return _Schedule_Type_Id
End Get
Set(ByVal Value As Int32)
_Schedule_Type_Id = Value
End Set
End Property
Public Property Schedule() As String
Get
Return _Schedule
End Get
Set(ByVal Value As String)
_Schedule = Value
End Set
End Property
Public Property Annex_Code() As String
Get
Return _Annex_Code
End Get
Set(ByVal Value As String)
_Annex_Code = Value
End Set
End Property
Public Property Schedule_Order() As Int32
Get
Return _Schedule_Order
End Get
Set(ByVal Value As Int32)
_Schedule_Order = Value
End Set
End Property
Public Property Remark() As String
Get
Return _Remark
End Get
Set(ByVal Value As String)
_Remark = Value
End Set
End Property
Public Property Record_Id() As Int32
Get
Return _Record_Id
End Get
Set(ByVal Value As Int32)
_Record_Id = Value
End Set
End Property
#End Region
#Region " Initialize Variables "
Public Sub New()
_Schedule_Id = 0
_Schedule_Type_Id = 0
_Schedule = String.Empty
_Annex_Code = String.Empty
_Schedule_Order = 0
_Remark = String.Empty
_Record_Id = 0
End Sub
#End Region
End Class
End Namespace
Comments