Public Class frmAttendanceList1
    Private Sub frmAttendanceList1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        btnFind.PerformClick()
    End Sub

    Private Sub btnFind_Click(sender As Object, e As EventArgs) Handles btnFind.Click
        sqlSTR = " SELECT        Attendance.ATTN_ID, Attendance.AttendanceDate, Employee_Information.EMP_CODE, Employee_Information.EmployeesName, WorkingHours.ShiftName, Attendance.TimeIn, Attendance.TimeOut FROM            WorkingHours LEFT OUTER JOIN " &
                " Employee_Information ON WorkingHours.ShiftID = Employee_Information.ShiftID RIGHT OUTER JOIN Attendance ON Employee_Information.EMPLOYEE_ID = Attendance.EMPLOYEE_ID " &
                " WHERE        (Attendance.AttendanceDate >= '" & Format(dtpFrom.Value, "yyyy-MM-dd") & "' AND Attendance.AttendanceDate <= '" & Format(dtpTo.Value, "yyyy-MM-dd") & "') "
        FillDataGrid(sqlSTR, DataGridView1)
        ExecuteSQLQuery(sqlSTR)
        If sqlDT.Rows.Count > 0 Then
            lblCount.Text = sqlDT.Rows.Count.ToString & " Record Found."
        Else
            lblCount.Text = "No Record Found."
        End If
    End Sub

    Private Sub DataGridView1_CellContentClick(sender As Object, e As DataGridViewCellEventArgs) Handles DataGridView1.CellContentClick
        If e.ColumnIndex = 0 Then
            If MsgBox("Are you sure you want to delete this record?", MsgBoxStyle.YesNo + MsgBoxStyle.Exclamation, "Confirm..") = MsgBoxResult.Yes Then
                ExecuteSQLQuery("DELETE FROM Attendance WHERE  ATTN_ID =" & DataGridView1.CurrentRow.Cells(1).Value & " ")
                btnFind.PerformClick()
                MsgBox("Record deleted successfully.", MsgBoxStyle.Information, "Information")
            End If
        End If
    End Sub
End Class