Selasa, 24 Januari 2012

jawaban no 33


Public Class Form1
    Dim LST As ListViewItem
    Private Sub kode_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles kode.SelectedIndexChanged
        Select Case kode.Text
            Case "TS001"
                Microsoft.VisualBasic.Right(kode.Text, 3)
                nama.Text = "Flashdisk 4GB"
                Microsoft.VisualBasic.Left(kode.Text, 2)
                merk.Text = "Toshiba"
            Case "TS002"
                Microsoft.VisualBasic.Right(kode.Text, 3)
                nama.Text = "Flashdisk 2GB"
                Microsoft.VisualBasic.Left(kode.Text, 2)
                merk.Text = "Toshiba"
            Case "VG001"
                Microsoft.VisualBasic.Right(kode.Text, 3)
                nama.Text = "Flashdisk 4GB"
                Microsoft.VisualBasic.Left(kode.Text, 2)
                merk.Text = "V-Gen"
            Case "VG002"
                Microsoft.VisualBasic.Right(kode.Text, 3)
                nama.Text = "Flashdisk 2GB"
                Microsoft.VisualBasic.Left(kode.Text, 2)
                merk.Text = "V-gen"
        End Select

        If kode.Text = "TS001" Then
            harga.Text = "105000"
        ElseIf kode.Text = "TS002" Then
            harga.Text = "75000"
        ElseIf kode.Text = "VG001" Then
            harga.Text = "90000"
        ElseIf kode.Text = "VG002" Then
            harga.Text = "60000"
        End If
    End Sub

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

        buat_table()
        kosong()

    End Sub
    Sub buat_table()
        With LV
            .Items.Clear()
            .FullRowSelect = True
            .GridLines = True
            .View = View.Details

            .Columns.Add("No Pembelian", 100)
            .Columns.Add("Kode Barang", 100)
            .Columns.Add("Nama Barang", 100, HorizontalAlignment.Center)
            .Columns.Add("Merk", 100, HorizontalAlignment.Left)
            .Columns.Add(" Harga ", 100, HorizontalAlignment.Left)
            .Columns.Add("Jumlah Beli", 100, HorizontalAlignment.Left)
            .Columns.Add("Total Harga", 100, HorizontalAlignment.Left)

        End With
    End Sub
    Sub simpan()
        LST = Me.lv.Items.Add(Me.no.Text)
        LST.SubItems.Add(Me.kode.Text)
        LST.SubItems.Add(Me.nama.Text)
        LST.SubItems.Add(Me.merk.Text)
        LST.SubItems.Add(Me.harga.Text)
        LST.SubItems.Add(Me.jumlah.Text)
        LST.SubItems.Add(Me.tharga.Text)

    End Sub


    Sub kosong()
        nama.Text = ""
        no.Text = ""
        kode.Text = ""
        merk.Text = ""
        harga.Text = ""
        jumlah.Text = ""
        tharga.Text = ""
        no.Focus()
    End Sub

  
  
    Private Sub btnhapusdata_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnhapusdata.Click
        If lv.SelectedItems.Count <> 0 Then

            lv.Items.Remove(lv.SelectedItems(0))
        Else
            MsgBox("maaf anda belum" & "memilih yang mana mau dihapus")
        End If
    End Sub

    Private Sub btnsimpan_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnsimpan.Click
        Call simpan()
    End Sub









Tidak ada komentar:

Posting Komentar