以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.net/bbs/index.asp)
--  专家坐堂  (http://foxtable.net/bbs/list.asp?boardid=2)
----  代码请教  (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=95100)

--  作者:cuicuibing
--  发布时间:2017/1/10 12:12:00
--  代码请教
Dim Filter As String
With e.Form.Controls("DropBox1")
    If .Value IsNot Nothing Then
        Filter = "内部加工单号  in (\'" & .Value.replace(",","\',\'") & "\')"
        End If
End With
With e.Form.Controls("combobox1")
    If .Value IsNot Nothing Then
        If Filter > "" Then
            Filter = Filter & " And "
        End If
        Filter = Filter & "工段 = \'" & .Value & "\'"
    End If
End With
With e.Form.Controls("DropBox3")
    If .Value IsNot Nothing Then
        If Filter >"" Then
            Filter = Filter & " And "
        End If
        Filter = Filter & "产品名称 = \'" & .Value & "\'"
    End If
End With

If Filter > "" Then
    DataTables("工序库调用_Table1").LoadFilter = Filter \'设置加载条件
    DataTables("工序库调用_Table1").Load()
End If
Dim cmd1 As New SQLCommand
Dim dt As DataTable
Dim cmd2 As New SQLCommand
Dim dr As DataRow
Dim dt2 As DataTable
Dim Val As Double
Dim val1 As Double
Dim s As Integer
cmd1.C
cmd1.CommandText = "SE LECT * From {派工明细表} " & iif(Filter>"", "Where " & filter, "")
dt = cmd1.ExecuteReader()
cmd2.C
cmd2.CommandText = "SE LECT * From {加工点清单} " & iif(Filter>"", "Where " & filter, "")
dt2 = cmd1.ExecuteReader()
For Each r As Row In Tables("工序库调用_table1").Rows
    Val = dt.SQLCompute("Sum(派工量)"," 编号= \'" & r("编号") & "\'")
    val1 = dt.SQLCompute("Sum(部件派工)"," 编号= \'" & r("编号") & "\'")
    r("可派工量") = r("工序数量") - val
    r("部件余量") = r("部件量") - val1
    dr = dt2.find("编号 =  \'" & r("编号") & "\'")
    If  dr IsNot Nothing Then
    r("状态") = " 已派 "
    End If
Next
Tables("工序库调用_table1").Filter = "[可派工量] > 0 "

e.Form.Controls("TreeView1").BuildTree("工序库调用_table1", "工段|工序名称|产品名称")
e.Form.Controls("TreeView2").BuildTree("工序库调用_table1", "产品名称|工段|工序名称")

使用代码筛选时,出现错误提示
              无法在system.string  和system.int32 上执行 ">" 操作。 

--  作者:cuicuibing
--  发布时间:2017/1/10 12:22:00
--  
找到原因了,列类型不对。