Setelah kita melihat contoh proram aplikasi penggajian PT HOYAMA memakai visual basic 6.0, selanjutnya kita melihat form data bonus.
Data Bonus ini dibentuk untuk menginput berapa besaran biaya honor bonus dan thr untuk karyawan beserta jumlah kali lipatnya. Misalnya untuk karyawan tetap besaran bonus yakni 5xlipat honor pokok dan untuk karyawan kontrak hanya 1xlipat honor pokok, begitu pula untuk THR (tunjangan hari raya).
Silahkan anda buat form menyerupai dibawah ini dengan name=formdatabonus
Catatan :
A. Buat tabel grid
B. Masukkan komponen crystal report
1. Buat Sub gres dengan nama sub aktif dan pastekan koding dibawah :
tkodebonus.Enabled = True
tnamabonus.Enabled = True
cgolongan.Enabled = True
tjklipat.Enabled = True
ctambah.Enabled = True
csimpan.Enabled = True
csunting.Enabled = True
cperbarui.Enabled = True
cbatal.Enabled = True
chapus.Enabled = True
ccari.Enabled = True
tcari.Enabled = True
ccetak.Enabled = True
tnamabonus.Enabled = True
cgolongan.Enabled = True
tjklipat.Enabled = True
ctambah.Enabled = True
csimpan.Enabled = True
csunting.Enabled = True
cperbarui.Enabled = True
cbatal.Enabled = True
chapus.Enabled = True
ccari.Enabled = True
tcari.Enabled = True
ccetak.Enabled = True
2. Buat Sub gres dengan nama sub nonaktif dan pastekan koding dibawah :
tkodebonus.Enabled = False
tnamabonus.Enabled = False
cgolongan.Enabled = False
tjklipat.Enabled = False
ctambah.Enabled = False
csimpan.Enabled = False
csunting.Enabled = False
cperbarui.Enabled = False
cbatal.Enabled = False
chapus.Enabled = False
ccari.Enabled = False
tcari.Enabled = False
ccetak.Enabled = False
tnamabonus.Enabled = False
cgolongan.Enabled = False
tjklipat.Enabled = False
ctambah.Enabled = False
csimpan.Enabled = False
csunting.Enabled = False
cperbarui.Enabled = False
cbatal.Enabled = False
chapus.Enabled = False
ccari.Enabled = False
tcari.Enabled = False
ccetak.Enabled = False
3. Buat Sub gres dengan nama sub tampil dan pastekan koding dibawah :
Call koneksi
rsdatabonus.Open "select*from tabelbonus", KON
Set grid1.DataSource = rsdatabonus
rsdatabonus.Open "select*from tabelbonus", KON
Set grid1.DataSource = rsdatabonus
4. Buat Sub gres dengan nama sub higienis dan pastekan koding dibawah :
tkodebonus.Text = Clear
tnamabonus.Text = Clear
cgolongan.Text = Clear
tjklipat.Text = Clear
tcari.Text = Clear
tnamabonus.Text = Clear
cgolongan.Text = Clear
tjklipat.Text = Clear
tcari.Text = Clear
5. Buat Sub gres dengan nama sub simpan dan pastekan koding dibawah :
Call koneksi
rsdatabonus.Open "insert into tabelbonus values('" & tkodebonus & "','" & tnamabonus & "','" & cgolongan & "','" & tjklipat & "')", KON
MsgBox "Data Sudah Tersimpan", vbInformation
Call tampil
Call bersih
Call nonaktif
ctambah.Enabled = True
ccari.Enabled = True
tcari.Enabled = True
rsdatabonus.Open "insert into tabelbonus values('" & tkodebonus & "','" & tnamabonus & "','" & cgolongan & "','" & tjklipat & "')", KON
MsgBox "Data Sudah Tersimpan", vbInformation
Call tampil
Call bersih
Call nonaktif
ctambah.Enabled = True
ccari.Enabled = True
tcari.Enabled = True
6. Buat Sub gres dengan nama sub perbarui dan pastekan koding dibawah :
Call koneksi
rsdatabonus.Open "update tabelbonus set namabonus='" & tnamabonus & "',golongan='" & cgolongan & "',kalilipat='" & tjklipat & "' where kodebonus='" & tkodebonus.Text & "'", KON
MsgBox "Data Berhasil di Update", vbInformation, "Info"
bersih
Call tampil
Call nonaktif
ctambah.Enabled = True
ccari.Enabled = True
tcari.Enabled = True
rsdatabonus.Open "update tabelbonus set namabonus='" & tnamabonus & "',golongan='" & cgolongan & "',kalilipat='" & tjklipat & "' where kodebonus='" & tkodebonus.Text & "'", KON
MsgBox "Data Berhasil di Update", vbInformation, "Info"
bersih
Call tampil
Call nonaktif
ctambah.Enabled = True
ccari.Enabled = True
tcari.Enabled = True
7. pastekan koding dibawah :
Private Sub Form_Load()
Me.Top = 100
Me.Left = 0
Me.Height = 7035
Me.Width = 8190
Call tampil
Call bersih
Call nonaktif
ctambah.Enabled = True
ccari.Enabled = True
tcari.Enabled = True
ccetak.Enabled = True
End Sub
Me.Top = 100
Me.Left = 0
Me.Height = 7035
Me.Width = 8190
Call tampil
Call bersih
Call nonaktif
ctambah.Enabled = True
ccari.Enabled = True
tcari.Enabled = True
ccetak.Enabled = True
End Sub
8. Double klik pada ctambah dan pastekan koding dibawah (declaration=click):
Call koneksi
Call bersih
Call aktif
rsdatabonus.Open "select*from tabelbonus order by kodebonus desc", KON
With rsdatabonus
If .BOF And .EOF Then
tkodebonus.Text = "B" + "01"
Else
tkodebonus.Text = "B" + Right(Str(Val(Right(.Fields("kodebonus"), 2)) + 101), 2)
End If
End With
tkodebonus.Enabled = False
tnamabonus.SetFocus
cbatal.Enabled = True
csunting.Enabled = False
cperbarui.Enabled = False
chapus.Enabled = False
Call tampil
cgolongan.Enabled = True
tjklipat.Enabled = True
ctambah.Enabled = False
Call bersih
Call aktif
rsdatabonus.Open "select*from tabelbonus order by kodebonus desc", KON
With rsdatabonus
If .BOF And .EOF Then
tkodebonus.Text = "B" + "01"
Else
tkodebonus.Text = "B" + Right(Str(Val(Right(.Fields("kodebonus"), 2)) + 101), 2)
End If
End With
tkodebonus.Enabled = False
tnamabonus.SetFocus
cbatal.Enabled = True
csunting.Enabled = False
cperbarui.Enabled = False
chapus.Enabled = False
Call tampil
cgolongan.Enabled = True
tjklipat.Enabled = True
ctambah.Enabled = False
9. Double klik pada csimpan dan pastekan koding dibawah (declaration=click):
If tkodebonus.Text = "" Or tnamabonus.Text = "" Or cgolongan.Text = "" Or tjklipat.Text = "" Then
MsgBox "Data Belum terisi semua", vbCritical
Else
Call simpan
End If
MsgBox "Data Belum terisi semua", vbCritical
Else
Call simpan
End If
10. Double klik pada csunting dan pastekan koding dibawah (declaration=click):
Call aktif
tkodebonus.Enabled = False
ctambah.Enabled = False
csimpan.Enabled = False
csunting.Enabled = False
chapus.Enabled = False
tkodebonus.Enabled = False
ctambah.Enabled = False
csimpan.Enabled = False
csunting.Enabled = False
chapus.Enabled = False
11. Double klik pada cperbarui dan pastekan koding dibawah (declaration=click):
If tkodebonus.Text = "" Or tnamabonus.Text = "" Or cgolongan.Text = "" Or tjklipat.Text = "" Then
MsgBox "Data Belum terisi semua", vbCritical
Else
Call perbarui
End If
MsgBox "Data Belum terisi semua", vbCritical
Else
Call perbarui
End If
12. Double klik pada chapus dan pastekan koding dibawah (declaration=click):
Call koneksi
a = MsgBox("Yakin Ingin Hapus Data ini?", vbQuestion + vbYesNo, "tanya")
If a = vbYes Then
rsdatabonus.Open "delete from tabelbonus where kodebonus='" & tcari.Text & "'", KON
MsgBox "Data telah terhapus", vbInformation
bersih
tcari.Text = ""
Call nonaktif
ctambah.Enabled = True
ccari.Enabled = True
tcari.Enabled = True
ccetak.Enabled = True
End If
Call tampil
a = MsgBox("Yakin Ingin Hapus Data ini?", vbQuestion + vbYesNo, "tanya")
If a = vbYes Then
rsdatabonus.Open "delete from tabelbonus where kodebonus='" & tcari.Text & "'", KON
MsgBox "Data telah terhapus", vbInformation
bersih
tcari.Text = ""
Call nonaktif
ctambah.Enabled = True
ccari.Enabled = True
tcari.Enabled = True
ccetak.Enabled = True
End If
Call tampil
13. Double klik pada cbatal dan pastekan koding dibawah (declaration=click):
Call bersih
Call nonaktif
ctambah.Enabled = True
ccari.Enabled = True
tcari.Enabled = True
ccetak.Enabled = True
Call nonaktif
ctambah.Enabled = True
ccari.Enabled = True
tcari.Enabled = True
ccetak.Enabled = True
14. Double klik pada ccari dan pastekan koding dibawah (declaration=click):
Call koneksi
rsdatabonus.Open "select*from tabelbonus where kodebonus='" & tcari.Text & "'", KON
If rsdatabonus.EOF Then
MsgBox "Data Tidak Ditemukan", vbCritical
Call bersih
tcari.SetFocus
Else
With rsdatabonus
tkodebonus.Text = .Fields("kodebonus")
tnamabonus.Text = .Fields("namabonus")
cgolongan.Text = .Fields("golongan")
tjklipat.Text = .Fields("kalilipat")
End With
Call nonaktif
tkodebonus.Enabled = False
csunting.Enabled = True
chapus.Enabled = True
cbatal.Enabled = True
End If
rsdatabonus.Open "select*from tabelbonus where kodebonus='" & tcari.Text & "'", KON
If rsdatabonus.EOF Then
MsgBox "Data Tidak Ditemukan", vbCritical
Call bersih
tcari.SetFocus
Else
With rsdatabonus
tkodebonus.Text = .Fields("kodebonus")
tnamabonus.Text = .Fields("namabonus")
cgolongan.Text = .Fields("golongan")
tjklipat.Text = .Fields("kalilipat")
End With
Call nonaktif
tkodebonus.Enabled = False
csunting.Enabled = True
chapus.Enabled = True
cbatal.Enabled = True
End If
15. Double klik pada ccetak dan pastekan koding dibawah (declaration=click):
cr.ReportFileName = "D:\Belajar MVB\databonus.rpt"
cr.WindowState = crptMaximized
cr.RetrieveDataFiles
cr.Action = 1
cr.WindowState = crptMaximized
cr.RetrieveDataFiles
cr.Action = 1
16. Double klik pada cgolongan dan pastekan koding dibawah (declaration=click):
tjklipat.SetFocus
Sumber http://www.hendrisetiawan.com