\' Gambas class file
Private hconn As Connection
Private hresult As Result
Public Sub _new()
End
Public Sub Form_Open()
ModComun.copiarBase()
hconn = ModComun.ConectarBase()
hresult = hconn.Exec("select * from personas") \'para tenertodos los registros en el hresul
\'relleno etiquetas..
LabelTotalRegistros.text = " de " & Str$(hresult.count)
\'cargo primer registro
ButtonPrimero_Click()
End
Public Function mostrarRegistro() As Boolean
If hresult.Available Then
TextBoxNombre.text = hresult["nombre"]
ValueBoxEdad.value = hresult["edad"]
ValueBoxRegistro.value = hresult.Index + 1
Return True \'ok, ha sido posible mostrar datos
Endif
Message.Info("No es posible desplazarse más")
Return False \'no ha sido posible ir a ese registro
End
Public Sub ButtonPrimero_Click()
hresult.MoveFirst
mostrarRegistro()
End
Public Sub ButtonSiguiente_Click()
If (hresult.index + 1) < hresult.count Then
hresult.MoveNext
mostrarRegistro()
Endif
End
Public Sub ButtonAnterior_Click()
If hresult.Index > 0 Then
hresult.MovePrevious
mostrarRegistro()
Endif
End
Public Sub ButtonUltimo_Click()
hresult.MoveLast
mostrarRegistro()
End
Public Sub ValueBoxRegistro_KeyPress()
\'ir a un registro determinado... escribiendo el numero y la tecla Enter o Return
If Key.code = Key.enter Or Key.code = Key.Return Then
If hresult.MoveTo(ValueBoxRegistro.value - 1) = False Then
mostrarRegistro()
Else
Message.Info("No existe ese registro")
Endif
Endif
End