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

📄 wdausers.vb

📁 数据库学习的绝好例子简单的数据库经典入门
💻 VB
字号:
Public Class WDAUsers
    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 User Functions "
    Public Function AddUser(ByVal User As DataSet) As Boolean
        Try
            MyBase.SQL = "usp_InsertUser"
            'Initialize the Command object
            MyBase.InitializeCommand()
            'Add the Parameters to the Parameters collection
            MyBase.AddParameter("@UserID", _
                SqlDbType.UniqueIdentifier, 16, _
                User.Tables("User").Rows(0).Item("UserID"))
            MyBase.AddParameter("@LoginName", _
                SqlDbType.VarChar, 15, _
                User.Tables("User").Rows(0).Item("LoginName"))
            MyBase.AddParameter("@Password", _
                SqlDbType.VarChar, 30, _
                User.Tables("User").Rows(0).Item("Password"))
            MyBase.AddParameter("@FirstName", _
                SqlDbType.VarChar, 30, _
                User.Tables("User").Rows(0).Item("FirstName"))
            MyBase.AddParameter("@LastName", _
                SqlDbType.VarChar, 30, _
                User.Tables("User").Rows(0).Item("LastName"))
            MyBase.AddParameter("@Email", _
                SqlDbType.VarChar, 50, _
                User.Tables("User").Rows(0).Item("Email"))
            MyBase.AddParameter("@Phone", _
                SqlDbType.VarChar, 20, _
                User.Tables("User").Rows(0).Item("Phone"))
            MyBase.AddParameter("@Status", _
                SqlDbType.Bit, 1, _
                User.Tables("User").Rows(0).Item("Status"))
            MyBase.AddParameter("@GroupID", _
                SqlDbType.UniqueIdentifier, 16, _
                User.Tables("User").Rows(0).Item("GroupID"))
            MyBase.AddParameter("@RoleID", _
                SqlDbType.UniqueIdentifier, 16, _
                User.Tables("User").Rows(0).Item("RoleID"))
            MyBase.AddParameter("@ManagerID", _
                SqlDbType.UniqueIdentifier, 16, _
                User.Tables("User").Rows(0).Item("ManagerID"))
            'Execute the stored procedure
            AddUser = ExecuteStoredProcedure()
        Catch ExceptionErr As Exception
            Throw New System.Exception(ExceptionErr.Message, _
            ExceptionErr.InnerException)
        End Try
    End Function

    Public Function GetUsers() As DataSet
        Try
            GetUsers = New DataSet
            MyBase.SQL = "usp_SelectUsers"
            'Fill the DataSet
            MyBase.FillDataSet(GetUsers, "Users")
        Catch ExceptionErr As Exception
            Throw New System.Exception(ExceptionErr.Message, _
            ExceptionErr.InnerException)
        End Try
    End Function

    Public Function GetUser(ByVal UserID As Guid) As DataSet
        Try
            GetUser = New DataSet
            MyBase.SQL = "usp_SelectUser"
            'Initialize the Command object
            MyBase.InitializeCommand()
            'Add a Parameter to the Parameters collection
            MyBase.AddParameter("@UserID", SqlDbType.UniqueIdentifier, _
                16, UserID)
            'Fill the DataSet
            MyBase.FillDataSet(GetUser, "User")
        Catch ExceptionErr As Exception
            Throw New System.Exception(ExceptionErr.Message, _
            ExceptionErr.InnerException)
        End Try
    End Function

    Public Function GetManagers() As DataSet
        Try
            GetManagers = New DataSet
            MyBase.SQL = "usp_SelectManagers"
            'Fill the DataSet
            MyBase.FillDataSet(GetManagers, "Managers")
        Catch ExceptionErr As Exception
            Throw New System.Exception(ExceptionErr.Message, _
            ExceptionErr.InnerException)
        End Try
    End Function

    Public Function GetManagerEmployees(ByVal ManagerID As Guid) As DataSet
        Try
            GetManagerEmployees = New DataSet
            MyBase.SQL = "usp_SelectManagerEmployees"
            'Initialize the Command object
            MyBase.InitializeCommand()
            'Add a Parameter to the Parameters collection
            MyBase.AddParameter("@ManagerID", SqlDbType.UniqueIdentifier, _
                16, ManagerID)
            'Fill the DataSet
            MyBase.FillDataSet(GetManagerEmployees, "Employees")
        Catch ExceptionErr As Exception
            Throw New System.Exception(ExceptionErr.Message, _
            ExceptionErr.InnerException)
        End Try
    End Function

    Public Function ValidateLogin(ByVal LoginName As String, _
        ByVal Password As String) As DataSet

        Try
            ValidateLogin = New DataSet
            MyBase.SQL = "usp_ValidateLogin"
            'Initialize the Command object
            MyBase.InitializeCommand()
            'Add the Parameters to the Parameters collection
            MyBase.AddParameter("@LoginName", SqlDbType.VarChar, _
                15, LoginName)
            MyBase.AddParameter("@Password", SqlDbType.VarChar, _
                30, Password)
            'Fill the DataSet
            MyBase.FillDataSet(ValidateLogin, "User")
        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 + -