You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
226 lines
9.7 KiB
226 lines
9.7 KiB
Imports System
|
|
Imports System.Data
|
|
Imports System.Data.SqlTypes
|
|
Imports System.Data.SqlClient
|
|
|
|
Namespace edokadb
|
|
|
|
Public Class clsMySysadminfunkion
|
|
Inherits edokadb.clsSysadminfunktion
|
|
|
|
Public treedata_for_search As New DataTable
|
|
Dim FoundNode As Integer = 0
|
|
Dim Searchstring As String = ""
|
|
Public Treesearch As New TreeView
|
|
|
|
#Region "Select Hierarchy"
|
|
Public Function SelectHierarchy() As DataTable
|
|
Dim scmCmdToExecute As SqlCommand = New SqlCommand()
|
|
'scmCmdToExecute.CommandText = "dbo.[sp_sysadminfunktion_hierarchie]"
|
|
scmCmdToExecute.CommandText = "dbo.[sp_get_sysadmin_tree]"
|
|
scmCmdToExecute.CommandType = CommandType.StoredProcedure
|
|
Dim dtToReturn As DataTable = New DataTable("sysadminfunktion")
|
|
Dim sdaAdapter As SqlDataAdapter = New SqlDataAdapter(scmCmdToExecute)
|
|
|
|
' // Use base class' connection object
|
|
scmCmdToExecute.Connection = m_scoMainConnection
|
|
|
|
Try
|
|
scmCmdToExecute.Parameters.Add(New SqlParameter("@imitarbeiternr", SqlDbType.Int, 4, ParameterDirection.Input, True, 10, 0, "", DataRowVersion.Proposed, Globals.MitarbeiterNr))
|
|
scmCmdToExecute.Parameters.Add(New SqlParameter("@iroot", SqlDbType.Int, 4, ParameterDirection.Input, True, 10, 0, "", DataRowVersion.Proposed, 0))
|
|
scmCmdToExecute.Parameters.Add(New SqlParameter("@isprache", SqlDbType.Int, 4, ParameterDirection.Input, True, 10, 0, "", DataRowVersion.Proposed, Globals.Sprache))
|
|
scmCmdToExecute.Parameters.Add(New SqlParameter("@imandant", SqlDbType.Int, 4, ParameterDirection.Input, True, 10, 0, "", DataRowVersion.Proposed, Globals.MandantNr))
|
|
scmCmdToExecute.Parameters.Add(New SqlParameter("@iErrorCode", SqlDbType.Int, 4, ParameterDirection.Output, True, 10, 0, "", DataRowVersion.Proposed, m_iErrorCode))
|
|
|
|
If m_bMainConnectionIsCreatedLocal Then
|
|
' // Open connection.
|
|
m_scoMainConnection.Open()
|
|
Else
|
|
If m_cpMainConnectionProvider.bIsTransactionPending Then
|
|
scmCmdToExecute.Transaction = m_cpMainConnectionProvider.stCurrentTransaction
|
|
End If
|
|
End If
|
|
|
|
' // Execute query.
|
|
sdaAdapter.Fill(dtToReturn)
|
|
m_iErrorCode = New SqlInt32(CType(scmCmdToExecute.Parameters.Item("@iErrorCode").Value, SqlInt32))
|
|
|
|
If Not m_iErrorCode.Equals(New SqlInt32(LLBLError.AllOk)) Then
|
|
' // Throw error.
|
|
Throw New Exception("Stored Procedure 'pr_sysadminfunktion_SelectAll' reported the ErrorCode: " & m_iErrorCode.ToString())
|
|
End If
|
|
|
|
Return dtToReturn
|
|
Catch ex As Exception
|
|
' // some error occured. Bubble it to caller and encapsulate Exception object
|
|
Throw New Exception("clsSysadminfunktion::SelectAll::Error occured." + ex.Message, ex)
|
|
Finally
|
|
If m_bMainConnectionIsCreatedLocal Then
|
|
' // Close connection.
|
|
m_scoMainConnection.Close()
|
|
End If
|
|
scmCmdToExecute.Dispose()
|
|
sdaAdapter.Dispose()
|
|
End Try
|
|
End Function
|
|
|
|
Public Function Check_for_MenuEntries() As Boolean
|
|
Dim tmpdata As New DataTable
|
|
tmpdata = Me.SelectHierarchy
|
|
If tmpdata.Rows.Count > 0 Then Return True Else Return False
|
|
tmpdata.Dispose()
|
|
End Function
|
|
|
|
#End Region
|
|
|
|
#Region "LoadTreeMenu"
|
|
Public Sub LoadTreeMenu(ByVal otv As TreeView)
|
|
Dim menueintraege As New clsMySysadminfunkion()
|
|
Dim menudata As DataTable
|
|
Dim i As Integer
|
|
Dim m_collDeletedNodes As Collection
|
|
Dim collNodeKeys As New Collection()
|
|
Dim tnNew As TreeNode
|
|
Dim tnParent As TreeNode
|
|
|
|
m_collDeletedNodes = Nothing
|
|
m_collDeletedNodes = New Collection()
|
|
|
|
menueintraege.cpMainConnectionProvider = conn
|
|
menudata = menueintraege.SelectHierarchy
|
|
|
|
For i = 0 To menudata.Rows.Count - 1
|
|
If menudata.Rows(i).Item("ParentID") = 0 Then
|
|
tnNew = otv.Nodes.Add(menudata.Rows(i).Item("bezeichnung"))
|
|
With tnNew
|
|
.Tag() = menudata.Rows(i).Item("sysadminfnktnr")
|
|
.ImageIndex() = menudata.Rows(i).Item("ImageIndex")
|
|
.SelectedImageIndex() = menudata.Rows(i).Item("ImageIndexOpen")
|
|
End With
|
|
Try
|
|
collNodeKeys.Add(tnNew, CType(menudata.Rows(i).Item("sysadminfnktnr"), String))
|
|
Catch ex As Exception
|
|
MsgBox(ex.Message, MsgBoxStyle.Critical)
|
|
End Try
|
|
Else
|
|
Try
|
|
tnParent = CType(collNodeKeys.Item(CType(menudata.Rows(i).Item("ParentID"), String)), TreeNode)
|
|
tnNew = tnParent.Nodes.Add(CType(menudata.Rows(i).Item("bezeichnung"), String))
|
|
With tnNew
|
|
.Tag() = CType(menudata.Rows(i).Item("sysadminfnktnr"), String)
|
|
.ImageIndex() = menudata.Rows(i).Item("ImageIndex")
|
|
.SelectedImageIndex() = menudata.Rows(i).Item("ImageIndexOpen")
|
|
End With
|
|
collNodeKeys.Add(tnNew, CType(menudata.Rows(i).Item("sysadminfnktnr"), String))
|
|
Catch ex As Exception
|
|
MsgBox(ex.Message, MsgBoxStyle.Critical)
|
|
End Try
|
|
End If
|
|
|
|
If treedata_for_search.Rows.Count < 1 Then
|
|
For Each c As DataColumn In menudata.Columns
|
|
If c.ColumnName = "ErweiterteSuche" Then
|
|
Dim dc As New DataColumn
|
|
dc.ColumnName = "ErweiterteSuche"
|
|
dc.DataType = System.Type.GetType("System.String")
|
|
dc.DefaultValue = " "
|
|
Me.treedata_for_search.Columns.Add(dc)
|
|
Else
|
|
Me.treedata_for_search.Columns.Add(c.ColumnName)
|
|
End If
|
|
Next
|
|
End If
|
|
For Each row As DataRow In menudata.Rows
|
|
Me.treedata_for_search.ImportRow(row)
|
|
Next
|
|
Next
|
|
End Sub
|
|
|
|
#End Region
|
|
|
|
|
|
|
|
#Region "Suche"
|
|
Public Function Init_Search()
|
|
FoundNode = 0
|
|
Searchstring = ""
|
|
Me.Treesearch.Nodes.Clear()
|
|
End Function
|
|
|
|
Public Function SearchNode(ByRef tree As TreeView, ByVal SearchString As String) As TreeNode
|
|
Me.Treesearch.Nodes.Clear()
|
|
For Each dr As DataRow In treedata_for_search.Rows
|
|
If InStr(UCase(dr.Item("Bezeichnung")), UCase(SearchString)) > 0 Then
|
|
Dim tn As New TreeNode
|
|
tn = Me.Treesearch.Nodes.Add(dr.Item("Bezeichnung"))
|
|
tn.Tag = dr.Item("sysadminfnktnr")
|
|
End If
|
|
Next
|
|
Return FindFirst(tree)
|
|
End Function
|
|
|
|
Public Function FindFirst(ByRef Tree As TreeView) As TreeNode
|
|
Try
|
|
If Me.Treesearch.Nodes.Count > 0 Then Me.Treesearch.SelectedNode = Me.Treesearch.Nodes(0)
|
|
Return FindNode(Tree.Nodes, Treesearch.SelectedNode.Tag, "")
|
|
Catch
|
|
End Try
|
|
End Function
|
|
|
|
|
|
|
|
Public Function FindNextNode(ByRef tree As TreeView) As TreeNode
|
|
Try
|
|
Treesearch.SelectedNode = Treesearch.SelectedNode.NextNode
|
|
If Treesearch.SelectedNode Is Nothing Then
|
|
Return FindFirst(tree)
|
|
End If
|
|
Return Me.FindNode(tree.Nodes, Treesearch.SelectedNode.Tag, "")
|
|
Catch ex As Exception
|
|
|
|
End Try
|
|
End Function
|
|
|
|
Public Function FindPrevNode(ByRef tree As TreeView) As TreeNode
|
|
Try
|
|
Treesearch.SelectedNode = Treesearch.SelectedNode.PrevNode
|
|
If Treesearch.SelectedNode Is Nothing Then
|
|
Return FindLastNode(tree)
|
|
End If
|
|
Return Me.FindNode(tree.Nodes, Treesearch.SelectedNode.Tag, "")
|
|
Catch ex As Exception
|
|
End Try
|
|
End Function
|
|
|
|
Public Function FindLastNode(ByRef tree As TreeView) As TreeNode
|
|
Try
|
|
Treesearch.SelectedNode = Treesearch.Nodes(Treesearch.Nodes.Count - 1)
|
|
Return Me.FindNode(tree.Nodes, Treesearch.SelectedNode.Tag, "")
|
|
Catch ex As Exception
|
|
End Try
|
|
|
|
End Function
|
|
|
|
Public Function FindNode(ByVal _nodeCollection As TreeNodeCollection, ByVal SearchVal As Integer, ByVal SearchString As String) As TreeNode
|
|
Dim tmpNode As TreeNode
|
|
For Each _child As TreeNode In _nodeCollection
|
|
If _child.Tag = SearchVal Then
|
|
|
|
Return _child
|
|
End If
|
|
' If InStr(UCase(_child.Text), UCase(SearchString)) > 0 Then
|
|
' Return _child
|
|
' End If
|
|
tmpNode = FindNode(_child.Nodes, SearchVal, SearchString)
|
|
If Not tmpNode Is Nothing Then
|
|
Return tmpNode
|
|
End If
|
|
Next
|
|
Return Nothing
|
|
End Function
|
|
#End Region
|
|
|
|
|
|
End Class
|
|
End Namespace
|