以文本方式查看主题

-  Foxtable(狐表)  (http://www.foxtable.com/bbs/index.asp)
--  专家坐堂  (http://www.foxtable.com/bbs/list.asp?boardid=2)
----  目录树删除节点问题  (http://www.foxtable.com/bbs/dispbbs.asp?boardid=2&id=130229)

--  作者:deliangzhaoe
--  发布时间:2019/1/16 12:03:00
--  目录树删除节点问题
目录树由表A列1、2、3生成,列4、5、6未参与生成。
从目录树中删除节点时,弹出询问对话框,点击是,删除本节点,表A删除当前对应行,点击否,不删除节点,不删除对应行。但现在点击否时,节点未删除,但表A中对应行的列4或5的单元格内容已经被删除。这是怎么回事?
代码:
Dim tr As WinForm.TreeView = e.Form.Controls("TreeView2")
Dim nd As WinForm.TreeNode = tr.SelectedNode
If nd IsNot Nothing Then
    Dim pth() As String = nd.FullPath.Split("\\")
    Select Case nd.Level
        Case 0
            DataTables("组织机构和职责").DeleteFor("企业名称 = \'" & pth(0) & "\'")
        Case 1
            DataTables("组织机构和职责").DeleteFor("企业名称 = \'" & pth(0) & "\' And 部门设置 = \'" & pth(1) & "\'")
        Case 2
            DataTables("组织机构和职责").DeleteFor("企业名称 = \'" & pth(0) & "\' And 部门设置 = \'" & pth(1) & "\' And 岗位设置 = \'" & pth(2) & "\'")
        Case 3
            DataTables("组织机构和职责").DeleteFor("企业名称 = \'" & pth(0) & "\' And 部门设置 = \'" & pth(1) & "\' And 岗位设置 = \'" & pth(2) & "\' and 第四层机构设置 = \'" & pth(3) & "\'")
        Case 4
            DataTables("组织机构和职责").DeleteFor("企业名称 = \'" & pth(0) & "\' And 部门设置 = \'" & pth(1) & "\' And 岗位设置 = \'" & pth(2) & "\' and 第四层机构设置 = \'" & pth(3) & "\' and 第五层机构设置 = \'" & pth(4) & "\'")
        Case 5
            DataTables("组织机构和职责").DeleteFor("企业名称 = \'" & pth(0) & "\' And 部门设置 = \'" & pth(1) & "\' And 岗位设置 = \'" & pth(2) & "\' and 第四层机构设置 = \'" & pth(3) & "\' and 第五层机构设置 = \'" & pth(4) & "\' and 第六层机构设置 = \'" & pth(5) & "\'")
    End Select
    Dim Result As DialogResult
    Result = MessageBox.Show("    如果删除选定的组织机构,将导致本机构的安全职责及责任制考核标准同时被删除.  您确定要删除当前节点吗?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question)
    If Result = DialogResult.Yes Then
        nd.Delete()
    Else
    End If
End If
tr.Select()

请帮忙改一下代码。谢谢

--  作者:有点甜
--  发布时间:2019/1/16 12:25:00
--  
Dim tr As WinForm.TreeView = e.Form.Controls("TreeView2")
Dim nd As WinForm.TreeNode = tr.SelectedNode
If nd IsNot Nothing Then
    Dim Result As DialogResult
    Result = MessageBox.Show("    如果删除选定的组织机构,将导致本机构的安全职责及责任制考核标准同时被删除.  您确定要删除当前节点吗?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question)
    If Result = DialogResult.Yes Then
        Dim pth() As String = nd.FullPath.Split("\\")
        Select Case nd.Level
            Case 0
                DataTables("组织机构和职责").DeleteFor("企业名称 = \'" & pth(0) & "\'")
            Case 1
                DataTables("组织机构和职责").DeleteFor("企业名称 = \'" & pth(0) & "\' And 部门设置 = \'" & pth(1) & "\'")
            Case 2
                DataTables("组织机构和职责").DeleteFor("企业名称 = \'" & pth(0) & "\' And 部门设置 = \'" & pth(1) & "\' And 岗位设置 = \'" & pth(2) & "\'")
            Case 3
                DataTables("组织机构和职责").DeleteFor("企业名称 = \'" & pth(0) & "\' And 部门设置 = \'" & pth(1) & "\' And 岗位设置 = \'" & pth(2) & "\' and 第四层机构设置 = \'" & pth(3) & "\'")
            Case 4
                DataTables("组织机构和职责").DeleteFor("企业名称 = \'" & pth(0) & "\' And 部门设置 = \'" & pth(1) & "\' And 岗位设置 = \'" & pth(2) & "\' and 第四层机构设置 = \'" & pth(3) & "\' and 第五层机构设置 = \'" & pth(4) & "\'")
            Case 5
                DataTables("组织机构和职责").DeleteFor("企业名称 = \'" & pth(0) & "\' And 部门设置 = \'" & pth(1) & "\' And 岗位设置 = \'" & pth(2) & "\' and 第四层机构设置 = \'" & pth(3) & "\' and 第五层机构设置 = \'" & pth(4) & "\' and 第六层机构设置 = \'" & pth(5) & "\'")
        End Select
        nd.Delete()
    Else
    End If
End If
tr.Select()

--  作者:deliangzhaoe
--  发布时间:2019/1/16 18:04:00
--  
谢谢,明白了