Senin, 16 Desember 2013

Kasus Pemograman Lisrtik Quis Online

Desain Program Seperti dibawah ini :




Listing Program :

Public Class Form1

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        rancangtabel()
        kodepelanggan()



    End Sub
    Sub kodepelanggan()

        Kd_Pelanggan.Items.Add("PAB - MED - 100")
        Kd_Pelanggan.Items.Add("TOK - BEL - 101")
        Kd_Pelanggan.Items.Add("SWA - MAR - 102")
        Kd_Pelanggan.Items.Add("RUM - BIN - 103")
        Kd_Pelanggan.Items.Add("PAB - PAK - 104")
        Kd_Pelanggan.Items.Add("SWA - TEM - 105")

    End Sub
    Sub rancangtabel()
        LV.Columns.Add("Kode", 100)
        LV.Columns.Add("Nama", 140)
        LV.Columns.Add("Tipe", 160)
        LV.Columns.Add("Harga", 110)
        LV.Columns.Add("Daerah", 100)
        LV.Columns.Add("Biayabeban", 100)
        LV.Columns.Add("Pemakaian", 100)
        LV.Columns.Add("Totaltagihan", 100)
        LV.Columns.Add("Pajak", 100)
        LV.Columns.Add("Pembayaran", 100)
        LV.View = View.Details
        LV.FullRowSelect = True
        LV.GridLines = True
    End Sub
    Sub isitabel()
        Dim a As New ListViewItem
        a.Text = Kd_Pelanggan.Text
        a.SubItems.Add(Nama.Text)
        a.SubItems.Add(Tipe.Text)
        a.SubItems.Add(Hrg.Text)
        a.SubItems.Add(Daerah.Text)
        a.SubItems.Add(Biaya_Beban.Text)
        a.SubItems.Add(Jlh_Pemakaian.Text)
        a.SubItems.Add(Total_Tagihan.Text)
        a.SubItems.Add(Pembayaran.Text)
        LV.Items.Add(a)
    End Sub

    Sub kodekonsumen()

        Kd_Pelanggan.Items.Add("MT- MJ- 010")
        Kd_Pelanggan.Items.Add("MK- MB- 011")
        Kd_Pelanggan.Items.Add("JK- MJ- 012")

    End Sub

    Private Sub Kd_Pelanggan_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Kd_Pelanggan.SelectedIndexChanged
        Dim a, b, c As String
        a = Strings.Right(Kd_Pelanggan.Text, 3)
        Select Case a
            Case "100" : Nama.Text = "Ahmad Yani"
            Case "101" : Nama.Text = "Zul Abdi Tambunan"
            Case "102" : Nama.Text = "Hafizatul Hasanah"
            Case "103" : Nama.Text = "Chanif Arvani"
            Case "104" : Nama.Text = "Enma Syahputri"
            Case "105" : Nama.Text = "Ridalwana"
        End Select

        b = Strings.Left(Kd_Pelanggan.Text, 3)
        Select Case b
            Case "TOK"
                Hrg.Text = 500
                Biaya_Beban.Text = 150000
                Tipe.Text = "Toko"
            Case "RUM"
                Hrg.Text = 200
                Biaya_Beban.Text = 50000
                Tipe.Text = "Rumah"
            Case "PAB"
                Hrg.Text = 10000
                Biaya_Beban.Text = 1000000
                Tipe.Text = "Pabrik"
            Case "SWA"
                Hrg.Text = 1500
                Biaya_Beban.Text = 400000
                Tipe.Text = "Swalayan"
        End Select

        c = Strings.Mid(Kd_Pelanggan.Text, 7, 3)
        Select Case c
            Case "MED"
                Daerah.Text = "Medan"
            Case "BEL"
                Daerah.Text = "Belawan"
            Case "MAR"
                Daerah.Text = "Marendal"
            Case "BIN"
                Daerah.Text = "Binjai"
            Case "PAK"
                Daerah.Text = "Lubuk Pakam"
            Case "TEM"
                Daerah.Text = "Tembung"
            Case Else
                Daerah.Text = "-"

        End Select
    End Sub

    Private Sub Jlh_Pemakaian_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles Jlh_Pemakaian.KeyPress
        If Asc(e.KeyChar) = 13 Then
            Total_Tagihan.Text = Val(Biaya_Beban.Text) + Val(Hrg.Text * Jlh_Pemakaian.Text)
            Pajak.Text = 0.01 * Total_Tagihan.Text
            Pembayaran.Text = Val(Total_Tagihan.Text) + Val(Pajak.Text)
        End If
    End Sub


    Private Sub Btn_Hapus_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Btn_Hapus.Click
        Kd_Pelanggan.Text = ""
        Nama.Text = ""
        Tipe.Text = ""
        Daerah.Text = ""
        Biaya_Beban.Text = ""
        Hrg.Text = ""
        Jlh_Pemakaian.Text = ""
        Total_Tagihan.Text = ""
        Pajak.Text = ""
        Pembayaran.Text = ""

    End Sub

    Private Sub Btn_Keluar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Btn_Keluar.Click
        Me.Close()

    End Sub

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

    Private Sub Btm_HapusData_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Btm_HapusData.Click
        LV.Items.Clear()
    End Sub

    Private Sub Btn_HapusDataYangDipilih_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Btn_HapusDataYangDipilih.Click
        LV.Items.Remove(LV.SelectedItems(0))
    End Sub
End Class


Semoga Bermanfaat.....

Tidak ada komentar:

Posting Komentar