En la etapa de Implementación se llevó a cabo la codificación de los formularios Usuario, Guardar la Huella y Verificar Huella, a continuación se un fragmento del código fuente.
Formulario de Usuarios
Fig. 24 Formulario de Usuarios Sistema Informático Biométrico Autor: Jorge Sánchez (2015)
82
Código Formulario de Usuarios Imports System.Windows.Forms PublicClassDialogUsuario
Dim codigoUsuario As Integer Dim condicionUsuario AsString Dim KeyAscii AsInteger
If (condicionUsuario = "nuevo") Then Dim cont AsInteger = 0
Dim conexion AsNew SqlClient.SqlConnection
Dim comando AsNew SqlClient.SqlCommand
Dim adaptador AsNew SqlClient.SqlDataAdapter
Dim dataTable AsNewDataTable
Dim sql AsString
conexion = conexionSQL()
sql = "SELECT count(*) as existe FROM
SISTEMA_BIOMETRICO_HUELLA.dbo.USUARIO WHERE Cedula=@cedula "
comando = New SqlClient.SqlCommand(sql, conexion)
comando.Parameters.Add(New SqlClient.SqlParameter("@cedula", SqlDbType.Int)) comando.Parameters("@cedula").Value = TextCedula.Text().Trim
With commando .Connection = conexion .CommandText = sql EndWith adaptador.SelectCommand = commando adaptador.Fill(DataTable) TextCedula.Enabled = False
If (dataTable.Rows(0).Item("existe") >= "1") Then
MsgBox("el usuario con numero de cedula: " + TextCedula.Text() + " ya esta
83 Else
sql = "insert into SISTEMA_BIOMETRICO_HUELLA.dbo.USUARIO (Cedula,
Nombres, Apellidos, Direccion, Telefono, Fecha_Nacimiento, Genero, Estractivo) " +
" values(@CEDULA, @NOMBRES, @APELLIDOS, @DIRECCION,
@TELEFONO,@FECHA_NACIMIENTO, @GENERO, @ESTAACTIVO)"
comando = New SqlClient.SqlCommand(sql, conexion)
comando.Parameters.Add(New SqlClient.SqlParameter("@CEDULA",
SqlDbType.Int))
comando.Parameters("@CEDULA").Value = TextCedula.Text()
comando.Parameters.Add(New SqlClient.SqlParameter("@NOMBRES",
SqlDbType.VarChar, 50))
comando.Parameters("@NOMBRES").Value = TextNombre.Text()
comando.Parameters.Add(New SqlClient.SqlParameter("@APELLIDOS",
SqlDbType.VarChar, 50))
comando.Parameters("@APELLIDOS").Value = TextApellido.Text()
comando.Parameters.Add(New SqlClient.SqlParameter("@DIRECCION",
SqlDbType.VarChar, 50))
comando.Parameters("@DIRECCION").Value = TextDireccion.Text()
comando.Parameters.Add(New SqlClient.SqlParameter("@TELEFONO",
SqlDbType.VarChar, 50))
comando.Parameters("@TELEFONO").Value = TextTelefono.Text() comando.Parameters.Add(New
SqlClient.SqlParameter("@FECHA_NACIMIENTO", SqlDbType.DateTime))
comando.Parameters("@FECHA_NACIMIENTO").Value =
DateTime_Fecha_Nacimiento.Text()
comando.Parameters.Add(NewSqlClient.SqlParameter("@GENERO",
SqlDbType.VarChar, 50))
If (cboxGenero.Text = "Masculino") Then
comando.Parameters("@GENERO").Value = "M"
ECT * FROM SISTEMA_BIOMETRICO_HUELLA.dbo.USUARIO WHERE ID_Usuario=@idUsuario"
84
comando = New SqlClient.SqlCommand(sql, conexion)
comando.Parameters.Add(New SqlClient.SqlParameter("@idUsuario",
SqlDbType.Int)) comando.Parameters("@idUsuario").Value = codigoUsuario
With commando
.Connection = conexion .CommandText = sql EndWith
EndSub
PublicSubNew() InitializeComponent() EndSub
EndSub
Sub TextNombre_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextNombre.TextChanged
EndSub
Private Sub TextCedula_KeyPress(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextCedula.KeyPress If Char.IsDigit(e.KeyChar) Then e.Handled = False ElseIf Char.IsControl(e.KeyChar) Then e.Handled = False
Else
e.Handled = True EndIf
EndSub EndClass
85
Formulario Guardar la Huella
Fig. 25Formulario Guardar Huella Sistema Informático Biométrico Autor: Jorge Sánchez (2015)
86
Código Guardar Huella Imports System.Text
Imports SecuGen.FDxSDKPro.Windows PublicClassGuardarHuella
Inherits System.Windows.Forms.Form
Dim m_FPM AsSGFingerPrintManager
Dim m_LedOn AsBoolean Dim m_ImageWidth AsInt32
Dim m_ImageHeight AsInt32
Dim m_RegMin1(400) AsByte Dim m_RegMin2(400) AsByte Dim m_VrfMin(400) AsByte
Dim m_DevList() AsSGFPMDeviceList
ProtectedOverloadsOverridesSub Dispose(ByVal disposing AsBoolean) If disposing Then
IfNot (components IsNothing) Then components.Dispose()
'BtnVerify
Me.BtnVerify.BackColor = System.Drawing.SystemColors.Deskto Me.BtnVerify.ForeColor = System.Drawing.SystemColors.HighlightText Me.BtnVerify.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft Me.BtnVerify.Location = New System.Drawing.Point(304, 308)
Me.BtnVerify.Name = "BtnVerify"
Me.BtnVerify.Size = New System.Drawing.Size(108, 23) Me.BtnVerify.TabIndex = 34
Me.BtnVerify.Text = "Guardar"
Me.BtnVerify.UseVisualStyleBackColor = False
'GuardarHuella
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
87 Dim iError AsInt32
Dim img_qlty AsInt32
ReDim fp_image(m_ImageWidth * m_ImageHeight) iError = m_FPM.GetImage(fp_image)
If iError = SGFPMError.ERROR_NONE Then DrawImage(fp_image, pictureBoxR2)
m_FPM.GetImageQuality(m_ImageWidth, m_ImageHeight, fp_image, img_qlty) progressBar_R2.Value = img_qlty
iError = m_FPM.CreateTemplate(fp_image, m_RegMin2) If (iError = SGFPMError.ERROR_NONE) Then
StatusBar.Text = "Second image is captured"
Else
DisplayError("CreateTemplate", iError) EndIf
Else
DisplayError("GetImage", iError) EndIf
EndSub
Private Sub BtnCapture3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnCapture3.Click
Dim fp_image() AsByte Dim iError AsInt32
Dim img_qlty AsInt32
ReDim fp_image(m_ImageWidth * m_ImageHeight) iError = m_FPM.GetImage(fp_image)
If iError = SGFPMError.ERROR_NONE Then DrawImage(fp_image, pictureBoxV1)
m_FPM.GetImageQuality(m_ImageWidth, m_ImageHeight, fp_image, img_qlty) progressBar_V1.Value = img_qlty
iError = m_FPM.CreateTemplate(fp_image, m_VrfMin) If (iError = SGFPMError.ERROR_NONE) Then
88
StatusBar.Text = "Image for verification is captured"
Else
DisplayError("CreateTemplate", iError) EndIf
Else
DisplayError("GetImage", iError) EndIf
EndSub
Private Sub BtnRegister_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnRegister.Click
Dim iError AsInt32
Dim matched AsBoolean Dim match_score AsInt32
Dim secu_level AsSGFPMSecurityLevel
matched = False match_score = 0
secu_level = comboBoxSecuLevel_R.SelectedIndex
iError = m_FPM.MatchTemplate(m_RegMin1, m_RegMin2, secu_level, matched) iError = m_FPM.GetMatchingScore(m_RegMin1, m_RegMin2, match_score) If (iError = SGFPMError.ERROR_NONE) Then
If (matched) Then
StatusBar.Text = "Registration Success, Matching Score: " +
Convert.ToString(match_score)
Else
StatusBar.Text = "Registration Failed"
EndIf Else
DisplayError("GetMatchingScore", iError EndIf
MsgBox("REGISTRADO CORRECTAMENTE SU HUELLA",
89 EndSub
''Guardar Huella
Dim conexion AsNew SqlClient.SqlConnection
Dim comando AsNew SqlClient.SqlCommand
Dim adaptador AsNew SqlClient.SqlDataAdapter
Dim dataTable AsNewDataTable
Dim sql AsString
conexion = conexionSQL()
sql = "insert into SISTEMA_BIOMETRICO_HUELLA.dbo.HUELLA (ID_Usuario
,Huella) " +
" values(@IDUSUARIO, @HUELLA)" comando = New
SqlClient.SqlCommand(sql, conexion)
comando.Parameters.Add(New SqlClient.SqlParameter("@IDUSUARIO",
SqlDbType.Int))
comando.Parameters("@IDUSUARIO").Value = codigoUsuario
comando.Parameters.Add(New SqlClient.SqlParameter("@HUELLA",
SqlDbType.VarBinary))
comando.Parameters("@HUELLA").Value = m_VrfMin
comando.Connection.Open() comando.ExecuteNonQuery()
comando.Connection.Close() Else
StatusBar.Text = "Verification Failed"
EndIf Else
DisplayError("MatchTemplate", iError) EndIf
MsgBox("GUARDADO CORRECTAMENTE SU HUELLA ",
90
Formulario Verificar la Huella
Fig. 26 Formulario Verificar Huella Sistema Informático Biométrico Autor: Jorge Sánchez (2015)
91
Código Verificar Huella Imports System.Text
Imports SecuGen.FDxSDKPro.Windows PublicClassVerificarHuella
Inherits System.Windows.Forms.Form
Dim m_FPM AsSGFingerPrintManager
Dim m_LedOn AsBoolean Dim m_ImageWidth AsInt32
Dim m_ImageHeight AsInt32
PublicFunction conexionSQL() As SqlClient.SqlConnection
Return New SqlClient.SqlConnection("Data Source=PAVILION-PC; initial
catalog=SISTEMA_BIOMETRICO_HUELLA; User ID=sa;Password=123")
EndFunction
PublicSub cargarReunion()
Dim conexion AsNew SqlClient.SqlConnection
Dim comando AsNew SqlClient.SqlCommand
Dim adaptador AsNew SqlClient.SqlDataAdapter
Dim dataTable AsNewDataTable
Dim sql AsString Try
conexion = conexionSQL()sql =
"SELECT * FROM SISTEMA_BIOMETRICO_HUELLA.dbo.JUNTA_AGUAS WHERE Estado='Pendiente' "
comando = New SqlClient.SqlCommand(sql, conexion) With commando
.Connection = conexion.CommandText = sql EndWith
adaptador.SelectCommand = commando adaptador.Fill(dataTable)
92
lblReunion.Text = dataTable.Rows(0).Item("Nombre")
lblDescripción.Text = dataTable.Rows(0).Item("Descripcion") lblFecha.Text = dataTable.Rows(0).Item("Fecha")
lblHora_Ingreso.Text = dataTable.Rows(0).Item("Hora_Inicio").ToString lblHora_Final.Text = dataTable.Rows(0).Item("Hora_Final").ToString
Private Sub BtnVerify_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnVerify.Click
Dim iError AsInt32
Dim IdUsuario AsInteger conexion = conexionSQL()
sql = "select * FROM SISTEMA_BIOMETRICO_HUELLA.dbo.HUELLA "
With commando .Connection = conexion .CommandText = sql EndWith
With commando .CommandType = CommandType.Text.CommandText = sql .Connection = conexion
EndWith
Dim da AsNew SqlClient.SqlDataAdapter' Crear nuevo SqlDataAdapter
Dim dataset AsNewDataSet' Crear nuevo dataset
da.SelectCommand = commando da.Fill(dataset, "Tabla")
Dim comprobar AsBoolean comprobar = False
With dataset.Tables("tabla") For f AsInteger = 0 To .Rows.Count – 1 m_VrfMin2 = .Rows(f).Item("Huella") m_FPM.MatchTemplate(m_VrfMin, m_VrfMin2, secu_level, comprobar) If comprobar Then IdUsuario = .Rows(f).Item("ID_Usuario") EndIf Next EndWith
If IdUsuario > 0 Then comando = New SqlClient.SqlCommand adaptador = New SqlClient.SqlDataAdapter dataTable = NewDataTable sql = "select count(*) as existe
FROM SISTEMA_BIOMETRICO_HUELLA.dbo.Reuniones " + " where
ID_Junta_Aguas=@idJunta and ID_Usuario=@IDUsuario "
comando = New SqlClient.SqlCommand(sql, conexion)
93
comando = New SqlClient.SqlCommand
conexion = conexionSQL() 'Dim transaccion As SqlClient.SqlTransaction
sql = "insert into SISTEMA_BIOMETRICO_HUELLA.dbo.REUNIONES
( ID_Junta_Aguas, ID_Usuario, Marco) " +" values(@IDJunta, @IDUsuario,
@Marco)"
comando = New SqlClient.SqlCommand(sql, conexion)
comando.Parameters.Add(New SqlClient.SqlParameter("@IDJunta",
SqlDbType.Int))
comando.Parameters("@IDJunta").Value = id_Junta comando.Parameters("@IDUsuario").Value = IdUsuario
comando.Parameters.Add(New SqlClient.SqlParameter("@Marco", SqlDbType.Bit)) comando.Parameters("@Marco").Value = True
conexion = conexionSQL() sql = "select ID_Reuniones from
SISTEMA_BIOMETRICO_HUELLA.dbo.REUNIONES order by ID_Reuniones
desc " comando = New SqlClient.SqlCommand(sql, conexion) With commando
.Connection = conexion .CommandText = sql EndWith adaptador.SelectCommand = commando adaptador.Fill(dataTable) Dim IdReunion As Integer IdReunion = dataTable.Rows(0).Item("ID_Reuniones") conexion = New SqlClient.SqlConnection
comando = New SqlClient.SqlCommand conexion = conexionSQL() sql = "insert into
SISTEMA_BIOMETRICO_HUELLA.dbo.MULTAS_REUNIONES
(ID_Reuniones,Precio,Pagado,ID_Multas) " + "
values(@ID_Reuniones,@Precio,@Pagado,@ID_Multas)"
comando = New SqlClient.SqlCommand(sql, conexion) SqlClient.SqlParameter("@Precio", SqlDbType.Decimal))
comando.Parameters.Add(New SqlClient.SqlParameter("@ID_Multas",
SqlDbType.Int))
comando.Parameters("@ID_Multas").Value = idMultaAtrazo comando.Connection.Open()
94
comando.ExecuteNonQuery() EndIf
comando.Connection.Close()
StatusBar.Text = "El Sr/a " + nombreUnido + " asiste a la reunion"
EndIf
MsgBox("VERIFICADO CORRECTAMENTE SU HUELLA",
MsgBoxStyle.Information, "Sistema Biométrico")
comando.Connection.Close() EndIf
Else
MsgBox("VERIFICADO CORRECTAMENTE") StatusBar.Text = "Verification Failed"
EndIf Else
DisplayError("MatchTemplate", iError) EndIf
MsgBox("HUELLA INCORRECTA",
MsgBoxStyle.Critical, "Sistema Biométrico") EndSub
95