\' Gambas class file
Public Struct datos
asunto As String
color As Integer
fecha As Date
descripcion As String
End Struct
Private ges As New GestionarDatos
Public Sub _new()
limpio()
End
Public Sub Form_Open()
Me.text = "Ejemplo de Estructuras: Programa Recordatorio"
Me.center
End
Public Sub ButtonAdd_Click()
Dim registroTmp As Datos
registroTmp = New Datos \'instancio
registroTmp.asunto = TextBoxAsunto.Text
registroTmp.color = ColorButtonNivelImportancia.Value
registroTmp.fecha = DateBoxFecha.Value
registroTmp.descripcion = TextAreaDescripcion.Text
\'añado el regitro usando el método .add
ges.add(registroTmp)
\'borro datos
limpio()
\'pongo el Id del registro
ValueBoxIndice.value = ges.getNumeroRegistros() + 1
End
\'-------------------------------------
Public Sub limpio()
TextAreaDescripcion.text = ""
TextBoxAsunto.text = ""
ColorButtonNivelImportancia.value = Color.White
DateBoxFecha.value = Now \'fecha actual
End
Public Sub ButtonIr_Click()
Dim registroTmp As Datos
registroTmp = ges.rescata(ValueBoxIndice.value)
If IsNull(registroTmp) Then
\'el indice ha sido mal introducido y no puedo hacer nada....
Else
TextBoxAsunto.text = registroTmp.asunto
TextAreaDescripcion.text = registroTmp.descripcion
DateBoxFecha.value = registroTmp.fecha
ColorButtonNivelImportancia.value = registroTmp.color
Endif
End
Public Sub ButtonBorrar_Click()
\'intengo borrar el indice indicado...
ges.erase(ValueBoxIndice.value)
If ges.erase(ValueBoxIndice.value) = True Then
limpio()
Endif
End
Public Sub ButtonPrimero_Click()
ValueBoxIndice.value = 0
ges.setIndice(0)
ButtonIr_Click()
End
Public Sub ButtonUltimo_Click()
ValueBoxIndice.value = ges.getNumeroRegistros()
ges.setIndice(ges.getNumeroRegistros())
ButtonIr_Click()
End
Public Sub ButtonAtras_Click()
ges.setIndice(ges.getIndice() - 1)
ValueBoxIndice.value = ges.getIndice()
ButtonIr_Click()
End
Public Sub ButtonSiguiente_Click()
ges.setIndice(ges.getIndice() + 1)
ValueBoxIndice.value = ges.getIndice()
ButtonIr_Click()
End
Public Sub ButtonModificar_Click()
\'segun el indice donde estoy, lo edito...
\'
Dim registroTmp As Datos
registroTmp = New Datos \'instancio
registroTmp.asunto = TextBoxAsunto.Text
registroTmp.color = ColorButtonNivelImportancia.Value
registroTmp.fecha = DateBoxFecha.Value
registroTmp.descripcion = TextAreaDescripcion.Text
\'añado el regitro usando el método .add
ges.modificar(registroTmp, ValueBoxIndice.value)
End
Public Sub ButtonLeerDatos_Click()
ges.leerdatos()
ButtonPrimero_Click()
End
Public Sub ButtonGuardarDatos_Click()
ges.guardardatos()
End