Imports DevExpress.XtraBars Imports DevExpress.XtraEditors.Controls Imports DevExpress.XtraEditors.Repository Imports DevExpress.XtraGrid.Columns Imports DigitalData.GUIs.ZooFlow.ClassConstants Public Class frmTreeViewNavi Dim RightAddActive As Boolean = False Dim FormShown As Boolean = False Dim oSelectedNodeID As Integer = 0 Private Sub frmTreeViewNavi_Load(sender As Object, e As EventArgs) Handles Me.Load Try Dim oSQL = "select SN_ID ChildID,SN_PARENT_ID ParentID,TERM_VALUE as CAPTION from VWIDB_STRUCTURE_NODES_STRUCTURE" Dim oDT As DataTable = My.DatabaseIDB.GetDatatable(oSQL) TreeList2.Nodes.Clear() TreeList2.KeyFieldName = oDT.Columns(0).ColumnName TreeList2.ParentFieldName = oDT.Columns(1).ColumnName TreeList2.DataSource = oDT If My.Application.Modules.Item(MODULE_ZOOFLOW).IsAdmin Then RibbonPageGroup2.Visible = True Else RibbonPageGroup2.Visible = False End If Catch ex As Exception End Try End Sub Private Sub TreeList2_GetStateImage(sender As Object, e As DevExpress.XtraTreeList.GetStateImageEventArgs) Handles TreeList2.GetStateImage If e.Node.Expanded Then e.NodeImageIndex = 1 Else e.NodeImageIndex = 0 End If End Sub Private Sub TreeList2_SelectionChanged(sender As Object, e As EventArgs) Handles TreeList2.SelectionChanged Try Dim KeyValue As Object KeyValue = TreeList2.FocusedNode(TreeList2.KeyFieldName) Console.WriteLine($"keyfield: {KeyValue.ToString}") If IsNumeric(KeyValue) And RightAddActive Then oSelectedNodeID = KeyValue Refresh_Relations() If XtraTabControlRelationScope.SelectedTabPageIndex = 0 Then Refresh_FreeUsers() End If End If Catch ex As Exception End Try End Sub Private Sub BarCheckItemAdminFolderRights_CheckedChanged(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles BarCheckItemAdminFolderRights.CheckedChanged Dim oitm As BarCheckItem = e.Item RightAddActive = oitm.Checked SplitContainerControl1.Collapsed = Not RightAddActive End Sub Private Sub Refresh_FreeUsers() Try Dim oSQL = $"SELECT GUID as USR_ID, EMAIL FROM DD_ECM.dbo.TBDD_USER USR WHERE GUID NOT IN ( SELECT ScopeID FROM VWIDB_SN_RELATIONS WHERE SN_ID = {oSelectedNodeID}) AND USR.ACTIVE = 1 AND LEN(EMAIL) > 0" Dim oDT As DataTable = My.DatabaseIDB.GetDatatable(oSQL) If Not IsNothing(oDT) Then GridViewFreeUser.Columns.Clear() GridControlFreeUser.DataSource = oDT GridViewFreeUser.Columns("USR_ID").Visible = False End If Catch ex As Exception End Try End Sub Private Sub Refresh_Relations() Try Dim oSQL = $"SELECT * FROM VWIDB_SN_RELATIONS WHERE SN_ID = {oSelectedNodeID}" Dim oDT As DataTable = My.DatabaseIDB.GetDatatable(oSQL) If Not IsNothing(oDT) Then GridViewRelations.Columns.Clear() Dim columnStateIcon As New DataColumn() columnStateIcon.DataType = GetType(Image) columnStateIcon.ColumnName = "ICON" columnStateIcon.Caption = "" oDT.Columns.Add(columnStateIcon) GridControlRelations.DataSource = oDT GridViewRelations.Columns("REL_ID").Visible = False GridViewRelations.Columns("SN_ID").Visible = False GridViewRelations.Columns("Scope").Visible = False GridViewRelations.Columns("NODE_CAPTION").Visible = False GridViewRelations.Columns.Item("ICON").MaxWidth = 25 GridViewRelations.Columns.Item("ICON").MinWidth = 25 GridViewRelations.Columns.Item("ICON").AppearanceCell.BackColor = Color.White GridViewRelations.Columns.Item("ICON").Fixed = FixedStyle.Left If oDT.Rows.Count > 0 Then Dim oRowIndex As Integer = 0 For Each oRow As DataRow In oDT.Rows Try Dim oScope = oRow.Item("Scope") If IsNothing(oScope) Then Exit Sub End If Dim oImageIndex As Integer oImageIndex = 1 If oScope.ToString = "GRP" Then oImageIndex = 0 End If GridViewRelations.SetRowCellValue(oRowIndex, "ICON", ImageCollection1.Images(oImageIndex)) oRowIndex += 1 Catch ex As Exception End Try Next End If End If Catch ex As Exception End Try End Sub Private Sub frmTreeViewNavi_Shown(sender As Object, e As EventArgs) Handles MyBase.Shown FormShown = True SplitContainerControl1.Collapsed = True End Sub Private Sub BarButtonItem1_ItemClick(sender As Object, e As ItemClickEventArgs) Handles BarButtonItem1.ItemClick If XtraTabControlRelationScope.SelectedTabPageIndex = 0 Then Dim oInsert = $"INSERT INTO [dbo].[TBIDB_STRUCTURE_NODES_RELATIONS] ([SN_ID] ,[USR_ID] ,[ADDED_WHO]) VALUES ({BarButtonItem2.Tag},,,{My.Application.User.UserName})" End If End Sub Private Sub GridViewFreeUser_FocusedRowChanged(sender As Object, e As DevExpress.XtraGrid.Views.Base.FocusedRowChangedEventArgs) Handles GridViewFreeUser.FocusedRowChanged Dim oFocusedUSR = GridViewFreeUser.GetFocusedRowCellValue(GridViewFreeUser.Columns("USR_ID")) If Not IsNothing(oFocusedUSR) Then RibbonPageGroup3.Enabled = True BarButtonItem1.Enabled = True BarButtonItem2.Enabled = False BarButtonItem2.Tag = oFocusedUSR Else RibbonPageGroup3.Enabled = False End If End Sub Private Sub GridViewRelations_FocusedRowChanged(sender As Object, e As DevExpress.XtraGrid.Views.Base.FocusedRowChangedEventArgs) Handles GridViewRelations.FocusedRowChanged Dim oFocusedRELID = GridViewRelations.GetFocusedRowCellValue(GridViewRelations.Columns("REL_ID")) If Not IsNothing(oFocusedRELID) Then RibbonPageGroup3.Enabled = True BarButtonItem1.Enabled = False BarButtonItem2.Enabled = True BarButtonItem2.Tag = oFocusedRELID Else RibbonPageGroup3.Enabled = False End If End Sub End Class