📄 admin.vb
字号:
cboUserManager.SelectedIndex = -1
txtUserUpdateDate.Text = String.Empty
'Reload the Users list
LoadUsers()
End Select
'Display a message that the record was added
ToolStripStatus.Text = "Record Added"
Catch ExceptionErr As Exception
MessageBox.Show(ExceptionErr.Message, strAppTitle)
End Try
End Sub
Private Sub ActionUpdate()
Try
'Update 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") = New Guid(txtProjectID.Text)
objDataRow.Item("ProjectName") = txtProjectName.Text
objDataRow.Item("ProjectDescription") = _
txtProjectDescription.Text
objDataRow.Item("SequenceNumber") = _
CType(txtSequenceNumber.Text, Integer)
'Add the DataRow to the DataSet
objDataSet.Tables("Project").Rows.Add(objDataRow)
'Update the Project in the database
If Not objProjects.UpdateProject(objDataSet) Then
Throw New Exception("Update Project Failed")
End If
End Using
'Clear the input fields
txtProjectID.Text = String.Empty
txtProjectName.Text = String.Empty
txtProjectDescription.Text = String.Empty
txtSequenceNumber.Text = String.Empty
txtProjectUpdateDate.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") = New Guid(txtGroupID.Text)
objDataRow.Item("GroupName") = txtGroupName.Text
objDataRow.Item("GroupDescription") = _
txtGroupDescription.Text
'Add the DataRow to the DataSet
objDataSet.Tables("Group").Rows.Add(objDataRow)
'Add the Group to the database
If Not objGroups.UpdateGroup(objDataSet) Then
Throw New Exception("Update Group Failed")
End If
End Using
'Clear the input fields
txtGroupID.Text = String.Empty
txtGroupName.Text = String.Empty
txtGroupDescription.Text = String.Empty
txtGroupUpdateDate.Text = String.Empty
'Reload the Groups list
LoadGroups()
Case "Group Projects"
'Turn the loading flag on so no items are processed
blnLoading = True
Call ActionAdd()
Case "Roles"
Case "Users"
End Select
'Display a message that the record was update
ToolStripStatus.Text = "Record Updated"
Catch ExceptionErr As Exception
MessageBox.Show(ExceptionErr.Message, strAppTitle)
End Try
End Sub
Private Sub ActionDelete()
Try
'Delete 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)
'Delete the project
If Not objProjects.DeleteProject( _
New Guid(txtProjectID.Text)) Then
Throw New Exception("Delete Project Failed")
End If
End Using
'Clear the input fields
txtProjectID.Text = String.Empty
txtProjectName.Text = String.Empty
txtProjectDescription.Text = String.Empty
txtSequenceNumber.Text = String.Empty
txtProjectUpdateDate.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)
'Delete the group
If Not objGroups.DeleteGroup( _
New Guid(txtGroupID.Text)) Then
Throw New Exception("Delete Group Failed")
End If
End Using
'Clear the input fields
txtGroupID.Text = String.Empty
txtGroupName.Text = String.Empty
txtGroupDescription.Text = String.Empty
txtGroupUpdateDate.Text = String.Empty
'Reload the Groups list
LoadGroups()
Case "Group Projects"
'Initialize a new instance of the business logic component
Using objGroups As New WroxBusinessLogic.WBLGroups( _
strCompany, strApplication)
'Delete the group projects
objGroups.DeleteGroupProjects( _
New Guid( _
cboGroups.SelectedItem.Item("GroupID").ToString))
End Using
'Clear previous bindings
If Not blnLoading Then
lstGroupProjects.DataSource = Nothing
lstGroupProjects.DisplayMember = String.Empty
lstGroupProjects.ValueMember = String.Empty
lstGroupProjects.Items.Clear()
blnLoading = True
cboGroups.SelectedIndex = -1
blnLoading = False
End If
Case "Roles"
Case "Users"
End Select
'Display a message that the record was deleted
ToolStripStatus.Text = "Record Deleted"
Catch ExceptionErr As Exception
MessageBox.Show(ExceptionErr.Message, strAppTitle)
End Try
End Sub
#End Region
#Region " Projects Procedures "
Private Sub LoadProjects()
'Declare variables
Dim objListViewItem As ListViewItem
'Initialize a new instance of the business logic component
Using objProjects As New WroxBusinessLogic.WBLProjects( _
strCompany, strApplication)
Try
'Clear previous bindings
lstProjects.DataSource = Nothing
lstProjects.DisplayMember = String.Empty
lstProjects.ValueMember = String.Empty
'Get all projects in a DataSet object
objProjectsDS = objProjects.GetProjects()
'Clear previous list
lvwProjects.Items.Clear()
'Process all rows
For intIndex = 0 To objProjectsDS.Tables("Projects").Rows.Count - 1
'Create a new listview item
objListViewItem = New ListViewItem
'Add the data to the listview item
objListViewItem.Text = objProjectsDS.Tables( _
"Projects").Rows(intIndex).Item("ProjectName")
objListViewItem.Tag = objProjectsDS.Tables( _
"Projects").Rows(intIndex).Item("ProjectID")
'Add the sub items to the listview item
objListViewItem.SubItems.Add(objProjectsDS.Tables( _
"Projects").Rows(intIndex).Item("ProjectDescription"))
objListViewItem.SubItems.Add(objProjectsDS.Tables( _
"Projects").Rows(intIndex).Item("SequenceNumber"))
objListViewItem.SubItems.Add(Format(objProjectsDS.Tables( _
"Projects").Rows(intIndex).Item("LastUpdateDate"), "g"))
'Add the listview item to the listview control
lvwProjects.Items.Add(objListViewItem)
Next
'Rebind ListBox control
lstProjects.DataSource = objProjectsDS.Tables("Projects")
lstProjects.DisplayMember = "ProjectName"
lstProjects.ValueMember = "ProjectID"
Catch ExceptionErr As Exception
MessageBox.Show(ExceptionErr.Message, strAppTitle)
End Try
End Using
'Cleanup
objListViewItem = Nothing
End Sub
Private Sub lvwProjects_Click(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles lvwProjects.Click
'Initialize a new instance of the business logic component
Using objProjects As New WroxBusinessLogic.WBLProjects( _
strCompany, strApplication)
Try
'Get the specific project selected in the ListView control
objDataSet = objProjects.GetProject( _
New Guid(lvwProjects.SelectedItems.Item(0).Tag.ToString))
'Populate the Project Details section
txtProjectID.Text = _
objDataSet.Tables("Project").Rows(0).Item( _
"ProjectID").ToString.ToUpper
txtProjectName.Text = _
objDataSet.Tables("Project").Rows(0).Item("ProjectName")
txtProjectDescription.Text = _
objDataSet.Tables("Project").Rows(0).Item( _
"ProjectDescription")
txtSequenceNumber.Text = _
objDataSet.Tables("Project").Rows(0).Item("SequenceNumber")
txtProjectUpdateDate.Text = _
objDataSet.Tables("Project").Rows(0).Item("LastUpdateDate")
Catch ExceptionErr As Exception
MessageBox.Show(ExceptionErr.Message, strAppTitle)
End Try
End Using
End Sub
Private Sub lstProjects_MouseDown(ByVal sender As Object, _
ByVal e As System.Windows.Forms.MouseEventArgs) _
Handles lstProjects.MouseDown
If e.Button = MouseButtons.Left Then
lstProjects.DoDragDrop(objProjectsDS.Tables("Projects").Rows( _
lstProjects.SelectedIndex)("ProjectID").ToString, _
DragDropEffects.Copy)
End If
End Sub
Private Sub lstGroupProjects_DragEnter(ByVal sender As Object, _
ByVal e As System.Windows.Forms.DragEventArgs) _
Handles lstGroupProjects.DragEnter
'Exit if nothing has been selected in the cboGroups ComboBox
If cboGroups.SelectedIndex = -1 Then
Exit Sub
End If
'Now ensure that the drag content is the correct type for this control
If (e.Data.GetDataPresent(DataFormats.Text)) Then
'If the item does not already exist then allow the copy
Dim objDataView As Data.DataView = New _
Data.DataView(objGroupProjectsDS.Tables("GroupProjects"))
objDataView.Sort = "ProjectID"
intIndex = objDataView.Find(e.Data.GetData(DataFormats.Text))
If intIndex = -1 Then
e.Effect = DragDropEffects.Copy
Else
e.Effect = DragDropEffects.None
End If
Else
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -