Jawaban Soal No.2
Public Class Form1
Sub buattabel()
lv.Columns.Add("NPM", 80, HorizontalAlignment.Center)
lv.Columns.Add("Nama", 180, HorizontalAlignment.Left)
lv.View = View.Details
lv.GridLines = True
lv.FullRowSelect = True
End Sub
Sub isitabel()
Dim lst As New ListViewItem
lst.Text = npm.Text
lst.SubItems.Add(nama.Text)
lv.Items.Add(lst)
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
buattabel()
End Sub
Private Sub simpan_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles simpan.Click
isitabel()
npm.Text = ""
nama.Text = ""
End Sub
Private Sub hapus_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles hapus.Click
lv.Items.Clear()
End Sub
Private Sub hapusyangdipilih_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles hapusyangdipilih.Click
lv.Items.Remove(lv.SelectedItems(0))
End Sub
End Class
Jawaban Soal No.3
Public Class Form1
Private Sub ok_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ok.Click
If username.Text = "Mentari" And password.Text = "111" Then
Formmenu.Show()
Me.Hide()
Else
MsgBox("Maaf, Password Anda Salah !!")
username.Text = ""
password.Text = ""
End If
End Sub
Private Sub keluar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles keluar.Click
End
End Sub
End Class
Public Class Formmenu
Private Sub KeluarToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles KeluarToolStripMenuItem.Click
End
End Sub
Private Sub DataPenggajianToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DataPenggajianToolStripMenuItem.Click
Karyawan.Show()
Me.Hide()
End Sub
End Class
Public Class Karyawan
Sub llembur()
uanglembur.Text = Val(jamlembur.Text) * Val(lembur.Text)
End Sub
Sub totalgaji()
total.Text = Val(gaji.Text) + Val(tunjanganistri.Text) + Val(tunjangananak.Text) + Val(uanglembur.Text) - Val(pajak.Text)
End Sub
Sub buattabel()
LV.Columns.Add("NIP", 50, HorizontalAlignment.Center)
LV.Columns.Add("Nama ", 80, HorizontalAlignment.Left)
LV.Columns.Add("Jabatan", 90, HorizontalAlignment.Left)
LV.Columns.Add("Gaji", 80, HorizontalAlignment.Left)
LV.Columns.Add("Status", 95, HorizontalAlignment.Left)
LV.Columns.Add("Tunj.Istri", 70, HorizontalAlignment.Left)
LV.Columns.Add("JumlahAnak", 75, HorizontalAlignment.Left)
LV.Columns.Add("Tunj.Anak", 70, HorizontalAlignment.Left)
LV.Columns.Add("JamLembur", 75, HorizontalAlignment.Left)
LV.Columns.Add("UangLemburPerjam", 115, HorizontalAlignment.Left)
LV.Columns.Add("UangLembur", 77, HorizontalAlignment.Left)
LV.Columns.Add("Pajak", 65, HorizontalAlignment.Left)
LV.Columns.Add("Total", 70, HorizontalAlignment.Left)
LV.View = View.Details
LV.GridLines = True
LV.FullRowSelect = True
End Sub
Sub isitabel()
Dim lst As New ListViewItem
lst.Text = nip.Text
lst.SubItems.Add(nama.Text)
lst.SubItems.Add(jabatan.Text)
lst.SubItems.Add(gaji.Text)
lst.SubItems.Add(status.Text)
lst.SubItems.Add(tunjanganistri.Text)
lst.SubItems.Add(jumlahanak.Text)
lst.SubItems.Add(tunjangananak.Text)
lst.SubItems.Add(jamlembur.Text)
lst.SubItems.Add(lembur.Text)
lst.SubItems.Add(uanglembur.Text)
lst.SubItems.Add(pajak.Text)
lst.SubItems.Add(total.Text)
LV.Items.Add(lst)
End Sub
Private Sub Karyawan_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
buattabel()
jabatan.Items.Add("Mandor")
jabatan.Items.Add("Kepala Bagian")
jabatan.Items.Add("Staf")
status.Items.Add("Menikah")
status.Items.Add("Belum Menikah")
jumlahanak.Items.Add("1")
jumlahanak.Items.Add("2")
jumlahanak.Items.Add("3")
jumlahanak.Items.Add("4")
jumlahanak.Items.Add("5")
jumlahanak.Items.Add("6")
End Sub
Private Sub nip_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs)
If nip.Text = "01011010" Then
nama.Text = "Ucok"
ElseIf nip.Text = "01011012" Then
nama.Text = "Dian S"
End If
End Sub
Private Sub gol_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles jabatan.SelectedIndexChanged
If jabatan.Text = "Mandor" Then
gaji.Text = 1750000
lembur.Text = 7500
ElseIf jabatan.Text = "Kepala Bagian" Then
gaji.Text = 2500000
lembur.Text = 10000
ElseIf jabatan.Text = "Staf" Then
gaji.Text = 1250000
lembur.Text = 5000
End If
End Sub
Private Sub status_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles status.SelectedIndexChanged
If status.Text = "Menikah" Then
tunjanganistri.Text = 0.09 * Val(gaji.Text)
tunjanganistri.Enabled = True
jumlahanak.Enabled = True
tunjangananak.Enabled = True
ElseIf status.Text = "Belum Menikah" Then
tunjanganistri.Enabled = False
jumlahanak.Enabled = False
tunjangananak.Enabled = False
End If
End Sub
Private Sub jumlahanak_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles jumlahanak.SelectedIndexChanged
If jumlahanak.Text = "1" Then
tunjangananak.Text = 0.03 * Val(gaji.Text)
ElseIf jumlahanak.Text >= "2" Then
tunjangananak.Text = 0.07 * Val(gaji.Text)
End If
End Sub
Private Sub gaji_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles gaji.TextChanged
pajak.Text = 0.015 * Val(gaji.Text)
End Sub
Private Sub simpan_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles simpan.Click
isitabel()
nip.Text = ""
nama.Text = ""
jabatan.Text = ""
gaji.Text = ""
status.Text = ""
tunjanganistri.Text = ""
jumlahanak.Text = ""
tunjangananak.Text = ""
pajak.Text = ""
total.Text = ""
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
nip.Text = ""
nama.Text = ""
jabatan.Text = ""
gaji.Text = ""
status.Text = ""
tunjanganistri.Text = ""
jumlahanak.Text = ""
tunjangananak.Text = ""
lembur.Text = ""
jamlembur.Text = ""
uanglembur.Text = ""
pajak.Text = ""
total.Text = ""
End Sub
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
LV.Items.Clear()
End Sub
Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
LV.Items.Remove(LV.SelectedItems(0))
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
totalgaji()
End Sub
Private Sub jamlembur_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles jamlembur.TextChanged
llembur()
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
End
End Sub
End Class