Foxtable(狐表)用户栏目专家坐堂 → 多条件数据加载


  共有2170人关注过本帖树形打印复制链接

主题:多条件数据加载

帅哥哟,离线,有人找我吗?
HANZHIGANG
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:一尾狐 帖子:430 积分:4655 威望:0 精华:0 注册:2015/3/21 14:25:00
多条件数据加载  发帖心情 Post By:2023/9/19 16:59:00 [只看该作者]

Dim Filter As String
With RibbonTabs("外协车辆结算").Groups("外协车辆结算").Items("车牌号")
    If .text > "" Then
        Filter = "车牌号 like '%" & .text & "%'"
    End If
End With

With RibbonTabs("外协车辆结算").Groups("外协车辆结算").Items("驾驶员")
    If .text > "" Then
        If Filter > "" Then
            Filter = Filter & " And "
        End If
        Filter = Filter & "驾驶员 like '%" & .text & "%'"
    End If
End With

With RibbonTabs("外协车辆结算").Groups("外协车辆结算").Items("结算单号")
    If .text > "" Then
        If Filter > "" Then
            Filter = Filter & " And "
        End If
        Filter = Filter & "结算单号 like '%" & .text & "%'"
    End If
End With

With RibbonTabs("外协车辆结算").Groups("外协车辆结算").Items("调度单号")
    If .text > "" Then
        If Filter > "" Then
            Filter = Filter & " And "
        End If
        Filter = Filter & "调度单号 like '%" & .text & "%'"
    End If
End With

With RibbonTabs("外协车辆结算").Groups("外协车辆结算").Items("结算员")
    If .text > "" Then
        If Filter > "" Then
            Filter = Filter & " And "
        End If
        Filter = Filter & "结算员 like '%" & .text & "%'"
    End If
End With

With RibbonTabs("外协车辆结算").Groups("外协车辆结算").Items("结自")
    If .value <> Nothing  Then
        If Filter > "" Then
            Filter = Filter & " And "
        End If
        Filter = Filter & "结算日期 >= '" & .value & "'"
    End If
End With

With RibbonTabs("外协车辆结算").Groups("外协车辆结算").Items("结至")
    If .value <> Nothing Then
        If Filter > "" Then
            Filter = Filter & " And "
        End If
        Filter = Filter & "结算日期 <= '" & .value & "'"
    End If
End With

If RibbonTabs("外协车辆结算").Groups("外协车辆结算").Items("返单公司").text = "是" Then
    If Filter > "" Then
        Filter = Filter & " And "
    End If
    Filter = Filter & "返单公司 = 1"
End If

If RibbonTabs("外协车辆结算").Groups("外协车辆结算").Items("返单公司").text = "否" Then
    If Filter > "" Then
        Filter = Filter & " And "
    End If
    Filter = Filter & "返单公司 = 0"
End If

If RibbonTabs("外协车辆结算").Groups("外协车辆结算").Items("结算").text = "是"
    If Filter >"" Then
        Filter = Filter & " And "
    End If
    Filter = Filter & "结算 = 1"
End If

If RibbonTabs("外协车辆结算").Groups("外协车辆结算").Items("结算").text = "否" Then
    If Filter > "" Then
        Filter = Filter & " And "
    End If
    Filter = Filter & "结算 = 0"
End If

If RibbonTabs("外协车辆结算").Groups("外协车辆结算").Items("支付").text = "是" Then
    If Filter > "" Then
        Filter = Filter & " And "
    End If
    Filter = Filter & "支付 = 1"
End If

If RibbonTabs("外协车辆结算").Groups("外协车辆结算").Items("支付").text = "否" Then
    If Filter > "" Then
        Filter = Filter & " And "
    End If
    Filter = Filter & "支付 = 0"
End If

If RibbonTabs("外协车辆结算").Groups("外协车辆结算").Items("锁定").text = "是" Then
    If Filter > "" Then
        Filter = Filter & " And "
    End If
    Filter = Filter & "锁定 = 1"
End If

If RibbonTabs("外协车辆结算").Groups("外协车辆结算").Items("锁定").text = "否" Then
    If Filter > "" Then
        Filter = Filter & " And "
    End If
    Filter = Filter & "锁定 = 0"
End If

If Filter > "" Then
    Tables("外协车辆结算").DataTable.loadfilter = Filter And "车辆类型 In ('挂靠车','外网车')"
    Tables("外协车辆结算").DataTable.load
Else
    Tables("外协车辆结算").DataTable.loadfilter = "车辆类型 In ('挂靠车','外网车')"
    Tables("外协车辆结算").DataTable.load
End IF

以上代码当条件为空时,会正确加载。

但条件不为空时会出现错误提示:

.NET Framework 版本:4.0.30319.42000
Foxtable 版本:2022.8.18.1
错误所在事件:菜单,查询,Click
详细错误信息:
从字符串“车牌号 like '%111%' And 结算 = 1”到类型“Long”的转换无效。
输入字符串的格式不正确。

 回到顶部
帅哥哟,离线,有人找我吗?
HANZHIGANG
  2楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:一尾狐 帖子:430 积分:4655 威望:0 精华:0 注册:2015/3/21 14:25:00
  发帖心情 Post By:2023/9/19 16:59:00 [只看该作者]

sql server 数据库

 回到顶部
帅哥哟,离线,有人找我吗?
有点蓝
  3楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:超级版主 帖子:110443 积分:562081 威望:0 精华:9 注册:2015/6/24 9:21:00
  发帖心情 Post By:2023/9/19 17:12:00 [只看该作者]

 Tables("外协车辆结算").DataTable.loadfilter = Filter And "车辆类型 In ('挂靠车','外网车')"
改为

 Tables("外协车辆结算").DataTable.loadfilter = Filter & " And 车辆类型 In ('挂靠车','外网车')"
[此贴子已经被作者于2023/9/19 17:12:36编辑过]

 回到顶部