' /////////////////////////////////////////////////////////////////////////// ' // Description: Data Access class for the table 'Doks' ' // Generated by LLBLGen v1.2.1045.38210 Final on: Freitag, 28. März 2003, 00:20:12 ' // Because the Base Class already implements IDispose, this class doesn't. ' /////////////////////////////////////////////////////////////////////////// Imports System Imports System.Data Imports System.Data.SqlTypes Imports System.Data.SqlClient Namespace edokadb ' /// ' /// Purpose: Data Access class for the table 'Doks'. ' /// Public Class clsDoks Inherits clsDBInteractionBase #Region " Class Member Declarations " Private m_biDokument As SqlBinary Private m_sDokumentID As SqlString #End Region ' /// ' /// Purpose: Class constructor. ' /// Public Sub New() ' // Nothing for now. End Sub ' /// ' /// Purpose: Insert method. This method will insert one new row into the database. ' /// ' /// True if succeeded, otherwise an Exception is thrown. ' /// ' /// Properties needed for this method: ' /// ' /// Properties set after a succesful call of this method: ' /// ' /// Overrides Public Function Insert() As Boolean Dim scmCmdToExecute As SqlCommand = New SqlCommand() scmCmdToExecute.CommandText = "dbo.[pr_Doks_Insert]" scmCmdToExecute.CommandType = CommandType.StoredProcedure ' // Use base class' connection object scmCmdToExecute.Connection = m_scoMainConnection Try scmCmdToExecute.Parameters.Add(New SqlParameter("@sDokumentID", SqlDbType.VarChar, 22, ParameterDirection.Input, False, 0, 0, "", DataRowVersion.Proposed, m_sDokumentID)) scmCmdToExecute.Parameters.Add(New SqlParameter("@biDokument", SqlDbType.Binary, 50, ParameterDirection.Input, True, 0, 0, "", DataRowVersion.Proposed, m_biDokument)) 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. scmCmdToExecute.ExecuteNonQuery() m_iErrorCode = New SqlInt32(CType(scmCmdToExecute.Parameters.Item("@iErrorCode").Value, Integer)) If Not m_iErrorCode.Equals(New SqlInt32(LLBLError.AllOk)) Then ' // Throw error. Throw New Exception("Stored Procedure 'pr_Doks_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("clsDoks::Insert::Error occured.", ex) Finally If m_bMainConnectionIsCreatedLocal Then ' // Close connection. m_scoMainConnection.Close() End If scmCmdToExecute.Dispose() End Try End Function ' /// ' /// Purpose: Update method. This method will Update one existing row in the database. ' /// ' /// True if succeeded, otherwise an Exception is thrown. ' /// ' /// Properties needed for this method: ' /// ' /// Properties set after a succesful call of this method: ' /// ' /// Overrides Public Function Update() As Boolean Dim scmCmdToExecute As SqlCommand = New SqlCommand() scmCmdToExecute.CommandText = "dbo.[pr_Doks_Update]" scmCmdToExecute.CommandType = CommandType.StoredProcedure ' // Use base class' connection object scmCmdToExecute.Connection = m_scoMainConnection Try scmCmdToExecute.Parameters.Add(New SqlParameter("@sDokumentID", SqlDbType.VarChar, 22, ParameterDirection.Input, False, 0, 0, "", DataRowVersion.Proposed, m_sDokumentID)) scmCmdToExecute.Parameters.Add(New SqlParameter("@biDokument", SqlDbType.Binary, 50, ParameterDirection.Input, True, 0, 0, "", DataRowVersion.Proposed, m_biDokument)) 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. scmCmdToExecute.ExecuteNonQuery() m_iErrorCode = New SqlInt32(CType(scmCmdToExecute.Parameters.Item("@iErrorCode").Value, Integer)) If Not m_iErrorCode.Equals(New SqlInt32(LLBLError.AllOk)) Then ' // Throw error. Throw New Exception("Stored Procedure 'pr_Doks_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("clsDoks::Update::Error occured.", ex) Finally If m_bMainConnectionIsCreatedLocal Then ' // Close connection. m_scoMainConnection.Close() End If scmCmdToExecute.Dispose() End Try End Function ' /// ' /// Purpose: Delete method. This method will Delete one existing row in the database, based on the Primary Key. ' /// ' /// True if succeeded, otherwise an Exception is thrown. ' /// ' /// Properties needed for this method: ' /// ' /// Properties set after a succesful call of this method: ' /// ' /// Overrides Public Function Delete() As Boolean Dim scmCmdToExecute As SqlCommand = New SqlCommand() scmCmdToExecute.CommandText = "dbo.[pr_Doks_Delete]" scmCmdToExecute.CommandType = CommandType.StoredProcedure ' // Use base class' connection object scmCmdToExecute.Connection = m_scoMainConnection Try scmCmdToExecute.Parameters.Add(New SqlParameter("@sDokumentID", SqlDbType.VarChar, 22, ParameterDirection.Input, False, 0, 0, "", DataRowVersion.Proposed, m_sDokumentID)) 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. scmCmdToExecute.ExecuteNonQuery() m_iErrorCode = New SqlInt32(CType(scmCmdToExecute.Parameters.Item("@iErrorCode").Value, Integer)) If Not m_iErrorCode.Equals(New SqlInt32(LLBLError.AllOk)) Then ' // Throw error. Throw New Exception("Stored Procedure 'pr_Doks_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("clsDoks::Delete::Error occured.", ex) Finally If m_bMainConnectionIsCreatedLocal Then ' // Close connection. m_scoMainConnection.Close() End If scmCmdToExecute.Dispose() End Try End Function ' /// ' /// Purpose: Select method. This method will Select one existing row from the database, based on the Primary Key. ' /// ' /// DataTable object if succeeded, otherwise an Exception is thrown. ' /// ' /// Properties needed for this method: ' /// ' /// Properties set after a succesful call of this method: ' /// ' /// Will fill all properties corresponding with a field in the table with the value of the row selected. ' /// Overrides Public Function SelectOne() As DataTable Dim scmCmdToExecute As SqlCommand = New SqlCommand() scmCmdToExecute.CommandText = "dbo.[pr_Doks_SelectOne]" scmCmdToExecute.CommandType = CommandType.StoredProcedure Dim dtToReturn As DataTable = new DataTable("Doks") Dim sdaAdapter As SqlDataAdapter = new SqlDataAdapter(scmCmdToExecute) ' // Use base class' connection object scmCmdToExecute.Connection = m_scoMainConnection Try scmCmdToExecute.Parameters.Add(new SqlParameter("@sDokumentID", SqlDbType.VarChar, 22, ParameterDirection.Input, False, 0, 0, "", DataRowVersion.Proposed, m_sDokumentID)) 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, Integer)) If Not m_iErrorCode.Equals(New SqlInt32(LLBLError.AllOk)) Then ' // Throw error. Throw New Exception("Stored Procedure 'pr_Doks_SelectOne' reported the ErrorCode: " & m_iErrorCode.ToString()) End If If dtToReturn.Rows.Count > 0 Then m_sDokumentID = New SqlString(CType(dtToReturn.Rows(0)("DokumentID"), String)) If dtToReturn.Rows(0)("Dokument") Is System.DBNull.Value Then m_biDokument = SqlBinary.Null Else m_biDokument = New SqlBinary(CType(dtToReturn.Rows(0)("Dokument"), Byte())) End If End If Return dtToReturn Catch ex As Exception ' // some error occured. Bubble it to caller and encapsulate Exception object Throw New Exception("clsDoks::SelectOne::Error occured.", ex) Finally If m_bMainConnectionIsCreatedLocal Then ' // Close connection. m_scoMainConnection.Close() End If scmCmdToExecute.Dispose() sdaAdapter.Dispose() End Try End Function ' /// ' /// Purpose: SelectAll method. This method will Select all rows from the table. ' /// ' /// DataTable object if succeeded, otherwise an Exception is thrown. ' /// ' /// Properties set after a succesful call of this method: ' /// ' /// Overrides Public Function SelectAll() As DataTable Dim scmCmdToExecute As SqlCommand = New SqlCommand() scmCmdToExecute.CommandText = "dbo.[pr_Doks_SelectAll]" scmCmdToExecute.CommandType = CommandType.StoredProcedure Dim dtToReturn As DataTable = new DataTable("Doks") 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, Integer)) If Not m_iErrorCode.Equals(New SqlInt32(LLBLError.AllOk)) Then ' // Throw error. Throw New Exception("Stored Procedure 'pr_Doks_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("clsDoks::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 [sDokumentID]() As SqlString Get Return m_sDokumentID End Get Set(ByVal Value As SqlString) Dim sDokumentIDTmp As SqlString = Value If sDokumentIDTmp.IsNull Then Throw New ArgumentOutOfRangeException("sDokumentID", "sDokumentID can't be NULL") End If m_sDokumentID = Value End Set End Property Public Property [biDokument]() As SqlBinary Get Return m_biDokument End Get Set(ByVal Value As SqlBinary) m_biDokument = Value End Set End Property #End Region End Class End Namespace