Public class RNpais
private id_pais as integer
private des as string
private campos as new arraylist
private command as sqlclient.sqlcommand
-- Aqui estaran las propiedades
-- acceso datos es mi clase donde tengo la conexion a la DB
Public Property Codigo() As Integer
Get
Return Id_Pais
End Get
Set(ByVal Value As Integer)
Dim Datos As New AccesoDatos.Operaciones(Command)
Dim dr As DataRow
dr = Datos.TraerUno("PAIS", Value, Command)
Id_Pais = dr(0)
Desc = dr(1)
End Set
End Property
Public Property Descripcion() As String
Get
Return Desc
End Get
Set(ByVal Value As String)
Try
If Id_Pais <> Nothing Then
Dim Datos As New AccesoDatos.Operaciones(Command)
Dim Valores As New ArrayList
Valores.Add("varchar")
Valores.Add(Value)
Datos.modificar("PAIS", Campos, Valores, "ID_PAIS=" & Id_Pais, Command)
Desc = Value
Else
Desc = Value
End If
Catch ex As Exception
Throw ex
End Try
End Set
End Property
-- constructores
Sub New(ByVal Comando As SqlClient.SqlCommand)
Command = Comando
Id_Pais = -1
Desc = ""
Campos.Add("varchar")
Campos.Add("DESCRIPCIONpais")
End Sub
Sub New(ByVal IDPAIS As Integer, ByVal Comando As SqlClient.SqlCommand)
Dim Datos As New AccesoDatos.Operaciones(Comando)
Dim dr As DataRow
Command = Comando
dr = Datos.TraerUno("PAIS", IDPAIS, Comando)
Id_Pais = IDPAIS
Desc = dr(1)
Campos.Add("varchar")
Campos.Add("DESCRIPCIONpais")
End Sub
-- Operaciones Basicas
Public Function Eliminar()
Try
Dim AD As New AccesoDatos.Operaciones(Command)
AD.eliminar("PAIS", Id_Pais, Command)
Catch ex As Exception
Throw ex
End Try
End Function
Public Function Nuevo(ByVal Descripcion_Pais As String) As Integer
Try
Dim AD As New AccesoDatos.Operaciones(Command)
Dim Valores As New ArrayList
Valores.Add("varchar")
Valores.Add(Descripcion_Pais)
Return AD.Insertar("PAIS", Campos, Valores)
Catch ex As Exception
Throw ex
End Try
End Function
Public Function TraerTodos() As DataTable
Dim ad As New AccesoDatos.Operaciones(Command)
Return ad.TraerTodos("PAIS", "")
End Function