Thursday, June 9, 2011

TUGAS VB : KASUS "PENJUALAN TIKET BUS"

1. Normalisasi Data

1. Normalisasi data
Normalisasi merupakan proses pengelompokkan elemen data menjadi table-tabel yang menunjukkan entity dan relasinya
Normalisasi adalah proses pengelompokan attribute attribute dari suatu relasi sehingga membentuk WELL STRUCTURE RELATION.






Step 1 Unnormalized





Notrans Kode Jnsbus qty no_penumpang
F001 BUS04 AC 2 PEN01
F002 BUS01 AC 2 PEN02
F003 BUS05 AC 1 PEN03






Step 2 bentuk 1NF






Notrans Kode Jnsbus qty no_penumpang
F001 BUS04 AC 1 PEN01
F001 BUS04 AC 1 PEN01
F002 BUS01 AC 1 PEN02
F002 BUS01 AC 1 PEN02
F003 BUS05 AC 1 PEN03







Step 3 bentuk 2NF





2. Spesifikasi File

A. Table Bus



B. Table Penumpang




C. Table Transaksi



Ketentuan :

1.Jika jenis bus yang dipilih adalah AC , maka tarif bus dikenakan biaya tambahan sebesar Rp. 20000 .
2.Jika jenis bus yang dipilih adalah NON AC , maka tarif bus tidak akan dikenakan biaya tambahan .



3. Rancangan Form dan Menu utama

A. Form Login


Listing :


Private Sub bsign_Click()
Form4.Show
End Sub

Private Sub Form_Activate()
tuser.Enabled = True
tpass.Enabled = True
tuser.SetFocus
End Sub


B. Form Master Bus



Listing :

Dim isidetail As Boolean

Private Sub bprint_Click()
crybus.Action = 1
End Sub

Private Sub cadd_Click()
bersih
aktif
tkode.SetFocus
End Sub

Private Sub ccancel_Click()
bersih
nonaktif
End Sub

Private Sub ccari_Click()
With adobus.Recordset
.Find "kode='" & tkode & "'"
If .BOF And .EOF Then
MsgBox "THE CODE" + tkobus + "IS NOT EXIST", 34, "INFO"
tkobus = ""
tkobus.SetFocus
Else
adobus.Refresh
tkobus = adobus.Recordset.Fields("kode")
tnabus = adobus.Recordset.Fields("nm_bus")
tnabus.SetFocus
End If
End With
End Sub

Private Sub cdel_Click()
If Len(Trim(tkode.Text)) = "" Then
Exit Sub
End If
t = MsgBox("DO YOU REALLY WANT TO DELETE THE RECORD?", 32 + 4, "ASK")
If t = vbYes Then
adobus.Recordset.Delete
bersih
Else
bersih
End If
End Sub

Private Sub cedit_Click()
isibus = False
aktif
tnama.SetFocus
cadd.Enabled = False
cdel.Enabled = False
cedit.Enabled = False
csave.Enabled = True
ccancel.Enabled = True
End Sub

Private Sub cexit_Click()
End
End Sub

Sub bersih()
ttgl = ""
tjam = ""
tkode = ""
tnama = ""
tnasup = ""
tjurusan = ""
ttarif = ""
End Sub

Sub aktif()
ttgl.Enabled = True
tjam.Enabled = True
tkode.Enabled = True
tnama.Enabled = True
tnasup.Enabled = True
tjurusan.Enabled = True
ttarif.Enabled = True
cadd.Enabled = True
csave.Enabled = True
ccancel.Enabled = True
cedit.Enabled = True
cdel.Enabled = True
cfirst.Enabled = True
cprev.Enabled = True
cnext.Enabled = True
clast.Enabled = True
bprint.Enabled = True
cexit.Enabled = True
ttgl = Date
tjam = Time()
End Sub

Sub nonaktif()
ttgl.Enabled = False
tjam.Enabled = False
tkode.Enabled = False
tnama.Enabled = False
tnasup.Enabled = False
tjurusan.Enabled = False
ttarif.Enabled = False
cadd.Enabled = True
csave.Enabled = False
ccancel.Enabled = False
cedit.Enabled = False
cdel.Enabled = False
cfirst.Enabled = False
cprev.Enabled = False
cnext.Enabled = False
clast.Enabled = False
bprint.Enabled = False
cexit.Enabled = False
End Sub

Private Sub cfirst_Click()
tkode.Enabled = False
adobus.Recordset.MoveFirst
tampildata
MsgBox "ALREADY EXIST IN THE FIRST RECORD", 64, "INFO"
cedit.Enabled = True
cadd.Enabled = True
cdel.Enabled = True
cedit.SetFocus
End Sub

Private Sub clast_Click()
tkode.Enabled = False
adobus.Recordset.MoveLast
tampildata
MsgBox "ALREADY EXIST IN THE LAST RECORD", 64, "INFO"
cedit.Enabled = True
cadd.Enabled = True
cdel.Enabled = True
cedit.SetFocus
End Sub

Private Sub cnext_Click()
tkode.Enabled = False
adobus.Recordset.MoveNext
If adobus.Recordset.EOF Then
MsgBox "ALREADY EXIST IN THE LAST RECORD", 48, "INFO"
adobus.Recordset.MoveLast
End If
tampildata
cedit.Enabled = True
cadd.Enabled = True
cdel.Enabled = True
cedit.SetFocus
End Sub

Private Sub cprev_Click()
tkode.Enabled = False
adobus.Recordset.MovePrevious
If adobus.Recordset.BOF Then
MsgBox "ALREADY EXIST IN THE FIRST RECORD", 48, "INFO"
adobus.Recordset.MoveFirst
End If
tampildata
cedit.Enabled = True
cadd.Enabled = True
cdel.Enabled = True
cedit.SetFocus
End Sub

Private Sub csave_Click()
On Error Resume Next
With adobus.Recordset
If isibus = True Then 'SIMPAN JIKA DATA BELUM ADA
.AddNew
.Fields("kode") = tkode
.Fields("nm_bus") = tnama
.Fields("nasup") = tnasup
.Fields("jurusan") = tjurusan
.Fields("tarif") = ttarif
.Update
Else 'JIKA DATA YANG ADA DIPERBAHARUI
.AddNew
.Fields("kode") = tkode
.Fields("nm_bus") = tnama
.Fields("nasup") = tnasup
.Fields("jurusan") = tjurusan
.Fields("tarif") = ttarif
.Update
End If
End With
adobus.RecordSource = "select*from table_bus"
adobus.Refresh
adobus.Refresh
On Error GoTo 0
End Sub

Private Sub Form_Activate()
nonaktif
ttgl = Date
tjam = Time()
End Sub

Sub tampildata()
tkode = adobus.Recordset.Fields("kode")
tnama = adobus.Recordset.Fields("nm_bus")
tnasup = adobus.Recordset.Fields("nasup")
tjurusan = adobus.Recordset.Fields("jurusan")
ttarif = adobus.Recordset.Fields("tarif")
End Sub





Private Sub tkode_KeyPress(KeyAscii As Integer)
KeyAscii = Asc(UCase(Chr(KeyAscii))) 'HURUF KAPITAL
If KeyAscii = 13 Then
adobus.RecordSource = "select*from table_bus where kode='" & tkode & "'"
adobus.Refresh
With adobus.Recordset
If .BOF And .EOF Then
t = MsgBox("THE CODE" & tkode & "IS NOT EXIST, DO YOU WANT TO ADD THE CODE?", vbYesNo + vbQuestion, "CONFIRM")
If t = vbYes Then
isibus = True
Call aktif
tnama.SetFocus
grid1.Refresh
Else
Call nonaktif
End If
Else
MsgBox "THE CODE" & tkode & "IS ALREADY EXIST", vbQuestion, "FOUND"
tampildata
tkode.Enabled = False
End If
End With
End If
End Sub


C. Form Master Penumpang



Listing :

Dim isipen As Boolean

Sub bersih()
tno = ""
tnapen = ""
talamat = ""
ttelp = ""
End Sub

Sub aktif()
tno.Enabled = True
tnapen.Enabled = True
talamat.Enabled = True
ttelp.Enabled = True
cadd.Enabled = True
csave.Enabled = True
ccancel.Enabled = True
cprint.Enabled = True
cexit.Enabled = True
End Sub

Sub nonaktif()
tno.Enabled = False
tnapen.Enabled = False
talamat.Enabled = False
ttelp.Enabled = False
cadd.Enabled = True
csave.Enabled = False
ccancel.Enabled = False
cprint.Enabled = False
cexit.Enabled = False
End Sub

Sub tampildata()
adopen.Recordset.Fields ("no_penumpang")
adopen.Recordset.Fields ("nm_penumpang")
adopen.Recordset.Fields ("alamat")
adopen.Recordset.Fields ("notelp")
End Sub

Private Sub cadd_Click()
bersih
aktif
tno.SetFocus
End Sub

Private Sub ccancel_Click()
bersih
nonaktif
End Sub

Private Sub cexit_Click()
End
End Sub

Private Sub cprint_Click()
crypen.Action = 1
End Sub

Private Sub csave_Click()
On Error Resume Next
With adopen.Recordset
If isipen = True Then 'SAVE RECORD IF IT'S NOT EXIST
.AddNew
.Fields("no_penumpang") = tno
.Fields("nm_penumpang") = tnapen
.Fields("alamat") = talamat
.Fields("notelp") = ttelp
.Update
Else 'RENEW RECORD
.AddNew
.Fields("no_penumpang") = tno
.Fields("nm_penumpang") = tnapen
.Fields("alamat") = talamat
.Fields("notelp") = ttelp
.Update
End If
End With
adopen.RecordSource = "select*from table_penumpang"
adopen.Refresh
On Error GoTo 0
End Sub

Private Sub Form_Activate()
bersih
nonaktif
End Sub


C. FORM MASTER TRANSAKSI



Listing :

Dim isidetail As Boolean
Sub bersih()
ckode = ""
tqty = ""
ttambahan = ""
ttarif = ""
ttobay = ""

tnopen = ""
tubay = ""
tukem = ""
End Sub
Sub aktif()
tnotrans.Enabled = True

tqty.Enabled = True
ttarif.Enabled = True
ttobay.Enabled = True
ttambahan.Enabled = True
ttgltrans.Enabled = True

oac.Enabled = True
onon.Enabled = True
tubay.Enabled = True
tukem.Enabled = True
ttgl.Enabled = True
tjam.Enabled = True
cadd.Enabled = True
csave.Enabled = True
cedit.Enabled = True
ccancel.Enabled = True
cexit.Enabled = True
cprint.Enabled = True
End Sub
Sub nonaktif()
tnotrans.Enabled = False
tqty.Enabled = False
ttarif.Enabled = True
ttobay.Enabled = False
ttobay.Enabled = False
ttgltrans.Enabled = False
oac.Enabled = False
onon.Enabled = False
ttambahan.Enabled = False
tubay.Enabled = False
tukem.Enabled = False
tjam.Enabled = False
ttgl.Enabled = False
cadd.Enabled = True
csave.Enabled = False
cedit.Enabled = False
ccancel.Enabled = False
cexit.Enabled = False
cprint.Enabled = False
End Sub
Sub tampildata()
tnotrans.Text = adodetail.Recordset.Fields("notrans")
tkode.Text = adodetail.Recordset.Fields("kode")
tqty.Text = adodetail.Recordset.Fields("qty")
ttambahan.Text = adodetail.Recordset.Fields("tambahan")
ttarif.Text = adodetail.Recordset.Fields("tarif")
ttobay.Text = adodetail.Recordset.Fields("tobay")
ttgltrans.Text = adodetail.Recordset.Fields("tgltrans")
tnopen.Text = adodetail.Recordset.Fields("no_penumpang")
tubay.Text = adodetail.Recordset.Fields("ubay")
tukem.Text = adodetail.Recordset.Fields("ukem")
End Sub

Private Sub cadd_Click()
aktif
bersih
ttgltrans.SetFocus
End Sub
Private Sub ccancel_Click()
bersih
nonaktif
End Sub
Private Sub cedit_Click()
isidetail = False
aktif
tnotrans.SetFocus
cadd.Enabled = False
cedit.Enabled = False
csave.Enabled = True
ccancel.Enabled = True
End Sub

Private Sub cexit_Click()
End
End Sub

Private Sub ckode_Click()
If ckode.Text = "BUS01" Then
ttarif.Text = 150000
Else
If ckode.Text = "BUS02" Then
ttarif.Text = 300000
Else
If ckode.Text = "BUS03" Then
ttarif.Text = 350000
Else
If ckode.Text = "BUS04" Then
ttarif.Text = 130000
Else
ttarif.Text = 500000
End If
End If
End If
End If
End Sub

Private Sub cprint_Click()
crytrans.Action = 1
End Sub

Private Sub csave_Click()


With adodetail.Recordset
If isidetail = True Then 'simpan jika data belum ada
.AddNew
.Fields("notrans") = tnotrans.Text
.Fields("kode") = d1.Text
.Fields("qty") = tqty.Text
.Fields("tobay") = Val(ttobay.Text)
.Fields("tgltrans") = ttgltrans.Text
.Fields("no_penumpang") = d2.Text
If oac.Value = True Then
.Fields("jnsbus") = "AC"
Else
.Fields("jnsbus") = "NON"
End If

.Fields("tambahan") = ttambahan.Text
.Fields("tarif") = ttarif.Text
.Fields("ubay") = tubay.Text
.Fields("ukem") = tukem.Text
.Update
Else 'simpan jika data yang ada diperbaharui
.Fields("notrans") = tnotrans
.Fields("kode") = ckode
.Fields("qty") = tqty
.Fields("tobay") = Val(ttobay)
.Fields("tgltrans") = ttgltrans
.Fields("no_penumpang") = tnopen
.Fields("tambahan") = ttambahan
.Fields("tarif") = ttarif
.Fields("ubay") = tubay
.Fields("ukem") = tukem
.Update
End If
End With
MSHFlexGrid1.Refresh
adodetail.RecordSource = "select*from table_trans"
adodetail.Refresh
On Error GoTo 0
bersih

End Sub

Private Sub d1_Change()
adobus.RecordSource = "select * from table_bus"
adobus.Recordset.MoveFirst
Do While Not adobus.Recordset.EOF
If d1.Text = adobus.Recordset!kode Then
ttarif.Text = adobus.Recordset!tarif
Exit Sub
End If
adobus.Recordset.MoveNext
Loop


End Sub

Private Sub Form_Activate()
bersih
nonaktif
auto
ttgl.Text = Date
tjam.Text = Time()

isidetail = True
ttgltrans = Date
End Sub

Private Sub oac_Click()
If oac = True Then
onon.Enabled = False
ttambahan.Text = 20000
End If
tqty.SetFocus
End Sub

Private Sub onon_Click()
If onon = True Then
oac.Enabled = False
ttambahan.Text = 0
End If
End Sub





Private Sub tnotrans_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
ckode.SetFocus
End If
End Sub

Private Sub tqty_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
ttobay.Text = (Val(ttambahan.Text) + Val(ttarif.Text) * Val(tqty.Text))
tubay.SetFocus
End If
End Sub

Private Sub tubay_Change()
tukem.Text = Val(tubay.Text) - Val(ttobay.Text)
End Sub

Sub auto()
Dim urut As String * 4
Dim hitung As Integer
With adodetail.Recordset
If .RecordCount = 0 Then
tnotrans = "F" + "001"
Else
.MoveLast
urut = Val(Right(!notrans, 3))
hitung = urut + 1
If hitung < 10 Then tnotrans = "F" + "00" + Trim(Str(hitung)) Else tnotrans = "F" + Trim(Str(hitung)) End If End If End With End Sub D. Form Menu Utama



Listing :

Dim stri As String
Dim i

Private Sub Form_Load()
stri = "SELAMAT DATANG DI LOKET CAPCUS"
i = 0
End Sub

Private Sub Form_Unload(Cancel As Integer)
Do
Me.Top = Me.Top + 40
Me.Move , Me.Left, Me.Top
DoEvents
Loop Until Me.Top > Screen.Height - 500
Unload Me: End
End Sub





Private Sub lbus_Click()
crybus.Action = 1
End Sub

Private Sub lpen_Click()
crypen.Action = 1
End Sub

Private Sub ltrans_Click()
crytrans.Action = 1
End Sub

Private Sub tbus_Click()
Form1.Show
End Sub

Private Sub texit_Click()
End
End Sub

Private Sub tformtrans_Click()
Form3.Show
End Sub

Private Sub Timer1_Timer()
Me.Width = Me.Width + 400
If Me.Width >= 9000 Then
Timer1.Enabled = False
End If
End Sub

Private Sub Timer2_Timer()
Static a
a = a + 10:
If a > 200 Then
Label1.ForeColor = (Rnd * 255)
End If
End Sub

Private Sub tpen_Click()
Form2.Show
End Sub

4 comments:

Unknown said...

jalan ga programnya?

Anonymous said...

yang buat namanya siapa?

Unknown said...

minta projeknya boleh?

rr said...

minta projectnya boleh kak ?

Post a Comment

LOVEMYLIFE © 2008. Design by :Yanku Templates Sponsored by: Tutorial87 Commentcute