Private Sub txtSearch_KeyDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles txtSearch.KeyDown
If txtSearch.Text <> "" Then
If (e.KeyCode = Keys.Enter) Then
Dim sqlCom As String = ""
sqlCom = "SELECT * FROM I_Equipment"
If cboSearch.SelectedIndex = 0 Then
sqlCom &= " WHERE (ID_P='" & txtSearch.Text & "')"
ElseIf cboSearch.SelectedIndex = 1 Then
sqlCom &= " WHERE (Name_P LIKE '%" & txtSearch.Text & "%')"
'ElseIf cboSearch.SelectedIndex = 2 Then
' sqlBook &= " WHERE (Brand_P LIKE '%" & txtSearch.Text & "%')"
End If
sqlCom &= " ORDER BY ID_P"
With Conn
If .State = ConnectionState.Open Then .Close()
.ConnectionString = strConnection
.Open()
End With
If IsFind = True Then
ds.Tables("I_Equipment").Clear()
End If
da.SelectCommand.CommandText = sqlCom
da.Fill(ds, "I_Equipment")
If ds.Tables("I_Equipment").Rows.Count <> 0 Then
IsFind = True
ClearAllBinding()
txtID_P.DataBindings.Add("Text", ds, "I_Equipment.ID_P")
txtName_P.DataBindings.Add("Text", ds, "I_Equipment.Name_P")
txtnumbre_P.DataBindings.Add("Text", ds, "I_Equipment.Remain_P")
txtNum_Check.DataBindings.Add("Text", ds, "I_Equipment.Num_Check")
'dtpDateCheck_P.DataBindings.Add("Text", ds, "t_Products.DateCheck_P")
'txtID_T.DataBindings.Add("Text", ds, "t_Employees.ID_T")
'txtBookTotal.DataBindings.Add("Text", ds, "Book.BookTotal")
dt = ds.Tables("I_Equipment")
ShowPosition()
btnAdd.Enabled = False
btnEdit.Enabled = True
btnMoveFirst.Enabled = True
btnMovePrevious.Enabled = True
btnMoveNext.Enabled = True
btnMoveLast.Enabled = True
btnEdit.Focus()
Else
IsFind = False
MessageBox.Show("อุปกรณ์ที่คุณค้นหา ไม่มีในฐานข้อมูล !!!", "ผลการตรวจสอบ", MessageBoxButtons.OK, MessageBoxIcon.Information)
ClearData()
lblShowPosition.Text = ""
btnAdd.Enabled = True
btnEdit.Enabled = False
btnMoveFirst.Enabled = False
btnMovePrevious.Enabled = False
btnMoveNext.Enabled = False
btnMoveLast.Enabled = False
txtSearch.Focus()
txtSearch.SelectAll()
Exit Sub
End If
End If
End If
End Sub