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 = ""