📄 wdatimesheets.vb
字号:
Public Class WDATimeSheets
Inherits WDABase
#Region " Constructor and Destructor "
Public Sub New(ByVal Company As String, ByVal Application As String)
MyBase.New(Company, Application)
End Sub
Public Shadows Sub Dispose()
MyBase.Dispose()
End Sub
#End Region
#Region " Public Timesheet Functions "
Public Function AddTimeSheet(ByVal TimeSheet As DataSet) As Boolean
Try
'Clear previous Command just in case it has been set
MyBase.Command = Nothing
MyBase.SQL = "usp_InsertTimeSheet"
'Initialize the Command object
MyBase.InitializeCommand()
'Add the Parameters to the Parameters collection
MyBase.AddParameter("inTimeSheetID", _
OracleClient.OracleType.Char, 36, _
TimeSheet.Tables("TimeSheet").Rows(0).Item("TimeSheetID"))
MyBase.AddParameter("inUserID", _
OracleClient.OracleType.Char, 36, _
TimeSheet.Tables("TimeSheet").Rows(0).Item("UserID"))
MyBase.AddParameter("inWeekEndingDate", _
OracleClient.OracleType.DateTime, 8, _
TimeSheet.Tables("TimeSheet").Rows(0).Item("WeekEndingDate"))
'Execute the stored procedure
AddTimeSheet = ExecuteStoredProcedure()
Catch ExceptionErr As Exception
Throw New System.Exception(ExceptionErr.Message, _
ExceptionErr.InnerException)
End Try
End Function
Public Function GetTimeSheet(ByVal UserID As Guid, _
ByVal WeekEndingDate As Date) As DataSet
Try
GetTimeSheet = New DataSet
MyBase.SQL = "TimeSheetPackage.usp_SelectTimeSheet"
'Clear previous Command just in case it has been set
MyBase.Command = Nothing
'Initialize the Command object
MyBase.InitializeCommand()
'Add the Parameters to the Parameters collection
MyBase.AddParameter("inUserID", _
OracleClient.OracleType.Char, 36, UserID.ToString)
MyBase.AddParameter("inWeekEndingDate", _
OracleClient.OracleType.DateTime, 8, WeekEndingDate)
MyBase.AddParameter("results_cursor", _
OracleClient.OracleType.Cursor, ParameterDirection.Output)
'Fill the DataSet
MyBase.FillDataSet(GetTimeSheet, "TimeSheet")
'Check the DataSet for 0 rows and create a new timesheet
'if necessary
If GetTimeSheet.Tables("TimeSheet").Rows.Count = 0 Then
'Create a new TimeSheet DataSet
Dim objDataSet As New DataSet
'Create a DataTable
Dim objDataTable As DataTable = objDataSet.Tables.Add("TimeSheet")
'Add the DataColumns to the table
objDataTable.Columns.Add( _
"TimeSheetID", Type.GetType("System.String"))
objDataTable.Columns.Add( _
"UserID", Type.GetType("System.String"))
objDataTable.Columns.Add( _
"WeekEndingDate", Type.GetType("System.DateTime"))
'Initialize a datarow object from the TimeSheet DataSet
Dim objDataRow As DataRow = objDataSet.Tables("TimeSheet").NewRow
'Set the values in the DataRow
objDataRow.Item("TimeSheetID") = Guid.NewGuid.ToString
objDataRow.Item("UserID") = UserID.ToString
objDataRow.Item("WeekEndingDate") = WeekEndingDate
'Add the DataRow to the DataSet
objDataSet.Tables("TimeSheet").Rows.Add(objDataRow)
'Add the TimeSheet to the database
If Not AddTimeSheet(objDataSet) Then
Throw New Exception("Insert TimeSheet Failed")
End If
'Now perform a recursive call to this procedure
Return GetTimeSheet(UserID, WeekEndingDate)
End If
Catch ExceptionErr As Exception
Throw New System.Exception(ExceptionErr.Message, _
ExceptionErr.InnerException)
End Try
End Function
Public Function SaveTimeSheet(ByVal TimeSheet As DataSet) As Boolean
Try
MyBase.SQL = "usp_UpdateTimeSheetItem"
'Initialize the Command object
MyBase.InitializeCommand()
'Add the Parameters to the Parameters collection
MyBase.AddParameter("inTimeSheetItemID", _
OracleClient.OracleType.Char, 36, Nothing)
MyBase.AddParameter("inHours", _
OracleClient.OracleType.Number, 3, Nothing)
'Process all rows in the table
For intIndex As Integer = 0 To _
TimeSheet.Tables("TimeSheet").Rows.Count - 2
'Update Monday's Hours
MyBase.Command.Parameters.Item("inTimeSheetItemID").Value = _
TimeSheet.Tables("TimeSheet").Rows(intIndex).Item( _
"MondayTimeSheetItemID").ToString
MyBase.Command.Parameters.Item("inHours").Value = _
TimeSheet.Tables("TimeSheet").Rows(intIndex).Item( _
"MondayHours")
SaveTimeSheet = ExecuteStoredProcedure()
'Update Tuesday's Hours
MyBase.Command.Parameters.Item("inTimeSheetItemID").Value = _
TimeSheet.Tables("TimeSheet").Rows(intIndex).Item( _
"TuesdayTimeSheetItemID").ToString
MyBase.Command.Parameters.Item("inHours").Value = _
TimeSheet.Tables("TimeSheet").Rows(intIndex).Item( _
"TuesdayHours")
SaveTimeSheet = ExecuteStoredProcedure()
'Update Wednesday's Hours
MyBase.Command.Parameters.Item("inTimeSheetItemID").Value = _
TimeSheet.Tables("TimeSheet").Rows(intIndex).Item( _
"WednesdayTimeSheetItemID").ToString
MyBase.Command.Parameters.Item("inHours").Value = _
TimeSheet.Tables("TimeSheet").Rows(intIndex).Item( _
"WednesdayHours")
SaveTimeSheet = ExecuteStoredProcedure()
'Update Thursday's Hours
MyBase.Command.Parameters.Item("inTimeSheetItemID").Value = _
TimeSheet.Tables("TimeSheet").Rows(intIndex).Item( _
"ThursdayTimeSheetItemID").ToString
MyBase.Command.Parameters.Item("inHours").Value = _
TimeSheet.Tables("TimeSheet").Rows(intIndex).Item( _
"ThursdayHours")
SaveTimeSheet = ExecuteStoredProcedure()
'Update Friday's Hours
MyBase.Command.Parameters.Item("inTimeSheetItemID").Value = _
TimeSheet.Tables("TimeSheet").Rows(intIndex).Item( _
"FridayTimeSheetItemID").ToString
MyBase.Command.Parameters.Item("inHours").Value = _
TimeSheet.Tables("TimeSheet").Rows(intIndex).Item( _
"FridayHours")
SaveTimeSheet = ExecuteStoredProcedure()
Next
Catch ExceptionErr As Exception
Throw New System.Exception(ExceptionErr.Message, _
ExceptionErr.InnerException)
End Try
End Function
Public Function SubmitTimeSheet(ByVal TimeSheetID As Guid) As Boolean
Try
MyBase.SQL = "usp_SubmitTimeSheet"
'Initialize the Command object
MyBase.InitializeCommand()
'Add the Parameters to the Parameters collection
MyBase.AddParameter("inTimeSheetID", _
OracleClient.OracleType.Char, 36, TimeSheetID.ToString)
'Execute the stored procedure
SubmitTimeSheet = ExecuteStoredProcedure()
Catch ExceptionErr As Exception
Throw New System.Exception(ExceptionErr.Message, _
ExceptionErr.InnerException)
End Try
End Function
Public Function ApproveTimeSheet(ByVal TimeSheetID As Guid, _
ByVal ManagerID As Guid) As Boolean
Try
MyBase.SQL = "usp_ApproveTimeSheet"
'Initialize the Command object
MyBase.InitializeCommand()
'Add the Parameters to the Parameters collection
MyBase.AddParameter("inTimeSheetID", _
OracleClient.OracleType.Char, 36, TimeSheetID.ToString)
MyBase.AddParameter("inManagerID", _
OracleClient.OracleType.Char, 36, ManagerID.ToString)
'Execute the stored procedure
ApproveTimeSheet = ExecuteStoredProcedure()
Catch ExceptionErr As Exception
Throw New System.Exception(ExceptionErr.Message, _
ExceptionErr.InnerException)
End Try
End Function
#End Region
End Class
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -