haiii kawan ada sedikit program neh
dalam program VB.NET 2008 dengan memakai listview dan gridview
dalam program VB.NET 2008 dengan memakai listview dan gridview
Public Class Form2
Sub rancang_tebel()
LV.Columns.Add("KODE BARANG", 50, HorizontalAlignment.Left)
LV.Columns.Add("NAMA BARANG", 100, HorizontalAlignment.Left)
LV.Columns.Add("HARGA BARANG", 100, HorizontalAlignment.Left)
LV.Columns.Add("JUMLAH BARANG", 50, HorizontalAlignment.Left)
LV.Columns.Add("TOTAL BARANG", 100, HorizontalAlignment.Left)
LV.Columns.Add("DISCOUND", 50, HorizontalAlignment.Left)
LV.Columns.Add("TOTAL BAYAR", 100, HorizontalAlignment.Left)
LV.GridLines = True
LV.FullRowSelect = True
LV.View = View.Details
End Sub
Private Sub kode_barang_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles kode_barang.KeyPress
If kode_barang.Text = "Me 001" Then
nama_barang.Text = "buku tulis"
harga_barang.Text = "2000"
ElseIf kode_barang.Text = "Me 002" Then
nama_barang.Text = "pengaris"
harga_barang.Text = "5000"
ElseIf kode_barang.Text = "Me 004" Then
nama_barang.Text = "pulpen"
harga_barang.Text = "5000"
End If
End Sub
Private Sub kode_barang_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles kode_barang.TextChanged
End Sub
Private Sub btn_proses_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_proses.Click
total_harga.Text = harga_barang.Text * jumlah_barang.Text
If total_harga.Text >= 500000 Then
discount.Text = 0.1 * total_harga.Text
Else
discount.Text = 0
End If
total_bayar.Text = Val(total_harga.Text) - Val(discount.Text)
End Sub
Sub isi_tabel()
Dim x As New ListViewItem
x.Text = kode_barang.Text
x.SubItems.Add(nama_barang.Text)
x.SubItems.Add(harga_barang.Text)
x.SubItems.Add(jumlah_barang.Text)
x.SubItems.Add(total_harga.Text)
x.SubItems.Add(discount.Text)
x.SubItems.Add(total_bayar.Text)
LV.Items.Add(x)
End Sub
Private Sub btn_simpan_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_simpan.Click
Call isi_tabel()
Call ISIGRIDVIEW()
Call HAPUS()
Call GRIDVIEW()
End Sub
Private Sub btn_hapus_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_hapus.Click
kode_barang.Text = ""
nama_barang.Text = ""
harga_barang.Text = ""
jumlah_barang.Text = ""
total_harga.Text = ""
discount.Text = ""
total_bayar.Text = ""
End Sub
Private Sub btn_keluar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_keluar.Click
Dim kodok As String
kodok = MsgBox("apakah Anda yakin ingin keluar", MsgBoxStyle.YesNo)
If kodok = vbYes Then
End If
Me.Close()
End Sub
Sub HAPUS()
kode_barang.Text = ""
nama_barang.Text = ""
harga_barang.Text = ""
jumlah_barang.Text = ""
total_harga.Text = ""
discount.Text = ""
total_bayar.Text = ""
End Sub
Private Sub LV_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles LV.Click
kode_barang.Text = LV.SelectedItems(0).SubItems(0).Text
nama_barang.Text = LV.SelectedItems(0).SubItems(1).Text
harga_barang.Text = LV.SelectedItems(0).SubItems(2).Text
jumlah_barang.Text = LV.SelectedItems(0).SubItems(3).Text
total_harga.Text = LV.SelectedItems(0).SubItems(4).Text
discount.Text = LV.SelectedItems(0).SubItems(5).Text
total_bayar.Text = LV.SelectedItems(0).SubItems(6).Text
End Sub
Private Sub LV_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles LV.SelectedIndexChanged
End Sub
Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Call rancang_tebel()
Call GRIDVIEW()
End Sub
Sub GRIDVIEW()
DG.ColumnCount = 7
DG.Columns(0).HeaderText = "KODE BARANG"
DG.Columns(1).HeaderText = "NAMA BARANG"
DG.Columns(2).HeaderText = "HARGA BARANG"
DG.Columns(3).HeaderText = "JUMLAH BARANG"
DG.Columns(4).HeaderText = "TOTAL HARGA"
DG.Columns(5).HeaderText = "DISCOUNT"
DG.Columns(6).HeaderText = "TOTAL BAYAR"
End Sub
Sub ISIGRIDVIEW()
DG.Rows.Add(kode_barang.Text, nama_barang.Text, jumlah_barang.Text, total_harga.Text, discount.Text, total_bayar.Text)
End Sub
End Class
0 komentar:
Posting Komentar