Kasus : Latihan Halaman 33
Listing Program
Public Class Form1
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")
buattabel()
End Sub
Private Sub Btnsimpan_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Btnsimpan.Click
Call isitabel()
End Sub
Sub cekharga()
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
Sub buattabel()
LV.Columns.Add("No. Pembelian", 100, HorizontalAlignment.Center)
LV.Columns.Add("Kode Barang", 100, HorizontalAlignment.Center)
LV.Columns.Add("Nama Barang", 100, HorizontalAlignment.Center)
LV.Columns.Add("Merk", 100, HorizontalAlignment.Center)
LV.Columns.Add("Harga", 100, HorizontalAlignment.Center)
LV.Columns.Add("Jumlah Beli", 100, HorizontalAlignment.Center)
LV.Columns.Add("Total Harga", 100, HorizontalAlignment.Center)
LV.View = View.Details
LV.GridLines = True
LV.FullRowSelect = True
End Sub
Sub isitabel()
Dim lst As New ListViewItem
lst.Text = No.Text
lst.SubItems.Add(Kode.Text)
lst.SubItems.Add(Nama_brg.Text)
lst.SubItems.Add(Merk.Text)
lst.SubItems.Add(Harga.Text)
lst.SubItems.Add(Jumlah_beli.Text)
lst.SubItems.Add(Total.Text)
LV.Items.Add(lst)
End Sub
Private Sub Btnkeluar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Btnkeluar.Click
End
End Sub
Private Sub Nama_brg_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Nama_brg.TextChanged
Call cekharga()
End Sub
Private Sub Merk_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Merk.TextChanged
Call cekharga()
End Sub
Private Sub Harga_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Harga.TextChanged
Call cekharga()
End Sub
Private Sub Jumlah_beli_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles Jumlah_beli.KeyPress
If Asc(e.KeyChar) = 13 Then
Total.Text = Harga.Text * Jumlah_beli.Text
End If
End Sub
Private Sub Jumlah_beli_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Jumlah_beli.TextChanged
Call cekharga()
End Sub
Private Sub Kode_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Kode.SelectedIndexChanged
Dim x As String
x = Microsoft.VisualBasic.Left(Kode.Text, 2)
If x = "TS" Then
Merk.Text = "Thosiba"
ElseIf x = "VG" Then
Merk.Text = "V-Gen"
End If
x = Microsoft.VisualBasic.Right(Kode.Text, 3)
If x = "001" Then
Nama_brg.Text = "Flashdisk 4GB"
ElseIf x = "002" Then
Nama_brg.Text = "Flashdisk 2GB"
End If
End Sub
Private Sub Btnbersih_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Btnbersih.Click
No.Text = ""
Kode.Text = ""
Nama_brg.Text = ""
Merk.Text = ""
Harga.Text = ""
Jumlah_beli.Text = ""
Total.Text = ""
No.Focus()
End Sub
Private Sub Btnhapussemua_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Btnhapussemua.Click
LV.Items.Clear()
End Sub
Private Sub Btnhapusdata_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Btnhapusdata.Click
LV.Items.Remove(LV.SelectedItems(0))
End Sub
End Class
Listing Program
Public Class Form1
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")
buattabel()
End Sub
Private Sub Btnsimpan_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Btnsimpan.Click
Call isitabel()
End Sub
Sub cekharga()
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
Sub buattabel()
LV.Columns.Add("No. Pembelian", 100, HorizontalAlignment.Center)
LV.Columns.Add("Kode Barang", 100, HorizontalAlignment.Center)
LV.Columns.Add("Nama Barang", 100, HorizontalAlignment.Center)
LV.Columns.Add("Merk", 100, HorizontalAlignment.Center)
LV.Columns.Add("Harga", 100, HorizontalAlignment.Center)
LV.Columns.Add("Jumlah Beli", 100, HorizontalAlignment.Center)
LV.Columns.Add("Total Harga", 100, HorizontalAlignment.Center)
LV.View = View.Details
LV.GridLines = True
LV.FullRowSelect = True
End Sub
Sub isitabel()
Dim lst As New ListViewItem
lst.Text = No.Text
lst.SubItems.Add(Kode.Text)
lst.SubItems.Add(Nama_brg.Text)
lst.SubItems.Add(Merk.Text)
lst.SubItems.Add(Harga.Text)
lst.SubItems.Add(Jumlah_beli.Text)
lst.SubItems.Add(Total.Text)
LV.Items.Add(lst)
End Sub
Private Sub Btnkeluar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Btnkeluar.Click
End
End Sub
Private Sub Nama_brg_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Nama_brg.TextChanged
Call cekharga()
End Sub
Private Sub Merk_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Merk.TextChanged
Call cekharga()
End Sub
Private Sub Harga_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Harga.TextChanged
Call cekharga()
End Sub
Private Sub Jumlah_beli_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles Jumlah_beli.KeyPress
If Asc(e.KeyChar) = 13 Then
Total.Text = Harga.Text * Jumlah_beli.Text
End If
End Sub
Private Sub Jumlah_beli_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Jumlah_beli.TextChanged
Call cekharga()
End Sub
Private Sub Kode_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Kode.SelectedIndexChanged
Dim x As String
x = Microsoft.VisualBasic.Left(Kode.Text, 2)
If x = "TS" Then
Merk.Text = "Thosiba"
ElseIf x = "VG" Then
Merk.Text = "V-Gen"
End If
x = Microsoft.VisualBasic.Right(Kode.Text, 3)
If x = "001" Then
Nama_brg.Text = "Flashdisk 4GB"
ElseIf x = "002" Then
Nama_brg.Text = "Flashdisk 2GB"
End If
End Sub
Private Sub Btnbersih_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Btnbersih.Click
No.Text = ""
Kode.Text = ""
Nama_brg.Text = ""
Merk.Text = ""
Harga.Text = ""
Jumlah_beli.Text = ""
Total.Text = ""
No.Focus()
End Sub
Private Sub Btnhapussemua_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Btnhapussemua.Click
LV.Items.Clear()
End Sub
Private Sub Btnhapusdata_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Btnhapusdata.Click
LV.Items.Remove(LV.SelectedItems(0))
End Sub
End Class
0 komentar:
Posting Komentar