以文本方式查看主题

-  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=60484)

--  作者:yyzlxc
--  发布时间:2014/11/25 17:50:00
--  [求助]目录树代码问题(已解决)

一段代码将获取的值写入目录树,出现错误提示,如何修改,请各位老师指教,谢谢。


Dim n0 As Integer = DataTables("工票信息").GetValues("作业ID").Count
Dim n1 As Integer = DataTables("工票信息").Compute("Count(工票ID)") \'工票数
Dim n2 As Integer = DataTables("工票信息").Compute("Count(工票编号)","Len(工票ID) = 8") \'绑定数
Dim n3 As Integer = DataTables("工票信息").Compute("Count(工票编号)","Right(工票ID,3) = \'已回收\'") \'回收数
trv.Nodes.Insert("作业计划合计("& n0 &"/"& n1 &"/"& n2 &"/"& n3 &")",0)

在窗口的AfterLoad事件中已将黄色部分的代码屏蔽掉了,按“刷新”按钮可以重现错误提示。


图片点击可在新窗口打开查看此主题相关图片如下:捕获0.jpg
图片点击可在新窗口打开查看


 下载信息  [文件大小:   下载次数: ]
图片点击可在新窗口打开查看点击浏览该文件:管理项目8.foxdb



另外,在作业计划合计节点显示的工票状态统计数据,是否可以在其他节点显示?如何实现,也请各位老师赐教,谢谢!!


[此贴子已经被作者于2014-11-25 20:39:33编辑过]

--  作者:有点甜
--  发布时间:2014/11/25 17:51:00
--  

 

[此贴子已经被作者于2014-11-25 17:52:58编辑过]

--  作者:有点甜
--  发布时间:2014/11/25 18:02:00
--  
Dim n3 As Integer = DataTables("工票信息").Compute("Count(工票编号)","iif(len(工票ID) > 3, Substring(工票ID, Len(工票ID)-2, 3) = \'已回收\', false)") \'回收数
--  作者:yyzlxc
--  发布时间:2014/11/25 18:33:00
--  
谢谢甜老师的指教,受甜老师的启发,用判断字节大于8位为已回收数,可以简化代码,谢谢甜老师。

Dim n3 As Integer = DataTables("工票信息").Compute("Count(工票编号)","len(工票ID) > 8") \'回收数

另外,能否在其他节点显示工票状态的统计数据,代码如何修改,请赐教。再次衷心感谢!!

--  作者:有点甜
--  发布时间:2014/11/25 19:28:00
--  

类似代码

 

Dim cmd As New SQLCommand
Dim dt As DataTable
cmd.CommandText = "SELECT DISTINCT 合同年月,客户简称,合同ID,生产ID,作业ID,工票编号 From {工票信息}"
dt = cmd.ExecuteReader()
Dim trv As WinForm.TreeView = Forms("工票管理").Controls("TreeView1")
trv.BuildTree(dt,"合同年月|客户简称|合同ID|生产ID|作业ID|工票编号","","")

trv.Nodes.Insert("作业计划合计",0)

For Each nd As WinForm.TreeNode In trv.AllNodes
    Select Case nd.Level
        Case 0
            If nd.Name = "作业计划合计" Then
                Dim n0 As Integer = DataTables("工票信息").GetValues("作业ID").Count
                Dim n1 As Integer = DataTables("工票信息").Compute("Count(工票ID)") \'工票数
                Dim n2 As Integer = DataTables("工票信息").Compute("Count(工票编号)","Len(工票ID) = 8") \'绑定数
                Dim n3 As Integer = DataTables("工票信息").Compute("Count(工票编号)","iif(len(工票ID) > 3, Substring(工票ID, Len(工票ID)-2, 3) = \'已回收\', false)") \'回收数
                nd.text = nd.Name & "("& n0 &"/"& n1 &"/"& n2 &"/"& n3 &")"
            Else
                Dim filter As String = "合同年月 = \'" & nd.Name & "\'"
                Dim n0 As Integer = DataTables("工票信息").GetValues("作业ID", filter).Count
                Dim n1 As Integer = DataTables("工票信息").Compute("Count(工票ID)", filter) \'工票数
                Dim n2 As Integer = DataTables("工票信息").Compute("Count(工票编号)","Len(工票ID) = 8 and " & filter) \'绑定数
                Dim n3 As Integer = DataTables("工票信息").Compute("Count(工票编号)","iif(len(工票ID) > 3, Substring(工票ID, Len(工票ID)-2, 3) = \'已回收\', false) and " & filter) \'回收数
                nd.text = nd.Name & "("& n0 &"/"& n1 &"/"& n2 &"/"& n3 &")"
            End If
        Case 1
            Dim ary() As String = nd.FullName.Split("\\")
            Dim filter As String = "合同年月 = \'" & ary(0) & "\' and 客户简称 = \'" & ary(1) & "\'"
            Dim n0 As Integer = DataTables("工票信息").GetValues("作业ID", filter).Count
            Dim n1 As Integer = DataTables("工票信息").Compute("Count(工票ID)", filter) \'工票数
            Dim n2 As Integer = DataTables("工票信息").Compute("Count(工票编号)","Len(工票ID) = 8 and " & filter) \'绑定数
            Dim n3 As Integer = DataTables("工票信息").Compute("Count(工票编号)","iif(len(工票ID) > 3, Substring(工票ID, Len(工票ID)-2, 3) = \'已回收\', false) and " & filter) \'回收数
            nd.text = nd.Name & "("& n0 &"/"& n1 &"/"& n2 &"/"& n3 &")"
           

    End Select
Next


--  作者:yyzlxc
--  发布时间:2014/11/25 20:39:00
--  
谢谢甜老师的赐教,问题全部得到圆满解决,再次衷心感谢。