Sunday, December 8, 2013

PEMBAYARAN TAGIHAN AIR MENGGUNAKAN IF -ELSE


Desain from di bawah ini :


Public Class Form1
    Dim i As Byte
    Sub buattable()
        LV.Columns.Add("No", 50, HorizontalAlignment.Center)
        LV.Columns.Add("tipe", 80, HorizontalAlignment.Center)
        LV.Columns.Add("nama", 180, HorizontalAlignment.Center)
        LV.Columns.Add("hargam3", 180, HorizontalAlignment.Center)
        LV.Columns.Add("biayabeban", 180, HorizontalAlignment.Center)
        LV.Columns.Add("pemakaianair", 180, HorizontalAlignment.Center)
        LV.Columns.Add("totaltagihan", 180, HorizontalAlignment.Center)
        LV.Columns.Add("pajak", 180, HorizontalAlignment.Center)
        LV.Columns.Add("pembayaran", 180, HorizontalAlignment.Center)
        LV.Columns.Add("daerah", 180, HorizontalAlignment.Center)
        LV.View = View.Details
        LV.GridLines = True
        LV.FullRowSelect = True

    End Sub
    Sub isitable()
        Dim lst As New ListViewItem
        lst.Text = i
        lst.SubItems.Add(tipe.Text)
        lst.SubItems.Add(nama.Text)
        lst.SubItems.Add(hargam3.Text)
        lst.SubItems.Add(biayabeban.Text)
        lst.SubItems.Add(pemakaianair.Text)
        lst.SubItems.Add(totaltagihan.Text)
        lst.SubItems.Add(pajak.Text)
        lst.SubItems.Add(pembayaran.Text)
        lst.SubItems.Add(daerah.Text)
        LV.Items.Add(lst)
        i = i + 1
    End Sub

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        buattable()
        Kodepelanggan.Items.Add("TOK-MED-100")
        Kodepelanggan.Items.Add("PAB-BEL-101")
        Kodepelanggan.Items.Add("SWA-BEL-102")
        Kodepelanggan.Items.Add("PAB-MED-103")
        Kodepelanggan.Items.Add("RUM-MED-104")
        i = 1
    End Sub

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

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

    Private Sub Btnsimpanke_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Btnsimpanke.Click
        isitable()
        tipe.Text = ""
        nama.Text = ""
        hargam3.Text = ""
        biayabeban.Text = ""
        pemakaianair.Text = ""
        totaltagihan.Text = ""
        pajak.Text = ""
        pembayaran.Text = ""
        daerah.Text = ""
    End Sub

    Private Sub Kodepelanggan_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Kodepelanggan.SelectedIndexChanged
        Dim x As String
        x = Microsoft.VisualBasic.Right(Kodepelanggan.Text, 3)



        If x = "100" Then
            nama.Text = "siska juli yanti"
        ElseIf x = "101" Then
            nama.Text = "Tri dessy novuta l"
        ElseIf x = "102" Then
            nama.Text = "Halima tusa'diah"
        ElseIf x = "103" Then
            nama.Text = "jeffry man"
        End If


        x = Microsoft.VisualBasic.Left(Kodepelanggan.Text, 3)

        If x = "PAB" Then
            hargam3.Text = 500
            biayabeban.Text = 250000
            tipe.Text = "Pabrik"
        ElseIf x = "TOK" Then
            hargam3.Text = 500
            biayabeban.Text = 25000
            tipe.Text = "Toko"
        ElseIf x = "RUM" Then
            hargam3.Text = 500
            biayabeban.Text = 10000
            tipe.Text = "Rumah"
        ElseIf x = "SWA" Then
            hargam3.Text = 200
            biayabeban.Text = 15000
            tipe.Text = "Swalayan"
        End If

        x = Microsoft.VisualBasic.Mid(Kodepelanggan.Text, 5, 3)
        If x = "MED" Then
            daerah.Text = "Medan"
        ElseIf x = "BEL" Then
            daerah.Text = "Belawan"
        End If
    End Sub

    Private Sub pemakaianair_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles pemakaianair.KeyPress
        If e.KeyChar = Chr(13) Then
            If Asc(e.KeyChar) = 13 Then
                totaltagihan.Text = hargam3.Text * pemakaianair.Text + Val(biayabeban.Text)
                pajak.Text = 0.01 * totaltagihan.Text
                pembayaran.Text = Val(totaltagihan.Text) + Val(pajak.Text)
            End If
        End If
    End Sub

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

0 comments:

Post a Comment