Public Class frmFingerprintRegistration
    Private Sub btnClose_Click(sender As Object, e As EventArgs) Handles btnClose.Click
        Me.Close()
    End Sub

    Private Sub txtEmployeesCode_TextChanged(sender As Object, e As EventArgs) Handles txtEmployeesCode.TextChanged
        If txtEmployeesCode.Text = "" Then
            txtEmpID.Text = ""
            txtEmployeesName.Text = ""
            txtFathersName.Text = ""
            txtShiftName.Text = ""
            txtFingerHashCode.Text = ""
            PictureBox1.Image = PayrollManagementSystem.My.Resources.no_image
        End If
    End Sub

    Private Sub btnSearch_Click(sender As Object, e As EventArgs) Handles btnSearch.Click
        If txtEmployeesCode.Text = "" Then
            ErrorProvider1.SetError(txtEmployeesCode, "Mandatory field.")
        Else
            ErrorProvider1.Clear()
            txtFingerHashCode.Text = ""
            ExecuteSQLQuery(" SELECT        Employee_Information.EMPLOYEE_ID, Employee_Information.EMP_CODE, Employee_Information.EmployeesName, Employee_Information.FathersName, WorkingHours.ShiftName, Employee_Information.PHOTO_FILE_NAME,  " &
                            " Employee_Fingerprint.FingerHashCode  FROM            Employee_Information LEFT OUTER JOIN WorkingHours ON Employee_Information.ShiftID = WorkingHours.ShiftID LEFT OUTER JOIN " &
                            " Employee_Fingerprint ON Employee_Information.EMPLOYEE_ID = Employee_Fingerprint.EMPLOYEE_ID   WHERE  (Employee_Information.EMP_CODE = '" + str_repl(txtEmployeesCode.Text) + "') ")
            If sqlDT.Rows.Count > 0 Then
                txtEmpID.Text = sqlDT.Rows(0)("EMPLOYEE_ID")
                txtEmployeesName.Text = sqlDT.Rows(0)("EmployeesName")
                txtFathersName.Text = sqlDT.Rows(0)("FathersName")
                txtShiftName.Text = sqlDT.Rows(0)("ShiftName")
                Try
                    PictureBox1.ImageLocation = Application.StartupPath + "\Upload\Employee\" + sqlDT.Rows(0)("PHOTO_FILE_NAME")
                    txtFingerHashCode.Text = sqlDT.Rows(0)("FingerHashCode")
                Catch ex As Exception
                    PictureBox1.Image = PayrollManagementSystem.My.Resources.no_image
                End Try
            Else
                txtEmpID.Text = ""
                txtEmployeesName.Text = ""
                txtFathersName.Text = ""
                txtShiftName.Text = ""
                txtFingerHashCode.Text = ""
                PictureBox1.Image = PayrollManagementSystem.My.Resources.no_image
                MsgBox("No Record Found.", MsgBoxStyle.Information, "Information")
            End If
        End If
    End Sub

    Private Sub btnSubmit_Click(sender As Object, e As EventArgs) Handles btnSubmit.Click
        If txtEmpID.Text = "" Or txtFingerHashCode.Text = "" Then
            ErrorProvider1.SetError(txtEmployeesCode, "Mandatory field.")
            ErrorProvider1.SetError(txtFingerHashCode, "Mandatory field.")
        Else
            ErrorProvider1.Clear()

            ExecuteSQLQuery("SELECT * FROM     Employee_Fingerprint  WHERE  (EMPLOYEE_ID = " & num_fltr(txtEmpID.Text) & ")")
            If sqlDT.Rows.Count > 0 Then
                If MsgBox("Are you sure to update Fingerprint?", MsgBoxStyle.YesNo + MsgBoxStyle.Exclamation, "Confirm..") = MsgBoxResult.Yes Then
                    UpdateFingerHashCode(num_fltr(txtEmpID.Text), txtFingerHashCode.Text)
                    MsgBox("Record has been saved successfully.", MsgBoxStyle.Information, "Information")
                End If
            Else
                SaveFingerHashCode(num_fltr(txtEmpID.Text), txtFingerHashCode.Text)
                MsgBox("Record has been saved successfully.", MsgBoxStyle.Information, "Information")
            End If

            txtEmpID.Text = ""
            txtEmployeesCode.Text = ""
            txtEmployeesName.Text = ""
            txtFathersName.Text = ""
            txtShiftName.Text = ""
            txtFingerHashCode.Text = ""
            btnSubmit.Text = "SAVE"
            PictureBox1.Image = PayrollManagementSystem.My.Resources.no_image
        End If
    End Sub
End Class