viernes, 25 de noviembre de 2016

CÓDIGO FUENTE EDICION DATOS

Public Class Form1
    Sub deshabilitar()
        Principio.Enabled = False
        Anterior.Enabled = False
        Siguiente.Enabled = False
        Ultimo.Enabled = False
        Nuevo.Enabled = False
        Guardar.Enabled = True
        Cancelar.Enabled = True
        Eliminar.Enabled = False
        Modificar.Enabled = False
        Salir.Enabled = False
        Buscar.Enabled = False
        Actualizar.Enabled = False
        '*************
        CedulaTextEdit.Enabled = True
        NombresTextEdit.Enabled = True
        EdadTextEdit.Enabled = True
        SexoComboBox.Enabled = True
        FotoPictureBox.Enabled = True

    End Sub
    Sub habilitar()
        Principio.Enabled = True
        Anterior.Enabled = True
        Siguiente.Enabled = True
        Ultimo.Enabled = True
        Nuevo.Enabled = True
        Guardar.Enabled = False
        Cancelar.Enabled = False
        Eliminar.Enabled = True
        Modificar.Enabled = True
        Salir.Enabled = True
        Buscar.Enabled = True
        Actualizar.Enabled = True
        '*************
        CedulaTextEdit.Enabled = False
        NombresTextEdit.Enabled = False
        EdadTextEdit.Enabled = False
        SexoComboBox.Enabled = False
        FotoPictureBox.Enabled = False
    End Sub
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        'TODO: esta línea de código carga datos en la tabla 'Mi_baseDataSet.Sujeto' Puede moverla o quitarla según sea necesario.
        Me.SujetoTableAdapter.Fill(Me.Mi_baseDataSet.Sujeto)
    End Sub

    Private Sub Nuevo_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Nuevo.Click
        deshabilitar()
        SujetoBindingSource.AddNew()
        CedulaTextEdit.Focus()
    End Sub

    Private Sub Eliminar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Eliminar.Click
        Try
            If MsgBox("Deseas eliminar el registro?", CType(vbQuestion + vbYesNo, MsgBoxStyle), _
                      "Eliminar registro") = vbNo Then Exit Sub
            SujetoBindingSource.RemoveCurrent()
            SujetoTableAdapter.Update(Mi_baseDataSet.Sujeto)
        Catch ex As Exception
            MsgBox("Lo sentimos su Base de Datos se encuentra vacia", MsgBoxStyle.Exclamation, "Datos")
        End Try
    End Sub

    Private Sub Principio_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Principio.Click
        SujetoBindingSource.MoveFirst()
    End Sub

    Private Sub Anterior_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Anterior.Click
        SujetoBindingSource.MovePrevious()
    End Sub

    Private Sub Siguiente_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Siguiente.Click
        SujetoBindingSource.MoveNext()
    End Sub

    Private Sub Ultimo_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Ultimo.Click
        SujetoBindingSource.MoveLast()
    End Sub

    Private Sub Guardar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Guardar.Click
        SujetoBindingSource.EndEdit()
        SujetoTableAdapter.Update(Mi_baseDataSet.Sujeto)
        MsgBox("La información se guardo correctamente..!", MsgBoxStyle.Information, "Registro de usuarios")
        habilitar()
    End Sub

    Private Sub Modificar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Modificar.Click
        deshabilitar()
        CedulaTextEdit.Enabled = False
    End Sub

    Private Sub Salir_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Salir.Click
        End
    End Sub
    Private Sub Cancelar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Cancelar.Click
        SujetoBindingSource.CancelEdit()
        habilitar()
    End Sub
    Private Sub Buscar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Buscar.Click
        Dim buscarce As String
        buscarce = InputBox("Introduzca el Nùmero de Cèdula: ", "Busqueda de Datos")
        Me.SujetoTableAdapter.buscarcedula(Me.Mi_baseDataSet.Sujeto, buscarce)
    End Sub

    Private Sub Actualizar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Actualizar.Click
        Me.SujetoTableAdapter.Fill(Me.Mi_baseDataSet.Sujeto)
    End Sub

    Private Sub Buscar1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Buscar1.Click
        Dim buscarnom As String
        buscarnom = InputBox("Introduzca el Nombre: ", "Busqueda de Datos")
        Me.SujetoTableAdapter.buscarnombres(Me.Mi_baseDataSet.Sujeto, buscarnom)
    End Sub


    Private Sub FotoPictureBox_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles FotoPictureBox.Click
        Try
            OpenFileDialog1.Title = "Abrir Imagen"
            OpenFileDialog1.FileName = "Imagenes"
            OpenFileDialog1.Filter = "All Files |*.*"
            OpenFileDialog1.ShowDialog()
            FotoPictureBox.Image = System.Drawing.Image.FromFile(OpenFileDialog1.FileName)
        Catch ex As Exception
            'Do Nathing End Try
        End Try
    End Sub
End Class

BÚSQUEDA DE CÉDULA

SELECT cedula, Nombres, Edad, Sexo, foto FROM Sujeto WHERE (cedula = ?)

BÚSQUEDA DE NOMBRES

SELECT cedula, Nombres, Edad, Sexo, foto FROM Sujeto WHERE (Nombres LIKE '%' + ? + '%')



0 comentarios:

Publicar un comentario