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

📄 admin.vb

📁 数据库学习的绝好例子简单的数据库经典入门
💻 VB
📖 第 1 页 / 共 5 页
字号:
            e.Effect = DragDropEffects.None
        End If
    End Sub

    Private Sub lstGroupProjects_DragDrop(ByVal sender As Object, _
        ByVal e As System.Windows.Forms.DragEventArgs) _
        Handles lstGroupProjects.DragDrop

        Dim objDataRow As Data.DataRow
        Dim objDataView As Data.DataView = New _
            Data.DataView(objProjectsDS.Tables("Projects"))
        objDataView.Sort = "ProjectID"
        intIndex = objDataView.Find(e.Data.GetData(DataFormats.Text))
        objDataRow = objGroupProjectsDS.Tables("GroupProjects").NewRow
        objDataRow.Item("ProjectID") = New _
            Guid(e.Data.GetData(DataFormats.Text).ToString)
        objDataRow.Item("ProjectName") = _
            objDataView.Item(intIndex).Item("ProjectName")
        objGroupProjectsDS.Tables("GroupProjects").Rows.Add(objDataRow)
        objGroupProjectsDS.AcceptChanges()
    End Sub

    Private Sub lstGroupProjects_KeyUp(ByVal sender As Object, _
        ByVal e As System.Windows.Forms.KeyEventArgs) _
        Handles lstGroupProjects.KeyUp

        If e.KeyCode = Keys.Delete Then
            objGroupProjectsDS.Tables("GroupProjects").Rows.RemoveAt( _
                lstGroupProjects.SelectedIndex)
            objGroupProjectsDS.AcceptChanges()
        End If
    End Sub
#End Region

#Region " Groups Procedures "
    Private Sub LoadGroups()
        'Declare variables
        Dim objListViewItem As ListViewItem

        'Turn the loading flag on so no items are processed
        blnLoading = True

        'Initialize a new instance of the business logic component
        Using objGroups As New WroxBusinessLogic.WBLGroups( _
            strCompany, strApplication)

            Try
                'Clear previous data bindings
                cboGroups.DataSource = Nothing
                cboGroups.DisplayMember = String.Empty
                cboGroups.ValueMember = String.Empty
                cboUserGroup.DataSource = Nothing
                cboUserGroup.DisplayMember = String.Empty
                cboUserGroup.ValueMember = String.Empty

                'Get all groups in a DataSet object
                objGroupsDS = objGroups.GetGroups()

                'Clear previous list
                lvwGroups.Items.Clear()

                'Process all rows
                For intIndex = 0 To objGroupsDS.Tables("Groups").Rows.Count - 1

                    'Create a new listview item
                    objListViewItem = New ListViewItem

                    'Add the data to the listview item
                    objListViewItem.Text = _
                        objGroupsDS.Tables("Groups").Rows(intIndex).Item( _
                        "GroupName")
                    objListViewItem.Tag = _
                        objGroupsDS.Tables("Groups").Rows(intIndex).Item( _
                        "GroupID")

                    'Add the sub items to the listview item
                    objListViewItem.SubItems.Add( _
                        objGroupsDS.Tables("Groups").Rows(intIndex).Item( _
                        "GroupDescription"))
                    objListViewItem.SubItems.Add( _
                        Format(objGroupsDS.Tables("Groups").Rows(intIndex).Item( _
                        "LastUpdateDate"), "g"))

                    'Add the listview item to the listview control
                    lvwGroups.Items.Add(objListViewItem)

                Next

                'Rebind ComboBox control
                cboGroups.DataSource = objGroupsDS.Tables("Groups")
                cboGroups.DisplayMember = "GroupName"
                cboGroups.ValueMember = "GroupID"
                cboUserGroup.DataSource = objGroupsDS.Tables("Groups")
                cboUserGroup.DisplayMember = "GroupName"
                cboUserGroup.ValueMember = "GroupID"

                'Reset the selected index
                cboGroups.SelectedIndex = -1
                cboUserGroup.SelectedIndex = -1
            Catch ExceptionErr As Exception
                MessageBox.Show(ExceptionErr.Message, strAppTitle)
            End Try
        End Using

        'Cleanup
        objListViewItem = Nothing

        'Turn off loading switch
        blnLoading = False
    End Sub

    Private Sub lvwGroups_Click(ByVal sender As Object, _
        ByVal e As System.EventArgs) Handles lvwGroups.Click

        'Initialize a new instance of the business logic component
        Using objGroups As New WroxBusinessLogic.WBLGroups( _
            strCompany, strApplication)

            Try
                'Get the specific Group selected in the ListView control
                objDataSet = objGroups.GetGroup( _
                    New Guid(lvwGroups.SelectedItems.Item(0).Tag.ToString))

                'Populate the Group Details section
                txtGroupID.Text = _
                    objDataSet.Tables("Group").Rows(0).Item( _
                    "GroupID").ToString.ToUpper
                txtGroupName.Text = _
                    objDataSet.Tables("Group").Rows(0).Item("GroupName")
                txtGroupDescription.Text = _
                    objDataSet.Tables("Group").Rows(0).Item("GroupDescription")
                txtGroupUpdateDate.Text = _
                    objDataSet.Tables("Group").Rows(0).Item("LastUpdateDate")
            Catch ExceptionErr As Exception
                MessageBox.Show(ExceptionErr.Message, strAppTitle)
            End Try
        End Using
    End Sub

    Private Sub cboGroups_SelectedIndexChanged(ByVal sender As Object, _
        ByVal e As System.EventArgs) Handles cboGroups.SelectedIndexChanged

        'Don't process if the ComboBox is being loaded
        If blnLoading Then
            Exit Sub
        End If

        'Initialize a new instance of the business logic component
        Using objGroups As New WroxBusinessLogic.WBLGroups( _
            strCompany, strApplication)

            Try
                'Clear previous bindings
                lstGroupProjects.DataSource = Nothing
                lstGroupProjects.DisplayMember = String.Empty
                lstGroupProjects.ValueMember = String.Empty

                'Get the Group Projects
                objGroupProjectsDS = objGroups.GetGroupProjects( _
                    New Guid(cboGroups.SelectedItem.Item("GroupID").ToString))

                'Rebind ListBox control
                lstGroupProjects.DataSource = _
                    objGroupProjectsDS.Tables("GroupProjects")
                lstGroupProjects.DisplayMember = "ProjectName"
                lstGroupProjects.ValueMember = "ProjectID"
            Catch ExceptionErr As Exception
                MessageBox.Show(ExceptionErr.Message, strAppTitle)
            End Try
        End Using
    End Sub
#End Region

#Region " Roles Procedures "
    Private Sub LoadRoles()
        'Declare variables
        Dim objListViewItem As ListViewItem

        'Turn the loading flag on so no items are processed
        blnLoading = True

        'Initialize a new instance of the business logic component
        Using objRoles As New WroxBusinessLogic.WBLRoles( _
            strCompany, strApplication)

            Try
                'Clear previous data bindings
                cboUserRole.DataSource = Nothing
                cboUserRole.DisplayMember = String.Empty
                cboUserRole.ValueMember = String.Empty

                'Get all roles in a DataSet object
                objRolesDS = objRoles.GetRoles()

                'Clear previous list
                lvwRoles.Items.Clear()

                'Process all rows
                For intIndex = 0 To objRolesDS.Tables("Roles").Rows.Count - 1
                    'Create a new listview item
                    objListViewItem = New ListViewItem
                    'Add the data to the listview item
                    objListViewItem.Text = _
                        objRolesDS.Tables("Roles").Rows(intIndex).Item("RoleName")
                    objListViewItem.Tag = _
                        objRolesDS.Tables("Roles").Rows(intIndex).Item("RoleID")
                    'Add the sub items to the listview item
                    objListViewItem.SubItems.Add( _
                        objRolesDS.Tables("Roles").Rows(intIndex).Item( _
                        "RoleDescription"))
                    objListViewItem.SubItems.Add( _
                        objRolesDS.Tables("Roles").Rows(intIndex).Item("Ranking"))
                    objListViewItem.SubItems.Add( _
                        Format(objRolesDS.Tables("Roles").Rows( _
                        intIndex).Item("LastUpdateDate"), "g"))
                    'Add the listview item to the listview control
                    lvwRoles.Items.Add(objListViewItem)
                Next

                'Rebind ComboBox control
                cboUserRole.DataSource = objRolesDS.Tables("Roles")
                cboUserRole.DisplayMember = "RoleName"
                cboUserRole.ValueMember = "RoleID"

                'Reset the selected index
                cboUserRole.SelectedIndex = -1
            Catch ExceptionErr As Exception
                MessageBox.Show(ExceptionErr.Message, strAppTitle)
            Finally
                'Cleanup
                objListViewItem = Nothing
            End Try
        End Using

        'Turn off loading switch
        blnLoading = False
    End Sub

    Private Sub lvwRoles_Click(ByVal sender As Object, _
        ByVal e As System.EventArgs) Handles lvwRoles.Click

        'Initialize a new instance of the business logic component
        Using objRoles As New WroxBusinessLogic.WBLRoles( _
            strCompany, strApplication)

            Try
                'Get the specific role selected in the ListView control
                objDataSet = objRoles.GetRole( _
                    New Guid(lvwRoles.SelectedItems.Item(0).Tag.ToString))

                'Populate the Role Details section
                txtRoleID.Text = _
                    objDataSet.Tables("Role").Rows(0).Item( _
                    "RoleID").ToString.ToUpper
                txtRoleName.Text = _
                    objDataSet.Tables("Role").Rows(0).Item("RoleName")
                txtRoleDescription.Text = _
                    objDataSet.Tables("Role").Rows(0).Item( _
                    "RoleDescription")
                txtRanking.Text = _
                    objDataSet.Tables("Role").Rows(0).Item("Ranking")
                txtRoleUpdateDate.Text = _
                    objDataSet.Tables("Role").Rows(0).Item("LastUpdateDate")

            Catch ExceptionErr As Exception
                MessageBox.Show(ExceptionErr.Message, strAppTitle)
            End Try
        End Using
    End Sub
#End Region

#Region "Users Procedures "
    Private Sub LoadUsers()
        'Declare variables
        Dim objListViewItem As ListViewItem

        'Initialize a new instance of the business logic component
        Using objUsers As New WroxBusinessLogic.WBLUsers( _
            strCompany, strApplication)

            Try
                'Get all users in a DataSet object
                objUsersDS = objUsers.GetUsers()

                'Clear previous list
                lvwUsers.Items.Clear()

                'Process all rows
                For intIndex = 0 To objUsersDS.Tables("Users").Rows.Count - 1
                    'Create a new listview item
                    objListViewItem = New ListViewItem
                    'Add the data to the listview item
                    objListViewItem.Text = _
                        objUsersDS.Tables("Users").Rows(intIndex).Item( _
                        "LoginName")
                    objListViewItem.Tag = _
                        objUsersDS.Tables("

⌨️ 快捷键说明

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