Jumat, 31 Mei 2013

Penggajian Karyawan Menggunakan Listview Pada Program Visual Studio

Public Class Form1

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        buatTabel()
        NIK.Items.Add("001")
        NIK.Items.Add("002")
        NIK.Items.Add("003")
        Jabatan.Items.Add("Mandor")
        Jabatan.Items.Add("Kepala Bagian")
        Jabatan.Items.Add("Staff")
        For i = 1 To 4
            CmbAnak.Items.Add(i)
        Next i
        For i = 1 To 10
            JLembur.Items.Add(i)
        Next i
        Status.Items.Add("Menikah")
        Status.Items.Add("Tidak Menikah")
    End Sub
    Sub buatTabel()
        lv.Columns.Add("NIK", 50, HorizontalAlignment.Center)
        lv.Columns.Add("Nama", 100, HorizontalAlignment.Left)
        lv.Columns.Add("Jabatan", 150, HorizontalAlignment.Center)
        lv.Columns.Add("Gaji", 90, HorizontalAlignment.Center)
        lv.Columns.Add("Status", 130, HorizontalAlignment.Center)
        lv.Columns.Add("Pajak", 90, HorizontalAlignment.Center)
        lv.Columns.Add("Total", 90, HorizontalAlignment.Center)
        lv.View = View.Details
        lv.GridLines = True
        lv.FullRowSelect = True
    End Sub
    Sub isitabel()
        Dim Lst As New ListViewItem
        Lst.Text = NIK.Text
        Lst.SubItems.Add(Nama.Text)
        Lst.SubItems.Add(Jabatan.Text)
        Lst.SubItems.Add(Gaji.Text)
        Lst.SubItems.Add(Status.Text)
        Lst.SubItems.Add(Pajak.Text)
        Lst.SubItems.Add(Total.Text)
        lv.Items.Add(Lst)
    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" : Gaji.Text = 175000
            Case "Kepala Bagian" : Gaji.Text = 250000
            Case "Staff" : Gaji.Text = 125000
        End Select
        Pajak.Text = 0.015 * Gaji.Text
    End Sub

Private Sub BtnProses_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnProses.Click
        Dim Honor As Double
        If Jabatan.Text = "Mandor" Then
            Honor = 7500
        ElseIf Jabatan.Text = "Kepala Bagian" Then
            Honor = 10000
        ElseIf Jabatan.Text = "Staff" Then
            Honor = 5000
        Else
            Honor = 0
        End If
        HLembur.Text = Honor * JLembur.Text
        Total.Text = Val(HLembur.Text) + Val(Gaji.Text) + Val(TIstri.Text) + Val(TAnak.Text) - Val(Pajak.Text)
    End Sub

Private Sub CmbAnak_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CmbAnak.SelectedIndexChanged
        If CmbAnak.Text >= 2 Then
            TAnak.Text = 0.07 * Gaji.Text
        ElseIf CmbAnak.Text >= 1 Then
            TAnak.Text = 0.03 * Gaji.Text
        Else
            TAnak.Text = 0
        End If

    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" : TIstri.Text = 0.09 * Gaji.Text : CmbAnak.Enabled = True
            Case "Tidak Menikah" : TIstri.Text = 0.09 * Gaji.Text : CmbAnak.Enabled = False : TAnak.Text = 0 : CmbAnak.Text = 0
        End Select

    End Sub

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

Private Sub BtnSimpan_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnSimpan.Click
        isitabel()
    End Sub

    Private Sub BtnHapusSemua_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnHapusSemua.Click
        lv.Items.Clear()
    End Sub


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

Private Sub NIK_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles NIK.SelectedIndexChanged
        If NIK.Text = "001" Then
            Nama.Text = "Awaluddin"
        ElseIf NIK.Text = "002" Then
            Nama.Text = "Ricky FM"
        ElseIf NIK.Text = "003" Then
            Nama.Text = "Dewa19"
        End If

    End Sub
End Class


Dan berikut adalah hasil desain nya sobat :

Hasil Setelah Diproses :

Hasil Setelah Disimpan ke Listview : 

Sekian sobat...
Semoga bermanfaat..

Tidak ada komentar: