Ver Mensaje Individual
  #2 (permalink)  
Antiguo 26/05/2008, 12:41
Gusys
 
Fecha de Ingreso: octubre-2003
Ubicación: La Paz - Bolivia
Mensajes: 116
Antigüedad: 21 años, 4 meses
Puntos: 1
Conversion CS a VB [continuacion]

Codigo tradicido en VB
Código:
Imports System
Imports System.Collections.Generic
Imports System.Text
Imports System.Data
Imports Common.Common.Factory
Imports SharedComponents.SharedComponents
Namespace DataAccessLayer
Public MustInherit Class DataObjectBase
Implements IDataObject
 
Private trans As IDbTransaction = Nothing
Private connection As IDbConnection = Nothing
Private currentConnection As String = String.Empty
Private dataTable As DataTable = Nothing
Private newRow As DataRow = Nothing
Private bCloseExternalConnectionAfterUse As Boolean = False
Private conditionClause As String = String.Empty
Public commandTextSelect As String = String.Empty
Public commandTextInsert As String = String.Empty
Public commandTextUpdate As String = String.Empty
Public commandTextDeleteByKey As String = String.Empty
Public commandTextDeleteAll As String = String.Empty
 
#Region "CONSTRUCTORS"
Public Sub New()
currentConnection = SharedVariables.ConnectionString
ConfigureDataObject()
End Sub
Public Sub New(ByVal connectionString As String)
connectionString = connectionString
ConfigureDataObject()
End Sub
Public Sub New(ByVal connectionString As String, ByVal condition As String)
currentConnection = connectionString
conditionClause = condition
ConfigureDataObject()
End Sub
Public Sub New(ByVal externalConnection As IDbConnection)
connection = externalConnection
ConfigureDataObject()
End Sub
Public Sub New(ByVal externalConnection As IDbConnection, ByVal condition As String)
connection = externalConnection
conditionClause = condition
ConfigureDataObject()
End Sub
#End Region
#Region "PROPERTIES"
Public Property Transaction() As IDbTransaction Implements IDataObject.Transaction
Get
Return trans
End Get
Set(ByVal value As IDbTransaction)
If trans Is value Then
Return
End If
trans = value
End Set
End Property
Public Property Connection() As IDbConnection Implements IDataObject.Connections
Get
Return Connection
End Get
Set(ByVal value As IDbConnection)
If connection Is value Then
Return
End If
connection = value
ConfigureDataObject()
End Set
End Property
Public Property ConnectionString() As String Implements IDataObject.ConnectionString
Get
Return currentConnection
End Get
Set(ByVal value As String)
If currentConnection = value Then
Return
End If
currentConnection = value
End Set
End Property
Public Property Condition() As String Implements IDataObject.Condition
Get
Return conditionClause
End Get
Set(ByVal value As String)
If conditionClause = value Then
Return
End If
conditionClause = value
End Set
End Property
Public Property DataTable() As DataTable Implements IDataObject.DataTable
Get
DataTable = GetDataTable()
Return DataTable
End Get
Set(ByVal value As DataTable)
End Set
End Property
Public Property CloseExternalConnectionAfterUse() As Boolean Implements IDataObject.CloseExternalConnectionAfterUse
Get
Return bCloseExternalConnectionAfterUse
End Get
Set(ByVal value As Boolean)
If bCloseExternalConnectionAfterUse = value Then
Return
End If
bCloseExternalConnectionAfterUse = value
End Set
End Property
 
#End Region
#Region "CRUID METHODS"
 
Public Function InsertData(ByVal row As DataRow) As Integer Implements IDataObject.InsertData
Me.OpenConnection()
Dim iResult As Integer = 0
Dim cmdInsert As IDbCommand = DataFactory.CreateCommand()
cmdInsert.CommandText = commandTextInsert
cmdInsert.CommandType = SharedVariables.DBCommandType
cmdInsert.Connection = Me.connection
If Not Me.trans Is Nothing Then
cmdInsert.Transaction = trans
End If
 
ConfigureParameterValue(cmdInsert, row)
 
Try
iResult = cmdInsert.ExecuteNonQuery()
Catch ex As Exception
Throw ex
Finally
Me.CloseConnection()
If Not cmdInsert Is Nothing Then
cmdInsert.Dispose()
cmdInsert = Nothing
End If
End Try
Return iResult
End Function
Public Function UpdateData(ByVal row As DataRow) As Integer Implements IDataObject.UpdateData
Me.OpenConnection()
Dim retVal As Integer = 0
Dim cmdUpdate As IDbCommand = DataFactory.CreateCommand()
cmdUpdate.CommandText = commandTextUpdate
cmdUpdate.CommandType = SharedVariables.DBCommandType
cmdUpdate.Connection = Me.connection
If Not Me.trans Is Nothing Then
cmdUpdate.Transaction = trans
End If
ConfigureParameterValue(cmdUpdate, row)
Try
retVal = cmdUpdate.ExecuteNonQuery()
Catch ex As Exception
Throw ex
Finally
Me.CloseConnection()
If Not cmdUpdate Is Nothing Then
cmdUpdate.Dispose()
cmdUpdate = Nothing
End If
End Try
Return retVal
End Function
Public Function DeleteByKey(ByVal strKey As String) As Integer Implements IDataObject.DeleteByKey
Dim retVal As Integer = 0
Try
retVal = DeleteAll(commandTextDeleteByKey & strKey)
Catch ex As Exception
Throw ex
Finally
End Try
Return retVal
End Function
Public Function DeleteAll(ByVal condition As String) As Integer Implements IDataObject.DeleteAll
Dim retVal As Integer = 0
Me.OpenConnection()
Dim cmdDelete As IDbCommand
cmdDelete = DataFactory.CreateCommand()
cmdDelete.CommandText = commandTextDeleteAll & condition
cmdDelete.Connection = connection
If Not trans Is Nothing Then cmdDelete.Transaction = trans
Try
retVal = cmdDelete.ExecuteNonQuery()
Catch ex As Exception
Throw ex
Finally
Me.CloseConnection()
If Not cmdDelete Is Nothing Then
cmdDelete.Dispose()
cmdDelete = Nothing
End If
End Try
Return retVal
End Function
 
#End Region
__________________
"El viento puede soplar fuerte, pero la montaña no lo reverencia"

Última edición por Gusys; 26/05/2008 a las 12:43 Razón: etiquetas code