如果做人事管理系统,几百人的话,需要模糊查询,像极品列车时刻表那样,
例如:输入zx,就能在下拉列表里显示库里的所有相关人名:“张笑,张小、章萧……”等等
模糊匹配:编号,姓名,部门,职务,简拼也行
范例文件:传统编辑模式
1.建一窗口1
2.插入:ComboBox1,Table1
3.ComboBox1的TextChanged事件代码:
Dim Ts As String() = {"编号","姓名","部门","职务"}
Dim t As Table =Tables("窗口1_Table1")
Dim st,ls ,py,Lm,str,Lss As String
st = e.sender.Text.ToUpper
If st IsNot Nothing Then
For Each Lm In Ts
For Each dr As DataRow In DataTables("员工").DataRows
py = GetPY(dr(Lm),True)
If dr(Lm).IndexOf(st)> -1 OrElse py.IndexOf(st) > -1 Then
If Ls Is Nothing Then
Ls = dr("_Identify")
Else
If Ls.IndexOf(dr("_Identify")) = -1 Then
ls+= "," & dr("_Identify")
End If
End If
If Lss Is Nothing Then
Lss = dr(Lm)
Else
If Lss.IndexOf(dr(Lm)) = -1 Then
Lss+ = "|" & dr(Lm)
End If
End If
End If
Next
Next
If ls IsNot Nothing Then
Ls ="[_Identify] In(" & Ls & ")"
Ls="select 编号,姓名 ,部门,职务 from{员工} where " & Ls
t.Fill(Ls,True)
e.sender.ComboList = Lss
End If
End If
Dim a As String ="张笑,张小,章萧,喜爱"
Dim sz As new List(of String)
For Each g As String In a.Split(",") '添加进 集合 sz
If sz.Contains(g)=False Then '判断有无重复
sz.Add(g)
End If
Next
Dim zm As String = "zx" '定义要查找的 拼音 首字母
For Each g As String In sz
If getpy(g,True) = zm Then
output.show(g)
End If
Next