Selasa, 21 Mei 2013

Membuat Aplikasi Sederhana Menggunakan Listview Di VB. Net 2008

Penggunaan Listview



Ini adalah Kodingnya

Import Mysql.Data Mysql Client
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
            juman.Items.Add(i)
        Next i

        For i = 1 To 10
            jamlem.Items.Add(i)
        Next i
        status.Items.Add("Menikah")
        status.Items.Add("Belum Menikah")
        buattabel()
    End Sub


Sumber : http://mesran.net/ 






    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" : tunis.Text = 0.09 * gaji.Text
            Case "Belum Menikah" : tunis.Text = 0
        End Select
    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(tunis.Text)
        lst.SubItems.Add(juman.Text)
        lst.SubItems.Add(tunak.Text)
        lst.SubItems.Add(jamlem.Text)
        lst.SubItems.Add(holem.Text)
        lst.SubItems.Add(pajak.Text)
        lst.SubItems.Add(total.Text)
        lv.Items.Add(lst)
    End Sub

    Private Sub juman_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles juman.SelectedIndexChanged

        If juman.Text >= 2 And status.Text = "Menikah" Then
            tunak.Text = 0.007 * gaji.Text
        ElseIf juman.Text = 1 And status.Text = "Menikah" Then

            tunak.Text = 0.003 * gaji.Text
        Else
            tunak.Text = 0

        End If
    End Sub

    Private Sub Btnproses_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Btnproses.Click
        total.Text = Val(holem.Text) + Val(gaji.Text) + Val(tunis.Text) + Val(tunak.Text) - Val(pajak.Text)
        isitabel()
        nik.Text = ""
        nama.Text = ""
        jabatan.Text = ""
        gaji.Text = ""
        status.Text = ""
        tunis.Text = ""
        tunak.Text = ""
        juman.Text = ""
        jamlem.Text = ""
        holem.Text = ""
        pajak.Text = ""
        total.Text = ""
    End Sub

    Private Sub jamlem_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles jamlem.SelectedIndexChanged
        If jabatan.Text = "Mandor" Then
            holem.Text = 7500 * jamlem.Text
        ElseIf jabatan.Text = "Kepala Bagian" Then
            holem.Text = 10000 * jamlem.Text
        ElseIf jabatan.Text = "Staff" Then
            holem.Text = 5000 * jamlem.Text
        Else
            holem.Text = 0
        End If
    End Sub

    Private Sub nik_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles nik.SelectedIndexChanged

        Select Case nik.Text
            Case "001" : nama.Text = "Iche Gustiyani"
            Case "002" : nama.Text = "Nurul Hidayati"
            Case "003" : nama.Text = "Minarya Sitepu"
        End Select
    End Sub

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

    Sub buattabel()
        lv.Columns.Add("NIK", 30, HorizontalAlignment.Center)
        lv.Columns.Add("Nama", 100, HorizontalAlignment.Left)
        lv.Columns.Add("Jabatan", 80, HorizontalAlignment.Center)
        lv.Columns.Add("Gaji", 80, HorizontalAlignment.Center)
        lv.Columns.Add("Status", 80, HorizontalAlignment.Center)
        lv.Columns.Add("Tunjangan Istri", 90, HorizontalAlignment.Center)
        lv.Columns.Add("Jumlah Anak", 90, HorizontalAlignment.Center)
        lv.Columns.Add("Tunjangan Anak", 90, HorizontalAlignment.Center)
        lv.Columns.Add("Jam Lembur", 90, HorizontalAlignment.Center)
        lv.Columns.Add("Honor Lembur", 100, HorizontalAlignment.Center)
        lv.Columns.Add("Pajak", 50, HorizontalAlignment.Center)
        lv.Columns.Add("Total", 90, HorizontalAlignment.Center)
        lv.View = View.Details
        lv.GridLines = True
        lv.FullRowSelect = True
    End Sub

Tidak ada komentar:

Posting Komentar