Public Class Penjualan
Private Sub cbBarang_SelectedIndexChanged(sender As Object, e As EventArgs) Handles
cbBarang.SelectedIndexChanged
If cbBarang.Text = "B001" Then
txtNama.Text = "Spidol"
txtHarga.Text = 23000
ElseIf cbBarang.Text = "B002" Then
txtNama.Text = "Buku"
txtHarga.Text = 5000
ElseIf cbBarang.Text = "B003" Then
txtNama.Text = "Pulpen"
txtHarga.Text = 3500
Else
MessageBox.Show("Kode barang
tidak tersedia")
End If
End Sub
Private Sub btnTambahkan_Click(sender As Object, e As EventArgs) Handles btnTambahkan.Click
Dim row As String() = New String() {cbBarang.Text, txtNama.Text, txtHarga.Text,
txtKts.Text, Val(txtHarga.Text) * Val(txtKts.Text)}
DataGridView1.Rows.Add(row)
Me.cbBarang.Text = ""
Me.txtNama.Clear()
Me.txtHarga.Clear()
Me.txtKts.Clear()
End Sub
Private Sub Penjualan_Load(sender As Object, e As EventArgs) Handles MyBase.Load
'menentukan
jumlah kolom
DataGridView1.ColumnCount = 5
'memberi
judul kolom
DataGridView1.Columns(0).Name = "Kode Barang"
DataGridView1.Columns(1).Name = "Nama Barang"
DataGridView1.Columns(2).Name = "Harga"
DataGridView1.Columns(3).Name = "Kuantitas"
DataGridView1.Columns(4).Name = "Jumlah"
End Sub
Private Sub btnHitung_Click(sender As Object, e As EventArgs) Handles btnHitung.Click
Dim i As Integer
Dim jlh As Double = 0
For i = 0 To Me.DataGridView1.Rows.Count - 1
jlh = jlh + Val(Me.DataGridView1.Rows(i).Cells(4).Value)
Next
txtSub.Text = jlh
End Sub
Private Sub txtDiskon_TextChanged(sender As Object, e As EventArgs) Handles
txtDiskon.TextChanged
If Val(txtDiskon.Text) <= Val(txtSub.Text) Then
txtGrand.Text = Val(txtSub.Text) -
Val(txtDiskon.Text)
Else
txtGrand.Text = 0
End If
End Sub
Private Sub txtBayar_TextChanged(sender As Object, e As EventArgs) Handles
txtBayar.TextChanged
If Val(txtBayar.Text) >= Val(txtGrand.Text) Then
txtKembalian.Text =
Val(txtBayar.Text) - Val(txtGrand.Text)
Else
txtKembalian.Text = 0
End If
End Sub
End Class


0 komentar:
Posting Komentar