⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 wdatimesheets.vb

📁 数据库学习的绝好例子简单的数据库经典入门
💻 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
#End Region
End Class

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -