Foxtable(狐表)用户栏目专家坐堂 → 单选项及多选目录树保存问题


  共有5183人关注过本帖树形打印复制链接

主题:单选项及多选目录树保存问题

美女呀,离线,留言给我吧!
采菊东篱下
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:八尾狐 帖子:1881 积分:10368 威望:0 精华:0 注册:2019/4/6 8:45:00
单选项及多选目录树保存问题  发帖心情 Post By:2022/6/12 13:39:00 [显示全部帖子]


图片点击可在新窗口打开查看此主题相关图片如下:qq图片20220612130225.png
图片点击可在新窗口打开查看

图片点击可在新窗口打开查看此主题相关图片如下:qq图片20220612130259.png
图片点击可在新窗口打开查看

图片点击可在新窗口打开查看此主题相关图片如下:qq图片20220612132247.png
图片点击可在新窗口打开查看

点选左边的
TreeView2二级目录树的姓名,再点选中间的单选控件,另勾选右边的TreeView1多选目录树,按保存按钮,希望软件用户列表姓名等于点选的TreeView2二级目录树姓名且此行未被锁定授权权限列保存为Tuse,同时勾选授权表姓名等于点选的TreeView2二级目录树姓名及对应列名等于勾选的TreeView1子目录树名称,我这样写不报错,但没显示勾选的勾。
选看红色这段代码吧,软件用户列表授权权限列没显示勾。
Dim trv1 As WinForm.TreeView = e.Form.Controls("TreeView1")
Dim trv2 As WinForm.TreeView = e.Form.Controls("TreeView2")
Dim nd2 As WinForm.TreeNode = trv2.SelectedNode
If nd2.Level = 2 Then
    Dim di As DataRow = DataTables("软件用户列表").SQLFind("[姓名] = '" & nd2.Name & "' And ([锁定] Is Null or [锁定] = false)")
    If di IsNot Nothing Then
        Dim rdo As WinForm.RadioButton
        rdo = e.Form.Controls("RadioButton1")
        If rdo.Checked = True Then
            di("授权权限") = True
        Else
            di("授权权限") = False
        End If
    End If
    di.Save()
    For Each nd1 As WinForm.TreeNode In e.Form.Controls("TreeView1").AllNodes
        If nd1.Name = "版块管理" OrElse nd1.Name = "权限分配" Then
            Continue For
            Dim das As List(Of DataRow) = DataTables("授权表").SQLSelect("[用户姓名] = '" & nd2.Name & "' And [版块管理] = '" & nd1.Name & "' And [权限分配] = '" & nd1.Name & "' And ([锁定] Is Null Or [锁定] = false)")
            For Each da As DataRow In das
                For Each c1 As DataCol In DataTables("授权表").DataCols
                    If c1.Name = "所属部门" OrElse c1.Name = "职位" OrElse c1.Name = "用户姓名" OrElse c1.Name = "版块管理" OrElse c1.Name = "表名" OrElse c1.Name = "权限分配" OrElse c1.Name = "锁定" Then
                        Continue For
                    ElseIf nd1.Name = c1.Name And nd1.Checked = True Then
                        da(c1) = True
                    ElseIf nd1.Name = c1.Name And nd1.Checked = False Then 
                        da(c1) = False
                    End If
                Next
            Next
            DataTables("授权表").SQLUpdate(das)
            DataTables("授权表").load
        End If
    Next
End If
[此贴子已经被作者于2022/6/12 21:04:12编辑过]

 回到顶部
美女呀,离线,留言给我吧!
采菊东篱下
  2楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:八尾狐 帖子:1881 积分:10368 威望:0 精华:0 注册:2019/4/6 8:45:00
  发帖心情 Post By:2022/6/12 21:11:00 [显示全部帖子]

弹出的提示分别是2、黄五、黄五、Ture

 回到顶部
美女呀,离线,留言给我吧!
采菊东篱下
  3楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:八尾狐 帖子:1881 积分:10368 威望:0 精华:0 注册:2019/4/6 8:45:00
  发帖心情 Post By:2022/6/12 21:17:00 [显示全部帖子]

哦,加
DataTables("软件用户列表").load
重新加载软件用户列表看到效果了,不过,下面这段红色代码同样没看到授权表的勾选效果。
Dim trv1 As WinForm.TreeView = e.Form.Controls("TreeView1")
Dim trv2 As WinForm.TreeView = e.Form.Controls("TreeView2")
Dim nd2 As WinForm.TreeNode = trv2.SelectedNode
If nd2.Level = 2 Then
    Dim di As DataRow = DataTables("软件用户列表").SQLFind("[姓名] = '" & nd2.Name & "' And ([锁定] Is Null or [锁定] = false)")
    If di IsNot Nothing Then
        Dim rdo As WinForm.CheckBox
        rdo = e.Form.Controls("CheckBox1")
        If rdo.Checked = True Then
            di("授权权限") = True
        Else
            di("授权权限") = False
        End If
    End If
    di.Save()
    DataTables("软件用户列表").load
    For Each nd1 As WinForm.TreeNode In e.Form.Controls("TreeView1").AllNodes
        If nd1.Name = "版块管理" OrElse nd1.Name = "权限分配" Then
            Continue For
            Dim das As List(Of DataRow) = DataTables("授权表").SQLSelect("[用户姓名] = '" & nd2.Name & "' And [版块管理] = '" & nd1.Name & "' And [权限分配] = '" & nd1.Name & "' And ([锁定] Is Null Or [锁定] = false)")
            For Each da As DataRow In das
                If da IsNot Nothing Then
                    For Each c1 As DataCol In DataTables("授权表").DataCols
                        If c1.Name = "所属部门" OrElse c1.Name = "职位" OrElse c1.Name = "用户姓名" OrElse c1.Name = "版块管理" OrElse c1.Name = "表名" OrElse c1.Name = "权限分配" OrElse c1.Name = "锁定" Then
                            Continue For
                        ElseIf nd1.Name = c1.Name And nd1.Checked = True Then
                            da(c1) = True
                        ElseIf nd1.Name = c1.Name And nd1.Checked = False Then 
                            da(c1) = False
                        End If
                    Next
                End If
            Next
            DataTables("授权表").SQLUpdate(das)
            DataTables("授权表").load
        End If
    Next
End If
[此贴子已经被作者于2022/6/12 21:44:32编辑过]

 回到顶部
美女呀,离线,留言给我吧!
采菊东篱下
  4楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:八尾狐 帖子:1881 积分:10368 威望:0 精华:0 注册:2019/4/6 8:45:00
  发帖心情 Post By:2022/6/12 23:18:00 [显示全部帖子]

nd1和nd2都没问题的,显示是我要作为条件的名字,现改为红字的代码授权表依然不显示TreeView2目录树打勾的数据:

Dim trv1 As WinForm.TreeView = e.Form.Controls("TreeView1")
Dim trv2 As WinForm.TreeView = e.Form.Controls("TreeView2")
Dim nd2 As WinForm.TreeNode = trv2.SelectedNode
If nd2.Level = 2 Then
    Dim di As DataRow = DataTables("软件用户列表").SQLFind("[姓名] = '" & nd2.Name & "' And ([锁定] Is Null or [锁定] = false)")
    If di IsNot Nothing Then
        Dim rdo As WinForm.CheckBox
        rdo = e.Form.Controls("CheckBox1")
        If rdo.Checked = True Then
            di("授权权限") = True
        Else
            di("授权权限") = False
        End If
    End If
    di.Save()
    DataTables("软件用户列表").load
    For Each nd1 As WinForm.TreeNode In e.Form.Controls("TreeView1").AllNodes
        Dim das As List(Of DataRow) = DataTables("授权表").SQLSelect("[用户姓名] = '" & nd2.Name & "' And [版块管理] = '" & nd1.Name & "' And [权限分配] = '" & nd1.Name & "' And ([锁定] Is Null Or [锁定] = false)")
        For Each da As DataRow In das
            If da IsNot Nothing Then
                For Each c1 As DataCol In DataTables("授权表").DataCols
                    If c1.Name = "所属部门" OrElse c1.Name = "职位" OrElse c1.Name = "用户姓名" OrElse c1.Name = "版块管理" OrElse c1.Name = "表名" OrElse c1.Name = "权限分配" OrElse c1.Name = "锁定" Then
                        Continue For
                    ElseIf nd1.Name = c1.Name And nd1.Checked = True Then
                        da(c1) = True
                    ElseIf nd1.Name = c1.Name And nd1.Checked = False Then 
                        da(c1) = False
                    End If
                Next
            End If
        Next        
        DataTables("授权表").SQLUpdate(das)
        DataTables("授权表").load
    Next
End If
[此贴子已经被作者于2022/6/12 23:18:15编辑过]

 回到顶部
美女呀,离线,留言给我吧!
采菊东篱下
  5楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:八尾狐 帖子:1881 积分:10368 威望:0 精华:0 注册:2019/4/6 8:45:00
  发帖心情 Post By:2022/6/13 19:38:00 [显示全部帖子]

    For Each c1 As DataCol In DataTables("授权表").DataCols
        If c1.Name = "所属部门" OrElse c1.Name = "职位" OrElse c1.Name = "用户姓名" OrElse c1.Name = "版块管理" OrElse c1.Name = "表名" OrElse c1.Name = "权限分配" OrElse c1.Name = "锁定" Then
            Continue For '上面这几列无需打勾,故跳过执行
            For Each nd1 As WinForm.TreeNode In e.Form.Controls("TreeView1").AllNodes
                If nd1.Level = 2 Then                
                    Dim Value() As String
                    Value = nd1.FullPath.Split("\")
                    Dim das As List(Of DataRow) = DataTables("授权表").SQLSelect("[用户姓名] = '" & nd2.Name & "' And [版块管理] = '" & Value(0) & "' And [权限分配] = '" & Value(1) & "' And ([锁定] Is Null Or [锁定] = false)")
                    msgbox(das.count) '无数据显示,应该是Value(0) 和Value(1)有问题,这里提取第一、二层字节名称不是这样写吗? 
                    For Each da As DataRow In das
                        If da IsNot Nothing Then 
                            If nd1.Name = c1.Name And nd1.Checked = True Then
                                da(c1) = True
                            ElseIf nd1.Name = c1.Name And nd1.Checked = False Then 
                                da(c1) = False
                            End If
                        End If
                    Next
                    DataTables("授权表").SQLUpdate(das)
                    DataTables("授权表").load
                End If 
            Next
        End If 
[此贴子已经被作者于2022/6/13 20:03:08编辑过]

 回到顶部
美女呀,离线,留言给我吧!
采菊东篱下
  6楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:八尾狐 帖子:1881 积分:10368 威望:0 精华:0 注册:2019/4/6 8:45:00
  发帖心情 Post By:2022/6/13 20:58:00 [显示全部帖子]

完整代码:可以了,不过很卡,要等一会,能不能运行快点?
Dim trv1 As WinForm.TreeView = e.Form.Controls("TreeView1")
Dim trv2 As WinForm.TreeView = e.Form.Controls("TreeView2")
Dim nd2 As WinForm.TreeNode = trv2.SelectedNode
If nd2.Level = 2 Then
    Dim di As DataRow = DataTables("软件用户列表").SQLFind("[姓名] = '" & nd2.Name & "' And ([锁定] Is Null or [锁定] = false)")
    If di IsNot Nothing Then
        Dim rdo As WinForm.CheckBox
        rdo = e.Form.Controls("CheckBox1")
        If rdo.Checked = True Then
            di("授权权限") = True
        Else
            di("授权权限") = False
        End If
    End If
    di.Save()
    DataTables("软件用户列表").load
    For Each nd1 As WinForm.TreeNode In e.Form.Controls("TreeView1").AllNodes
        If nd1.Level = 2 Then                
            Dim Value() As String
            Value = nd1.FullPath.Split("\")
            Dim das As List(Of DataRow) = DataTables("授权表").SQLSelect("[用户姓名] = '" & nd2.Name & "' And [版块管理] = '" & Value(0) & "' And [权限分配] = '" & Value(1) & "' And ([锁定] Is Null Or [锁定] = false)")
            For Each da As DataRow In das
                If da IsNot Nothing Then
                    For Each c1 As DataCol In DataTables("授权表").DataCols
                        If c1.Name = "所属部门" OrElse c1.Name = "职位" OrElse c1.Name = "用户姓名" OrElse c1.Name = "版块管理" OrElse c1.Name = "表名" OrElse c1.Name = "权限分配" OrElse c1.Name = "锁定" Then
                            Continue For
                        ElseIf nd1.Name = c1.Name And nd1.Checked = True Then
                            da(c1) = True
                        ElseIf nd1.Name = c1.Name And nd1.Checked = False Then 
                            da(c1) = False
                        End If
                    Next
                End If
            Next
            DataTables("授权表").SQLUpdate(das)
            DataTables("授权表").load
        End If 
    Next
End If

 回到顶部
美女呀,离线,留言给我吧!
采菊东篱下
  7楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:八尾狐 帖子:1881 积分:10368 威望:0 精华:0 注册:2019/4/6 8:45:00
  发帖心情 Post By:2022/6/13 22:47:00 [显示全部帖子]

    帮助里的授权形式我是考虑过,现在的企业管理人员流动性很大,不能因为其离职了删除其曾有授权,因为许多数据已引用、结帐,不允许修改、删除,授权表中他的名字、授权只能锁定,因此帮助里的授权方法不行了,它不能锁定专门人。不同人有不同权限,授权是对独立人专定的,企业现用的授权形式也是根据人所在部门、职位、管理版块开设权限,因此帮助里的授权形式只能作编程方法学习,不能搬到应用软件,它不乎合企业的实际要求,所以授权表要用到后台数据,我是20多年的工业会计,用过很多软件,深知管理需要,软件应用,隔行如隔山,我不是专业编程员,才在编程方面这么多问题问你。 
    我上面的代码是保存目录树中勾选的数据,要先在授权表中查找与勾选目录树相乎的列,然后勾选或取消勾选。
[此贴子已经被作者于2022/6/13 23:11:53编辑过]

 回到顶部
美女呀,离线,留言给我吧!
采菊东篱下
  8楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:八尾狐 帖子:1881 积分:10368 威望:0 精华:0 注册:2019/4/6 8:45:00
  发帖心情 Post By:2022/6/13 22:49:00 [显示全部帖子]

改为这样授权表完全没反应:
Dim trv1 As WinForm.TreeView = e.Form.Controls("TreeView1")
Dim trv2 As WinForm.TreeView = e.Form.Controls("TreeView2")
Dim nd2 As WinForm.TreeNode = trv2.SelectedNode
If nd2.Level = 2 Then
    Dim di As DataRow = DataTables("软件用户列表").SQLFind("[姓名] = '" & nd2.Name & "' And ([锁定] Is Null or [锁定] = false)")
    If di IsNot Nothing Then
        Dim rdo As WinForm.CheckBox
        rdo = e.Form.Controls("CheckBox1")
        If rdo.Checked = True Then
            di("授权权限") = True
        Else
            di("授权权限") = False
        End If
    End If
    di.Save()
    DataTables("软件用户列表").load
    For Each nd1 As WinForm.TreeNode In e.Form.Controls("TreeView1").AllNodes
        If nd1.Level = 2 Then                
            Dim Value() As String
            Value = nd1.FullPath.Split("\")
            For Each c1 As DataCol In DataTables("授权表").DataCols
                If c1.Name = "所属部门" OrElse c1.Name = "职位" OrElse c1.Name = "用户姓名" OrElse c1.Name = "版块管理" OrElse c1.Name = "表名" OrElse c1.Name = "权限分配" OrElse c1.Name = "锁定" Then
                    Continue For
                    Dim das As List(Of DataRow) = DataTables("授权表").SQLSelect("[用户姓名] = '" & nd2.Name & "' And [版块管理] = '" & Value(0) & "' And [权限分配] = '" & Value(1) & "' And nd1.Name = c1.Name And nd1.Checked = True And ([锁定] Is Null Or [锁定] = false)")
                    For Each da As DataRow In das
                        If da IsNot Nothing Then
                            da(c1) = True
                        Else
                            da(c1) = False
                        End If
                    Next
                    DataTables("授权表").SQLUpdate(das)
                    DataTables("授权表").load
                End If
            Next
        End If 
    Next
End If

 回到顶部
美女呀,离线,留言给我吧!
采菊东篱下
  9楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:八尾狐 帖子:1881 积分:10368 威望:0 精华:0 注册:2019/4/6 8:45:00
  发帖心情 Post By:2022/6/13 23:39:00 [显示全部帖子]

    我是边做边想,边学的,一开始时你直接把代码写给我,说实在的,那时我对一些用法还没完全吃透,现在多做多想回头再看你以前写的代码,终于明白了,现在我可以根据自己的想法慢慢写些代码了,当然知识面那么广,有些错误是大意,有些错误真是自己没细想,很多时候调试技巧我是做过的,大约知道问题在哪,但找解决方法往往花了很多时间精力,不断反复回看视频教学,帮助,学习基本方法,不断加深理解,碰碰试试中学习吧,尽量多看多想,实在不行才问你。
[此贴子已经被作者于2022/6/13 23:43:09编辑过]

 回到顶部
美女呀,离线,留言给我吧!
采菊东篱下
  10楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:八尾狐 帖子:1881 积分:10368 威望:0 精华:0 注册:2019/4/6 8:45:00
  发帖心情 Post By:2022/6/14 0:50:00 [显示全部帖子]

改为这样,少一个循环了,还是慢。
Dim trv1 As WinForm.TreeView = e.Form.Controls("TreeView1")
Dim trv2 As WinForm.TreeView = e.Form.Controls("TreeView2")
Dim nd2 As WinForm.TreeNode = trv2.SelectedNode
If nd2.Level = 2 Then
    Dim di As DataRow = DataTables("软件用户列表").SQLFind("[姓名] = '" & nd2.Name & "' And ([锁定] Is Null or [锁定] = false)")
    If di IsNot Nothing Then
        Dim rdo As WinForm.CheckBox
        rdo = e.Form.Controls("CheckBox1")
        If rdo.Checked = True Then
            di("授权权限") = True
        Else
            di("授权权限") = False
        End If
    End If
    di.Save()
    DataTables("软件用户列表").load
    For Each nd1 As WinForm.TreeNode In e.Form.Controls("TreeView1").AllNodes
        If nd1.Level = 2 Then 
            Dim Value() As String
            Value = nd1.FullPath.Split("\")
            Dim da As DataRow = DataTables("授权表").SQLFind("[用户姓名] = '" & nd2.Name & "' And [版块管理] = '" & Value(0) & "' And [权限分配] = '" & Value(1) & "' And ([锁定] Is Null Or [锁定] = false)")
            If da IsNot Nothing Then
                For Each c1 As DataCol In DataTables("授权表").DataCols
                    If c1.Name = "所属部门" OrElse c1.Name = "职位" OrElse c1.Name = "用户姓名" OrElse c1.Name = "版块管理" OrElse c1.Name = "表名" OrElse c1.Name = "权限分配" OrElse c1.Name = "锁定" Then
                        Continue For
                    ElseIf nd1.Name = c1.Name And nd1.Checked = True Then
                        da(c1) = True
                    ElseIf nd1.Name = c1.Name And nd1.Checked = False Then 
                        da(c1) = False
                    End If
                Next
            End If
            da.Save()
            DataTables("授权表").load
        End If 
    Next
End If

 回到顶部
总数 13 1 2 下一页