-
Notifications
You must be signed in to change notification settings - Fork 1
/
frmSalarySlipsReport.vb
executable file
·112 lines (98 loc) · 5.41 KB
/
frmSalarySlipsReport.vb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
Imports System.Data.OleDb
Imports CrystalDecisions.CrystalReports.Engine
Imports CrystalDecisions.Shared
Public Class frmSalarySlipsReport
Dim rdr As OleDbDataReader = Nothing
Dim dtable As DataTable
Dim con As OleDbConnection = Nothing
Dim adp As OleDbDataAdapter
Dim ds As DataSet
Dim cmd As OleDbCommand = Nothing
Dim dt As New DataTable
Dim cs As String = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=|DataDirectory|\PayrollManagerDB.accdb;Persist Security Info=False;"
Private Sub frmSalarySlipsReport_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
fillcombo()
End Sub
Private Sub button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles button4.Click
Try
Dim rpt As New rptSalarySlips() 'The report you created.
Dim myConnection As OleDbConnection
Dim MyCommand As New OleDbCommand()
Dim myDA As New OleDbDataAdapter()
Dim myDS As New PayrollManagerDBDataSet 'The DataSet you created.
myConnection = New OleDbConnection(cs)
MyCommand.Connection = myConnection
MyCommand.CommandText = "select PaymentID,Datefrom,dateTo,EmployeeRegistration.employeeid,employeename,designation,department,EmployeePayment.salary,presentdays,advance,deduction,overtime,overtimeamount,paymentdate,modeofpayment,netpay from EmployeePayment,EmployeeRegistration where EmployeeRegistration.EmployeeID=EmployeePayment.EmployeeID and PaymentDate between #" & DateFrom.Text & "# And #" & DateTo.Text & "#"
MyCommand.CommandType = CommandType.Text
myDA.SelectCommand = MyCommand
myDA.Fill(myDS, "EmployeePayment")
myDA.Fill(myDS, "EmployeeRegistration")
rpt.SetDataSource(myDS)
CrystalReportViewer1.ReportSource = rpt
Catch ex As Exception
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
End Sub
Private Sub button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles button5.Click
DateFrom.Text = Today
DateTo.Text = Today
CrystalReportViewer1.ReportSource = Nothing
End Sub
Sub fillcombo()
Try
Dim CN As New oledbConnection(cs)
CN.Open()
adp = New oledbDataAdapter()
adp.SelectCommand = New OleDbCommand("SELECT distinct (employeename) FROM employeeRegistration,EmployeePayment where EmployeeRegistration.EmployeeID=Employeepayment.EmployeeID", CN)
ds = New DataSet("ds")
adp.Fill(ds)
dtable = ds.Tables(0)
EmployeeName.Items.Clear()
For Each drow As DataRow In dtable.Rows
EmployeeName.Items.Add(drow(0).ToString())
'DocName.SelectedIndex = -1
Next
Catch ex As Exception
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Try
Dim rpt As New rptSalarySlips() 'The report you created.
Dim myConnection As OleDbConnection
Dim MyCommand As New OleDbCommand()
Dim myDA As New OleDbDataAdapter()
Dim myDS As New PayrollManagerDBDataSet 'The DataSet you created.
myConnection = New OleDbConnection(cs)
MyCommand.Connection = myConnection
MyCommand.CommandText = "select PaymentID,Datefrom,dateTo,EmployeeRegistration.employeeid,employeename,designation,department,EmployeePayment.salary,presentdays,advance,deduction,overtime,overtimeamount,paymentdate,modeofpayment,netpay from EmployeePayment,EmployeeRegistration where EmployeeRegistration.EmployeeID=EmployeePayment.EmployeeID and PaymentDate between #" & DateTimePicker2.Text & "# And #" & DateTimePicker1.Text & "# and Employeename='" & EmployeeName.Text & "'"
MyCommand.CommandType = CommandType.Text
myDA.SelectCommand = MyCommand
myDA.Fill(myDS, "EmployeePayment")
myDA.Fill(myDS, "EmployeeRegistration")
rpt.SetDataSource(myDS)
CrystalReportViewer2.ReportSource = rpt
Catch ex As Exception
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
End Sub
Private Sub button8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles button8.Click
EmployeeName.Text = ""
CrystalReportViewer2.ReportSource = Nothing
DateTimePicker1.Text = Today
DateTimePicker2.Text = Today
End Sub
Private Sub TabControl1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TabControl1.Click
EmployeeName.Text = ""
CrystalReportViewer2.ReportSource = Nothing
DateTimePicker1.Text = Today
DateTimePicker2.Text = Today
DateFrom.Text = Today
DateTo.Text = Today
CrystalReportViewer1.ReportSource = Nothing
End Sub
Private Sub frmSalarySlipsReport_FormClosing(ByVal sender As System.Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles MyBase.FormClosing
Me.Hide()
frmMainMenu.Show()
End Sub
End Class