Senin, 20 Mei 2013

Menyimpan Dengan Listview

Silahkan Design Form seperti dibawah ini :

Bingung...?
Aq kasih tau dehh...
buat 8 label, 5 textbox, 3 combo box, 1 listview, 4 commbo Button

Sudahhh......?
Klo Sudah ketik listing programnya
berikut ini :


Sub addnik()
        With nik
            .Items.Add("001")
            .Items.Add("002")
            .Items.Add("003")
        End With
    End Sub
   
    Sub addjabatan()
        With jabatan
            .Items.Add("Mandor")
            .Items.Add("Kepala Bagian")
            .Items.Add("Staf")
        End With
    End Sub
    Sub addstatus()
        With status
            .Items.Add("menikah")
            .Items.Add("Belum menikah")
        End With
    End Sub
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        addjabatan()
        addnik()
        addstatus()
        rancangtabel()

    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 "Staf" : gaji.Text = 1250000
        End Select
        pajak.Text = 0.15 * gaji.Text
    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 = "Kiky"
            Case "002" : nama.Text = "susanty"
            Case "003" : nama.Text = "farhan"
        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"
                tunj_keluarga.Text = 0.15 * gaji.Text
            Case "Belum Menikah"
                tunj_keluarga.Text = 0
                tunj_keluarga.Text = "0"
        End Select
    End Sub

    Private Sub proses_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles proses.Click
        total_gaji.Text = Val(gaji.Text) + Val(tunj_keluarga.Text) - Val(pajak.Text)

    End Sub

    Private Sub baru_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles baru.Click
        nik.Text = ""
        nama.Text = ""
        jabatan.Text = ""
        gaji.Text = ""
        status.Text = ""
        tunj_keluarga.Text = ""
        pajak.Text = ""
        total_gaji.Text = ""
    End Sub

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

    Private Sub simpan_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles simpan.Click
        isitabel()
    End Sub
Sub rancangtabel()
        With LV
            .Columns.Add("NIK", 100, HorizontalAlignment.Center)
            .Columns.Add("Nama", 100, HorizontalAlignment.Center)
            .Columns.Add("Jabatan", 100, HorizontalAlignment.Center)
            .Columns.Add("Gaji", 100, HorizontalAlignment.Center)
            .Columns.Add("Status", 100, HorizontalAlignment.Center)
            .Columns.Add("Tunj.Keluarga", 100, HorizontalAlignment.Center)
            .Columns.Add("Pajak", 100, HorizontalAlignment.Center)
            .Columns.Add("Total Gaji", 100, HorizontalAlignment.Center)
            .GridLines = True
            .View = View.Details
            .FullRowSelect = True
        End With
    End Sub
    Sub isitabel()
        Dim x As New ListViewItem
        x.Text = nik.Text
        x.SubItems.Add(nama.Text)
        x.SubItems.Add(jabatan.Text)
        x.SubItems.Add(gaji.Text)
        x.SubItems.Add(status.Text)
        x.SubItems.Add(tunj_keluarga.Text)
        x.SubItems.Add(pajak.Text)
        x.SubItems.Add(total_gaji.Text)
        LV.Items.Add(x)
    End Sub

  NB : sub rancang tabel dipanggil di form load
                sub isi tabel dipanggil dibutton simpan

Kalu sudah, hasilnya akan terlihat seperti berikut :

Gampanggg kan...
Selamat mencoba ya

0 komentar:

Posting Komentar

Template by:

Free Blog Templates