Ver Mensaje Individual
  #3 (permalink)  
Antiguo 16/05/2008, 17:26
tuchy
 
Fecha de Ingreso: febrero-2006
Mensajes: 124
Antigüedad: 19 años, 2 meses
Puntos: 0
Respuesta: un pequeño problema

Pongo el codigo completo:

Código:
Option Explicit

Dim cn As Connection
Dim rst As Recordset


Private Sub Buscar_Click()

End Sub

' Primer registro, siguiente, etc...
Private Sub cmdNav_Click(Index As Integer)

    ' Si hay registro activo sale
    If rst.BOF And rst.EOF Then Exit Sub

    Select Case Index
        Case 0
            rst.MoveFirst
        Case 1
            rst.MovePrevious
            If rst.BOF Then rst.MoveFirst
        Case 2
            rst.MoveNext
            If rst.EOF Then rst.MoveLast
        Case 3
            rst.MoveLast
    End Select

    ' Carga la imagen en el Picture
    Call Mostrar_Imagen

End Sub

Private Sub Command1_Click(Index As Integer)

    Select Case Index
 
        'Agrega un nuevo registro
        Case 0
            rst.AddNew
            Picture1.Cls
            'Elimina el registro activo
            
            CmdNuevo
            
        Case 1
            If rst.EOF Or rst.BOF Then Exit Sub
            If MsgBox("Eliminar Registro", vbQuestion + vbYesNo) = vbNo Then Exit Sub
            
            Picture1.Cls
    
            'Elimina el archivo de la carpeta de imagenes
            If rst(Field_Img) <> "" Then
                Call Kill(Carpeta_IMG & rst(Field_Img))
            End If
        
            rst.Delete
            
            If rst.RecordCount > 0 Then
               cmdNormal
            Else
               cmdSinRegistros
            End If
            
            If rst.EOF Or rst.BOF Then
                Exit Sub
            End If
            rst.MoveNext
            
            If rst.EOF Then
               On Error Resume Next
               rst.MoveLast
            End If
            'Carga la imagen del registro activo
            Mostrar_Imagen
            Exit Sub
             
        ' Botón Actualizar los cambios en la base de datos
        Case 2
            If Not rst.EOF And Not rst.BOF Then
                rst.Update
                Guardar_Imagen
                cmdNormal
            End If

        ' Cancela la atualización o edición del registro que se editando o añadiendo
        Case 3
            cmdEditar
            Setear_TextBox
            Exit Sub
  
        'Botón Editar el registro activo
        Case 4
            If rst.EOF And rst.BOF Then Exit Sub
            rst.CancelUpdate
  
            If Not rst.BOF And Not rst.EOF Then
                If rst(Field_Img) <> "" Then
                    Call Dibujar_Imagen(Picture1, Carpeta_IMG & rst(Field_Img))
                End If
                
            End If
            
            If rst.RecordCount > 0 Then
                cmdNormal
            Else
                cmdSinRegistros
            End If
        'Carga una imagen en el control Picture1
        Case 5
  
            With CommonDialog1
                .DialogTitle = " Seleccionar imagen"
                .Filter = "BMP|*.bmp|JPEG|*.jpeg|GIF|*.gif|JPG|*.jpg|Todos|*.*"
     
                .ShowOpen
     
                If .FileName = "" Then
                    Exit Sub
                Else
         
                    ' Graba el nombre en el campo, el id de imagen _
                    que es el mismo que el campo Id
         
                    rst(Field_Img) = rst!id '
         
        
                    ' se dibuja la imagen en el Picture
                    Call Dibujar_Imagen(Picture1, .FileName)
         
                End If
            End With
            
            Exit Sub

        Case 6

            ' Limpia la imagen del Picture y Elimina el id de _
            imagen del registro actual de la base
            
            If MsgBox("Desea eliminar la imagen ?", vbYesNo + vbQuestion) = vbYes Then
               Picture1.Cls
               rst(Field_Img) = ""
               Exit Sub
            End If

    End Select

    
    Setear_TextBox

    ' Muestra la imagen
    Mostrar_Imagen

End Sub