Public Sub custqry()
If custfn.Text <> "" Or custln.Text <> "" Then
Dim SQLCN As New SqlClient.SqlConnection("Server=ICS-SVR1;User ID=sa;Password=;Database=ICS-DISPATCH")
Dim SQLCmd As New SqlCommand
SQLCN.Close()
SQLCN.Open()
Me.custlv1.Items.Clear()
custlvds.Clear()
SQLCmd.CommandType = CommandType.Text
SQLCmd.Connection = SQLCN
SQLCmd.CommandText = "SELECT * from CUSTDB WHERE custfn LIKE " & custfn.Text & "% and custln LIKE " & custln.Text & "% and custcn like %" & custcn.Text & " and custph like %" & custph.Text & ""
SqlDataAdapter1.Fill(custlvds, "custdb")
SQLCN.Close()
Dim dr As DataRow
Dim oItem As ListViewItem
Dim osItem As ListViewItem.ListViewSubItem
If Not custlvds Is Nothing Then
For Each dr In custlvds.Tables(0).Rows
oItem = New ListViewItem
oItem.Tag = dr("CID")
osItem = New ListViewItem.ListViewSubItem
oItem.Text = dr("custfn")
osItem.Text = dr("custln") & ""
oItem.SubItems.Add(osItem)
osItem = New ListViewItem.ListViewSubItem
osItem.Text = dr("custcn") & ""
oItem.SubItems.Add(osItem)
osItem = New ListViewItem.ListViewSubItem
osItem.Text = dr("custph") & ""
oItem.SubItems.Add(osItem)
Me.custlv1().Items.Add(oItem)
Next
End If
ElseIf custfn.Text <> "" Then
Exit Sub
ElseIf custln.Text <> "" Then
Exit Sub
Else
Me.custlv1.Items.Clear()
End If
End Sub