Public Class frmPayslip
    Private Sub btnFind_Click(sender As Object, e As EventArgs) Handles btnFind.Click
        FillDataGrid(" SELECT   Payroll.PAYROLL_ID, Employee_Information.EMP_CODE, Employee_Information.EmployeesName, Employee_Information.FathersName, Payroll.SalaryDate, Payroll.TotalPresentDays, Payroll.GrossPay,  " &
                     " Payroll.FinalSalary FROM    Payroll LEFT OUTER JOIN " &
                     " Employee_Information ON Payroll.EMPLOYEE_ID = Employee_Information.EMPLOYEE_ID WHERE   (Payroll.SalaryDate >= '" & Format(dtpFrom.Value, "yyyy-MM-dd") & "' AND Payroll.SalaryDate <= '" & Format(dtpTo.Value, "yyyy-MM-dd") & "') ", DataGridView1)
    End Sub

    Private Sub frmPayslip_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        btnFind.PerformClick()
    End Sub

    Private Sub DataGridView1_CellContentClick(sender As Object, e As DataGridViewCellEventArgs) Handles DataGridView1.CellContentClick
        If e.ColumnIndex = 0 Then
            PrintSalarySlip(" SELECT  Payroll.PAYROLL_ID, Employee_Information.EMP_CODE, Employee_Information.EmployeesName, Employee_Information.FathersName, Employee_Information.MobileNumber, Payroll.SalaryDate, Payroll.BasicSalary, " &
                            " Payroll.Overtime, Payroll.Allowances, Payroll.Bonus, Payroll.GrossPay, Payroll.Deduction, Payroll.CashAdvance, Payroll.IncomeTAX, Payroll.FinalSalary, Payroll.TotalPresentDays, Payroll.SalaryDateFrom, " &
                            " Payroll.SalaryDateTo FROM     Payroll LEFT OUTER JOIN Employee_Information ON Payroll.EMPLOYEE_ID = Employee_Information.EMPLOYEE_ID  WHERE   (Payroll.PAYROLL_ID = " & DataGridView1.CurrentRow.Cells(2).Value & ") ")
        ElseIf e.ColumnIndex = 1 Then
            If MsgBox("Are you sure you want to delete this record?", MsgBoxStyle.YesNo + MsgBoxStyle.Exclamation, "Confirm..") = MsgBoxResult.Yes Then
                ExecuteSQLQuery("DELETE FROM Payroll WHERE  PAYROLL_ID =" & DataGridView1.CurrentRow.Cells(2).Value & " ")
                btnFind.PerformClick()
                MsgBox("Record deleted successfully.", MsgBoxStyle.Information, "Information")
            End If
        End If
    End Sub
End Class