Anda di halaman 1dari 4

MATERI PRAKTEK LAB C-D MALAM FATMAWATI A

PERTEMUAN 14

TRANSAKSI ONE TO ONE

Buat Table Transaksi

Name Tipe
Size
Idfaktur Text 6
Tglfaktur Text
15
Id_menu Text 5
Jml Integer 4
Bayar Double 8

Build dengan nama transresto

Buat DBlist

Properties
Rowsource = Data1
ListField = Id_menu
DataSource = Data1
DataField = Id_menu
Buat Data1
RecordsetType=0 Table
Recordsource = menuresto
Buat Data2
RecordsetType=1 Dynaset
Recordsource = transresto

@ SIA VISUAL BASIC PRA UAS MEI 2010 FMA


MATERI PRAKTEK LAB C-D MALAM FATMAWATI A

Ketentuan Soal !

Form saat loading maka dalam keadaan NonAktif


Grid tidak dapat dirubah dan maxlength dari Idfaktur = 6 dan Id_menu = 5
Tanggal Faktur mengikuti tanggal system
Saat IdFaktur di enter fokus ke Id_menu
Id_menu di isi maka nama menu dan harga akan muncul
Dan berfokus pada Input Jumlah Beli
Buat Validasi Huruf Besar pada Id_menu dan data tidak boleh kosong
Bayar = harga * jumlahbeli
Jika uangbayar > bayar maka akan muncul pesan uang kembali sebesar ..?
Jika uangbayar < bayar muncul validasi message Box (“uang kurang”)
Dan akan tampil label kembalian
Command Add untuk tambah data dari awal dan berfokus pada Idfaktur
Command Cancel untuk membatalkan pengisian
Command Save untuk menyimpan data dan ada message jika berhasil disimpan
Command Exit untuk keluar dari form

Buat prosedure bersih,aktif ,non

Sub bersih( ) Sub aktif( ) Sub non( )


txtidfaktur = "" txtidfaktur.Enabled = txtidfaktur.Enabled =
TXTID_MENU = "" True False
TXTNAMA_MENU = txttgl.Enabled = True txttgl.Enabled = False
"" TXTID_MENU.Enabled TXTID_MENU.Enabled
txtharga = "" = True = False
txtjml = "" txtnama.Enabled = True txtnama.Enabled = False
txtbyr = "" txtharga.Enabled = True txtharga.Enabled = False
txtubay = "" txtjml.Enabled = True txtjml.Enabled = False
L_KEM.Caption = txtbyr.Enabled = True txtbyr.Enabled = False
"KEMBALI" txtubay.Enabled = True txtubay.Enabled = False
End Sub End Sub End Sub

Private Sub C_ADD_Click( )


bersih
aktif
txtidfaktur.SetFocus
End Sub

Private Sub C_CAN_Click( )


bersih
'txtidfaktur.SetFocus

@ SIA VISUAL BASIC PRA UAS MEI 2010 FMA


MATERI PRAKTEK LAB C-D MALAM FATMAWATI A

non
End Sub

Private Sub C_EXIT_Click( )


End
End Sub

Private Sub C_SAVE_Click( )


With Data2.Recordset
.AddNew
!idfaktur = txtidfaktur.Text
txttgl.Text = Date
!tglfaktur = txttgl.Text
!id_menu = TXTID_MENU.Text
!JML = txtjml.Text
!bayar = txtbyr.Text
.Update
On Error GoTo 0
End With
MsgBox "DATA TERSIMPAN", vbInformation, "INFO"
non
End Sub

Private Sub Form_Activate( )


txttgl = Date
TXTID_MENU.MaxLength = 5
txtidfaktur.MaxLength = 6
non
End Sub

Private Sub TXTID_MENU_KeyPress(KeyAscii As Integer)


KeyAscii = Asc(UCase(Chr(KeyAscii)))
If KeyAscii = 13 Then
Data1.Recordset.Index = "menudex"
Data1.Recordset.Seek "=", TXTID_MENU.Text

If Not Data1.Recordset.NoMatch Then


txtnama.Text = Data1.Recordset!nama_menu
txtharga.Text = Data1.Recordset!harga
txtjml.SetFocus
Else
MsgBox "Tak ada", vbInformation, "ok"
End If
End If
End Sub

@ SIA VISUAL BASIC PRA UAS MEI 2010 FMA


MATERI PRAKTEK LAB C-D MALAM FATMAWATI A

Private Sub txtidfaktur_KeyPress(KeyAscii As Integer)


If KeyAscii = 13 Then
If txtidfaktur.Text = "" Then
MsgBox "not kosong", vbInformation, "ok"
Else
TXTID_MENU.SetFocus
End If
End If
End Sub

Private Sub txtjml_KeyPress(KeyAscii As Integer)


If KeyAscii = 13 Then
txtbyr = Val(txtharga) * Val(txtjml)
txtubay.SetFocus
End If
End Sub

Private Sub txtubay_KeyPress(KeyAscii As Integer)


If KeyAscii = 13 Then
If Val(txtubay) > Val(txtbyr) Then
L_KEM.Caption = Val(txtubay) - Val(txtbyr)
MsgBox "KEMBALI= RP " + L_KEM, 64 + 0, "KMB"
ElseIf Val(txtubay) < Val(txtbyr) Then
MsgBox "kurang ", 64 + 0, "KMB"
txtubay = ""
txtubay.SetFocus
End If
End If
End Sub

@ SIA VISUAL BASIC PRA UAS MEI 2010 FMA

Anda mungkin juga menyukai