Desaign yukk ....
ini Codingnya ...
kita pakai Kondisi SELECT-CASE ya
Public Class Form1
Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
kodebarang.Items.Add("TS001")
kodebarang.Items.Add("TS002")
kodebarang.Items.Add("VG001")
kodebarang.Items.Add("VG002")
RancangTable()
End Sub
Sub RancangTable()
ListView1.Columns.Add("No Pembelian", 80, HorizontalAlignment.Center)
ListView1.Columns.Add("Kode Barang", 100, HorizontalAlignment.Center)
ListView1.Columns.Add("Nama Barang", 100, HorizontalAlignment.Center)
ListView1.Columns.Add("Merek", 100, HorizontalAlignment.Center)
ListView1.Columns.Add("Harga", 100, HorizontalAlignment.Center)
ListView1.Columns.Add("Jumlah Beli", 100, HorizontalAlignment.Center)
ListView1.Columns.Add("Total Harga", 100, HorizontalAlignment.Center)
ListView1.View = View.Details
ListView1.FullRowSelect = True
ListView1.GridLines = True
End Sub
Sub IsiTable()
Dim list As New ListViewItem
list.Text = nopembelian.Text
list.SubItems.Add(kodebarang.Text)
list.SubItems.Add(namabarang.Text)
list.SubItems.Add(merk.Text)
list.SubItems.Add(harga.Text)
list.SubItems.Add(jumlahbeli.Text)
list.SubItems.Add(totalharga.Text)
ListView1.Items.Add(list)
End Sub
Private Sub Kode_Barang_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles kodebarang.SelectedIndexChanged
Dim x As String
x = Microsoft.VisualBasic.Left(kodebarang.Text, 2)
Select Case x
Case "TS"
merk.Text = "Toshiba"
Case "VG"
merk.Text = "V-Gen"
End Select
Dim j As String
j = Microsoft.VisualBasic.Right(kodebarang.Text, 3)
Select Case j
Case "001"
namabarang.Text = "Flashdisk 4 GB"
Case "002"
namabarang.Text = "Flashdisk 2 GB"
End Select
Select Case x & j
Case "TS" & "001"
harga.Text = 105000
Case "TS" & "002"
harga.Text = 75000
Case "VG" & "001"
harga.Text = 90000
Case "VG" & "002"
harga.Text = 60000
End Select
End Sub
Private Sub Jumlah_Beli_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles jumlahbeli.KeyPress
Dim x As Integer = Asc(e.KeyChar)
If x = 13 Then
totalharga.Text = harga.Text * jumlahbeli.Text
End If
End Sub
Private Sub Simpan_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnSimpanKeListView.Click
IsiTable()
End Sub
Private Sub Bersih_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnBersih.Click
nopembelian.Text = ""
kodebarang.Text = ""
namabarang.Text = ""
merk.Text = ""
harga.Text = ""
jumlahbeli.Text = ""
totalharga.Text = ""
End Sub
Private Sub Hapus_Semua_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnHapusSemuaData.Click
ListView1.Items.Clear()
End Sub
Private Sub HapusData_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnHapusDataYangDiPilih.Click
ListView1.Items.Remove(ListView1.SelectedItems(0))
End Sub
Private Sub Keluar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButnKeluar.Click
End
End Sub
End Class
dan inilah hasilnya :
Thursday, January 8, 2015
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment