Imports System.Collections.Generic
Imports System.ComponentModel
Imports System.Drawing
Imports System.Data
Imports System.Linq
Imports System.Text
Imports System.Windows.Forms
Imports System.Data.SqlClient
Namespace Simple_Code
Public Partial Class UserControl1
Inherits UserControl
Private dsl_select As DataSet
Public Value As String() = New String(5) {}
Private isConnected As Boolean
Private FMatchType As Integer
Private fpcHandle As Integer
Private time As Integer = 0
Private i As Integer = 3
Private VerifyCheck As Boolean = False
Private VerTemplate As Object
Private RegTemplate As Object
Private RegTemplateStr As String
Private izkfpver As String
Private test As String
Public Event [property] As PropertyChangedEventHandler
Public Delegate Sub PropertyChangedEventHandler(s As String)
Public Sub New()
InitializeComponent()
End Sub
Public Function Connection() As String()
axZKFPEngX1.FPEngineVersion = "9"
izkfpver = axZKFPEngX1.FPEngineVersion
axZKFPEngX1.SensorIndex = 0
If axZKFPEngX1.InitEngine() = 0 Then
Try
Value(0) = "Connect"
Value(1) = "Finger Serial Number :" + axZKFPEngX1.SensorSN.ToString()
Value(2) = "Finger Count :" + axZKFPEngX1.SensorCount.ToString()
Value(3) = "Finger Index :" + axZKFPEngX1.SensorIndex.ToString()
Value(4) = "ImageWidth Record :" + axZKFPEngX1.ImageWidth.ToString()
Value(5) = "ImageHeight Record :" + axZKFPEngX1.ImageHeight.ToString()
isConnected = True
fpcHandle = axZKFPEngX1.CreateFPCacheDB()
Catch
axZKFPEngX1.EndEngine()
Value(0) = "Disconnect"
Value(1) = ""
Value(2) = ""
Value(3) = ""
Value(4) = ""
Value(5) = ""
isConnected = False
End Try
End If
Return Value
End Function
Public Sub Disconnect()
axZKFPEngX1.EndEngine()
'GlobalValue.FingerValue = null;
isConnected = False
End Sub
Public Sub BeginEnroll()
If isConnected = True Then
If axZKFPEngX1.IsRegister Then
axZKFPEngX1.CancelEnroll()
End If
axZKFPEngX1.EnrollCount = 3
axZKFPEngX1.BeginEnroll()
RaiseEvent [property]("Begin Enroll")
Else
RaiseEvent [property]("No Sensor Connected")
End If
End Sub
Private Sub axZKFPEngX1_OnFingerTouching(sender As Object, e As EventArgs)
RaiseEvent [property]("FingerTouching")
End Sub
Private Sub axZKFPEngX1_OnFingerLeaving(sender As Object, e As EventArgs)
RaiseEvent [property]("OnFingerLeaving")
End Sub
Private Sub axZKFPEngX1_OnEnroll(sender As Object, e As AxZKFPEngXControl.IZKFPEngXEvents_OnEnrollEvent)
Dim tmp As Byte() = New Byte(-1) {}
If e.actionResult Then
'MessageBox.Show(e.aTemplate.ToString());
'GlobalValue.FingerValue = tmp;
tmp = DirectCast(e.aTemplate, Byte())
Else
'GlobalValue.FingerValue = tmp;
tmp = Nothing
End If
Dim con As System.Data.SqlClient.SqlConnection
con = New System.Data.SqlClient.SqlConnection()
con.ConnectionString = "Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|Database.mdf;Integrated Security=True;User Instance=True"
Dim sql As String = "UPDATE Finger_Table SET Finger_Value=@Finger_Value WHERE User_ID= " + GlobalValue.Index + ""
Dim cmd As New SqlCommand(sql, con)
con.Open()
Dim parafinger As New SqlParameter()
parafinger.ParameterName = "@Finger_Value"
parafinger.Value = tmp
cmd.Parameters.Add(parafinger)
cmd.ExecuteNonQuery()
RaiseEvent [property]("OnEnroll")
End Sub
Public Sub BeginVerify()
If Not isConnected Then
MessageBox.Show("Please Initial sensor first!", "notice")
Return
End If
If axZKFPEngX1.IsRegister Then
axZKFPEngX1.CancelEnroll()
End If
VerifyCheck = True
axZKFPEngX1.BeginCapture()
RaiseEvent [property]("OnVerify")
End Sub
Private Sub axZKFPEngX1_OnCapture(sender As Object, e As AxZKFPEngXControl.IZKFPEngXEvents_OnCaptureEvent)
'string tmpbyte;
VerTemplate = e.aTemplate
Dim vartemplat As Byte() = DirectCast(VerTemplate, Byte())
'int score = 9;
'int processedFPNumber = 1;
'int ID;
'string tempstr;
Dim Template As String = axZKFPEngX1.GetTemplateAsString()
If e.actionResult AndAlso VerifyCheck = True Then
VerifyCheck = False
Dim check As Boolean = False
Dim temp As String
axZKFPEngX1.OneToOneThreshold = 40
axZKFPEngX1.Threshold = 40
temp = axZKFPEngX1.GetTemplateAsString()
Dim con As System.Data.SqlClient.SqlConnection
con = New System.Data.SqlClient.SqlConnection()
dsl_select = New DataSet()
'try
'{
con.ConnectionString = "Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|Database.mdf;Integrated Security=True;User Instance=True"
Dim sql As String = "SELECT Finger_Value FROM Finger_Table WHERE User_ID = '" + GlobalValue.Index + "'"
Dim da As New SqlDataAdapter(sql, con)
con.Open()
da.Fill(dsl_select, "SELECT")
Dim dRow As DataRow = dsl_select.Tables("SELECT").Rows(0)
'tmpbyte = dRow.ItemArray.GetValue(0);
Dim fingerTemp As Object = dRow.ItemArray.GetValue(0)
If axZKFPEngX1.VerFinger(fingerTemp, VerTemplate, False, check) = True Then
MessageBox.Show("Sucess!!")
Else
MessageBox.Show("Fail!!")
'}
'catch
'{
'}
End If
End If
End Sub
End Class
End Namespace