以文本方式查看主题 - Foxtable(狐表) (http://foxtable.net/bbs/index.asp) -- 专家坐堂 (http://foxtable.net/bbs/list.asp?boardid=2) ---- 单选项及多选目录树保存问题 (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=177959) |
-- 作者:采菊东篱下 -- 发布时间:2022/6/12 13:39:00 -- 单选项及多选目录树保存问题 此主题相关图片如下: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编辑过]
|
-- 作者:有点蓝 -- 发布时间:2022/6/12 21:03:00 -- 调试 Dim nd2 As WinForm.TreeNode = trv2.SelectedNode msgbox(nd2.Level) msgbox(nd2.Name ) msgbox(nd2.text) If nd2.Level = 2 Then Dim di As DataRow = DataTables("软件用户列表").SQLFind("[姓名] = \'" & nd2.Name & "\' And ([锁定] Is Null or [锁定] = false)") msgbox(nd2 IsNot Nothing) If di IsNot Nothing Then Dim rdo As WinForm.RadioButton |
-- 作者:采菊东篱下 -- 发布时间:2022/6/12 21:11:00 -- 弹出的提示分别是2、黄五、黄五、Ture |
-- 作者:采菊东篱下 -- 发布时间: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编辑过]
|
-- 作者:有点蓝 -- 发布时间:2022/6/12 22:02:00 -- 还学不会调试? For Each nd1 As WinForm.TreeNode In e.Form.Controls("TreeView1").AllNodes msgbox(nd1.Name) If nd1.Name = "版块管理" OrElse nd1.Name = "权限分配" Then msgbox(1) Continue For msgbox(2)这一句永远不会执行,想想为什么:http://www.foxtable.com/webhelp/topics/0226.htm |
-- 作者:采菊东篱下 -- 发布时间: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编辑过]
|
-- 作者:有点蓝 -- 发布时间:2022/6/13 8:30:00 -- 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)") msgbox(das.count) For Each da As DataRow In das If da IsNot Nothing Then For Each c1 As DataCol In DataTables("授权表").DataCols msgbox(c1.Name) If c1.Name = "所属部门" OrElse c1.Name = "职位" OrElse c1.Name = "用户姓名" OrElse c1.Name = "版块管理" OrElse c1.Name = "表名" OrElse c1.Name = "权限分配" OrElse c1.Name = "锁定" Then msgbox("Continue ") Continue For ElseIf nd1.Name = c1.Name And nd1.Checked = True Then msgbox("c1=true") da(c1) = True ElseIf nd1.Name = c1.Name And nd1.Checked = False Then msgbox("c1=False") da(c1) = False End If Next End If Next DataTables("授权表").SQLUpdate(das) Next DataTables("授权表").load End If
|
-- 作者:采菊东篱下 -- 发布时间: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编辑过]
|
-- 作者:有点蓝 -- 发布时间:2022/6/13 20:36: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 \'上面这几列无需打勾,故跳过执行 else For Each nd1 As WinForm.TreeNode In e.Form.Controls("TreeView1").AllNodes If nd1.Level = 2 Then |
-- 作者:采菊东篱下 -- 发布时间: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
|