Dim t As Table =Tables("市场客户模糊查询_Table1")
Dim py,Lm,Ts, Bm,sql,Lb,sl As String
Dim Ls As New List(Of Integer)
Dim Lss As New List(Of String)
Static st As String
Dim drs As New List(of DataRow) \'定义一个DataRow行的集合
Ts = "编号,客户姓名,联系电话,小区地址,市场部,设计部" \'查询相关列
Bm = "中冠市场部客户表"
If st = e.sender.Text.ToUpper Then
Return
Else
st = e.sender.Text.ToUpper
End If
e.sender.Text = st
Sendkeys.Send("^{END}") \'光标定于输入框最后
drs = DataTables(Bm).Select("客户姓名 > \'\'")
\'赋值drs=员工表--姓名列不为空的 DataRow行
If drs.count > 0 Then \'如drs行数>0,执行...
If st IsNot Nothing Then \'如输入框内容不为空,执行...
For Each Lm In Ts.split(",") \'遍历查询相关列
For Each dr As DataRow In drs \'遍历所有行
py = GetPY(dr(Lm),True) \'赋值py = 查询行查询列的简拼
If dr(Lm).IndexOf(st)> -1 OrElse py.IndexOf(st) > -1 Then
\'如查询行查询列内容(或简拼)包含输入框内容,执行...
If Ls.Contains(dr("_Identify")) = False Then \'如不包含则增加
ls.Add(dr("_Identify"))
End If
If Lss.Contains(dr(Lm)) = False Then
Lss.Add(dr(Lm))
End If
End If
Next
Next
If Ls.count > 0 Then
For Each n As Integer In Ls
sql+ = "," & n
Next
sql = "[_Identify] In(" & sql.Trim(",") & ")" \'包含主键[_Identify]内容
sql = "select " & Ts & " from{" & Bm & "} where " & sql \'合成SQL语句
t.Fill(sql,True) \'生成SQL查询表
For Each sl In Lss
lb+ = "|" & sl
Next
e.sender.ComboList = lb \'形成输入框列表
Else
MessageBox.show("抱歉,数据库中没有您想查询的信息!" )
\'e.sender.value = ""
e.sender.Select
Return
End If
End If
End If