📄 timesheet.vb
字号:
End If
End With
grdTimeSheet.Columns.Add(objColumn)
'Change the locked icon if the timesheet is readonly
If objTimeSheetDS.Tables("TimeSheet").Rows(0).Item("Submitted") _
Or Not blnEmployeeDisplay Then
imgStatus.Image = ImageList1.Images(1)
Else
imgStatus.Image = ImageList1.Images(0)
End If
End Using
End Sub
#End Region
#Region " Menu and Toolbar Procedures "
Private Sub exitToolStripMenuItem_Click(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles exitToolStripMenuItem.Click
Me.Close()
End Sub
Private Sub MyTimeSheetToolStripMenuItem_Click(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles MyTimeSheetToolStripMenuItem.Click
'Undock the Panel
pnlManager.Dock = DockStyle.None
'Move it out of the way
pnlManager.Location = New Point(5000, 5000)
'Set the Dock property to Fill
'(this will cause the location to change to 0,0)
pnlEmployee.Dock = DockStyle.Top
'Set the view flag
blnEmployeeDisplay = True
End Sub
Private Sub EmployeeTimeSheetsToolStripMenuItem_Click(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles _
EmployeeTimeSheetsToolStripMenuItem.Click
'Undock the Panel
pnlEmployee.Dock = DockStyle.None
'Move it out of the way
pnlEmployee.Location = New Point(5000, 5000)
'Set the Dock property to Fill
'(this will cause the location to change to 0,0)
pnlManager.Dock = DockStyle.Top
'Set the view flag
blnEmployeeDisplay = False
End Sub
Private Sub aboutToolStripMenuItem_Click(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles aboutToolStripMenuItem.Click
Dim objAbout As New About
objAbout.ShowDialog(Me)
objAbout.Dispose()
objAbout = Nothing
End Sub
#End Region
#Region " Utility Functions "
Private Function GetCurrentWeekEndingDate() As String
GetCurrentWeekEndingDate = DateSerial( _
Year(Now), Month(Now), DateAndTime.Day(Now) - _
DatePart("w", Now, FirstDayOfWeek.Sunday) + 6)
End Function
Private Function GetPreviousWeekEndingDate() As String
GetPreviousWeekEndingDate = DateSerial( _
Year(Now), Month(Now), DateAndTime.Day(Now) - _
DatePart("w", Now, FirstDayOfWeek.Sunday) - 1)
End Function
#End Region
#Region " Timesheet Functions "
Private Sub cboWeekEnding_SelectedIndexChanged(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles cboWeekEnding.SelectedIndexChanged
If Not blnEmployeeDisplay And blnLoading Then
Exit Sub
End If
'Load the timesheet
Call LoadTimeSheet(cboWeekEnding)
End Sub
Private Sub grdTimeSheet_CurrentCellChanged(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles grdTimeSheet.CurrentCellChanged
'Declare variables
Dim objDataRowView As Data.DataRowView
Dim objDataRowTotal As Data.DataRowView
'Get the total row so we can update the totals
objDataRowTotal = objTimeSheetDV.Item(objTimeSheetDV.Count - 1)
'Recalculate Monday's total
intTotal = 0
For intIndex As Integer = 0 To objTimeSheetDV.Count - 2
objDataRowView = objTimeSheetDV.Item(intIndex)
intTotal += objDataRowView.Item("MondayHours")
Next
'Update Monday's total
objDataRowTotal.Item("MondayHours") = intTotal
'Recalculate Tuesday's total
intTotal = 0
For intIndex As Integer = 0 To objTimeSheetDV.Count - 2
objDataRowView = objTimeSheetDV.Item(intIndex)
intTotal += objDataRowView.Item("TuesdayHours")
Next
'Update Tuesday's total
objDataRowTotal.Item("TuesdayHours") = intTotal
'Recalculate Wednesday's total
intTotal = 0
For intIndex As Integer = 0 To objTimeSheetDV.Count - 2
objDataRowView = objTimeSheetDV.Item(intIndex)
intTotal += objDataRowView.Item("WednesdayHours")
Next
'Update Wednesday's total
objDataRowTotal.Item("WednesdayHours") = intTotal
'Recalculate Thursday's total
intTotal = 0
For intIndex As Integer = 0 To objTimeSheetDV.Count - 2
objDataRowView = objTimeSheetDV.Item(intIndex)
intTotal += objDataRowView.Item("ThursdayHours")
Next
'Update Thursday's total
objDataRowTotal.Item("ThursdayHours") = intTotal
'Recalculate Friday's total
intTotal = 0
For intIndex As Integer = 0 To objTimeSheetDV.Count - 2
objDataRowView = objTimeSheetDV.Item(intIndex)
intTotal += objDataRowView.Item("FridayHours")
Next
'Update Friday's total
objDataRowTotal.Item("FridayHours") = intTotal
'Commit the changes to the total row
objDataRowTotal.EndEdit()
End Sub
Private Sub cboEmployee_SelectedIndexChanged(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles cboEmployee.SelectedIndexChanged
strUserID = objEmployees.Tables("Employees").Rows( _
cboEmployee.SelectedIndex).Item("UserID").ToString
End Sub
Private Sub cboEmployeeWeekEnding_SelectedIndexChanged( _
ByVal sender As Object, ByVal e As System.EventArgs) _
Handles cboEmployeeWeekEnding.SelectedIndexChanged
If blnLoading Then
Exit Sub
End If
'Load the timesheet
Call LoadTimeSheet(cboEmployeeWeekEnding)
End Sub
Private Sub btnSave_Click(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles btnSave.Click
'Initialize a new instance of the business logic component
Using objTimeSheets As New WroxBusinessLogic.WBLTimeSheets( _
strCompany, strApplication)
Try
'Save the timesheet changes
If Not objTimeSheets.SaveTimeSheet(objTimeSheetDS) Then
Throw New Exception("Save TimeSheet Failed")
End If
'Display a statusbar message
ToolStripStatus.Text = "Timesheet saved"
Catch ExceptionErr As Exception
MessageBox.Show(ExceptionErr.Message, strAppTitle)
End Try
End Using
End Sub
Private Sub btnSubmit_Click(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles btnSubmit.Click
'Initialize a new instance of the business logic component
Using objTimeSheets As New WroxBusinessLogic.WBLTimeSheets( _
strCompany, strApplication)
Try
'Submit the timesheet
If Not objTimeSheets.SubmitTimeSheet( _
New Guid(objTimeSheetDS.Tables("TimeSheet").Rows(0).Item( _
"TimeSheetID").ToString)) Then
Throw New Exception("Submit TimeSheet Failed")
End If
'Reload the timesheet so it becomes read-only
Call LoadTimeSheet(cboWeekEnding)
'Display a statusbar message
ToolStripStatus.Text = "Timesheet submitted"
Catch ExceptionErr As Exception
MessageBox.Show(ExceptionErr.Message, strAppTitle)
End Try
End Using
End Sub
Private Sub btnApprove_Click(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles btnApprove.Click
'Initialize a new instance of the business logic component
Using objTimeSheets As New WroxBusinessLogic.WBLTimeSheets( _
strCompany, strApplication)
Try
'Submit the timesheet
If Not objTimeSheets.ApproveTimeSheet( _
New Guid(objTimeSheetDS.Tables("TimeSheet").Rows(0).Item( _
"TimeSheetID").ToString), New Guid(strManagerID)) Then
Throw New Exception("Approve TimeSheet Failed")
End If
'Display a statusbar message
ToolStripStatus.Text = "Timesheet approved"
Catch ExceptionErr As Exception
MessageBox.Show(ExceptionErr.Message, strAppTitle)
End Try
End Using
End Sub
#End Region
End Class
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -