TUTORIAL PROGRAM KASIR
TUTORIAL KASIR
Nb: Program dapat diunduh pada bagian bawah halaman
Pertama-tama bukalah program Visual Basic 2010 dengancara:
1. Klik "Start"
2. Pilih Microsoft Visual Basic 2010
3.Setelahmucul "Start Page" pilih "New Project"
Pertama-tama bukalah program Visual Basic 2010 dengancara:
1. Klik "Start"
2. Pilih Microsoft Visual Basic 2010
3.Setelahmucul "Start Page" pilih "New Project"
4. Setelahmunculhalaman New Project pilih “Windows Forms Application”
5. Klik “OK”
6. Selanjutnyamuncullembarkerja Visual Basic yang biasadisebut Form
6. Selanjutnyamuncullembarkerja Visual Basic yang biasadisebut Form
7. Form
diisidenganberbagaikomponen yang didapatmelalui "Toolbox"
8. Isi form
Form 1 (form pembayaran)
Komponen
|
Properties
|
Keterangan
|
Form
1
|
Name
|
Form
1
|
Label
1
|
Name
Text
|
Label
1
Butik
LANETIFA
|
Label
2
|
Name
Text
|
Label
2
Nama
|
Label
3
|
Name
Text
|
Label
3
Alamat
|
Label
4
|
Name
Text
|
Label
4
NamaBarang
|
Label
5
|
Name
Text
|
Label
5
Harga
|
Label
6
|
Name
Text
|
Label
6
JumlahBarang
|
Label
7
|
Name
Text
|
Label
7
Diskon
|
Label
8
|
Name
Text
|
Label
8
Sub
Total Harga
|
Label
9
|
Name
Text
|
Label
9
HargaPembayaran
|
Label
10
|
Name
Text
|
Label
10
Bayar
|
Label
11
|
Name
Text
|
Label
11
Kembalian
|
Label
12
|
Name
Text
|
Label
12
Unit
|
Label
13
|
Name
Text
|
Label
13
%
|
Label
14
|
Name
Text
|
Label
14
Double
click untuk total hargapembayaran
|
Label
15
|
Name
Text
|
Label
15
|
Label
16
|
Name
Text
|
Label
16
|
Textbox
1
|
Name
Text
|
Textbox
1
|
Textbox
2
|
Name
Text
|
Textbox
2
|
Textbox
3
|
Name
Text
Enabled
|
Textbox
3
False
|
Textbox
4
|
Name
Text
|
Textbox
4
|
Textbox
5
|
Name
Text
|
Textbox
5
|
Textbox
6
|
Name
Text
Enabled
|
Textbox
6
False
|
Textbox
7
|
Name
Text
Enabled
|
Textbox
7
False
|
Textbox
8
|
Name
Text
|
Textbox
8
|
Textbox
9
|
Name
Text
Enabled
|
Textbox
9
False
|
Combobox
1
|
Name
|
Combobox
1
|
Button
1
|
Name
Text
|
Button
1
Next
Item
|
Button 4
|
Name
Text
|
Button 2
Payment
|
Button 5
|
Name
Text
|
Button 3
Hitung
|
Button 6
|
Name
Text
|
Button 4
Confirm
Total Harga
|
Button
7
|
Name
Text
|
Button
5
UlangdariAwal
|
Button
8
|
Name
Text
|
Button
6
StrukPembelian
|
PublicClassForm1
Dim
diskon AsInteger = 0
Dim
potongan AsDouble
Dim
harga1 AsInteger
Dim
jumlah_barang AsByte
Dim
total_harga AsDouble
Dim
total_pembayaran AsDouble
Dim
firstnumber AsSingle
Dim
arithmetic AsString
è Menjelaskan
variabel-variabel yang akan dipakai beserta tipe data pada masing-masing
variabelnya
PrivateSub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) HandlesMyBase.Load
With ComboBox1
.Items.Add("Kemeja")
.Items.Add("Polo Shirt")
.Items.Add("Kaos")
.Items.Add("Jegging")
.Items.Add("Celana Jeans")
.Items.Add("Rok")
.Items.Add("Blazer")
.Items.Add("Jaket")
.Items.Add("Sweater")
EndWith
EndSub
è Menggunakan
combo box dan “.Items.Add.” untuk menambahkan pilihan yang ada di combo box
PrivateSub ComboBox1_SelectedIndexChanged(ByVal
sender As System.Object,
ByVal e As
System.EventArgs) Handles
ComboBox1.SelectedIndexChanged
If
ComboBox1.Text = ("Kemeja") Then TextBox3.Text = (" 175000")
If
ComboBox1.Text = ("Polo Shirt") Then TextBox3.Text = (" 150000")
If
ComboBox1.Text = ("Kaos") Then TextBox3.Text = (" 90000")
If
ComboBox1.Text = ("Jegging") Then TextBox3.Text = (" 250000")
If
ComboBox1.Text = ("Celana Jeans") Then TextBox3.Text = (" 300000")
If
ComboBox1.Text = ("Rok") Then TextBox3.Text = (" 275000")
If
ComboBox1.Text = ("Blazer") Then TextBox3.Text = (" 225000")
If
ComboBox1.Text = ("Jaket") Then TextBox3.Text = (" 375000")
If
ComboBox1.Text = ("Sweater") Then TextBox3.Text = (" 325000")
EndSub
è Menjelaskan suatu kondisi jika memilih suatu barang maka secara
otomatis harga akan muncul pada text box ketiga
PrivateSub Button1_Click(ByVal
sender As System.Object,
ByVal e As
System.EventArgs) Handles
Button1.Click
WithForm2.DataGridView1
Form2.DataGridView1.Rows.Add(Me.ComboBox1.Text,
Me.TextBox3.Text, Me.TextBox8.Text,
Me.TextBox8.Text, Me.TextBox6.Text,
Me.TextBox7.Text, Me.TextBox9.Text)
EndWith
firstnumber
= Val(TextBox6.Text)
TextBox5.Text = ""
arithmetic
= "+"
ComboBox1.Text = ""
TextBox3.Text = ""
TextBox4.Text = ""
TextBox8.Text = ""
TextBox7.Text
= ""
TextBox9.Text = ""
ComboBox1.SelectedItem = Nothing
EndSub
è Pada sub ini, terdapat listing yang berisi agar dapat melakukan
rekapan berupa struk yang akan muncul di form2. Selain itu, dengan menekan tombol
new item, maka otomatis akan mengisi data berikutnya sehingga terdapat rumus
untuk data input semua dikosongkan agar dapat diisi pengisian data kembali.
Selain itu, juga terdapat peringatan jika terjadi salah pengisian.
PrivateSub Button4_Click(ByVal
sender As System.Object,
ByVal e As
System.EventArgs) Handles
Button4.Click
Dim name
= ",00 "
Dim name1
= Val(TextBox6.Text)
Dim name2
= Val(TextBox7.Text)
Dim
selisih1 = Val(name2 - name1)
Dim
selisih2 = Val(name1 - name2)
Dim bayar
= Val(TextBox7.Text)
If
Val(TextBox7.Text) > Val(TextBox6.Text) Then
MsgBox("Anda Harus Membayar Sebesar Rp "&
name1 & name &"Bayar Rp "&
bayar & name &"Kembali Rp "&
selisih1 & name)
If
Val(TextBox7.Text) < Val(TextBox6.Text) Then
MsgBox("Anda Harus Membayar Sebesar Rp "&
name1 & name &"Bayar Rp "&
bayar & name &"Kekurangan yang Harus
Anda Bayar Rp "& selisih2 & name)
EndSub
è Menjelaskan suatu kondisi jika nilai bayar lebih besar dari harga
pembayaran maka akan msuncul message box dengan format Anda Harus Membayar
Sebesar … Bayar Rp… Sebesar
Rp… tetapi sebaliknya jika nilai bayar lebih kecil
dari harga pembayaran maka akan muncul message box dengan format Harus
Membayar Sebesar … Bayar Rp…kekurangan yang hHarus Anda Bayar Rp…”
PrivateSub Button6_Click(ByVal
sender As System.Object,
ByVal e As
System.EventArgs) Handles
Button6.Click
If
TextBox1.Text = ""Or TextBox2.Text = ""Then
MsgBox("Mohon untuk mengisi nama dan alamat Anda")
Else
Me.Show()
Dim
potongan AsDouble
Dim total
AsDouble
Dim
subtotal AsDouble
Dim harga
AsDouble
Dim
jumlah AsDouble
If
Val(TextBox8.Text) <= 100 Then
harga = Val(TextBox3.Text)
jumlah = Val(TextBox4.Text)
potongan = (harga * jumlah * Val(TextBox8.Text) / 100)
subtotal = ((harga * jumlah) - potongan)
total = (Val(TextBox6.Text) + Val(TextBox5.Text))
TextBox5.Text = subtotal
TextBox6.Text = total
EndIf
EndIf
à
Jika kolom nama maupun alamat belum terisi maka akan muncul message box "Mohon
untuk mengisi nama dan alamat Anda" tetapi jika sudah terisi maka akan melanjutkan ke proses
perhitungan seperti rumus yang telah dituliskan namun dengan syarat diskon yang
diisikan <100 jikalau diskon yang diisi 100 atau lebih maka tidak dapat dip
roses (penjelasan menyangkut dengan private sub textbox8)
If
TextBox5.Text = "0"Or TextBox5.Text = ""Then
MsgBox("Harap mengisi nama barang atau jumlah barang")
EndIf
EndSub
è Jika kolom nama barang maupun jumlah barang belum diisi maka akan
muncul messagebox dengan pesan "Harap mengisi nama barang atau jumlah barang”
PrivateSub Button7_Click(ByVal
sender As System.Object,
ByVal e As
System.EventArgs) Handles
Button7.Click
ComboBox1.Text = ""
TextBox3.Text = ""
TextBox4.Text = ""
TextBox5.Text = ""
TextBox8.Text = ""
TextBox6.Text = ""
ComboBox1.SelectedItem = Nothing
EndSub
è Jika tombol 7 () maka kolom pada textbox 1, 3, 4, 5, 6, 7, 8 dan
combobox 1 akan kosong
PrivateSub TextBox4_KeyPress(ByVal
sender AsObject, ByVal
e As System.Windows.Forms.KeyPressEventArgs) Handles
TextBox4.KeyPress
Dim input
AsBoolean = Char.IsDigit(e.KeyChar)
If (Not input) Then
e.Handled = True
EndSub
è Untuk mengunci agar saat menginput pada textbox4 tidak dapat diisi
dengan huruf hanya angka saja
PrivateSub TextBox4_TextChanged(ByVal
sender As System.Object,
ByVal e As
System.EventArgs) Handles
TextBox4.TextChanged
EndSub
PrivateSub TextBox1_KeyPress(ByVal
sender AsObject, ByVal
e As System.Windows.Forms.KeyPressEventArgs) Handles
TextBox1.KeyPress
Dim input
AsBoolean = Char.IsDigit(e.KeyChar)
If
(input) Then e.Handled = True
EndSub
è Untuk mengunci agar saat menginput pada textbox1 tidak dapat diisi
dengan huruf hanya angka saja
PrivateSub TextBox8_TextChanged_1(ByVal
sender As System.Object,
ByVal e As
System.EventArgs) Handles
TextBox8.TextChanged
If
Val(TextBox8.Text) < 0 Or Val(TextBox8.Text)
>= 100 Then
MsgBox("Diskon Invalid")
TextBox8.Text = ""
EndIf
EndSub
è Jikalau diskon yang diisikan lebih dari ataupun sama dengan 100 maka
akan muncul messagebox dengan pesan "Diskon Invalid"
PrivateSub Button8_Click(ByVal
sender As System.Object,
ByVal e As
System.EventArgs) Handles
Button8.Click
Form2.Show()
Form2.DataGridView1.Show()
EndSub
è List
ini digunakan untuk memunculkan rekapan data struk pada form2
PrivateSub Button5_Click(ByVal
sender As System.Object,
ByVal e As
System.EventArgs) Handles
Button5.Click
TextBox9.Text = Val(TextBox7.Text) - Val(TextBox6.Text)
If
Val(TextBox7.Text) < Val(TextBox6.Text) Then
MsgBox("Harga Pembayaran Anda masih kurang")
EndIf
EndSub
EndClass
è Pada textbox9 (kolom kembali) nilai bayar kurang dari nilai pada
kolom total harga pembayaran maka akan muncul messagebox dengan pesan "Harga
Pembayaran Anda masih kurang"
Form 2
Komponen
|
Properties
|
Keterangan
|
Form 2
|
Name
|
DataGridView
1
|
BorderStyle
|
Fixed3D
|
|
Columns
|
NamaBarang,
Harga, Jumlah, Diskon, Total Harga, Pembayaran, Kembali
|
|
Dock
|
Fill
|
|
Button 1
|
Name
|
Button
1
|
Text
|
Exit
|
|
Button 2
|
Name
|
Button
2
|
Text
|
Back
|
|
Column 1
|
Name
|
Column
1
|
HeaderText
|
NamaBarang
|
|
Column 2
|
Name
|
Column
2
|
HeaderText
|
Harga
|
|
Column 3
|
Name
|
Column
3
|
HeaderText
|
Jumlah
|
|
Column 4
|
Name
|
Column
4
|
HeaderText
|
Diskon
|
|
Column 5
|
Name
|
Column
5
|
HeaderText
|
Total
Harga
|
|
Column 6
|
Name
|
Column
6
|
HeaderText
|
Pembayaran
|
|
Column 7
|
Name
|
Column
7
|
HeaderText
|
Kembali
|
PublicClassForm2
PrivateSub Button1_Click(ByVal
sender As System.Object,
ByVal e As
System.EventArgs) Handles
Button1.Click
Form1.Close()
Me.Close()
MsgBox("Terima kasih telah membeli produk kami. Silahkan
berkunjung kembali")
EndSub
è Tombol1 (exit) diklik maka akan menutup semua jendela pada program
dengan messagebox dengan pesan"Terima kasih telah membeli produk kami. Silahkan
berkunjung kembali"
PrivateSub Button2_Click(ByVal
sender As System.Object,
ByVal e As
System.EventArgs) Handles
Button2.Click
Me.Hide()
Form1.Show()
EndSub
è Tombol2
(back) diklik maka akan kembali menampilkan pda form1
EndClass
Untuk program dapat didownload di sini
0 komentar:
Posting Komentar