Imports System Imports System.Data Imports System.Data.SqlTypes Imports System.Data.SqlClient Namespace VertragsverwaltungLLBL Public Class clsMADetail_RTB Inherits clsDBInteractionBase #Region " Class Member Declarations " Private m_iRTBAnteil, m_iMADetail_RTBNr As SqlInt32 Private m_sTGNummer, m_sName As SqlString #End Region Public Sub New() ' // Nothing for now. End Sub Overrides Public Function Insert() As Boolean Dim scmCmdToExecute As SqlCommand = New SqlCommand() scmCmdToExecute.CommandText = "dbo.[pr_MADetail_RTB_Insert]" scmCmdToExecute.CommandType = CommandType.StoredProcedure ' // Use base class' connection object scmCmdToExecute.Connection = m_scoMainConnection Try scmCmdToExecute.Parameters.Add(New SqlParameter("@sTGNummer", SqlDbType.VarChar, 255, ParameterDirection.Input, True, 0, 0, "", DataRowVersion.Proposed, m_sTGNummer)) scmCmdToExecute.Parameters.Add(New SqlParameter("@sName", SqlDbType.VarChar, 255, ParameterDirection.Input, True, 0, 0, "", DataRowVersion.Proposed, m_sName)) scmCmdToExecute.Parameters.Add(New SqlParameter("@iRTBAnteil", SqlDbType.Int, 4, ParameterDirection.Input, True, 10, 0, "", DataRowVersion.Proposed, m_iRTBAnteil)) scmCmdToExecute.Parameters.Add(new SqlParameter("@iMADetail_RTBNr", SqlDbType.Int, 4, ParameterDirection.Output, True, 10, 0, "", DataRowVersion.Proposed, m_iMADetail_RTBNr)) scmCmdToExecute.Parameters.Add(new SqlParameter("@iErrorCode", SqlDbType.Int, 4, ParameterDirection.Output, True, 10, 0, "", DataRowVersion.Proposed, m_iErrorCode)) If m_bMainConnectionIsCreatedLocal Then ' // Open connection. m_scoMainConnection.Open() Else If m_cpMainConnectionProvider.bIsTransactionPending Then scmCmdToExecute.Transaction = m_cpMainConnectionProvider.stCurrentTransaction End If End If ' // Execute query. m_iRowsAffected = scmCmdToExecute.ExecuteNonQuery() m_iMADetail_RTBNr = New SqlInt32(CType(scmCmdToExecute.Parameters.Item("@iMADetail_RTBNr").Value, Integer)) m_iErrorCode = New SqlInt32(CType(scmCmdToExecute.Parameters.Item("@iErrorCode").Value, SqlInt32)) If Not m_iErrorCode.Equals(New SqlInt32(LLBLError.AllOk)) Then ' // Throw error. Throw New Exception("Stored Procedure 'pr_MADetail_RTB_Insert' reported the ErrorCode: " & m_iErrorCode.ToString()) End If Return True Catch ex As Exception ' // some error occured. Bubble it to caller and encapsulate Exception object Throw New Exception("clsMADetail_RTB::Insert::Error occured.", ex) Finally If m_bMainConnectionIsCreatedLocal Then ' // Close connection. m_scoMainConnection.Close() End If scmCmdToExecute.Dispose() End Try End Function Overrides Public Function Update() As Boolean Dim scmCmdToExecute As SqlCommand = New SqlCommand() scmCmdToExecute.CommandText = "dbo.[pr_MADetail_RTB_Update]" scmCmdToExecute.CommandType = CommandType.StoredProcedure ' // Use base class' connection object scmCmdToExecute.Connection = m_scoMainConnection Try scmCmdToExecute.Parameters.Add(New SqlParameter("@iMADetail_RTBNr", SqlDbType.Int, 4, ParameterDirection.Input, False, 10, 0, "", DataRowVersion.Proposed, m_iMADetail_RTBNr)) scmCmdToExecute.Parameters.Add(New SqlParameter("@sTGNummer", SqlDbType.VarChar, 255, ParameterDirection.Input, True, 0, 0, "", DataRowVersion.Proposed, m_sTGNummer)) scmCmdToExecute.Parameters.Add(New SqlParameter("@sName", SqlDbType.VarChar, 255, ParameterDirection.Input, True, 0, 0, "", DataRowVersion.Proposed, m_sName)) scmCmdToExecute.Parameters.Add(New SqlParameter("@iRTBAnteil", SqlDbType.Int, 4, ParameterDirection.Input, True, 10, 0, "", DataRowVersion.Proposed, m_iRTBAnteil)) scmCmdToExecute.Parameters.Add(new SqlParameter("@iErrorCode", SqlDbType.Int, 4, ParameterDirection.Output, True, 10, 0, "", DataRowVersion.Proposed, m_iErrorCode)) If m_bMainConnectionIsCreatedLocal Then ' // Open connection. m_scoMainConnection.Open() Else If m_cpMainConnectionProvider.bIsTransactionPending Then scmCmdToExecute.Transaction = m_cpMainConnectionProvider.stCurrentTransaction End If End If ' // Execute query. m_iRowsAffected = scmCmdToExecute.ExecuteNonQuery() m_iErrorCode = New SqlInt32(CType(scmCmdToExecute.Parameters.Item("@iErrorCode").Value, SqlInt32)) If Not m_iErrorCode.Equals(New SqlInt32(LLBLError.AllOk)) Then ' // Throw error. Throw New Exception("Stored Procedure 'pr_MADetail_RTB_Update' reported the ErrorCode: " & m_iErrorCode.ToString()) End If Return True Catch ex As Exception ' // some error occured. Bubble it to caller and encapsulate Exception object Throw New Exception("clsMADetail_RTB::Update::Error occured.", ex) Finally If m_bMainConnectionIsCreatedLocal Then ' // Close connection. m_scoMainConnection.Close() End If scmCmdToExecute.Dispose() End Try End Function Overrides Public Function Delete() As Boolean Dim scmCmdToExecute As SqlCommand = New SqlCommand() scmCmdToExecute.CommandText = "dbo.[pr_MADetail_RTB_Delete]" scmCmdToExecute.CommandType = CommandType.StoredProcedure ' // Use base class' connection object scmCmdToExecute.Connection = m_scoMainConnection Try scmCmdToExecute.Parameters.Add(New SqlParameter("@iMADetail_RTBNr", SqlDbType.Int, 4, ParameterDirection.Input, False, 10, 0, "", DataRowVersion.Proposed, m_iMADetail_RTBNr)) scmCmdToExecute.Parameters.Add(new SqlParameter("@iErrorCode", SqlDbType.Int, 4, ParameterDirection.Output, True, 10, 0, "", DataRowVersion.Proposed, m_iErrorCode)) If m_bMainConnectionIsCreatedLocal Then ' // Open connection. m_scoMainConnection.Open() Else If m_cpMainConnectionProvider.bIsTransactionPending Then scmCmdToExecute.Transaction = m_cpMainConnectionProvider.stCurrentTransaction End If End If ' // Execute query. m_iRowsAffected = scmCmdToExecute.ExecuteNonQuery() m_iErrorCode = New SqlInt32(CType(scmCmdToExecute.Parameters.Item("@iErrorCode").Value, SqlInt32)) If Not m_iErrorCode.Equals(New SqlInt32(LLBLError.AllOk)) Then ' // Throw error. Throw New Exception("Stored Procedure 'pr_MADetail_RTB_Delete' reported the ErrorCode: " & m_iErrorCode.ToString()) End If Return True Catch ex As Exception ' // some error occured. Bubble it to caller and encapsulate Exception object Throw New Exception("clsMADetail_RTB::Delete::Error occured.", ex) Finally If m_bMainConnectionIsCreatedLocal Then ' // Close connection. m_scoMainConnection.Close() End If scmCmdToExecute.Dispose() End Try End Function Overrides Public Function SelectOne() As DataTable Dim scmCmdToExecute As SqlCommand = New SqlCommand() scmCmdToExecute.CommandText = "dbo.[pr_MADetail_RTB_SelectOne]" scmCmdToExecute.CommandType = CommandType.StoredProcedure Dim dtToReturn As DataTable = new DataTable("MADetail_RTB") Dim sdaAdapter As SqlDataAdapter = new SqlDataAdapter(scmCmdToExecute) ' // Use base class' connection object scmCmdToExecute.Connection = m_scoMainConnection Try scmCmdToExecute.Parameters.Add(new SqlParameter("@iMADetail_RTBNr", SqlDbType.Int, 4, ParameterDirection.Input, False, 10, 0, "", DataRowVersion.Proposed, m_iMADetail_RTBNr)) scmCmdToExecute.Parameters.Add(new SqlParameter("@iErrorCode", SqlDbType.Int, 4, ParameterDirection.Output, True, 10, 0, "", DataRowVersion.Proposed, m_iErrorCode)) If m_bMainConnectionIsCreatedLocal Then ' // Open connection. m_scoMainConnection.Open() Else If m_cpMainConnectionProvider.bIsTransactionPending Then scmCmdToExecute.Transaction = m_cpMainConnectionProvider.stCurrentTransaction End If End If ' // Execute query. sdaAdapter.Fill(dtToReturn) m_iErrorCode = New SqlInt32(CType(scmCmdToExecute.Parameters.Item("@iErrorCode").Value, SqlInt32)) If Not m_iErrorCode.Equals(New SqlInt32(LLBLError.AllOk)) Then ' // Throw error. Throw New Exception("Stored Procedure 'pr_MADetail_RTB_SelectOne' reported the ErrorCode: " & m_iErrorCode.ToString()) End If If dtToReturn.Rows.Count > 0 Then m_iMADetail_RTBNr = New SqlInt32(CType(dtToReturn.Rows(0)("MADetail_RTBNr"), Integer)) If dtToReturn.Rows(0)("TGNummer") Is System.DBNull.Value Then m_sTGNummer = SqlString.Null Else m_sTGNummer = New SqlString(CType(dtToReturn.Rows(0)("TGNummer"), String)) End If If dtToReturn.Rows(0)("Name") Is System.DBNull.Value Then m_sName = SqlString.Null Else m_sName = New SqlString(CType(dtToReturn.Rows(0)("Name"), String)) End If If dtToReturn.Rows(0)("RTBAnteil") Is System.DBNull.Value Then m_iRTBAnteil = SqlInt32.Null Else m_iRTBAnteil = New SqlInt32(CType(dtToReturn.Rows(0)("RTBAnteil"), Integer)) End If End If Return dtToReturn Catch ex As Exception ' // some error occured. Bubble it to caller and encapsulate Exception object Throw New Exception("clsMADetail_RTB::SelectOne::Error occured.", ex) Finally If m_bMainConnectionIsCreatedLocal Then ' // Close connection. m_scoMainConnection.Close() End If scmCmdToExecute.Dispose() sdaAdapter.Dispose() End Try End Function Overrides Public Function SelectAll() As DataTable Dim scmCmdToExecute As SqlCommand = New SqlCommand() scmCmdToExecute.CommandText = "dbo.[pr_MADetail_RTB_SelectAll]" scmCmdToExecute.CommandType = CommandType.StoredProcedure Dim dtToReturn As DataTable = new DataTable("MADetail_RTB") Dim sdaAdapter As SqlDataAdapter = new SqlDataAdapter(scmCmdToExecute) ' // Use base class' connection object scmCmdToExecute.Connection = m_scoMainConnection Try scmCmdToExecute.Parameters.Add(new SqlParameter("@iErrorCode", SqlDbType.Int, 4, ParameterDirection.Output, True, 10, 0, "", DataRowVersion.Proposed, m_iErrorCode)) If m_bMainConnectionIsCreatedLocal Then ' // Open connection. m_scoMainConnection.Open() Else If m_cpMainConnectionProvider.bIsTransactionPending Then scmCmdToExecute.Transaction = m_cpMainConnectionProvider.stCurrentTransaction End If End If ' // Execute query. sdaAdapter.Fill(dtToReturn) m_iErrorCode = New SqlInt32(CType(scmCmdToExecute.Parameters.Item("@iErrorCode").Value, SqlInt32)) If Not m_iErrorCode.Equals(New SqlInt32(LLBLError.AllOk)) Then ' // Throw error. Throw New Exception("Stored Procedure 'pr_MADetail_RTB_SelectAll' reported the ErrorCode: " & m_iErrorCode.ToString()) End If Return dtToReturn Catch ex As Exception ' // some error occured. Bubble it to caller and encapsulate Exception object Throw New Exception("clsMADetail_RTB::SelectAll::Error occured.", ex) Finally If m_bMainConnectionIsCreatedLocal Then ' // Close connection. m_scoMainConnection.Close() End If scmCmdToExecute.Dispose() sdaAdapter.Dispose() End Try End Function #Region " Class Property Declarations " Public Property [iMADetail_RTBNr]() As SqlInt32 Get Return m_iMADetail_RTBNr End Get Set(ByVal Value As SqlInt32) Dim iMADetail_RTBNrTmp As SqlInt32 = Value If iMADetail_RTBNrTmp.IsNull Then Throw New ArgumentOutOfRangeException("iMADetail_RTBNr", "iMADetail_RTBNr can't be NULL") End If m_iMADetail_RTBNr = Value End Set End Property Public Property [sTGNummer]() As SqlString Get Return m_sTGNummer End Get Set(ByVal Value As SqlString) m_sTGNummer = Value End Set End Property Public Property [sName]() As SqlString Get Return m_sName End Get Set(ByVal Value As SqlString) m_sName = Value End Set End Property Public Property [iRTBAnteil]() As SqlInt32 Get Return m_iRTBAnteil End Get Set(ByVal Value As SqlInt32) m_iRTBAnteil = Value End Set End Property #End Region End Class End Namespace