Jumat, 27 Januari 2012

Jawaban No 3 ( adlinhasibuan )

Untuk kasus lihat di sini KASUS
*******************************

Public Class Form1

    Private Sub btnok_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnok.Click
        If username.Text = "adlinhasibuan" And password.Text = "merahmudahasibuan" Then
            menuutama.Show()
            Me.Hide()
        Else
            MsgBox("Data Username/Password Salah?")
            username.Text = ""
            password.Text = ""
        End If
    End Sub
End Class
______________________________________________________________




Public Class gajipegawai

    Private Sub gajipegawai_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("Tidak Nikah")
        status.Items.Add("Menikah")

        Dim jmlh As Byte
        For jmlh = 1 To 30
            jlh_anak.Items.Add(jmlh)
        Next

        Dim lama As Byte
        For lama = 1 To 30
            lama_lembur.Items.Add(lama)
        Next

        bersih()
        RancangTabel()
        nama.Focus()
    End Sub
    Sub RancangTabel()
        With LV
            .Columns.Add("Nama", 70, HorizontalAlignment.Center)
            .Columns.Add("Jabatan", 120, HorizontalAlignment.Left)
            .Columns.Add("Gaji Pokok", 100, HorizontalAlignment.Left)
            .Columns.Add("Status", 100, HorizontalAlignment.Left)
            .Columns.Add("Tunj Istri", 120, HorizontalAlignment.Left)
            .Columns.Add("Jmlah Anak", 90, HorizontalAlignment.Center)
            .Columns.Add("Tunj Anak", 90, HorizontalAlignment.Center)
            .Columns.Add("Pajak", 120, HorizontalAlignment.Left)
            .Columns.Add("Lama Lembur", 120, HorizontalAlignment.Left)
            .Columns.Add("Upah Lembur", 120, HorizontalAlignment.Left)
            .Columns.Add("Gaji", 120, HorizontalAlignment.Left)
            .GridLines = True
            .FullRowSelect = True
            .View = View.Details


        End With
    End Sub
    Sub MasukTabel()
        Dim ist As New ListViewItem
        With ist
            .Text = nama.Text
            .SubItems.Add(jabatan.Text)
            .SubItems.Add(gaji.Text)
            .SubItems.Add(status.Text)
            .SubItems.Add(tjg_i.Text)
            .SubItems.Add(jlh_anak.Text)
            .SubItems.Add(tjg_a.Text)
            .SubItems.Add(pajak.Text)
            .SubItems.Add(lama_lembur.Text)
            .SubItems.Add(lembur.Text)
            .SubItems.Add(totgaji.Text)
            LV.Items.Add(ist)

        End With
    End Sub
    Sub bersih()
        nama.Text = ""
        jabatan.Text = ""
        gaji.Text = ""
        tjg_a.Text = ""
        tjg_i.Text = ""
        jlh_anak.Text = ""
        lembur.Text = ""
        lama_lembur.Text = ""
        totgaji.Text = ""
        pajak.Text = ""
        status.Text = ""
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnsimpan.Click
        MasukTabel()
        bersih()

    End Sub

    Private Sub jabatan_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles jabatan.SelectedIndexChanged
        If jabatan.Text = "Mandor" Then
            gaji.Text = 1750000
        ElseIf jabatan.Text = "Kepala Bagian" Then
            gaji.Text = 2500000
        ElseIf jabatan.Text = "Staff" Then
            gaji.Text = 1250000
        Else
            gaji.Text = 0
        End If
        pajak.Text = 0.015 * gaji.Text

    End Sub

    Private Sub lama_lembur_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lama_lembur.SelectedIndexChanged
        If jabatan.Text = "Mandor" Then
            lembur.Text = lama_lembur.Text * 7500
        ElseIf jabatan.Text = "Kepala Bagian" Then
            lembur.Text = lama_lembur.Text * 10000
        ElseIf jabatan.Text = "Staff" Then
            lembur.Text = lama_lembur.Text * 5000
        Else
            lembur.Text = 0
        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
            tjg_i.Text = 0.09 * gaji.Text
            If jlh_anak.Text = "1" Then
                tjg_a.Text = 0.03 * gaji.Text
            ElseIf jlh_anak.Text >= "2" Then
                tjg_a.Text = 0.07 * gaji.Text
            End If
        Else
            tjg_i.Text = "0"
            tjg_a.Text = "0"
        End If

    End Sub

    Private Sub jlh_anak_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles jlh_anak.SelectedIndexChanged
        If status.Text = "Menikah" Then
            tjg_i.Text = 0.09 * gaji.Text
            If jlh_anak.Text = "1" Then
                tjg_a.Text = 0.03 * gaji.Text
            ElseIf jlh_anak.Text >= "2" Then
                tjg_a.Text = 0.07 * gaji.Text
            End If
        Else
            tjg_i.Text = "0"
            tjg_a.Text = "0"
        End If

    End Sub

    Private Sub btnhapus_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnhapus.Click
        nama.Text = ""
        jabatan.Text = ""
        gaji.Text = ""
        tjg_a.Text = ""
        tjg_i.Text = ""
        jlh_anak.Text = ""
        lembur.Text = ""
        lama_lembur.Text = ""
        totgaji.Text = ""
        pajak.Text = ""
        status.Text = ""

    End Sub

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

   

    Private Sub lembur_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lembur.TextChanged
        totgaji.Text = Val(gaji.Text) + Val(tjg_i.Text) + Val(tjg_a.Text) + Val(lembur.Text) - Val(pajak.Text)
    End Sub

Private Sub btnkeluar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnkeluar.Click
        End
    End Sub


End Class







Tidak ada komentar:

Posting Komentar