改代码
If e.node.Level = 0 Then
e.node.Expand
ElseIf e.node.Level =1 Then
Dim bmm As String = e.node.Name.Split("+")(0)
DataTables("授权表").LoadFilter = "用户组='" & e.node.ParentNode.Name & "' and bm ='" & bmm & "'"
DataTables("授权表").Load()
Dim zd As new Dictionary(of String,String)
zd.Clear
Dim ms As Integer = 0
For Each dr As DataRow In DataTables("授权表").dataRows
If zd.ContainsKey(dr("lm"))=False Then
zd.Add(dr("lm"),"1")
End If
If dr.IsNull("lm")=True Then
ms +=1
End If
Next
If ms=0 Then
Dim rw As DataRow = DataTables("授权表").AddNew
rw("用户组") = e.node.ParentNode.Name
rw("bm") = bmm
rw.Save
End If
Dim ss As new List(of String)
For Each cl As Col In Tables(bmm).Cols
If zd.ContainsKey(cl.Name)=False Then
If Connections.Count=0 Then
Dim rw As DataRow = DataTables("授权表").AddNew
rw("用户组") = e.node.ParentNode.Name
rw("bm") = bmm
rw("lm") = cl.Name
Else
ss.Add("('" & e.node.ParentNode.Name & "','" & bmm & "','" & cl.name & "',0,0)")
zd.Add(cl.Name,"1")
End If
End If
Next
Dim cmd As new SQLCommand
cmd.C
For Each s As String In ss
cmd.CommandText = "Insert Into 授权表 (用户组,bm,lm,不可见,不可编辑) Values " & s
cmd.ExecuteScalar
Next
DataTables("授权表").LoadFilter = "用户组='" & e.node.ParentNode.Name & "' and bm ='" & bmm & "'"
DataTables("授权表").Load()
For Each cl As Col In Tables(bmm).Cols
Dim lmm As String = IIF(cl.Caption > "" ,cl.Caption,cl.Name)
Dim bm2 As String = IIF(DataTables(bmm).Caption > "" ,DataTables(bmm).Caption,bmm)
DataTables("授权表").ReplaceFor("列名",lmm,"lm='" & cl.Name & "'")
DataTables("授权表").ReplaceFor("表名",bm2,"bm='" & bmm & "'")
Next
DataTables("授权表").AcceptChanges()
End If