Foxtable(狐表)用户栏目专家坐堂 → [原创]2次筛选结果不一致


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

主题:[原创]2次筛选结果不一致

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


加好友 发短信
等级:幼狐 帖子:63 积分:455 威望:0 精华:0 注册:2019/8/21 10:46:00
[原创]2次筛选结果不一致  发帖心情 Post By:2019/9/27 13:45:00 [只看该作者]

相同筛选条件,上午正常,下午错误,是试用期到了吗?
图片点击可在新窗口打开查看此主题相关图片如下:查询1.jpg
图片点击可在新窗口打开查看

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


加好友 发短信
等级:幼狐 帖子:63 积分:455 威望:0 精华:0 注册:2019/8/21 10:46:00
查询代码  发帖心情 Post By:2019/9/27 13:50:00 [只看该作者]

Dim text As String = ""
With e.Form.Controls("T姓名")
    If .Value IsNot Nothing Then
        text = "姓名 Like '%" & .Value & "%'"
    End If
End With
With e.Form.Controls("C部门1")
    If .Value IsNot Nothing Then
        If text > "" Then
            text = text & " And "
        End If
        text = text & "部门 = '" & .Value & "'"
    End If
End With
With e.Form.Controls("C部门2")
    If .Value IsNot Nothing Then
        If text > "" Then
            text = text & " Or "
        End If
        text = text & "部门 = '" & .Value & "'"
    End If
End With

With e.Form.Controls("C岗位")
    If .Value IsNot Nothing Then
        If text >"" Then
            text = text & " And "
        End If
        text = text & "岗位 = '" & .Value & "'"
    End If
End With
With e.Form.Controls("T电话")
    If .Value IsNot Nothing Then
        If text >"" Then
            text = text & " And "
        End If
        text = text & "联系电话 Like '%" & .Value & "%'"
    End If
End With
With e.Form.Controls("T籍贯")
    If .Value IsNot Nothing Then
        If text >"" Then
            text = text & " And "
        End If
        text = text & "籍贯 Like '%" & .Value & "%'"
    End If
End With
With e.Form.Controls("T身份证")
    If .Value IsNot Nothing Then
        If text >"" Then
            text = text & " And "
        End If
        text = text & "身份证 Like '%" & .Value & "%'"
    End If
End With
With e.Form.Controls("C学历")
    If .Value IsNot Nothing Then
        If text >"" Then
            text = text & " And "
        End If
        text = text & "学历 = '" & .Value & "'"
    End If
End With
With e.Form.Controls("C性别")
    If .Value IsNot Nothing Then
        If text >"" Then
            text = text & " And "
        End If
        If .Value = "不区分男女" Then
            text = text & "性别 = '男'" & " Or 性别 = '女'"
        Else
            text = text & "性别 = '" & .Value & "'"
        End If
    End If
End With
With e.Form.Controls("C宿舍")
    If .Value IsNot Nothing Then
        If text >"" Then
            text = text & " And "
        End If
        If .Value = "所有宿舍"
            text = text & "宿舍 <> ''"
        Else
            text = text & "宿舍 = '" & .Value & "'"
        End If
    End If
End With

With e.Form.Controls("D入职1")
    If .Value IsNot Nothing Then
        If text >"" Then
            text = text & " And "
        End If
        text = text & "入职日期 >= #" & .Value & "#"
    End If
End With
With e.Form.Controls("D入职2")
    If .Value IsNot Nothing Then
        If text >"" Then
            text = text & " And "
        End If
        text = text & "入职日期 <= #" & .Value & "#"
    End If
End With

With e.Form.Controls("D离职1")
    If .Value IsNot Nothing Then
        If text >"" Then
            text = text & " And "
        End If
        text = text & "离职日期 >= #" & .Value & "#"
    End If
End With
With e.Form.Controls("D离职2")
    If .Value IsNot Nothing Then
        If text >"" Then
            text = text & " And "
        End If
        text = text & "离职日期 <= #" & .Value & "#"
    End If
End With
With e.Form.Controls("N年龄1")
    If .Value IsNot Nothing Then
        If text >"" Then
            text = text & " And "
        End If
        text = text & "年龄 >= " & CInt(.Value)
    End If
End With
With e.Form.Controls("N年龄2")
    If .Value IsNot Nothing Then
        If text >"" Then
            text = text & " And "
        End If
        text = text & "年龄 <= " & CInt(.Value)
    End If
End With
With e.Form.Controls("N工龄1")
    If .Value IsNot Nothing Then
        If text >"" Then
            text = text & " And "
        End If
        Dim N工龄 As Date
        N工龄 = Date.Today.AddYears(0 - CInt(.Value))
        text = text & "入职日期 <= #" & N工龄 & "#"
    End If
End With
With e.Form.Controls("N工龄2")
    If .Value IsNot Nothing Then
        If text >"" Then
            text = text & " And "
        End If
        Dim N工龄 As Date
        N工龄 = Date.Today.AddYears(0 - CInt(.Value))
        text = text & "入职日期 >= #" & N工龄 & "#"
    End If
End With
With e.Form.Controls("C等级")
    If .Value IsNot Nothing Then
        If text >"" Then
            text = text & " Or "
        End If
        text = text & "职位等级 <= " & .Value
    End If
End With

If e.Form.Controls("C在职").Checked = True ' 如果在职状态选择了"是"
    If text >"" Then
        text = text & " And "
    End If
    text = text & "在职 = True"
Else
    If text >"" Then
        text = text & " And "
    End If
    text = text & "在职 = True" & " Or " & "在职 = False"
End If
If e.Form.Controls("C社保").Checked = True ' 如果在职状态选择了"是"
    If text >"" Then
        text = text & " And "
    End If
    text = text & "社保 = True"
Else
    If text >"" Then
        text = text & " And "
    End If
    text = text & "社保 = True" & " Or " & "社保 = False"
End If

If text > "" Then
    Vars("kh") = "员工信息"
    Dim tb As Table = Tables("查询员工_T员工")
    Dim Tsort As String '排序
    With e.Form.Controls("C排序1")
        If .Value IsNot Nothing Then
            Tsort = .Value
            If e.Form.Controls("C升1").Value = "降序" Then
                Tsort = Tsort & " Desc"
            End If
        End If
    End With
    With e.Form.Controls("C排序2")
        If .Value IsNot Nothing Then
            If Tsort >"" Then
                Tsort = Tsort & " , "
            End If
            Tsort = Tsort & .Value
            If e.Form.Controls("C升2").Value = "降序" Then
                Tsort = Tsort & " Desc"
            End If
        End If
    End With
    With e.Form.Controls("C排序3")
        If .Value IsNot Nothing Then
            If Tsort >"" Then
                Tsort = Tsort & " , "
            End If
            Tsort = Tsort & .Value
            If e.Form.Controls("C升3").Value = "降序" Then
                Tsort = Tsort & " Desc"
            End If
        End If
    End With
    'MessageBox.Show(Tsort)
    DataTables(Vars("kh")).LoadFilter = text '设置加载条件
    'DataTables(Vars("kh")).LoadOrder = Tsort '设置排序条件
    DataTables(Vars("kh")).Load() '加载数据
    'Tables("查询员工_T员工").SetColVisibleWidth("姓名|60|部门|60|岗位|80|身份证|160|年龄|40|工龄|44")
    tb.DataSource  = DataTables(Vars("kh"))
    tb.Sort = Tsort
    Dim rgd As WinForm.RecordGrid = e.Form.Controls("RecordGrid1")
    rgd.Table = Tables("查询员工_T员工") '指定绑定表
    rgd.Build() '重新生成记录窗口
    e.Form.Controls("T记录数").Value = "记录查询到:" & Tables("查询员工_T员工").count & " 条"
End If
text = ""

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


加好友 发短信
等级:超级版主 帖子:105926 积分:538693 威望:0 精华:9 注册:2015/6/24 9:21:00
  发帖心情 Post By:2019/9/27 14:13:00 [只看该作者]

您的意思是,什么条件都不变,连续点击2次查询,返回的结果都不一样?

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


加好友 发短信
等级:幼狐 帖子:63 积分:455 威望:0 精华:0 注册:2019/8/21 10:46:00
  发帖心情 Post By:2019/9/27 14:50:00 [只看该作者]

查出来了,代码错了。
If e.Form.Controls("C社保").Checked = True ' 如果在职状态选择了"是"
    If text >"" Then
        text = text & " And "
    End If
    text = text & "社保 = True"
Else
    If text >"" Then
        text = text & " And "  
    End If
    text = text & "社保 = True" & " Or " & "社保 = False" ----------错误代码
End If
-----------------------------
我本意是:【部门】和【社保】条件都满足的记录,不知怎么改?
------------------------------

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


加好友 发短信
等级:超级版主 帖子:105926 积分:538693 威望:0 精华:9 注册:2015/6/24 9:21:00
  发帖心情 Post By:2019/9/27 14:59:00 [只看该作者]

不勾选就不要添加条件咯
If e.Form.Controls("C社保").Checked = True ' 如果在职状态选择了"是"
    If text >"" Then
        text = text & " And "
    End If
    text = text & "社保 = True"
End If

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


加好友 发短信
等级:幼狐 帖子:63 积分:455 威望:0 精华:0 注册:2019/8/21 10:46:00
  发帖心情 Post By:2019/9/27 15:11:00 [只看该作者]

谢谢蓝老师

 回到顶部