Sabtu, 28 Januari 2012

Jawaban Soal 3 (Fince Tinus Waruwu)

Kasus Penggajian Karyawan
Listing Program :





Public Class Form_Login

Private Sub Pass_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles Pass.KeyPress
        If Asc(e.KeyChar) = 13 Then
            If User.Text = "Fince" And Pass.Text = "123" Then
                Form_Menu_Utama.show()
                Me.Hide()
            Else
                MsgBox("Maaf Username dan Password Salah")
                User.Text = ""
                Pass.Text = ""
                User.Focus()
            End If
        End If
End Sub

Private Sub Keluar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Keluar.Click
        Close()
End Sub
End Class


Public Class Form_Menu_Utama

Private Sub PenggajianKaryawanToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PenggajianKaryawanToolStripMenuItem.Click
        Form_Penggajian_Karyawan.Show()
End Sub

Private Sub ExitToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ExitToolStripMenuItem.Click
        Close()
End Sub
End Class


Public Class Form_Penggajian_Karyawan

Private Sub Form_Penggajian_Karyawan_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        jabatan.Items.Add("Mandor")
        jabatan.Items.Add("Kepala Bagian")
        jabatan.Items.Add("Staff")

        status.Items.Add("Menikah")
        status.Items.Add("Tidak Menikah")

  Call buattabel()
End Sub

Private Sub jabatan_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles jabatan.SelectedIndexChanged
        Select Case jabatan.Text
            Case "Mandor" : Me.gaji_poko.Text = 1750000
            Case "Kepala Bagian" : Me.gaji_poko.Text = 2500000
            Case "Staff" : Me.gaji_poko.Text = 1250000
        End Select
End Sub

Private Sub status_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles status.SelectedIndexChanged
        Select Case status.Text
            Case "Menikah" : Me.tunjangan_istri.Text = gaji_poko.Text * 0.09
                pajak.Text = 0.015 * gaji_poko.Text
            Case "Tidak Menikah" : Me.tunjangan_istri.Text = 0
                jumlah_anak.Text = 0 : Me.tujangan_anak.Text = 0
                pajak.Text = 0.015 * gaji_poko.Text
        End Select
End Sub

Private Sub jumlah_anak_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles jumlah_anak.KeyPress
        If Asc(e.KeyChar) = 13 Then
            If jumlah_anak.Text = 1 Then
                tujangan_anak.Text = gaji_poko.Text * 0.03
            ElseIf jumlah_anak.Text = 2 Then
                tujangan_anak.Text = gaji_poko.Text * 0.07
            ElseIf jumlah_anak.Text > 2 Then
                tujangan_anak.Text = 0
            End If
        End If
End Sub

Private Sub jam_Lembur_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles jam_Lembur.KeyPress
        If Asc(e.KeyChar) = 13 Then
            If jabatan.Text = "Mandor" Then
                Upah_lembur.Text = 7500 * jam_Lembur.Text
            ElseIf jabatan.Text = "Kepala Bagian" Then
                Upah_lembur.Text = 10000 * jam_Lembur.Text
            ElseIf jabatan.Text = "Staff" Then
                Upah_lembur.Text = 5000 * jam_Lembur.Text
            End If
 total_gaji.Text = Val(gaji_poko.Text) + Val(tunjangan_istri.Text) + Val(tujangan_anak.Text) + Val(Upah_lembur.Text) - pajak.Text
        End If
End Sub
   
Sub buattabel()
        lv.View = View.Details
        lv.GridLines = True
        lv.FullRowSelect = True
        lv.Columns.Add("Kode", 80)
        lv.Columns.Add("Nama", 140)
        lv.Columns.Add("Jabatan", 120)
        lv.Columns.Add("Gaji Pokok", 100)
        lv.Columns.Add("Status", 100)
        lv.Columns.Add("Tunjangan Istri", 100)
        lv.Columns.Add("Jumlah Anak", 120)
        lv.Columns.Add("Tunjangan Anak", 100)
        lv.Columns.Add("Pajak", 100)
        lv.Columns.Add("Jam Lembur", 100)
        lv.Columns.Add("Upah Lembur", 100)
        lv.Columns.Add("Total Gaji", 100)
 End Sub


 Sub IsiTabel()
        Dim Lst As New ListViewItem
        Lst.Text = kode.Text
        Lst.SubItems.Add(nama.Text)
        Lst.SubItems.Add(jabatan.Text)
        Lst.SubItems.Add(gaji_poko.Text)
        Lst.SubItems.Add(status.Text)
        Lst.SubItems.Add(tunjangan_istri.Text)
        Lst.SubItems.Add(jumlah_anak.Text)
        Lst.SubItems.Add(tujangan_anak.Text)
        Lst.SubItems.Add(pajak.Text)
        Lst.SubItems.Add(jam_Lembur.Text)
        Lst.SubItems.Add(Upah_lembur.Text)
        Lst.SubItems.Add(total_gaji.Text)
        Lst.SubItems.Add(jumlah_anak.Text)
        LV.Items.Add(Lst)
End Sub

Sub berish(ByVal F As Form)
        Dim X As Object
        For Each X In F.Controls
            If TypeOf X Is TextBox Then X.Text = ""
            If TypeOf X Is ComboBox Then X.Text = ""
        Next
 End Sub
   
Private Sub bersih_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bersih.Click
        Call berish(Me)
 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 hapus_data_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles hapus_data.Click
        lv.Items.Remove(lv.SelectedItems(0))
 End Sub

 Private Sub simpan_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles simpan.Click
        Call IsiTabel()
 End Sub

 Private Sub keluar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles keluar.Click
        Dim i As MsgBoxResult
        i = MsgBox("Apa anda ingin keluar?", MsgBoxStyle.Information + MsgBoxStyle.YesNo, "Perhatian")
        If i = MsgBoxResult.Yes Then
            Close()
        End If
    End Sub
End Class


Hasil Program




Tampilan Form Login

Tampilan Form Menu Utama

Tampilan Form Penggajian Karyawan


















Jawaban Soal 2 (Fince Tinus Waruwu)

Kasus : Quiz No 2 Halaman 33

Listing Program :

Public Class Form1

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        kode.Items.Add("TS001")
        kode.Items.Add("TS002")
        kode.Items.Add("VG001")
        kode.Items.Add("VG002")

        Dim i As Integer
        For i = 1 To 20
            no.Items.Add(i)
        Next

        Call buattabel()
End Sub

Private Sub kode_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles kode.SelectedIndexChanged
        Dim x, y As String
        x = Microsoft.VisualBasic.Left(kode.Text, 2)
        y = Microsoft.VisualBasic.Right(kode.Text, 3)
        Select Case x
            Case "TS" : merk.Text = "Thosiba"
                Select Case y
                    Case "001" : Me.nama.Text = "Flashdisk 4GB" : Me.harga.Text = 105000
                    Case "002" : Me.nama.Text = "Flashdisk 2GB" : Me.harga.Text = 72000
                End Select
            Case "VG" : merk.Text = "V-Gen"
                Select Case y
                    Case "001" : Me.nama.Text = "Flashdisk 4GB" : Me.harga.Text = 90000
                    Case "002" : Me.nama.Text = "Flashdisk 2GB" : Me.harga.Text = 60000
                End Select
        End Select
    End Sub

Private Sub jumlah_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles jumlah.KeyPress
        If Asc(e.KeyChar) = 13 Then
            total.Text = harga.Text * jumlah.Text
        End If
    End Sub

Sub buattabel()
        lv.View = View.Details
        lv.GridLines = True
        lv.FullRowSelect = True
        lv.Columns.Add("No Pembelian", 80)
        lv.Columns.Add("Kode", 100)
        lv.Columns.Add("Nama", 120)
        lv.Columns.Add("Merk", 100)
        lv.Columns.Add("Harga", 100)
        lv.Columns.Add("Jumlah", 100)
        lv.Columns.Add("Total", 100)
End Sub


Sub IsiTabel()
        Dim Lst As New ListViewItem
        Lst.Text = no.Text
        Lst.SubItems.Add(kode.Text)
        Lst.SubItems.Add(nama.Text)
        Lst.SubItems.Add(merk.Text)
        Lst.SubItems.Add(harga.Text)
        Lst.SubItems.Add(jumlah.Text)
        Lst.SubItems.Add(total.Text)
        LV.Items.Add(Lst)
End Sub

Private Sub simpan_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles simpan.Click
        Call IsiTabel()
End Sub

Private Sub keluar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles keluar.Click
        Dim i As MsgBoxResult
        i = MsgBox("Apa anda ingin keluar?", MsgBoxStyle.Information + MsgBoxStyle.YesNo, "Perhatian")
        If i = MsgBoxResult.Yes Then
            Close()
        End If
End Sub

Private Sub bersih_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bersih.Click
        Call berish(Me)
End Sub

Sub berish(ByVal F As Form)
        Dim X As Object
        For Each X In F.Controls
            If TypeOf X Is TextBox Then X.Text = ""
            If TypeOf X Is ComboBox Then X.Text = ""
        Next
End Sub

Private Sub hapus_data_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles hapus_data.Click
        lv.Items.Remove(lv.SelectedItems(0))
End Sub

    Private Sub hapus_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles hapus.Click
        lv.Items.Clear()
    End Sub
End Class


Hasil Program