Kamis, 06 Juni 2013

PENGGAJIAN KARYAWAN MENGGUNAKAN LISTVIEW PADA PROGRAM MICROSOFT VISUAL STUDIO 2008

1.      Design form:
2.  Listing program
Public Class Form1
    Sub buattabel()
        Lv.Columns.Add("nik", 40, HorizontalAlignment.Center)
        Lv.Columns.Add("nama", 40, HorizontalAlignment.Center)
        Lv.Columns.Add("jabatan", 80, HorizontalAlignment.Center)
        Lv.Columns.Add("gaji", 60, HorizontalAlignment.Center)
        Lv.Columns.Add("status", 60, HorizontalAlignment.Center)
        Lv.Columns.Add("tunj_istri", 80, HorizontalAlignment.Center)
        Lv.Columns.Add("jmlh_anak", 80, HorizontalAlignment.Center)
        Lv.Columns.Add("tunj_anak", 80, HorizontalAlignment.Center)
        Lv.Columns.Add("jmlh_lembur", 80, HorizontalAlignment.Center)
        Lv.Columns.Add("honor_lembur", 90, HorizontalAlignment.Center)
        Lv.Columns.Add("pajak", 50, HorizontalAlignment.Center)
        Lv.Columns.Add("total", 50, 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(tunj_istri.Text)
        lst.SubItems.Add(jmlh_anak.Text)
        lst.SubItems.Add(tunj_anak.Text)
        lst.SubItems.Add(jam_lembur.Text)
        lst.SubItems.Add(honor_lembur.Text)
        lst.SubItems.Add(pajak.Text)
        lst.SubItems.Add(total.Text)
        Lv.Items.Add(lst)
    End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        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
            jmlh_anak.Items.Add(i)
        Next i
        For i = 1 To 10
            jam_lembur.Items.Add(i)
        Next i
        status.Items.Add("menikah")
        status.Items.Add("tidak menikah")
        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" : gaji.Text = 1750000
            Case "kepala bagian" : gaji.Text = 2500000
            Case "staff" : gaji.Text = 1250000
        End Select
        pajak.Text = 0.015 * gaji.Text
    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" : tunj_istri.Text = 0.09 * gaji.Text : jmlh_anak.Enabled = True
            Case "tidak menikah" : tunj_istri.Text = 0 : jmlh_anak.Enabled = False : tunj_anak.Text = 0
        End Select
    End Sub
    Private Sub jmlh_anak_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles jmlh_anak.SelectedIndexChanged
        If jmlh_anak.Text >= 2 Then
            tunj_anak.Text = 0.07 * gaji.Text
        ElseIf jmlh_anak.Text = 1 Then
            tunj_anak.Text = 0.03 * gaji.Text
        Else
            jmlh_anak.Text = 0
        End If
    End Sub
    Private Sub proses_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles proses.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
        honor_lembur.Text = honor * jam_lembur.Text
        total.Text = Val(honor_lembur.Text) + Val(gaji.Text) + Val(tunj_istri.Text) + Val(tunj_anak.Text) - Val(pajak.Text)
    End Sub
    Private Sub baru_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles baru.Click
        nik.Text = ""
        nama.Text = ""
        jabatan.Text = ""
        gaji.Text = ""
        status.Text = ""
        tunj_anak.Text = ""
        tunj_istri.Text = ""
        jmlh_anak.Text = ""
        jam_lembur.Text = ""
        honor_lembur.Text = ""
        pajak.Text = ""
        total.Text = ""
    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 dari program ini?", MsgBoxStyle.Question + MsgBoxStyle.YesNo, "Daftar Nilai")
        If i = MsgBoxResult.Yes Then
            Close()
        End If
    End Sub
  
 Private Sub simpan_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles simpan.Click
        isitabel()
        nik.Text = ""
        nama.Text = ""
        jabatan.Text = ""
        gaji.Text = ""
        status.Text = ""
        tunj_istri.Text = ""
        jmlh_anak.Text = ""
        tunj_anak.Text = ""
        jam_lembur.Text = ""
        honor_lembur.Text = ""
        pajak.Text = ""
        total.Text = ""
    End Sub
End Class

Tidak ada komentar:

Poskan Komentar