tktonghop
Option Explicit
Dim CN As New ADODB.Connection
Dim RsTim As New ADODB.Recordset
Private Sub HienthiHD()
Dim Rshd As New ADODB.Recordset
Rshd.LockType = adLockOptimistic
Rshd.CursorType = adOpenKeyset
Rshd.Source = "Select * From hop_dong"
Rshd.ActiveConnection = CN
Rshd.Open
If Rshd.RecordCount <> 0 Then
cbosm.Clear
While Not Rshd.EOF
cbosm.AddItem Rshd!somay
Rshd.MoveNext
Wend
Else
cbosm.Clear
End If
End Sub
Private Sub HienthiNgay()
Dim RsNgay As New ADODB.Recordset
RsNgay.LockType = adLockOptimistic
RsNgay.CursorType = adOpenKeyset
RsNgay.Source = "Select * From cuoc_goi"
RsNgay.ActiveConnection = CN
RsNgay.Open
If RsNgay.RecordCount <> 0 Then
cbong.Clear
While Not RsNgay.EOF
cbong.AddItem RsNgay!ngaygoi
RsNgay.MoveNext
Wend
Else
cbong.Clear
End If
End Sub
Private Sub CmdBack_Click()
RsTim.MovePrevious
If RsTim.BOF = True Then
RsTim.MoveFirst
End If
Hienthi
End Sub
Private Sub Hienthi()
txtsm.Text = RsTim.Fields("cuoc_goi.somay")
txtmav.Text = RsTim!mavung
txtmaht.Text = RsTim!mahinhthuc
txtsmn.Text = RsTim!somayden
txtng.Text = RsTim!ngaygoi
txtgbd.Text = RsTim!giobd
txttgll.Text = RsTim!tgll
End Sub
Private Sub CmdNext_Click()
RsTim.MoveNext
If RsTim.EOF = True Then
RsTim.MoveLast
End If
Hienthi
End Sub
Private Sub CmdThoat_Click()
Unload Me
End Sub
Private Sub Cmdtk_Click()
Dim St As String
St = "SELECT * FROM hop_dong,cuoc_goi where hop_dong.somay = cuoc_goi.somay"
If cbosm.Text <> "" Then
St = St & " and cuoc_goi.somay='" & Left(cbosm.Text, 7) & "'"
End If
If cbong.Text <> "" Then
St = St & " and cuoc_goi.ngaygoi= #" & cbong.Text & "#"
End If
Set RsTim = New ADODB.Recordset
RsTim.LockType = adLockOptimistic
RsTim.CursorType = adOpenKeyset
RsTim.Source = St
RsTim.ActiveConnection = CN
If RsTim.State = adStateOpen Then
RsTim.Close
End If
RsTim.Open
If RsTim.RecordCount <> 0 Then
HienthiLV
RsTim.MoveFirst
Else
lvds.ListItems.Clear
MsgBox "Khong thay ban ghi can tim", vbQuestion, "Thong bao"
End If
End Sub
Private Sub HienthiLV()
Dim LV As ListItem
lvds.ListItems.Clear
While Not RsTim.EOF
Set LV = lvds.ListItems.Add(, , RsTim.Fields("hop_dong.somay"))
LV.SubItems(1) = RsTim!mavung
LV.SubItems(2) = RsTim!mahinhthuc
LV.SubItems(3) = RsTim!somayden
LV.SubItems(4) = RsTim!ngaygoi
LV.SubItems(5) = RsTim!giobd
LV.SubItems(6) = RsTim!tgll
RsTim.MoveNext
Wend
End Sub
Private Sub Form_Load()
CN.Provider = "Microsoft.Jet.OLEDB.4.0"
CN.ConnectionString = App.Path & "\cuocdt.mdb"
CN.Open
HienthiHD
HienthiNgay
End Sub
Bạn đang đọc truyện trên: Truyen247.Pro