Setelah kita melihat contoh proram aplikasi penggajian PT HOYAMA memakai visual basic 6.0, selanjutnya kita melihat form data karyawan.
Data karyawan ini dimaksudkan untuk memisahkan departemen dan golongannya biar ketika penghitungan honor gampang yaitu hanya tinggal menginput nomor induk karyawan saja.
Silahkan anda menciptakan form dibawah ini dengan name=formkaryawan
Catatan :
A. Buat tabel grid
B. MAsukkan komponen crystal report
C. Tanggal Masuk memakai DTpicker
D. Anggota serikat, pada List (lihat properties) tambahkan Ya dan Tidak
E. Status kawin, pada List (lihat properties) tambahkan Ya dan Tidak
F. Shift, pada List (lihat properties) tambahkan Shift dan Nonshift
G. dibawah commandbutton hapus buat sebuah textbox dengan name=kodedd1, dan pada properties visible=false
1. Buat Sub gres dengan nama sub aktif dan pastekan koding dibawah :
tidkaryawan.Enabled = True
tnamakaryawan.Enabled = True
tglmsk.Enabled = True
cdivisi.Enabled = True
cdepartemen.Enabled = True
cserikat.Enabled = True
cstatus.Enabled = True
cshift.Enabled = True
cjabatan.Enabled = True
tjabatan.Enabled = True
cgolongan.Enabled = True
tgajipokok.Enabled = True
Cjenisk.Enabled = True
ccuti.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
tnamakaryawan.Enabled = True
tglmsk.Enabled = True
cdivisi.Enabled = True
cdepartemen.Enabled = True
cserikat.Enabled = True
cstatus.Enabled = True
cshift.Enabled = True
cjabatan.Enabled = True
tjabatan.Enabled = True
cgolongan.Enabled = True
tgajipokok.Enabled = True
Cjenisk.Enabled = True
ccuti.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 :
tidkaryawan.Enabled = False
tnamakaryawan.Enabled = False
tglmsk.Enabled = False
cdivisi.Enabled = False
cdepartemen.Enabled = False
cserikat.Enabled = False
cstatus.Enabled = False
cshift.Enabled = False
cjabatan.Enabled = False
tjabatan.Enabled = False
cgolongan.Enabled = False
tgajipokok.Enabled = False
Cjenisk.Enabled = False
ccuti.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
tnamakaryawan.Enabled = False
tglmsk.Enabled = False
cdivisi.Enabled = False
cdepartemen.Enabled = False
cserikat.Enabled = False
cstatus.Enabled = False
cshift.Enabled = False
cjabatan.Enabled = False
tjabatan.Enabled = False
cgolongan.Enabled = False
tgajipokok.Enabled = False
Cjenisk.Enabled = False
ccuti.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 higienis dan pastekan koding dibawah :
tidkaryawan.Text = ""
tnamakaryawan.Text = ""
cserikat.Text = ""
cstatus.Text = ""
cshift.Text = ""
cdivisi.Text = ""
cdepartemen.Text = ""
Cjenisk.Text = ""
cjabatan.Text = ""
tjabatan.Text = ""
cgolongan.Text = ""
tgajipokok.Text = ""
ccuti.Text = ""
tnamakaryawan.Text = ""
cserikat.Text = ""
cstatus.Text = ""
cshift.Text = ""
cdivisi.Text = ""
cdepartemen.Text = ""
Cjenisk.Text = ""
cjabatan.Text = ""
tjabatan.Text = ""
cgolongan.Text = ""
tgajipokok.Text = ""
ccuti.Text = ""
4. Buat Sub gres dengan nama sub tampil dan pastekan koding dibawah :
Call koneksi
rsdatakaryawan.Open "select*from tabelkaryawan", KON
Set grid1.DataSource = rsdatakaryawan
rsdatakaryawan.Open "select*from tabelkaryawan", KON
Set grid1.DataSource = rsdatakaryawan
5. Pastekan koding dibawah :
Private Sub Form_Load()
Call tampil
Call bersih
Call nonaktif
ctambah.Enabled = True
ccari.Enabled = True
tcari.Enabled = True
ccetak.Enabled = True
ccuti.Clear
For a = 1 To 24
ccuti.AddItem a
Next a
Me.Top = 100
Me.Left = 0
Me.Height = 7470
Me.Width = 14580
End Sub
Call tampil
Call bersih
Call nonaktif
ctambah.Enabled = True
ccari.Enabled = True
tcari.Enabled = True
ccetak.Enabled = True
ccuti.Clear
For a = 1 To 24
ccuti.AddItem a
Next a
Me.Top = 100
Me.Left = 0
Me.Height = 7470
Me.Width = 14580
End Sub
6. Double klik pada cdivisi dan pastekan koding dibawah (declaration=click):
If cdivisi.Text = "Produksi 1" Then
cdepartemen.Clear
cdepartemen.AddItem "Al Machining Wheel"
cdepartemen.AddItem "AT Mission"
ElseIf cdivisi.Text = "Produksi 2" Then
cdepartemen.Clear
cdepartemen.AddItem "Belt Assembly"
cdepartemen.AddItem "M-CVT"
ElseIf cdivisi.Text = "Produksi 3" Then
cdepartemen.Clear
cdepartemen.AddItem "Forging"
cdepartemen.AddItem "Head Cylinder"
End If
cdepartemen.Clear
cdepartemen.AddItem "Al Machining Wheel"
cdepartemen.AddItem "AT Mission"
ElseIf cdivisi.Text = "Produksi 2" Then
cdepartemen.Clear
cdepartemen.AddItem "Belt Assembly"
cdepartemen.AddItem "M-CVT"
ElseIf cdivisi.Text = "Produksi 3" Then
cdepartemen.Clear
cdepartemen.AddItem "Forging"
cdepartemen.AddItem "Head Cylinder"
End If
7. Double klik pada cgolongan dan pastekan koding dibawah (declaration=click):
Call koneksi
rsdatadasar.Open "select*from tabeldasar where golongan='" & cgolongan.Text & "'", KON
With rsdatadasar
If rsdatadasar.EOF Then
MsgBox "Data Gaji Pokok Belum Di input Pada Data Dasar", vbCritical
tgajipokok.Text = ""
Else
tgajipokok.Text = rsdatadasar.Fields("gajipokok")
tgajipokok.Enabled = False
kodedd1.Text = rsdatadasar.Fields("kodedasar")
End If
End With
If cgolongan.Text = "Kontrak 1" Then
cjabatan.Clear
cjabatan.AddItem "Operator"
cjabatan.AddItem "Admin Office"
ElseIf cgolongan.Text = "Kontrak 2" Then
cjabatan.Clear
cjabatan.AddItem "Operator"
cjabatan.AddItem "Admin Office"
ElseIf cgolongan.Text = "K Grade 1" Then
cjabatan.Clear
cjabatan.AddItem "Operator"
cjabatan.AddItem "Admin Office"
ElseIf cgolongan.Text = "K Grade 2" Then
cjabatan.Clear
cjabatan.AddItem "Operator"
cjabatan.AddItem "Admin Office"
cjabatan.AddItem "Leader Grup"
cjabatan.AddItem "Foreman"
ElseIf cgolongan.Text = "K Grade 3" Then
cjabatan.Clear
cjabatan.AddItem "Leader Grup"
cjabatan.AddItem "Foreman"
cjabatan.AddItem "General Foreman"
cjabatan.AddItem "Leader Prod Enginering"
ElseIf cgolongan.Text = "K Grade 4" Then
cjabatan.Clear
cjabatan.AddItem "Foreman"
cjabatan.AddItem "General Foreman"
cjabatan.AddItem "Leader Prod Enginering"
cjabatan.AddItem "HRD"
cjabatan.AddItem "Supervisor"
ElseIf cgolongan.Text = "Top Management" Then
cjabatan.Clear
cjabatan.AddItem "Manager Divisi"
cjabatan.AddItem "Manager Departement"
cjabatan.AddItem "General Manager"
cjabatan.AddItem "General HRD"
End If
rsdatadasar.Open "select*from tabeldasar where golongan='" & cgolongan.Text & "'", KON
With rsdatadasar
If rsdatadasar.EOF Then
MsgBox "Data Gaji Pokok Belum Di input Pada Data Dasar", vbCritical
tgajipokok.Text = ""
Else
tgajipokok.Text = rsdatadasar.Fields("gajipokok")
tgajipokok.Enabled = False
kodedd1.Text = rsdatadasar.Fields("kodedasar")
End If
End With
If cgolongan.Text = "Kontrak 1" Then
cjabatan.Clear
cjabatan.AddItem "Operator"
cjabatan.AddItem "Admin Office"
ElseIf cgolongan.Text = "Kontrak 2" Then
cjabatan.Clear
cjabatan.AddItem "Operator"
cjabatan.AddItem "Admin Office"
ElseIf cgolongan.Text = "K Grade 1" Then
cjabatan.Clear
cjabatan.AddItem "Operator"
cjabatan.AddItem "Admin Office"
ElseIf cgolongan.Text = "K Grade 2" Then
cjabatan.Clear
cjabatan.AddItem "Operator"
cjabatan.AddItem "Admin Office"
cjabatan.AddItem "Leader Grup"
cjabatan.AddItem "Foreman"
ElseIf cgolongan.Text = "K Grade 3" Then
cjabatan.Clear
cjabatan.AddItem "Leader Grup"
cjabatan.AddItem "Foreman"
cjabatan.AddItem "General Foreman"
cjabatan.AddItem "Leader Prod Enginering"
ElseIf cgolongan.Text = "K Grade 4" Then
cjabatan.Clear
cjabatan.AddItem "Foreman"
cjabatan.AddItem "General Foreman"
cjabatan.AddItem "Leader Prod Enginering"
cjabatan.AddItem "HRD"
cjabatan.AddItem "Supervisor"
ElseIf cgolongan.Text = "Top Management" Then
cjabatan.Clear
cjabatan.AddItem "Manager Divisi"
cjabatan.AddItem "Manager Departement"
cjabatan.AddItem "General Manager"
cjabatan.AddItem "General HRD"
End If
8. Double klik pada cjabatan dan pastekan koding dibawah (declaration=click):
Call koneksi
rsdatadasar.Open "select*from tabeldasar where golongan='" & cgolongan.Text & "' and jabatan='" & cjabatan.Text & "'", KON
With rsdatadasar
If rsdatadasar.EOF Then
MsgBox "Data T.Jabatan Belum Di input Pada Data Dasar", vbCritical
tjabatan.Text = ""
Else
kodedd1.Text = rsdatadasar.Fields("kodedasar")
End If
End With
Call koneksi
rsdatadasar.Open "select*from tabeldasar where kodedasar='" & kodedd1.Text & "'", KON
If rsdatadasar.EOF Then
MsgBox "Data T.Jabatan Belum Di input Pada Data Dasar", vbCritical
tjabatan.Text = ""
Else
tjabatan.Text = rsdatadasar.Fields("tjabatan")
tjabatan.Enabled = False
End If
rsdatadasar.Open "select*from tabeldasar where golongan='" & cgolongan.Text & "' and jabatan='" & cjabatan.Text & "'", KON
With rsdatadasar
If rsdatadasar.EOF Then
MsgBox "Data T.Jabatan Belum Di input Pada Data Dasar", vbCritical
tjabatan.Text = ""
Else
kodedd1.Text = rsdatadasar.Fields("kodedasar")
End If
End With
Call koneksi
rsdatadasar.Open "select*from tabeldasar where kodedasar='" & kodedd1.Text & "'", KON
If rsdatadasar.EOF Then
MsgBox "Data T.Jabatan Belum Di input Pada Data Dasar", vbCritical
tjabatan.Text = ""
Else
tjabatan.Text = rsdatadasar.Fields("tjabatan")
tjabatan.Enabled = False
End If
9. Double klik pada ctambah dan pastekan koding dibawah (declaration=click):
Call koneksi
Call bersih
Call aktif
rsdatakaryawan.Open "select*from tabelkaryawan order by idkaryawan desc", KON
With rsdatakaryawan
If .BOF And .EOF Then
tidkaryawan.Text = "ID" + "001"
Else
tidkaryawan.Text = "ID" + Right(Str(Val(Right(.Fields("idkaryawan"), 3)) + 1001), 3)
End If
End With
tnamakaryawan.SetFocus
Call aktif
tidkaryawan.Enabled = False
ctambah.Enabled = False
cbatal.Enabled = True
csunting.Enabled = False
cperbarui.Enabled = False
chapus.Enabled = False
Call tampil
Call bersih
Call aktif
rsdatakaryawan.Open "select*from tabelkaryawan order by idkaryawan desc", KON
With rsdatakaryawan
If .BOF And .EOF Then
tidkaryawan.Text = "ID" + "001"
Else
tidkaryawan.Text = "ID" + Right(Str(Val(Right(.Fields("idkaryawan"), 3)) + 1001), 3)
End If
End With
tnamakaryawan.SetFocus
Call aktif
tidkaryawan.Enabled = False
ctambah.Enabled = False
cbatal.Enabled = True
csunting.Enabled = False
cperbarui.Enabled = False
chapus.Enabled = False
Call tampil
10. Double klik pada csimpan dan pastekan koding dibawah (declaration=click):
If tnamakaryawan.Text = "" Or cdivisi.Text = "0" Or cdepartemen.Text = "" Or Cjenisk.Text = "0" Or cserikat.Text = "0" Or cstatus.Text = "0" Or cgolongan.Text = "0" Or cjabatan.Text = "0" Or ccuti.Text = "0" Or cshift.Text = "0" Then
MsgBox "Data Belum terisi semua", vbCritical
Else
Call koneksi
rsdatakaryawan.Open "insert into tabelkaryawan values('" & tidkaryawan & "','" & tnamakaryawan & "','" & Cjenisk & "','" & cdivisi & "','" & cdepartemen & "','" & tglmsk & "','" & cserikat & "','" & cstatus & "','" & cgolongan & "','" & tgajipokok & "','" & cjabatan & "','" & tjabatan & "','" & cshift & "','" & ccuti & "','" & kodedd1 & "')", KON
MsgBox "Data Sudah Tersimpan", vbInformation
Call tampil
Call bersih
Call nonaktif
ctambah.Enabled = True
tcari.Enabled = True
ccari.Enabled = True
End If
MsgBox "Data Belum terisi semua", vbCritical
Else
Call koneksi
rsdatakaryawan.Open "insert into tabelkaryawan values('" & tidkaryawan & "','" & tnamakaryawan & "','" & Cjenisk & "','" & cdivisi & "','" & cdepartemen & "','" & tglmsk & "','" & cserikat & "','" & cstatus & "','" & cgolongan & "','" & tgajipokok & "','" & cjabatan & "','" & tjabatan & "','" & cshift & "','" & ccuti & "','" & kodedd1 & "')", KON
MsgBox "Data Sudah Tersimpan", vbInformation
Call tampil
Call bersih
Call nonaktif
ctambah.Enabled = True
tcari.Enabled = True
ccari.Enabled = True
End If
11. Double klik pada csunting dan pastekan koding dibawah (declaration=click):
Call aktif
tidkaryawan.Enabled = False
tgajipokok.Enabled = False
tjabatan.Enabled = False
ctambah.Enabled = False
csimpan.Enabled = False
csunting.Enabled = False
chapus.Enabled = False
tidkaryawan.Enabled = False
tgajipokok.Enabled = False
tjabatan.Enabled = False
ctambah.Enabled = False
csimpan.Enabled = False
csunting.Enabled = False
chapus.Enabled = False
12. Double klik pada cperbarui dan pastekan koding dibawah (declaration=click):
If tnamakaryawan.Text = "" Or cdivisi.Text = "0" Or cdepartemen.Text = "" Or Cjenisk.Text = "" Or Cjenisk.Text = "" Or cserikat.Text = "0" Or cstatus.Text = "0" Or cgolongan.Text = "0" Or cjabatan.Text = "0" Or ccuti.Text = "0" Or cshift.Text = "0" Then
MsgBox "Data Belum terisi semua", vbCritical
Else
Call koneksi
rsdatakaryawan.Open "update tabelkaryawan set namakaryawan='" & tnamakaryawan & "',jeniskelamin='" & Cjenisk & "',divisi='" & cdivisi & "',departemen='" & cdepartemen & "',tglmasuk='" & tglmsk & "',serikat='" & cserikat & "',status='" & cstatus & "',golongan='" & cgolongan & "',gajipokok='" & tgajipokok & "',jabatan='" & cjabatan & "',tjabatan='" & tjabatan & "',shift='" & cshift & "',cuti='" & ccuti & "',kodedasar='" & kodedd1 & "' where idkaryawan='" & tidkaryawan.Text & "'", KON
MsgBox "Data Berhasil di Update", vbInformation, "Info"
bersih
Call tampil
Call nonaktif
ctambah.Enabled = True
ccari.Enabled = True
tcari.Enabled = True
End If
MsgBox "Data Belum terisi semua", vbCritical
Else
Call koneksi
rsdatakaryawan.Open "update tabelkaryawan set namakaryawan='" & tnamakaryawan & "',jeniskelamin='" & Cjenisk & "',divisi='" & cdivisi & "',departemen='" & cdepartemen & "',tglmasuk='" & tglmsk & "',serikat='" & cserikat & "',status='" & cstatus & "',golongan='" & cgolongan & "',gajipokok='" & tgajipokok & "',jabatan='" & cjabatan & "',tjabatan='" & tjabatan & "',shift='" & cshift & "',cuti='" & ccuti & "',kodedasar='" & kodedd1 & "' where idkaryawan='" & tidkaryawan.Text & "'", KON
MsgBox "Data Berhasil di Update", vbInformation, "Info"
bersih
Call tampil
Call nonaktif
ctambah.Enabled = True
ccari.Enabled = True
tcari.Enabled = True
End If
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 chapus dan pastekan koding dibawah (declaration=click):
Call koneksi
a = MsgBox("Yakin Ingin Hapus Data ini?", vbQuestion + vbYesNo, "tanya")
If a = vbYes Then
rsdatakaryawan.Open "delete from tabelkaryawan where idkaryawan='" & 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
rsdatakaryawan.Open "delete from tabelkaryawan where idkaryawan='" & 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
15. Double klik pada ccetak dan pastekan koding dibawah (declaration=click):
cr.ReportFileName = "D:\Belajar MVB\datakaryawan.rpt"
cr.WindowState = crptMaximized
cr.RetrieveDataFiles
cr.Action = 1
cr.WindowState = crptMaximized
cr.RetrieveDataFiles
cr.Action = 1
16. Double klik pada ccari dan pastekan koding dibawah (declaration=click):
Call koneksi
rsdatakaryawan.Open "select*from tabelkaryawan where idkaryawan='" & tcari.Text & "'", KON
If rsdatakaryawan.EOF Then
MsgBox "Data Tidak Ditemukan", vbCritical
tcari.Text = ""
tcari.SetFocus
Else
With rsdatakaryawan
tidkaryawan.Text = .Fields("idkaryawan")
tnamakaryawan.Text = .Fields("namakaryawan")
Cjenisk.Text = .Fields("jeniskelamin")
cdivisi.Text = .Fields("divisi")
cdepartemen.Text = .Fields("departemen")
tglmsk = .Fields("tglmasuk")
cserikat.Text = .Fields("serikat")
cstatus.Text = .Fields("status")
cgolongan.Text = .Fields("golongan")
tgajipokok.Text = .Fields("gajipokok")
cjabatan.Text = .Fields("jabatan")
tjabatan.Text = .Fields("tjabatan")
cshift.Text = .Fields("shift")
ccuti.Text = .Fields("cuti")
kodedd1.Text = .Fields("kodedasar")
End With
Call nonaktif
tidkaryawan.Enabled = False
csunting.Enabled = True
chapus.Enabled = True
cbatal.Enabled = True
tcari.Enabled = True
ccari.Enabled = True
End If
rsdatakaryawan.Open "select*from tabelkaryawan where idkaryawan='" & tcari.Text & "'", KON
If rsdatakaryawan.EOF Then
MsgBox "Data Tidak Ditemukan", vbCritical
tcari.Text = ""
tcari.SetFocus
Else
With rsdatakaryawan
tidkaryawan.Text = .Fields("idkaryawan")
tnamakaryawan.Text = .Fields("namakaryawan")
Cjenisk.Text = .Fields("jeniskelamin")
cdivisi.Text = .Fields("divisi")
cdepartemen.Text = .Fields("departemen")
tglmsk = .Fields("tglmasuk")
cserikat.Text = .Fields("serikat")
cstatus.Text = .Fields("status")
cgolongan.Text = .Fields("golongan")
tgajipokok.Text = .Fields("gajipokok")
cjabatan.Text = .Fields("jabatan")
tjabatan.Text = .Fields("tjabatan")
cshift.Text = .Fields("shift")
ccuti.Text = .Fields("cuti")
kodedd1.Text = .Fields("kodedasar")
End With
Call nonaktif
tidkaryawan.Enabled = False
csunting.Enabled = True
chapus.Enabled = True
cbatal.Enabled = True
tcari.Enabled = True
ccari.Enabled = True
End If
Sumber http://www.hendrisetiawan.com