Contoh Source Code Fingerprint Menggunakan VB.Net

 

Pada artikel ini, akan membuat contoh untuk konek ke mesin fingerprint CZKEM

Berikut adalah contoh konek ke fingerprint menggunakan VB.Net

1. Connection Ke Fingerprint CZKEM

Componen VB.Net

  • Driver CZKEM 
  • Form
  • ComboBox : cboMesin
  • Button : cmdConnect
  • Import dll CZKEM


Private Sub cmdConnect_Click()

Dim dwErrCode As Long

    Me.MousePointer = 11

    If IsNull(cboMesin.Column(1)) = True Then

        MsgBox "Pilih Mesin Sidik Jari yang Akan Anda Hubungkan!", vbCritical, "Select Device First"

        cboMesin.SetFocus

        Me.MousePointer = 0

        Exit Sub

    End If

    

    CZKEM1.Disconnect

    

    If cmdConnect.Caption = "Connect" Then

        Select Case cboMesin.Column(2)

            Case "USB"

                dConn = CZKEM1.Connect_Com(CLng(cboMesin.Column(5)), CLng(cboMesin.Column(1)), CLng(cboMesin.Column(6)))

                DeviceNumber = cboMesin.Column(1)

                If dConn Then

                    CZKEM1.ACUnlock DeviceNumber, 1

                    cmdConnect.Caption = "Disconnect"

                    CZKEM1.RegEvent DeviceNumber, 65535

                Else

                    CZKEM1.GetLastError dwErrCode

                    MsgBox "Error Description : " & GetLastErrorName(dwErrCode), vbCritical, "Can't Connect Device"

                    DeviceNumber = 0

                End If

            Case Else

                dConn = CZKEM1.Connect_Net(cboMesin.Column(3), cboMesin.Column(4))

                DeviceNumber = cboMesin.Column(1)

                If dConn Then

                    CZKEM1.ACUnlock DeviceNumber, 1

                    cmdConnect.Caption = "Disconnect"

                    CZKEM1.RegEvent DeviceNumber, 65535

                Else

                    CZKEM1.GetLastError dwErrCode

                    MsgBox "Error Description : " & GetLastErrorName(dwErrCode), vbCritical, "Can't Connect Device"

                    DeviceNumber = 0

                End If

        End Select

        Me.MousePointer = 0

        Exit Sub

    End If

    

    If cmdConnect.Caption = "Disconnect" Then

        CZKEM1.Disconnect

        cmdConnect.Caption = "Connect"

        dConn = False

        DeviceNumber = 0

    End If

    Me.MousePointer = 0

End Sub


2. Baca Log

Private Sub GetLogData()

Dim DeviceNumber As Long

Dim EnrollNum As String

Dim dwVerifyMode As Long

Dim dwInOutMode As Long

Dim dwYear As Long

Dim dwMonth As Long

Dim dwDay As Long

Dim dwHour As Long

Dim dwMinute As Long

Dim dwSecond As Long

Dim dwWorkCode As Long


    CZKEM1.ReadAllGLogData DeviceNumber

   

    While CZKEM1.SSR_GetGeneralLogData(DeviceNumber, EnrollNum, dwVerifyMode, dwInOutMode, dwYear, dwMonth, dwDay, dwHour, dwMinute, dwSecond, dwWorkCode)

        Text1.Text = EnrollNum

        Text2.Text = Format(dwDay, "00") & "/" & Format(dwMonth, "00") & "/" & Format(dwYear, "0000")

        Text3.Text = Format(dwHour, "00") & ":" & Format(dwMinute, "00") & ":" & Format(dwSecond, "00")

    Wend

End Sub


3. Hapus log

dwBackupNumber = 12

    If CZKEM1.SSR_DeleteEnrollData(DeviceNumber, EnrollNum, dwBackupNumber ) = True Then

        CZKEM1.RefreshData DeviceNumber

    Else

        CZKEM1.GetLastError dwErrCode

        MsgBox "Error Description : " & GetLastErrorName(dwErrCode), vbCritical, "Can't Connect Device"

        Me.MousePointer = 0

        Exit Sub

    End If