Kamis, 12 Desember 2013

0 Tugas Listview tentang penjualan harga barang


Jangan Lupa Tinggalkan Komentar Kalian Ya...!!!


Public Class Form1
    Sub buat()
        lv.Columns.Add("No Pembelian", 150, HorizontalAlignment.Center)
        lv.Columns.Add("Kode Barang", 200, HorizontalAlignment.Center)
        lv.Columns.Add("Nama Barang", 200, HorizontalAlignment.Center)
        lv.Columns.Add("Merk", 100, HorizontalAlignment.Center)
        lv.Columns.Add("Harga", 100, HorizontalAlignment.Center)
        lv.Columns.Add("Jumlah Beli", 200, HorizontalAlignment.Center)
        lv.Columns.Add("Total Harga", 200, HorizontalAlignment.Center)
        lv.View = View.Details
        lv.GridLines = True
        lv.FullRowSelect = True

    End Sub

    Sub isi()
        Dim lst As New ListViewItem
        lst.Text = np.Text
        lst.SubItems.Add(kb.Text)
        lst.SubItems.Add(nb.Text)
        lst.SubItems.Add(merk.Text)
        lst.SubItems.Add(harga.Text)
        lst.SubItems.Add(jb.Text)
        lst.SubItems.Add(th.Text)
        lv.Items.Add(lst)
    End Sub

    Private Sub btnsimpan_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnsimpan.Click
        isi()
        np.Text = ""
        kb.Text = ""
        nb.Text = ""
        merk.Text = ""
        harga.Text = ""
        jb.Text = ""
        th.Text = ""

    End Sub

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        buat()
        kb.Items.Add("TS001")
        kb.Items.Add("TS002")
        kb.Items.Add("VG001")
        kb.Items.Add("VG002")
    End Sub

    Private Sub kb_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles kb.SelectedIndexChanged
        Dim X, Y As String
        X = Microsoft.VisualBasic.Left(kb.Text, 2)
        Y = Microsoft.VisualBasic.Right(kb.Text, 3)


        If X = "TS" Then
            If Y = "001" Then
                merk.Text = "THOSIBA"
                nb.Text = "Flashdisk 4 GB"
                harga.Text = "80000"
            ElseIf Y = "002" Then
                merk.Text = "THOSIBA"
                nb.Text = "Flashdisk 2 GB"
                harga.Text = "60000"
            End If

        ElseIf X = "VG" Then

            If Y = "001" Then
                merk.Text = "V-Gen"
                nb.Text = "Flashdisk 4 GB"
                harga.Text = "45000"

            ElseIf Y = "002" Then
                merk.Text = "V-Gen"
                nb.Text = "Flashdisk 2 GB"
                harga.Text = "40000"
            End If

        End If

    End Sub
    Private Sub jb_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles jb.KeyPress
        If e.KeyChar = Chr(13) Then
            th.Text = Val(harga.Text * jb.Text)
        End If
    End Sub

    Private Sub btnbersih_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnbersih.Click
        np.Text = ""
        kb.Text = ""
        nb.Text = ""
        merk.Text = ""
        harga.Text = ""
        jb.Text = ""
        th.Text = ""
    End Sub

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

    Private Sub btnhd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnhd.Click
        lv.Items.Remove(lv.Items(0))
    End Sub

    Private Sub btnkeluar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnkeluar.Click
        Me.Close()
    End Sub
End Class

0 komentar:

Posting Komentar