Public Class Form1
Private Sub Form1_FormClosing(ByVal
sender As Object,
ByVal e As
System.Windows.Forms.FormClosingEventArgs) Handles
Me.FormClosing
e.Cancel = True
If
MsgBox("Anda Yakin?",
MsgBoxStyle.YesNo) = MsgBoxResult.Yes Then
End
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")
buattable()
End Sub
Sub kde()
If
Microsoft.VisualBasic.Left(kode.Text, 2) = "TS"
Then
Merek.Text = "Thosiba"
ElseIf
Microsoft.VisualBasic.Left(kode.Text, 2) = "VG"
Then
Merek.Text = "V-Gen"
End If
If
Microsoft.VisualBasic.Right(kode.Text, 3) = "001"
Then
Nama_Barang.Text = "Flashdick 4GB"
ElseIf
Microsoft.VisualBasic.Right(kode.Text, 3) = "002"
Then
Nama_Barang.Text = "Flashdick 2GB"
End If
End Sub
Private Sub kode_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles
kode.SelectedIndexChanged
kde()
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 Harga_TextChanged(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles Harga.TextChanged
End Sub
Private Sub Jumlah_KeyPress(ByVal
sender As Object,
ByVal e As
System.Windows.Forms.KeyPressEventArgs) Handles
Jumlah.KeyPress
If
Asc(e.KeyChar) = 13 Then
Total.Text = Jumlah.Text *
Harga.Text
End If
End Sub
Sub
buattable()
LV.Columns.Add("No
Pembelian", 100, HorizontalAlignment.Center)
LV.Columns.Add("Kode
Barang", 80, HorizontalAlignment.Center)
LV.Columns.Add("Nama
BArang", 80, HorizontalAlignment.Center)
LV.Columns.Add("Merek",
80, HorizontalAlignment.Center)
LV.Columns.Add("Harga",
80, HorizontalAlignment.Center)
LV.Columns.Add("Jumlah
Beli", 80, HorizontalAlignment.Center)
LV.Columns.Add("Total
Harga", 80, HorizontalAlignment.Center)
LV.View = View.Details
LV.FullRowSelect = True
LV.GridLines = True
End Sub
Sub isi()
Dim lst
As New
ListViewItem
lst.Text = No_pem.Text
lst.SubItems.Add(kode.Text)
lst.SubItems.Add(Nama_Barang.Text)
lst.SubItems.Add(Merek.Text)
lst.SubItems.Add(Harga.Text)
lst.SubItems.Add(Jumlah.Text)
lst.SubItems.Add(Total.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()
End Sub
Private Sub Hapus_semua_Click(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles Hapus_semua.Click
LV.Items.Clear()
End Sub
Private Sub Hapus_data_Click(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles Hapus_data.Click
LV.Items.Remove(LV.SelectedItems(0))
End Sub
Private Sub Jumlah_TextChanged(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles Jumlah.TextChanged
If Not IsNumeric(Jumlah.Text) Then
Jumlah.Clear()
End If
Total.ReadOnly = True
End Sub
Private Sub BtnBesih_Click(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles BtnBesih.Click
brsh(Me)
End Sub
Sub brsh(ByVal F As Form1)
Dim x As Object
For Each x In F.Controls
If TypeOf x Is TextBox Then x.text = ""
If TypeOf x Is ComboBox Then x.text = ""
Next
End Sub
Private Sub BtnKeluar_Click(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles BtnKeluar.Click
If
MsgBox("Apakah Anda Ingin Keluar?",
MsgBoxStyle.YesNo) = MsgBoxResult.Yes Then
End
End If
End Sub
End Class
Tidak ada komentar:
Posting Komentar