Beruflich Dokumente
Kultur Dokumente
MySqlClient
Delegate Sub FunctionCall(ByVal param)
Public Class MainForm
Private Sub EnrollButton_Click(ByVal sender As System.Object, ByVal e As Sys
tem.EventArgs) Handles EnrollButton.Click
Dim Enroller As New EnrollmenForm()
AddHandler Enroller.OnTemplate, AddressOf OnTemplate
Enroller.ShowDialog()
End Sub
Private Sub VerifyButton_Click(ByVal sender As System.Object, ByVal e As Sys
tem.EventArgs) Handles VerifyButton.Click
If txtfullname.Text = "" Then
MsgBox("Please input your fullname no.", MsgBoxStyle.Information)
Else
objconn.Open()
Dim cmd As New MySqlCommand("SELECT * FROM employeefp where fname ='
" & txtfullname.Text & "'", objconn)
Dim rdr As MySqlDataReader = cmd.ExecuteReader()
rdr.Read()
If rdr.HasRows Then
Dim Verifier As New VerificationForm
' Verifier.Verify(Template)
verification.Show()
Else
MsgBox("The id doesn`t exist", MsgBoxStyle.Information)
End If
End If
objconn.Close()
End Sub
Private Sub SaveButton_Click(ByVal sender As System.Object, ByVal e As Syste
m.EventArgs) Handles SaveButton.Click
Using files As New IO.MemoryStream
Template.Serialize(files)
objconn.Open()
If Not Template Is Nothing Then
Dim cmd = New MySqlCommand("INSERT INTO employeefp SET FP=@FP,fn
ame=@fname,lname=@lname", objconn)
cmd.Parameters.Add(New MySqlParameter("@FP", Template.Bytes))
cmd.Parameters.Add(New MySqlParameter("@fname", txtfullname.Text
))
cmd.Parameters.Add(New MySqlParameter("@lname", txtprisno.Text))
cmd.ExecuteNonQuery()
objconn.Close()
MessageBox.Show("Template Successfuly Saved.", "Finger Enrolled"
)
End If
End Using
End Sub
Private Sub CloseButton_Click(ByVal sender As System.Object, ByVal e As Syst
em.EventArgs)
End Sub
Private Sub OnTemplate(ByVal template)
Invoke(New FunctionCall(AddressOf _OnTemplate), template)
End Sub
=========================
CODE FOR SAVING FINGERPRINT
Private Sub SaveButton_Click(sender As Object, e As EventArgs)
Dim fingerprintData As New MemoryStream()
Template.Serialize(fingerprintData)
fingerprintData.Position = 0
Dim br As New BinaryReader(fingerprintData)
Dim bytes As [Byte]() = br.ReadBytes(DirectCast(fingerprintData.Length,
Int32))
'Insert the file into database
Dim cn As New SqlConnection("Data Source=10.115.5.3; Initial Catalog=Enr
ollmentSampledb;Integrated Security=SSPI;")
Dim cmd As New SqlCommand("INSERT INTO tblUser VALUES(@ID_NUMBER, @FIRST
NAME, @LASTNAME, @FINGERPRINT, @DATE_ADDED, @DATE_MODIFIED)", cn)
cmd.Parameters.Add("ID_NUMBER", SqlDbType.NVarChar).Value = tboxIdNum.Te
xt
cmd.Parameters.Add("FIRSTNAME", SqlDbType.NVarChar).Value = tboxFname.Te
xt
cmd.Parameters.Add("LASTNAME", SqlDbType.NVarChar).Value = tboxLname.Tex
t
cmd.Parameters.Add("FINGERPRINT", SqlDbType.Image).Value = bytes
cmd.Parameters.Add("DATE_ADDED", SqlDbType.DateTime).Value = DateTime.No
w
cmd.Parameters.Add("DATE_MODIFIED", SqlDbType.DateTime).Value = DateTime
.Now
cn.Open()
cmd.ExecuteNonQuery()
cn.Close()
tboxIdNum.Text = ""
tboxFname.Text = ""
tboxLname.Text = ""
End Sub
----------------------------------------------VERIFICATION 1---------------------------------------------------
Imports System.IO
Imports DPFP.Processing
Imports MySql.Data.MySqlClient
Public Class verificationMainForm
Inherits capturemain
Dim no As Integer
Dim now As String
Private Template As DPFP.Template
Private Verificator As DPFP.Verification.Verification
Public Sub Verify(ByVal template As DPFP.Template)
Me.Template = template
ShowDialog()
End Sub
Protected Overrides Sub Init()
MyBase.Init()
MyBase.Text = "Fingerprint Verification"
Verificator = New DPFP.Verification.Verification()
UpdateStatus(0)
End Sub
Protected Overrides Sub Process(ByVal Sample As DPFP.Sample)
MyBase.Process(Sample)
' Process the sample and create a feature set for the enrollment purpose
.
Dim features As DPFP.FeatureSet = ExtractFeatures(Sample, DPFP.Processin
g.DataPurpose.Verification)
' Check quality of the sample and start verification if it's good
' TODO: move to a separate task
' If features IsNot Nothing Then
Try
Using conn As New MySqlConnection("Server = 127.0.0.1;port=3307;user
id=account;password=;database=oass;")
conn.Open()
Try
Dim cmd As New MySqlCommand("SELECT * FROM employee order by
no asc ", conn)
Dim dr As MySqlDataReader = cmd.ExecuteReader()
Dim resulttext As String
While (dr.Read())
Dim fpno As Long = Convert.ToInt64(dr("no"))
Dim fpbyte As Byte() = DirectCast(dr("fingerprint"), Byt
e())
Try
conn.Open()
Dim query As String
Dim command As MySqlCommand
Dim reader As MySqlDataReader
query = "select * from access where EmpID = '" & idn
o & "' and name = '" & fname & "' and date = '" & Today & "'"
command = New MySqlCommand(query, conn)
reader = command.ExecuteReader
Try
conn.Open()
Dim cmd4 As New MySqlCommand("UPDATE access
set timeout = '" & TimeOfDay & "' where name = '" & fname & "' ", conn)
cmd4.ExecuteNonQuery()
MessageBox.Show("Access Granted. Date and Ti
me were recorded.")
Catch ex As MySqlException
MessageBox.Show(ex.Message)
Finally
conn.Dispose()
End Try
Else
MessageBox.Show("Nothing")
End If
Catch ex As MySqlException
MessageBox.Show(ex.Message)
Finally
conn.Dispose()
End Try
Else
SetStatus("The fingerprint was NOT VERIFIED.")
End If
Finally
conn.Close()
End Try
End Using
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
' End If
End Sub
Protected Sub UpdateStatus(ByVal FAR As Integer)
' Show "False accept rate" value
SetStatus(String.Format("False Accept Rate (FAR) = {0}", FAR))
End Sub
Private Sub verificationMainForm_Load(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles MyBase.Load
End Sub
End Class
System.IO
System.Data
System.Configuration
MySql.Data.MySqlClient
cmd.Parameters.AddWithValue("@Content", bytes)
con.Open()
cmd.ExecuteNonQuery()
con.Close()
End Using
End Using
End Using
End Using
Response.Redirect(Request.Url.AbsoluteUri)
End Sub
---------------------------CAPTURE---------------------Imports System.IO
Public Class FrmCap
'Create constant using attend in function of DLL file.
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
DestroyWindow(hHwnd)
End If
End Sub
' Use SendMessage to copy the data to the clipboard Then transfer the image to t
he picture box.
Private Sub btnSave_Click(ByVal sender As System.Object, ByVal e As System.Event
Args) Handles btnSave.Click
Dim data As IDataObject
Dim bmap As Image
' Copy image to clipboard
SendMessage(hHwnd, CAP_EDIT_COPY, 0, 0)
' Get image from clipboard and convert it to a bitmap
data = Clipboard.GetDataObject()
If data.GetDataPresent(GetType(System.Drawing.Bitmap)) Then
bmap = CType(data.GetData(GetType(System.Drawing.Bitmap)), Image)
picCapture.Image = bmap
Dim saveFileDialog1 As New SaveFileDialog()
saveFileDialog1.Filter = "Jpeg Image|*.jpg|Bitmap Image|*.bmp|Gif Image|*.gif"
saveFileDialog1.Title = "Save an Image File"
saveFileDialog1.FileName = "Image001"
saveFileDialog1.ShowDialog()
' If the file name is not an empty string open it for saving.
If saveFileDialog1.FileName <> "" Then
' Saves the Image via a FileStream created by the OpenFile method.
Dim fs As System.IO.FileStream = CType _
(saveFileDialog1.OpenFile(), System.IO.FileStream)
picCapture.Image.Save(fs, System.Drawing.Imaging.ImageFormat.Jpeg)
fs.Close()
End If
End If
End Sub
Private Sub frmcap_Leave(ByVal sender As Object, ByVal e As System.EventArgs) Ha
ndles Me.Leave
' Disconnect from device
SendMessage(hHwnd, CAP_DRIVER_DISCONNECT, iDevice, 0)
' close window
DestroyWindow(hHwnd)
End Sub
Private Sub FRMCAP_Load(ByVal sender As System.Object, ByVal e As System.EventAr
gs) Handles MyBase.Load
OpenForm()
End Sub
End Class
--------------------------------CRYSTAL REPORT SELECT--------------------Imports CrystalDecisions.CrystalReports.Engine
Imports System.IO
Public Class Form1