LƯU ĐỒ GIẢI THUẬT

Một phần của tài liệu Luận văn: Thiết kế hệ thống bãi giữ xe ôtô tự động pot (Trang 72 - 111)

IV.VIẾT CODE CHO GIAO DIỆN

Code Form Giao diện giao tiếp

Option Explicit

Dim Nhan() As Byte

' KHAI BAO BIEN DE KET NOI CSDL Dim sqlLuuDL As String

Public rsLuuDL As New ADODB.Recordset Dim sqlXera As String

Public rsCapnhatXera As New ADODB.Recordset Dim sqlPhanloaixe As String

Dim rsPhanloaixe As New ADODB.Recordset Public Soxe As String

Public Loaixe As String Dim sott As Integer Public ngayvao As Date Dim giovao As String Dim ngayra As Date Dim giora As String

Public thanhtien As Double Public thoigian As String

Private Sub Chitiet_Click()

Load Baixe

Baixe.Show

End Sub

Private Sub ClosePort_Click()

If MSComm1.PortOpen = True Then MSComm1.PortOpen = False OPENPORT.Enabled = True

End If End Sub

Private Sub CmbXera_Click() Dim soxe1 As String soxe1 = CmbXera.Text

rsCapnhatXera.Find "[so xe] = '" & soxe1 & "'", , , adBookmarkFirst If Not rsCapnhatXera.EOF Then

txtLoaixera.Text = rsCapnhatXera.Fields(1) End If

End Sub

Private Sub CmbXera_Change() Dim soxe1 As String

soxe1 = CmbXera.Text

rsCapnhatXera.Find "[so xe] = '" & soxe1 & "'", , , adBookmarkFirst If Not rsCapnhatXera.EOF Then

txtLoaixera.Text = rsCapnhatXera.Fields(1) End If

End Sub

Private Sub cmdBoqua_Click() txtSoxevao.Text = ""

CmbLoaixevao.Text = "Chon loai xe" CmbXera.Text = "Xe ra"

txtLoaixera.Text = "Chon loai xe"

txtSoxevao.Enabled = False CmbLoaixevao.Enabled = False CmbXera.Enabled = False txtLoaixera.Enabled = False CmdLuuVao.Enabled = False CmdLuuRa.Enabled = False

Private Sub CmdPhanloaixe_Click() Load Form5

Form5.Show End Sub

Private Sub lbxevao_Click()

txtSoxevao.Enabled = True

CmbLoaixevao.Enabled = True

CmbXera.Enabled = False

txtLoaixera.Enabled = False lbxevao.ForeColor = &HFF0000 txtLoaixera.Text = "Loai xe ra" CmbXera.Text = "Xe ra" txtSoxevao.Text = ""

CmdLuuRa.Enabled = False

CmdLuuVao.Enabled = True

cmdBoqua.Enabled = True

End Sub

Private Sub lbxera_Click()

CmdLuuVao.Enabled = False

CmdLuuRa.Enabled = True

cmdBoqua.Enabled = True

txtSoxevao.Text = "Xe vao" txtSoxevao.Enabled = False CmbLoaixevao.Enabled = False CmbXera.Enabled = True txtLoaixera.Enabled = True txtLoaixera.Locked = True lbxera.ForeColor = &HFF0000

rsCapnhatXera.Sort = "[so xe] ASC" If rsCapnhatXera.RecordCount > 0 Then rsCapnhatXera.MoveFirst

Do While Not rsCapnhatXera.EOF

CmbXera.AddItem rsCapnhatXera.Fields(2) rsCapnhatXera.MoveNext Loop rsCapnhatXera.MoveFirst CmbXera.Text = rsCapnhatXera.Fields(2) txtLoaixera.Text = rsCapnhatXera.Fields(1) End If End Sub

Private Sub CmdLuuVao_Click() Dim Error As Integer

TIEP.Enabled = True

sqlLuuDL = "select * from chitiet" Error = kiemtra

Set rsLuuDL = LayDL(sqlLuuDL) If Error = 0 Then

If Val(CmbLoaixevao.Text) = False Then

MsgBox "Loai xe vao chi duoc chon gia tri tu 1 den 4 " CmbLoaixevao.Text = ""

Exit Sub End If

If Val(CmbLoaixevao.Text) > 4 Then

MsgBox "Loai xe khong duoc lon hon 4" CmbLoaixevao.Text = ""

Exit Sub End If

GhiDL rsLuuDL LuuDL rsLuuDL txtSoxevao.Text = "" CmbLoaixevao.Text = "" End If If Error = 1 Then

MsgBox "Vui long nhap so xe!" Exit Sub

End If

If Error = 2 Then

MsgBox "Vui long chon loai xe!" Exit Sub

End If

If Error = 3 Then

MsgBox "So xe chi duoc nhap 7 ki tu!" txtSoxevao.Text = ""

Exit Sub End If

If Error = 4 Then

MsgBox "Loai xe chi duoc chon tu 1 den 4!" CmbLoaixevao.Text = ""

Exit Sub End If End Sub

Private Sub GhiDL(rs As ADODB.Recordset) Dim s As String

Dim MALN As Variant Dim tam As Variant

Set rsDem = LayDL(s) MALN = 0

Do While (Not rsDem.EOF) tam = rsDem![stt]

If (MALN < tam) Then MALN = tam End If rsDem.MoveNext Loop MALN = MALN + 1 rs.Fields(0) = MALN rs.Fields(1) = CmbLoaixevao.Text rs.Fields(2) = txtSoxevao.Text rs.Fields(3) = Date rs.Fields(4) = Time rs.Fields(5) = 0 rs.Fields(6) = 0 rs.Fields(7) = 0 rs.Fields(8) = 0 Set rsDem = Nothing End Sub

Private Sub Sco_Click()

Timer18.Enabled = False MSComm1.Output = "a" Timer18.Enabled = True sco.Enabled = False End Sub

End End Sub

Private Sub Form_mousemove(button As Integer, shift As Integer, X As Single, Y As Single)

lbxevao.FontUnderline = False lbxevao.ForeColor = &HFF& End Sub

Private Sub lbxevao_mousemove(button As Integer, shift As Integer, X As Single, Y As Single) lbxevao.FontUnderline = True lbxevao.ForeColor = &HC000C0 lbxera.FontUnderline = False lbxera.ForeColor = &HFF0000 End Sub

Private Sub lbxera_mousemove(button As Integer, shift As Integer, X As Single, Y As Single) lbxera.FontUnderline = True lbxera.ForeColor = &HC000C0 lbxevao.FontUnderline = False lbxevao.ForeColor = &HFF0000 End Sub

Private Sub Form_Load()

'---'

cnn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\baigiuxe.mdb;Persist Security Info=False"

cnn.CursorLocation = adUseClient cnn.Open

txtSoxevao.Enabled = False CmbXera.Enabled = False

txtLoaixera.Enabled = False txtSoxevao.Text = " Xe vao" CmdLuuVao.Enabled = False CmdLuuRa.Enabled = False cmdBoqua.Enabled = False Dim i As Integer For i = 1 To 4 Me.CmbLoaixevao.AddItem i Next i '---' MSComm1.CommPort = 1 MSComm1.Settings = "9600,N,8,1" MSComm1.InputLen = 0 MSComm1.RThreshold = 11 MSComm1.InputMode = comInputModeBinary MSComm1.PortOpen = True OPENPORT.Enabled = True CLOSEPORT.Enabled = False Timer18.Enabled = True End Sub

Private Sub OpenPort_Click()

If MSComm1.PortOpen = True Then MSComm1.PortOpen = False End If MSComm1.PortOpen = True Timer18.Enabled = True Timer19.Enabled = True OPENPORT.Enabled = False CLOSEPORT.Enabled = True

Private Sub MSComm1_OnComm()

If MSComm1.InBufferCount >= 11 Then MSComm1.InputLen = 0 Nhan() = MSComm1.Input Dim i, j, k, l, m, n, o, p, q, r, s As Integer i = Nhan(0) j = Nhan(1) k = Nhan(2) l = Nhan(3) m = Nhan(4) n = Nhan(5) o = Nhan(6) p = Nhan(7) q = Nhan(8) r = Nhan(9) s = Nhan(10)

Text3.Text = o 'xe 4 cho Text4.Text = p 'xe 7 cho Text5.Text = q 'xe 12 cho Text6.Text = r 'xe 30 cho Text7.Text = s 'tong so xe If i = 1 Then 'mo cua vao Timer1.Enabled = True Cuavao.Text = " MỞ "

If XanhVao.Visible = False Then XanhVao.Visible = True TatXanhVao.Visible = False DoVao.Visible = False TatDoVao.Visible = True End If

CTraiVao.Width = CTraiVao.Width - 1 CPhaiVao.Width = CPhaiVao.Width - 1 CPhaiVao.Left = CPhaiVao.Left + 1

Loop Until CTraiVao.Width = 15 And CPhaiVao.Width = 15 End If

End If

If i = 2 Then 'dong cua vao Timer1.Enabled = True Cuavao.Text = " ĐĨNG " If XanhVao.Visible = True Then XanhVao.Visible = False TatXanhVao.Visible = True DoVao.Visible = True TatDoVao.Visible = False End If

If CTraiVao.Width = 15 And CPhaiVao.Width = 15 Then Do

CTraiVao.Width = CTraiVao.Width + 1 CPhaiVao.Width = CPhaiVao.Width + 1 CPhaiVao.Left = CPhaiVao.Left - 1

Loop Until CTraiVao.Width = 495 And CPhaiVao.Width = 495 End If

End If

If j = 1 Then 'mo cua ra Timer2.Enabled = True Cuara.Text = " MỞ " If XanhRa.Visible = False Then XanhRa.Visible = True TatXanhRa.Visible = False DoRa.Visible = False

End If

If CTraiRa.Width = 495 And CPhaiRa.Width = 495 Then Do

CTraiRa.Width = CTraiRa.Width - 1 CPhaiRa.Width = CPhaiRa.Width - 1 CPhaiRa.Left = CPhaiRa.Left + 1

Loop Until CTraiRa.Width = 15 And CPhaiRa.Width = 15 End If

End If

If j = 2 Then 'dong cua ra

Timer2.Enabled = True Cuara.Text = " ĐĨNG " If XanhRa.Visible = True Then XanhRa.Visible = False TatXanhRa.Visible = True DoRa.Visible = True TatDoRa.Visible = False End If

If CTraiRa.Width = 15 And CPhaiRa.Width = 15 Then Do

CTraiRa.Width = CTraiRa.Width + 1 CPhaiRa.Width = CPhaiRa.Width + 1 CPhaiRa.Left = CPhaiRa.Left - 1

Loop Until CTraiRa.Width = 495 And CPhaiRa.Width = 495 End If

End If

If k = 1 Then 'bai xe trong Timer3.Enabled = True

TTrang.Text = " TRỐNG XE " If XanhTrong.Visible = False Then

TatXanhTrong.Visible = False DoDay.Visible = False

TatDoDay.Visible = True End If

End If

If k = 2 Then 'bai xe day

Timer3.Enabled = True TTrang.Text = " ĐẦY XE " If XanhTrong.Visible = True Then XanhTrong.Visible = False TatXanhTrong.Visible = True DoDay.Visible = True TatDoDay.Visible = False End If End If

If l = 1 Then ' mo den chieu sang Timer5.Enabled = True HTDen.Text = " MỞ " If XanhDen.Visible = False Then XanhDen.Visible = True TatXanhDen.Visible = False DoDen.Visible = False TatDoDen.Visible = True End If End If

If l = 2 Then 'tat den chieu sang Timer5.Enabled = True HTDen.Text = " TẮT " If XanhDen.Visible = True Then XanhDen.Visible = False

DoDen.Visible = True TatDoDen.Visible = False End If End If If m = 1 Then CmbLoaixevao.Text = "1" End If If m = 2 Then CmbLoaixevao.Text = "2" End If If m = 3 Then CmbLoaixevao.Text = "3" End If If m = 4 Then CmbLoaixevao.Text = "4" End If If n = 1 Then txtLoaixera.Text = "1" End If If n = 2 Then txtLoaixera.Text = "2" End If If n = 3 Then txtLoaixera.Text = "3" End If If n = 4 Then txtLoaixera.Text = "4" End If End Sub

Dim gio1 As Integer Dim phut1 As Integer Dim tam1 As Integer Dim tam2 As Integer Dim tam3 As Integer Dim gio2 As Integer Dim phut2 As Integer Dim gio3 As Integer Dim phut3 As Integer Dim Gia As Double

sqlXera = "select [so xe], [loai xe] from chitiet where [so xe] like '" & CmbXera.Text & "' and [loai xe] like '" & txtLoaixera.Text & "' "

Set rsCapnhatXera = LayDL(sqlXera)

If (rsCapnhatXera.BOF = True And rsCapnhatXera.EOF = True) Then MsgBox ("Khong co so xe nay, hay chon trong combo so xe!") Else

rsCapnhatXera.MoveFirst sqlXera = "select * from chitiet" Set rsCapnhatXera = LayDL(sqlXera)

sqlXera = "select stt from chitiet where [so xe] = '" & Soxe & "' and [loai xe]='" & Loaixe & "' "

sott = rsCapnhatXera.Fields(0) Soxe = CmbXera.Text

Loaixe = txtLoaixera.Text

sqlXera = "UPDATE chitiet SET [ngay ra] = '" & Date & _

"' WHERE [loai xe] = '" & Loaixe & "' and [so xe] = '" & Soxe & "'" 'and [stt] = '" & Val(sott) & "' "

Set rsCapnhatXera = LayDL(sqlXera)

sqlXera = "UPDATE chitiet SET [gio ra] = '" & Time & _

Set rsCapnhatXera = LayDL(sqlXera)

sqlXera = "select [gio vao] from chitiet where [so xe] = '" & Soxe & "' and [loai xe] = '" & Loaixe & "'" 'and [stt] = '" & Val(sott) & "' "

Set rsCapnhatXera = LayDL(sqlXera) gio1 = (Hour(rsCapnhatXera![gio vao])) phut1 = (Minute(rsCapnhatXera![gio vao])) gio2 = Hour(Time)

phut2 = Minute(Time) gio3 = gio2 - gio1 phut3 = phut2 - phut1 tam1 = gio1 * 60 + phut1 tam2 = gio2 * 60 + phut2 tam3 = tam2 - tam1 gio3 = tam3 / 60

phut3 = tam3 - (gio3 * 60) thoigian = gio3 & " :" & phut3

sqlXera = "UPDATE chitiet SET [thoi gian goi (gio)] = '" & thoigian & _ "' WHERE [loai xe] = '" & Loaixe & "' and [so xe] = '" & Soxe & "'" 'and [stt] = '" & Val(sott) & "'" 'and [gio vao] = '" & giovao & "' "

Set rsCapnhatXera = LayDL(sqlXera)

sqlPhanloaixe = "select [gia tien (vnd/gio)] from phanloaixe where loai = '" & Loaixe & "'" 'and [stt] = '" & Val(sott) & "' "

Set rsPhanloaixe = LayDL(sqlPhanloaixe) Gia = rsPhanloaixe![gia tien (vnd/gio)] If Val(gio3 = 0) And Val(phut3) < 30 Then gio3 = 1

thanhtien = Val(Gia) * Val(gio3) End If

If (Val(phut3) > 15) And Val(gio3 > 0) Then thanhtien = Val(Gia) * (Val(gio3) + 1)

thanhtien = Val(Gia) * Val(gio3) End If

sqlXera = "UPDATE chitiet SET [thanh tien (vnd)]= '" & Val(thanhtien) & "' WHERE [loai xe] = '" & Loaixe & "' and [so xe] = '" & Soxe & "'" 'and [stt] = '" & Val(sott) & "' " 'and [gio vao] = '" & giovao & "' "

Set rsCapnhatXera = LayDL(sqlXera) soxe1 = Soxe

loaixe1 = Loaixe

sqlXera = "select [gio vao] from chitiet where [so xe] = '" & Soxe & "' and [loai xe] = '" & Loaixe & "'" 'and [stt] = '" & Val(sott) & "' "

Set rsCapnhatXera = LayDL(sqlXera) giovao1 = rsCapnhatXera![gio vao]

sqlXera = "select [ngay vao] from chitiet where [so xe] = '" & Soxe & "' and [loai xe] = '" & Loaixe & "'" 'and [stt] = '" & Val(sott) & "' "

Set rsCapnhatXera = LayDL(sqlXera) ngayvao1 = rsCapnhatXera![ngay vao] thoigian1 = thoigian thanhtien1 = thanhtien Load Form4 Form4.Show End If End Sub

Private Sub TIEP_Click() Load Form3 Form3.Show End Sub

Private Sub Thoat2_Click() Unload Me

End Sub

End Sub

Private Sub Timer7_Timer() Dim X, Y

X = Right(FORM2.Caption, 1)

Y = Left(FORM2.Caption, Len(FORM2.Caption) - 1) FORM2.Caption = X + Y

End Sub

Private Sub Timer8_Timer() Tgian.Caption = Time End Sub

Private Sub Timer9_Timer() Ngay.Caption = Date End Sub

Private Sub Timer16_Timer() Dim U As String Dim V As String U = Left(Label2.Caption, 1) V = Right(Label2.Caption, Len(Label2.Caption) - 1) Label2.Caption = V + U End Sub

Private Sub Form_Unload(Cancel As Integer) Set rsLuuDL = Nothing

cnn.Close End Sub

Private Sub Timervao_Timer()

If lbxevao.ForeColor = vbBlue Then lbxera.ForeColor = vbRed Else lbxevao.ForeColor = vbBlue

End Sub

Private Sub XOA_Click() Load Form4

End Sub

Private Function kiemtra() As Integer If (Me.txtSoxevao.Text = "") Then kiemtra = 1 Exit Function End If If (Me.CmbLoaixevao.Text = "") Then kiemtra = 2 Exit Function End If

If Len(Me.txtSoxevao.Text) > 7 Or Len(Me.txtSoxevao.Text) < 7 Then kiemtra = 3

Exit Function End If

If Len(Me.CmbLoaixevao.Text) < 1 Or Len(Me.CmbLoaixevao.Text) > 1 Then kiemtra = 4 Exit Function Else kiemtra = 0 End If End Function

Code Form Cơ sở dữ liệu

Option Explicit Dim sql As String Dim str1 As String

Public rs1 As New ADODB.Recordset

Public rsCapnhatXe As New ADODB.Recordset Dim sqlCapnhat As String

Dim Loaixe As String Dim ngayvao As Date Dim giovao As String Dim ngayra As Date Dim giora As String '---

Private Sub cbSoxe_Click() Soxe = cbSoxe.Text rsCapnhatXe.MoveFirst

rsCapnhatXe.Find "[so xe] = '" & Soxe & "'", , , adBookmarkFirst If Not rsCapnhatXe.EOF Then

txtStt.Text = rsCapnhatXe.Fields(0) DTPNgayvao.Value = rsCapnhatXe.Fields(3) txtGiovao.Text = rsCapnhatXe.Fields(4) txtThoigian.Text = rsCapnhatXe.Fields(7) txtLoaixe.Text = rsCapnhatXe.Fields(1) DTPNgayra.Value = rsCapnhatXe.Fields(5) txtGiora.Text = rsCapnhatXe.Fields(6) txtThanhtien.Text = rsCapnhatXe.Fields(8) End If End Sub

Private Sub CmdTim_Click()

OptSoxe.Visible = True OptLoaixe.Visible = True OptNgayvao.Visible = True OptNgayra.Visible = True If (OptSoxe) Then

str1 = "select * from chitiet where [so xe] like '" & cbSoxe.Text & "'" Set rs1 = LayDL(str1)

Call XUATBANGCHITIETXETIM(cbSoxe.Text) Else

If (OptNgayvao = True) Then

str1 = "select * from chitiet where [ngay vao] like '" & DTPNgayvao.Value & "'" Set rs1 = LayDL(str1)

rs1.Sort = "stt ASC"

Call XUATBANGCHITIETXETIM(DTPNgayvao.Value) Else

If (OptLoaixe = True) Then

str1 = "select * from chitiet where [loai xe] like '" & txtLoaixe.Text & "'" Set rs1 = LayDL(str1)

rs1.Sort = "stt ASC"

Call XUATBANGCHITIETXETIM(txtLoaixe.Text) Else

str1 = "select * from chitiet where [ngay ra] like '" & DTPNgayra.Value & "'" Set rs1 = LayDL(str1) rs1.Sort = "stt ASC" Call XUATBANGCHITIETXETIM(DTPNgayra.Value) End If End If End If End Sub

Private Sub cmdTimkiem_Click() OptSoxe.Visible = True OptLoaixe.Visible = True OptNgayvao.Visible = True OptNgayra.Visible = True txtLoaixe.Enabled = False DTPNgayvao.Enabled = False

cbSoxe.Enabled = False CmdTimkiem.Visible = False CmdTim.Visible = True cmdXoa.Visible = False CmdTimXoa.Visible = True lbStt.Visible = False LbGiovao.Visible = False LbThoigiangoi.Visible = False lbGiora.Visible = False LbThanhtien.Visible = False txtStt.Visible = False txtGiovao.Visible = False txtThoigian.Visible = False txtGiora.Visible = False txtThanhtien.Visible = False End Sub

Private Sub CmdTimXoa_Click()

CmdTimkiem.Visible = True cmdXoa.Visible = True CmdTimkiem.Visible = True CmdTim.Visible = False lbStt.Visible = True LbGiovao.Visible = True LbThoigiangoi.Visible = True lbGiora.Visible = True LbThanhtien.Visible = True txtStt.Visible = True txtGiovao.Visible = True txtThoigian.Visible = True

txtThanhtien.Visible = True OptSoxe.Visible = False OptLoaixe.Visible = False OptNgayvao.Visible = False OptNgayra.Visible = False End Sub

Private Sub cmdXoa_Click() Dim sql As String

Dim rs1 As New ADODB.Recordset Dim vitri As Integer

OptSoxe.Visible = False OptLoaixe.Visible = False OptNgayvao.Visible = False OptNgayra.Visible = False

sql = "select * from chitiet where [so xe]= '" & Soxe & "'"

Set rs1 = LayDL(sql)

If (rs1.BOF = True And rs1.EOF = True) Then

MsgBox ("Khong co so xe nay, hay chon trong combo so xe!") Else

If MsgBox("Ban co chac la xoa khong ?", vbYesNo) = vbYes Then rsCapnhatXe.Find "[so xe] = '" & Soxe & "'", , , adBookmarkFirst rsCapnhatXe.Delete LuuDL rsCapnhatXe vitri = cbSoxe.ListIndex cbSoxe.RemoveItem vitri cbSoxe.Refresh Call XUATBANGCHITIETXE End If End If

End Sub

Private Sub MSHFlexGridChitiet_Click() MSHFlexGridChitiet.Refresh Dim sql As String

Dim rs1 As New ADODB.Recordset

txtStt.Text = MSHFlexGridChitiet.MouseRow

Set rs1 = Nothing

End Sub

Private Sub OptLoaixe_Click()

txtLoaixe.Enabled = True DTPNgayvao.Enabled = False DTPNgayra.Enabled = False cbSoxe.Enabled = False txtLoaixe.Locked = False End Sub

Private Sub OptNgayra_Click()

txtLoaixe.Enabled = False DTPNgayvao.Enabled = False DTPNgayra.Enabled = True cbSoxe.Enabled = False End Sub

Private Sub OptNgayvao_Click() txtLoaixe.Enabled = False DTPNgayvao.Enabled = True DTPNgayra.Enabled = False cbSoxe.Enabled = False

Private Sub OptSoxe_Click() txtLoaixe.Enabled = False DTPNgayvao.Enabled = False DTPNgayra.Enabled = False cbSoxe.Enabled = True End Sub

Private Sub THOAT_Click() End

rs1.Close End Sub

Private Sub TROVE_Click() Unload Me End Sub

Private Sub Form_Load()

OptSoxe.Visible = False OptLoaixe.Visible = False OptNgayvao.Visible = False OptNgayra.Visible = False txtStt.Locked = False cbSoxe.Locked = False DTPNgayvao.Enabled = True DTPNgayra.Enabled = True txtThoigian.Locked = True txtThanhtien.Locked = True txtLoaixe.Locked = True txtGiora.Locked = True txtGiovao.Locked = True CmdTim.Visible = False

txtStt.Text = rsCapnhatXe.Fields(0) txtLoaixe.Text = rsCapnhatXe.Fields(1) DTPNgayvao.Value = rsCapnhatXe.Fields(3) txtGiovao.Text = rsCapnhatXe.Fields(4) txtGiora.Text = rsCapnhatXe.Fields(6) DTPNgayra.Value = rsCapnhatXe.Fields(5) txtThoigian.Text = rsCapnhatXe.Fields(7) txtThanhtien.Text = rsCapnhatXe.Fields(8) cbSoxe.Text = rsCapnhatXe.Fields(2) sqlCapnhat = "select * from chitiet" Set rsCapnhatXe = LayDL(sqlCapnhat) If rsCapnhatXe.RecordCount > 0 Then

rsCapnhatXe.MoveFirst Do While Not rsCapnhatXe.EOF

cbSoxe.AddItem rsCapnhatXe.Fields(2) rsCapnhatXe.MoveNext Loop End If Call XUATBANGCHITIETXE End Sub

Private Sub Form_Unload(Cancel As Integer)

MSHFlexGridChitiet.Refresh

Set rsCapnhatXe = Nothing Set rs1 = Nothing

End Sub

Private Sub XUATBANGCHITIETXETIM(thamso As String) Dim i As Integer

Dim soluong As Integer soluong = 0

Mang(0) = "STT" Mang(1) = "LOẠI XE" Mang(2) = "SỐ XE" Mang(3) = "NGÀY VÀO" Mang(4) = "GIỜ VÀO" Mang(5) = "NGÀY RA" Mang(6) = "GIỜ RA"

Mang(7) = "THỜI GIAN GỬI (GIỜ) Mang(8) = "THÀNH TIỀN (VNĐ)" While Not rs1.EOF

soluong = soluong + 1 rs1.MoveNext

Wend

MSHFlexGridChitiet.Rows = soluong + 1 MSHFlexGridChitiet.Cols = 9

If (rs1.BOF = True And rs1.EOF = True) Then MsgBox ("Co so du lieu rong!")

Else rs1.MoveFirst End If For i = 0 To 8 MSHFlexGridChitiet.Row = 0 MSHFlexGridChitiet.Col = i MSHFlexGridChitiet.Text = Mang(i) Next i i = 1 rs1.Sort = " stt asc"

While Not rs1.EOF

MSHFlexGridChitiet.Row = i MSHFlexGridChitiet.Col = 0

MSHFlexGridChitiet.Text = rs1.Fields(0) MSHFlexGridChitiet.Col = 1

MSHFlexGridChitiet.ColWidth(1) = 900 MSHFlexGridChitiet.Text = rs1![loai xe] MSHFlexGridChitiet.Col = 2

MSHFlexGridChitiet.ColWidth(2) = 1000 MSHFlexGridChitiet.Text = rs1![so xe] MSHFlexGridChitiet.Col = 3

MSHFlexGridChitiet.ColWidth(3) = 1200 MSHFlexGridChitiet.Text = rs1![ngay vao] MSHFlexGridChitiet.Col = 4

MSHFlexGridChitiet.ColWidth(4) = 1000 MSHFlexGridChitiet.Text = rs1![gio vao] MSHFlexGridChitiet.Col = 5

MSHFlexGridChitiet.ColWidth(5) = 1200 MSHFlexGridChitiet.Text = rs1![ngay ra] MSHFlexGridChitiet.Col = 6

MSHFlexGridChitiet.ColWidth(6) = 900 MSHFlexGridChitiet.Text = rs1![gio ra] MSHFlexGridChitiet.Col = 7 MSHFlexGridChitiet.ColWidth(7) = 1500 MSHFlexGridChitiet.Text = rs1.Fields(7) MSHFlexGridChitiet.Col = 8 MSHFlexGridChitiet.ColWidth(8) = 1800 MSHFlexGridChitiet.Text = rs1.Fields(8) i = i + 1 rs1.MoveNext Wend Set rs1 = LayDL(str1) End Sub

Dim i As Integer

Dim soluong As Integer

str1 = "select * from chitiet " Set rs1 = LayDL(str1) soluong = 0

Dim Mang(9) As String Mang(0) = "STT" Mang(1) = "LOẠI XE" Mang(2) = "SỐ XE" Mang(3) = "NGÀY VÀO" Mang(4) = "GIỜ VÀO" Mang(5) = "NGÀY RA" Mang(6) = "GIỜ RA"

Mang(7) = "THỜI GIAN GỬI (GIỜ)" Mang(8) = "THÀNH TIỀN (VNĐ)" While Not rs1.EOF

soluong = soluong + 1 rs1.MoveNext Wend MSHFlexGridChitiet.Rows = soluong + 1 MSHFlexGridChitiet.Cols = 9 rs1.MoveFirst For i = 0 To 8 MSHFlexGridChitiet.Row = 0 MSHFlexGridChitiet.Col = i MSHFlexGridChitiet.Text = Mang(i) Next i i = 1 rs1.Sort = " stt asc" While Not rs1.EOF

MSHFlexGridChitiet.Col = 0

MSHFlexGridChitiet.ColWidth(0) = 500 MSHFlexGridChitiet.Text = rs1.Fields(0) MSHFlexGridChitiet.Col = 1

MSHFlexGridChitiet.ColWidth(1) = 900 MSHFlexGridChitiet.Text = rs1![loai xe] MSHFlexGridChitiet.Col = 2

MSHFlexGridChitiet.ColWidth(2) = 1000 MSHFlexGridChitiet.Text = rs1![so xe] MSHFlexGridChitiet.Col = 3

MSHFlexGridChitiet.ColWidth(3) = 1200 MSHFlexGridChitiet.Text = rs1![ngay vao] MSHFlexGridChitiet.Col = 4

MSHFlexGridChitiet.ColWidth(4) = 1000 MSHFlexGridChitiet.Text = rs1![gio vao] MSHFlexGridChitiet.Col = 5

MSHFlexGridChitiet.ColWidth(5) = 1200 MSHFlexGridChitiet.Text = rs1![ngay ra] MSHFlexGridChitiet.Col = 6

MSHFlexGridChitiet.ColWidth(6) = 900 MSHFlexGridChitiet.Text = rs1![gio ra] MSHFlexGridChitiet.Col = 7 MSHFlexGridChitiet.ColWidth(7) = 1500 MSHFlexGridChitiet.Text = rs1.Fields(7) MSHFlexGridChitiet.Col = 8 MSHFlexGridChitiet.ColWidth(8) = 1800 MSHFlexGridChitiet.Text = rs1.Fields(8) i = i + 1 rs1.MoveNext Wend

End Sub

Code Form Phiếu thu :

Dim So As Integer Dim tam As Integer Private Sub CmdIn_Click()

MsgBox "Da thu tien!" End Sub

Private Sub Form_Load()

lbNgay.Caption = Date

So = 0

If (So < tam) Then

LbSo.Caption = tam + 1 Else So = 1 LbSo.Caption = So End If LbSoxe.Caption = soxe1 LbLoaixe.Caption = loaixe1 LbNgaygui.Caption = ngayvao1 LbGiogui.Caption = giovao1 Lbthoigian.Caption = thoigian1 LbThanhtien.Caption = thanhtien1 tam = So End Sub Code Form Cập nhật :

Dim sqlPhanloaixe As String

Dim rsPhanloaixe As New ADODB.Recordset Dim sqlCapnhatPhanloai As String

Dim rsXoa As New ADODB.Recordset Dim sql As String

Dim rsxe As New ADODB.Recordset Dim kiemtra As Integer

Private Sub cmdCapnhat_Click() kiemtra = 2 cmdLuu.Visible = True cmdThem.Visible = False cmdCapnhat.Enabled = False cmdXoa.Enabled = False txtLoaixe.Enabled = False txtChitietxe.Locked = False txtGiatien.Locked = False End Sub

Private Sub cmdLuu_Click() Dim str As String

Một phần của tài liệu Luận văn: Thiết kế hệ thống bãi giữ xe ôtô tự động pot (Trang 72 - 111)

Tải bản đầy đủ (PDF)

(126 trang)