📄 admin.vb
字号:
Private Sub ProjectsToolStripMenuItem_Click(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles ProjectsToolStripMenuItem.Click
Navigate("pnlNavProjects")
pnlNavProjects.BackgroundImage = imlNavigation.Images(ImageSelected)
End Sub
Private Sub GroupsToolStripMenuItem_Click(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles GroupsToolStripMenuItem.Click
Navigate("pnlNavGroups")
pnlNavGroups.BackgroundImage = imlNavigation.Images(ImageSelected)
End Sub
Private Sub GroupProjectsToolStripMenuItem_Click(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles GroupProjectsToolStripMenuItem.Click
Navigate("pnlNavGroupProjects")
pnlNavGroupProjects.BackgroundImage = imlNavigation.Images(ImageSelected)
End Sub
Private Sub RolesToolStripMenuItem_Click(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles RolesToolStripMenuItem.Click
Navigate("pnlNavRoles")
pnlNavRoles.BackgroundImage = imlNavigation.Images(ImageSelected)
End Sub
Private Sub UsersToolStripMenuItem_Click(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles UsersToolStripMenuItem.Click
Navigate("pnlNavUsers")
pnlNavUsers.BackgroundImage = imlNavigation.Images(ImageSelected)
End Sub
Private Sub AddToolStripMenuItem_Click(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles AddToolStripMenuItem.Click
ActionAdd()
End Sub
Private Sub UpdateToolStripMenuItem_Click(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles UpdateToolStripMenuItem.Click
ActionUpdate()
End Sub
Private Sub DeleteToolStripMenuItem_Click(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles DeleteToolStripMenuItem.Click
ActionDelete()
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
Private Sub newToolStripButton_Click(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles newToolStripButton.Click
FileNew()
End Sub
Private Sub cutToolStripButton_Click(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles cutToolStripButton.Click
EditCut()
End Sub
Private Sub copyToolStripButton_Click(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles copyToolStripButton.Click
EditCopy()
End Sub
Private Sub pasteToolStripButton_Click(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles pasteToolStripButton.Click
EditPaste()
End Sub
Private Sub UndoToolStripButton_Click(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles UndoToolStripButton.Click
EditUndo()
End Sub
Private Sub AddToolStripButton_Click(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles AddToolStripButton.Click
ActionAdd()
End Sub
Private Sub UpdateToolStripButton_Click(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles UpdateToolStripButton.Click
ActionUpdate()
End Sub
Private Sub DeleteToolStripButton_Click(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles DeleteToolStripButton.Click
ActionDelete()
End Sub
#End Region
#Region " Add, Update and Delete Procedures "
Private Sub ActionAdd()
Try
'Add database row based on the active screen
Select Case strActiveScreen
Case "Projects"
'Initialize a new instance of the business logic component
Using objProjects As New WroxBusinessLogic.WBLProjects( _
strCompany, strApplication)
'Get a new Project DataSet
objDataSet = objProjects.GetNewProjectDS()
'Initialize a datarow object from the Project DataSet
Dim objDataRow As Data.DataRow = _
objDataSet.Tables("Project").NewRow
'Set the values in the DataRow
objDataRow.Item("ProjectID") = Guid.NewGuid()
objDataRow.Item("ProjectName") = txtProjectName.Text
objDataRow.Item("ProjectDescription") = _
txtProjectDescription.Text
objDataRow.Item("SequenceNumber") = _
CType(txtSequenceNumber.Text, Byte)
'Add the DataRow to the DataSet
objDataSet.Tables("Project").Rows.Add(objDataRow)
'Add the Project
If Not objProjects.AddProject(objDataSet) Then
Throw New Exception("Insert Project Failed")
End If
End Using
'Clear the input fields
txtProjectName.Text = String.Empty
txtProjectDescription.Text = String.Empty
txtSequenceNumber.Text = String.Empty
'Reload the Projects list
LoadProjects()
Case "Groups"
'Initialize a new instance of the business logic component
Using objGroups As New WroxBusinessLogic.WBLGroups( _
strCompany, strApplication)
'Get a new Group DataSet
objDataSet = objGroups.GetNewGroupDS()
'Initialize a datarow object from the Group DataSet
Dim objDataRow As Data.DataRow = _
objDataSet.Tables("Group").NewRow
'Set the values in the DataRow
objDataRow.Item("GroupID") = Guid.NewGuid()
objDataRow.Item("GroupName") = txtGroupName.Text
objDataRow.Item("GroupDescription") = _
txtGroupDescription.Text
'Add the DataRow to the DataSet
objDataSet.Tables("Group").Rows.Add(objDataRow)
'Add the Groups to the database
If Not objGroups.AddGroup(objDataSet) Then
Throw New Exception("Insert Group Failed")
End If
End Using
'Clear the input fields
txtGroupName.Text = String.Empty
txtGroupDescription.Text = String.Empty
'Reload the Groups list
LoadGroups()
Case "Group Projects"
'Turn the loading flag on so no items are processed
blnLoading = True
'Delete any previous projects
Call ActionDelete()
'Turn the loading flag off
blnLoading = False
'Initialize a new instance of the business logic component
Using objGroups As New WroxBusinessLogic.WBLGroups( _
strCompany, strApplication)
'Get a new GroupProjects DataSet
objDataSet = objGroups.GetNewGroupProjectsDS()
For intIndex = 0 To objGroupProjectsDS.Tables( _
"GroupProjects").Rows.Count - 1
'Initialize a datarow object from the
'GroupProjects(DataSet)
Dim objDataRow As Data.DataRow = _
objDataSet.Tables("GroupProjects").NewRow
'Set the values in the DataRow
objDataRow.Item("GroupProjectID") = Guid.NewGuid()
objDataRow.Item("GroupID") = _
cboGroups.SelectedItem.Item("GroupID")
objDataRow.Item("ProjectID") = _
objGroupProjectsDS.Tables( _
"GroupProjects").Rows(intIndex).Item("ProjectID")
'Add the DataRow to the DataSet
objDataSet.Tables("GroupProjects").Rows.Add(objDataRow)
Next
'Add the GroupProjects to the database
If Not objGroups.AddGroupProjects(objDataSet) Then
Throw New Exception("Insert Group Failed")
End If
End Using
'Clear previous bindings
lstGroupProjects.DataSource = Nothing
lstGroupProjects.DisplayMember = String.Empty
lstGroupProjects.ValueMember = String.Empty
lstGroupProjects.Items.Clear()
'Turn the loading flag on so no items are processed
blnLoading = True
cboGroups.SelectedIndex = -1
'Turn the loading flag off
blnLoading = False
Case "Roles"
'Initialize a new instance of the business logic component
Using objRoles As New WroxBusinessLogic.WBLRoles( _
strCompany, strApplication)
'Get a new Role DataSet
objDataSet = objRoles.GetNewRoleDS()
'Initialize a datarow object from the Role DataSet
Dim objDataRow As Data.DataRow = _
objDataSet.Tables("Role").NewRow
'Set the values in the DataRow
objDataRow.Item("RoleID") = Guid.NewGuid
objDataRow.Item("RoleName") = txtRoleName.Text
objDataRow.Item("RoleDescription") = _
txtRoleDescription.Text
If IsNumeric(txtRanking.Text) Then
objDataRow.Item("Ranking") = _
CType(txtRanking.Text, Byte)
Else
Throw New Exception( _
"Ranking must contain a numeric value.")
End If
'Add the DataRow to the DataSet
objDataSet.Tables("Role").Rows.Add(objDataRow)
'Add the Role to the database
If Not objRoles.AddRole(objDataSet) Then
Throw New Exception("Insert Role Failed")
End If
End Using
'Clear the input fields
txtRoleID.Text = String.Empty
txtRoleName.Text = String.Empty
txtRoleDescription.Text = String.Empty
txtRanking.Text = String.Empty
txtRoleUpdateDate.Text = String.Empty
'Reload the Roles list
LoadRoles()
Case "Users"
'Initialize a new instance of the business logic component
Using objUsers As New WroxBusinessLogic.WBLUsers( _
strCompany, strApplication)
'Get a new User DataSet
objDataSet = objUsers.GetNewUserDS()
'Initialize a datarow object from the User DataSet
Dim objDataRow As Data.DataRow = _
objDataSet.Tables("User").NewRow
'Set the values in the DataRow
objDataRow.Item("UserID") = Guid.NewGuid
objDataRow.Item("LoginName") = txtLogin.Text
objDataRow.Item("Password") = txtPassword.Text
objDataRow.Item("FirstName") = txtFirstName.Text
objDataRow.Item("LastName") = txtLastName.Text
objDataRow.Item("Email") = txtEmail.Text
objDataRow.Item("Phone") = txtPhone.Text
objDataRow.Item("Status") = optStatusActive.Checked
objDataRow.Item("GroupID") = _
cboUserGroup.SelectedItem.Item("GroupID")
objDataRow.Item("RoleID") = _
cboUserRole.SelectedItem.Item("RoleID")
If cboUserManager.SelectedIndex <> -1 Then
objDataRow.Item("ManagerID") = _
cboUserManager.SelectedItem.item("ManagerID")
End If
'Add the DataRow to the DataSet
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -