Minggu, 08 Desember 2013

Program Pemakaian Listrik




Desain Awal




Sintax:


Public Class Form1

    Sub buattable()
        lv.Columns.Add("ID Pelanggan", 50, HorizontalAlignment.Center)
        lv.Columns.Add("Nama", 50, HorizontalAlignment.Center)
        lv.Columns.Add("Daerah", 50, HorizontalAlignment.Center)
        lv.Columns.Add("Tipe", 70, HorizontalAlignment.Center)
        lv.Columns.Add("Biaya", 65, HorizontalAlignment.Center)
        lv.Columns.Add("Harga PerKWH", 65, HorizontalAlignment.Center)
        lv.Columns.Add("Pemakaian", 65, HorizontalAlignment.Center)
        lv.Columns.Add("Total Tagihan", 65, HorizontalAlignment.Center)
        lv.Columns.Add("Pajak", 65, HorizontalAlignment.Center)
        lv.Columns.Add("Pembayaran", 65, HorizontalAlignment.Center)

        lv.GridLines = True
        lv.FullRowSelect = True
        lv.View = View.Details
    End Sub
    Sub isitabel()
        Dim ist As New ListViewItem
        ist.Text = id.Text
        ist.SubItems.Add(nama.Text)
        ist.SubItems.Add(daerah.Text)
        ist.SubItems.Add(tipe.Text)
        ist.SubItems.Add(beban.Text)
        ist.SubItems.Add(harga.Text)

        ist.SubItems.Add(besar.Text)
        ist.SubItems.Add(total.Text)
        ist.SubItems.Add(pajak.Text)
        ist.SubItems.Add(bayar.Text)
        lv.Items.Add(ist)
    End Sub
   
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        buattable()
        id.Items.Add("1320")
        id.Items.Add("1321")
        id.Items.Add("1322")
        id.Items.Add("1323")
        id.Items.Add("1324")
        id.Items.Add("1325")
        daerah.Items.Add("Amplas")
        daerah.Items.Add("Simpang Limun")
        daerah.Items.Add("Menteng")
        daerah.Items.Add("Denai")
        daerah.Items.Add("Sukaramai")
        tipe.Items.Add("Toko")
        tipe.Items.Add("Rumah")
        tipe.Items.Add("Swalayan")
        tipe.Items.Add("Pabrik")

    End Sub

    Private Sub id_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles id.SelectedIndexChanged
         Select id.Text
            Case "1320"
                nama.Text = "Yayuk sulistiawati"
            Case "1321"
                nama.Text = "Chandra Pancari"
            Case "1322"
                nama.Text = "Rina Purnama"
            Case "1323"
                nama.Text = "vera Alinka"
            Case "1324"
                nama.Text = "Siti Hazar"

        End Select
    End Sub

    Private Sub tipe_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tipe.SelectedIndexChanged
Select tipe.Text
            Case "Toko"
                beban.Text = "150000"
                harga.Text = "500"
            Case "Rumah"
                beban.Text = "500000"
                harga.Text = "200"
            Case "Swalayan"
                beban.Text = "400000"
                harga.Text = "1500"
            Case "Pabrik"
                beban.Text = "1000000"
                harga.Text = "1000"

        End Select

    End Sub

    Private Sub bayar_KeyPress1(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles bayar.KeyPress
        Dim tombol As Integer = Asc(e.KeyChar)
        If tombol = 13 Then
            total.Text = beban.Text + (harga.Text * besar.Text)
            pajak.Text = 0.5 * total.Text
            bayar.Text = Val(total.Text) + Val(pajak.Text)
        End If

    End Sub

 
   
    Private Sub simpan_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles simpan.Click
        isitabel()
        id.Text = ""
        nama.Text = ""
        daerah.Text = ""
        tipe.Text = ""
        beban.Text = ""
        harga.Text = ""
        besar.Text = ""
        total.Text = ""
        pajak.Text = ""
        bayar.Text = ""
    End Sub

    Private Sub hapus_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles hapus.Click
        id.Text = ""
        nama.Text = ""
        daerah.Text = ""
        tipe.Text = ""
        beban.Text = ""
        harga.Text = ""
        besar.Text = ""
        total.Text = ""
        pajak.Text = ""
        bayar.Text = ""
    End Sub

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

    Private Sub pilih_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles pilih.Click
        lv.Items.Remove(lv.SelectedItems(0))
    End Sub
   
    Private Sub keluar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles keluar.Click
        Dim tanya As String
        tanya = MsgBox("Apakah Anda ingin Keluar?", MsgBoxStyle.YesNo)
        If tanya = vbCancel Then
            Me.Close()
        ElseIf tanya = vbNo Then
            Me.Focus()
        ElseIf tanya = vbYes Then
            Me.Close()
        End If

    End Sub
End Class

Desain Akhir

Tidak ada komentar:

Posting Komentar