Provider Microsoft - Ace.Oledb.12.0 Data Source - Datadirectory - /payrollmanagerdb - Accdb Persist Security Info False
Provider Microsoft - Ace.Oledb.12.0 Data Source - Datadirectory - /payrollmanagerdb - Accdb Persist Security Info False
OleDbType.VarChar,
OleDbType.VarChar,
OleDbType.VarChar,
OleDbType.VarChar,
10, "status"))
30, "intime"))
30, "outtime"))
10,
cmd.Parameters("@d1").Value = WorkingDate.Text
cmd.Parameters("@d2").Value = EmployeeID.Text
cmd.Parameters("@d4").Value = Status.Text
If Status.Text = "P" Then
cmd.Parameters("@d5").Value
cmd.Parameters("@d6").Value
ElseIf Status.Text = "A" Then
cmd.Parameters("@d5").Value
cmd.Parameters("@d6").Value
End If
= InTime.Text
= OutTime.Text
= txtInTime.Text
= txtOutTime.Text
cmd.Parameters("@d7").Value = Overtime.Text
cmd.Parameters("@d8").Value = BasicWorkingTime.Text
cmd.ExecuteReader()
MessageBox.Show("Successfully saved", "Employee Attendance",
MessageBoxButtons.OK, MessageBoxIcon.Information)
If con.State = ConnectionState.Open Then
con.Close()
End If
con.Close()
Save.Enabled = False
End If
Catch ex As Exception
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
End Sub
Private Sub Submit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles Submit.Click
Try
If EmployeeID.Text = "" Then
MessageBox.Show("Please select employee id", "input error", MessageBoxButtons.OK,
MessageBoxIcon.Error)
Exit Sub
End If
Update_Record.Enabled = True
Delete.Enabled = True
con = New oledbConnection(cs)
con.Open()
Dim ct As String = "select
Employeename,EmployeeAttendance.Basicworkingtime,status,intime,outtime,overtime from
EmployeeAttendance,EmployeeRegistration where
EmployeeRegistration.EmployeeID=EmployeeAttendance.EmployeeID and
EmployeeRegistration.employeeid=@find and WorkingDate=@find1"
cmd = New oledbCommand(ct)
cmd.Connection = con
cmd.Parameters.Add(New oledbParameter("@find", oledbType.Varchar, 30,
"employeeid"))
cmd.Parameters("@find").Value = Trim(EmployeeID.Text)
cmd.Parameters.Add(New oledbParameter("@find1", oledbType.Varchar, 30,
"workingdate"))
cmd.Parameters("@find1").Value = Trim(WorkingDate.Text)
rdr = cmd.ExecuteReader()
If rdr.Read Then
EmployeeName.Text = Trim(rdr.GetString(0))
BasicWorkingTime.Text = Trim(rdr.GetString(1))
Status.Text = Trim(rdr.GetString(2))
If Status.Text = "P" Then
InTime.Text = Trim(rdr.GetString(3))
OutTime.Text = Trim(rdr.GetString(4))
ElseIf Status.Text = "A" Then
txtOutTime.Visible = True
txtInTime.Visible = True
txtOutTime.Text = Trim(rdr.GetString(3))
txtInTime.Text = Trim(rdr.GetString(4))
End If
InTime.Text = Trim(rdr.GetString(3))
OutTime.Text = Trim(rdr.GetString(4))
Overtime.Text = Trim(rdr.GetString(5))
Else
MessageBox.Show("No record found", "Sorry", MessageBoxButtons.OK,
MessageBoxIcon.Information)
End If
If Not rdr Is Nothing Then
rdr.Close()
End If
If con.State = ConnectionState.Open Then
con.Close()
End If
Catch ex As Exception
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
End Sub
Private Sub Update_Record_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Update_Record.Click
Try
con = New OleDbConnection(cs)
con.Open()
Dim cb As String = "update employeeAttendance set status='" & Status.Text &
"',intime=@d5,outtime=@d6,overtime='" & Overtime.Text & "',basicworkingtime='" &
BasicWorkingTime.Text & "' where workingdate= #" & WorkingDate.Text & "# and Employeeid='"
& EmployeeID.Text & "'"
cmd = New oledbCommand(cb)
cmd.Connection = con
cmd.Parameters.Add(New OleDbParameter("@d5", OleDbType.VarChar, 30, "intime"))
cmd.Parameters.Add(New oledbParameter("@d6", oledbType.Varchar, 30, "outtime"))
If Status.Text = "P" Then
cmd.Parameters("@d5").Value
cmd.Parameters("@d6").Value
ElseIf Status.Text = "A" Then
cmd.Parameters("@d5").Value
cmd.Parameters("@d6").Value
End If
= InTime.Text
= OutTime.Text
= txtOutTime.Text
= txtInTime.Text
End If
End Sub
Private Sub Status_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Status.SelectedIndexChanged
If Status.Text = "P" Then
txtOutTime.Visible = False
txtInTime.Visible = False
InTime.Enabled = True
OutTime.Enabled = True
InTime.Text = Now
OutTime.Text = Now
Overtime.Text = ""
ElseIf Status.Text = "A" Then
txtOutTime.Visible = True
txtInTime.Visible = True
txtOutTime.Text = "00:00:00"
txtInTime.Text = "00:00:00"
Overtime.Text = "00:00:00"
End If
End Sub
Private Sub OutTime_ValueChanged(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles OutTime.ValueChanged
Dim ts As TimeSpan
TimeSpan.TryParse(BasicWorkingTime.Text, ts)
Dim duration As TimeSpan = OutTime.Value - InTime.Value
Overtime.Text = Convert.ToString(duration - ts)
End Sub
Private Sub InTime_ValueChanged(ByVal sender As Object, ByVal e As System.EventArgs)
Handles InTime.ValueChanged
Dim ts As TimeSpan
TimeSpan.TryParse(BasicWorkingTime.Text, ts)
Dim duration As TimeSpan = OutTime.Value - InTime.Value
Overtime.Text = Convert.ToString(duration - ts)
End Sub
Private Sub DataGridView1_RowHeaderMouseClick(ByVal sender As System.Object, ByVal e As
System.Windows.Forms.DataGridViewCellMouseEventArgs) Handles
DataGridView1.RowHeaderMouseClick
Try
Dim dr As DataGridViewRow = DataGridView1.SelectedRows(0)
Me.EmployeeName.Text = dr.Cells(0).Value.ToString()
Me.EmployeeID.Text = dr.Cells(1).Value.ToString()
Catch ex As Exception
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
End Sub
Private Sub Label2_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles Label2.Click
End Sub
End Class
Imports System.Data.OleDb
Imports Excel = Microsoft.Office.Interop.Excel
Public Class frmAdvanceEntryRecord
DataGridView1.DataSource = myDataSet.Tables("EmployeeRegistration").DefaultView
Dim sum As Double = 0
For Each r As DataGridViewRow In Me.DataGridView1.Rows
sum = sum + r.Cells(3).Value
Next
TotalAdvance.Text = sum
con.Close()
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
DataGridView1.DataSource = Nothing
EmployeeName.Text = ""
Total.Visible = False
End Sub
Private Sub button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles button4.Click
Try
GroupBox1.Visible = True
con = New OleDbConnection(cs)
con.Open()
cmd = New OleDbCommand("select (workingdate) as [Entry Date],
(EmployeeRegistration.EmployeeID) as [Employee ID],(EmployeeName) as [EmployeeName],
(Amount) as [Advance] from Advanceentry,employeeRegistration where
EmployeeRegistration.EmployeeID=AdvanceEntry.EmployeeID and amount > 0 and WorkingDate
between #" & DateFrom.Text & "# And #" & DateTo.Text & "# order by workingdate", con)
Dim myDA As oledbDataAdapter = New oledbDataAdapter(cmd)
Dim myDataSet As DataSet = New DataSet()
myDA.Fill(myDataSet, "AdvanceEntry")
myDA.Fill(myDataSet, "EmployeeRegistration")
DataGridView2.DataSource = myDataSet.Tables("AdvanceEntry").DefaultView
DataGridView2.DataSource = myDataSet.Tables("EmployeeRegistration").DefaultView
Dim sum As Double = 0
For Each r As DataGridViewRow In Me.DataGridView2.Rows
sum = sum + r.Cells(3).Value
Next
TextBox1.Text = sum
con.Close()
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.value = Today
DateTo.value = Today
DataGridView2.DataSource = Nothing
GroupBox1.Visible = False
End Sub