Program Kasir Restoran Lama Saji dengan VB.NET
Dalam kesempatan kali ini ,saya sudah membuat Program Kasir Restoran Lama Saji yang sebelumnya sudah saya buat dalam bahasa java. Langsung saja , program ini di buat untuk memenuhi tugas UTS Pemrograman oleh dosen Pak Agus Suharto.
Di dalam program ini saya menggunakan berbagai toolbox di antaranya :
- Label
- TextBox
- ComboBox
- CheckBox
- Button
- ListBox
- DateTimePicker
- SaveFileDialog
Dan saya menggunakan dua form yaitu form utama dan form order.
Form Utama
Form Order
Source Code
Form Utama
- Button Order
Private Sub Order_Click(sender As Object, e As EventArgs) Handles Order.Click
Form_order.Show()
Me.Hide()
End Sub
- Button About
Private Sub About_Click(sender As Object, e As EventArgs) Handles About.Click
MsgBox("Restoran Lama Saji sudah dibuat sejak saya mengerjakan tugas semester 2. Saat itu saya menggunakan bahasa JAVA dan alhamdulillah saya akan melanjutkannya di semester 4 ini. Terimakasih", MsgBoxStyle.OkOnly + MsgBoxStyle.Information, "About it")
End Sub
- Button Exit
Private Sub Keluar_Click(sender As Object, e As EventArgs) Handles Keluar.Click
Dim keluar = MsgBox("Apakah anda yakin?", MsgBoxStyle.YesNo + MsgBoxStyle.Question, "Konfirmasi")
If keluar = vbYes Then
Me.Close()
End If
End Sub
Form Order
Jangan lupa untuk menginport Windows.Office.Interop.Word/Excel yang sebelumnya telah di add Reference Microsoft Word 16.0 Library dan Microsoft Excel 16.0 serta menjadikan variabel word dan excel di Form_order class seperti ini :
- Form_utama
Private Sub Form_order_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Kasir.Items.Add("-Pilih-")
Kasir.Items.Add("Putri")
Kasir.Items.Add("Joko")
Kasir.Items.Add("Hasan")
Kasir.Items.Add("Made")
Kasir.Items.Add("Steffi")
End Sub
- CheckBox1
Private Sub CheckBox1_CheckedChanged_1(sender As Object, e As EventArgs) Handles CheckBox1.CheckedChanged
If CheckBox1.Checked = False Then
RpNasiGoreng.Text = "0"
QtyNasiGoreng.Text = "0"
TotalNasiGoreng.Text = "0"
Else
RpNasiGoreng.Text = "13000"
QtyNasiGoreng.Text = ""
TotalNasiGoreng.Text = ""
End If
End Sub
- CheckBox2
Private Sub CheckBox2_CheckedChanged_1(sender As Object, e As EventArgs) Handles CheckBox2.CheckedChanged
If CheckBox2.Checked = False Then
RpMieGoreng.Text = "0"
QtyMieGoreng.Text = "0"
TotalMieGoreng.Text = "0"
Else
RpMieGoreng.Text = "12000"
QtyMieGoreng.Text = ""
TotalMieGoreng.Text = ""
End If
End Sub
- Checkbox3
Private Sub CheckBox3_CheckedChanged_1(sender As Object, e As EventArgs) Handles CheckBox3.CheckedChanged
If CheckBox3.Checked = False Then
RpKwetiauGoreng.Text = "0"
QtyKwetiauGoreng.Text = "0"
TotalKwetiauGoreng.Text = "0"
Else
RpKwetiauGoreng.Text = "10000"
QtyKwetiauGoreng.Text = ""
TotalKwetiauGoreng.Text = ""
End If
End Sub
- CheckBox4
Private Sub CheckBox4_CheckedChanged_1(sender As Object, e As EventArgs) Handles CheckBox4.CheckedChanged
If CheckBox4.Checked = False Then
RpKwetiauKuah.Text = "0"
QtyKwetiauKuah.Text = "0"
TotalKwetiauKuah.Text = "0"
Else
RpKwetiauKuah.Text = "11000"
QtyKwetiauKuah.Text = ""
TotalKwetiauKuah.Text = ""
End If
End Sub
- CheckBox5
Private Sub CheckBox5_CheckedChanged_1(sender As Object, e As EventArgs) Handles CheckBox5.CheckedChanged
If CheckBox5.Checked = False Then
RpAirMineral.Text = "0"
QtyAirMineral.Text = "0"
TotalAirMineral.Text = "0"
Else
RpAirMineral.Text = "4000"
QtyAirMineral.Text = ""
TotalAirMineral.Text = ""
End If
End Sub
- CheckBox6
Private Sub CheckBox6_CheckedChanged_1(sender As Object, e As EventArgs) Handles CheckBox6.CheckedChanged
If CheckBox6.Checked = False Then
RpEsTehManis.Text = "0"
QtyEsTehManis.Text = "0"
TotalEsTehManis.Text = "0"
Else
RpEsTehManis.Text = "6000"
QtyEsTehManis.Text = ""
TotalEsTehManis.Text = ""
End If
End Sub
- CheckBox7
Private Sub CheckBox7_CheckedChanged_1(sender As Object, e As EventArgs) Handles CheckBox7.CheckedChanged
If CheckBox7.Checked = False Then
RpTehManisHangat.Text = "0"
QtyTehManisHangat.Text = "0"
TotalTehManisHangat.Text = "0"
Else
RpTehManisHangat.Text = "5000"
QtyTehManisHangat.Text = ""
TotalTehManisHangat.Text = ""
End If
End Sub
- CheckBox8
Private Sub CheckBox8_CheckedChanged(sender As Object, e As EventArgs) Handles CheckBox8.CheckedChanged
If CheckBox8.Checked = False Then
RpKlepon.Text = "0"
QtyKlepon.Text = "0"
TotalKlepon.Text = "0"
Else
RpKlepon.Text = "2000"
QtyKlepon.Text = ""
TotalKlepon.Text = ""
End If
End Sub
- CheckBox9
Private Sub CheckBox9_CheckedChanged(sender As Object, e As EventArgs) Handles CheckBox9.CheckedChanged
If CheckBox9.Checked = False Then
RpKueApe.Text = "0"
QtyKueApe.Text = "0"
TotalKueApe.Text = "0"
Else
RpKueApe.Text = "2500"
QtyKueApe.Text = ""
TotalKueApe.Text = ""
End If
End Sub
- CheckBox10
Private Sub CheckBox10_CheckedChanged(sender As Object, e As EventArgs) Handles CheckBox10.CheckedChanged
If CheckBox10.Checked = False Then
RpMarCok.Text = "0"
QtyMarCok.Text = "0"
TotalMarCok.Text = "0"
Else
RpMarCok.Text = "10000"
QtyMarCok.Text = ""
TotalMarCok.Text = ""
End If
End Sub
- CheckBox11
Private Sub CheckBox11_CheckedChanged(sender As Object, e As EventArgs) Handles CheckBox11.CheckedChanged
If CheckBox11.Checked = False Then
RpMarKe.Text = "0"
QtyMarKe.Text = "0"
TotalMarKe.Text = "0"
Else
RpMarKe.Text = "11000"
QtyMarKe.Text = ""
TotalMarKe.Text = ""
End If
End Sub
- Button Cek
Private Sub Cek_Click(sender As Object, e As EventArgs) Handles Cek.Click
Dim a = RpNasiGoreng.Text * QtyNasiGoreng.Text
TotalNasiGoreng.Text = a
Dim b = RpMieGoreng.Text * QtyMieGoreng.Text
TotalMieGoreng.Text = b
Dim c = RpKwetiauGoreng.Text * QtyKwetiauGoreng.Text
TotalKwetiauGoreng.Text = c
Dim d = RpKwetiauKuah.Text * QtyKwetiauKuah.Text
TotalKwetiauKuah.Text = d
Dim f = a + b + c + d
TotalMakanan.Text = f
Dim g = RpAirMineral.Text * QtyAirMineral.Text
TotalAirMineral.Text = g
Dim h = RpEsTehManis.Text * QtyEsTehManis.Text
TotalEsTehManis.Text = h
Dim i = RpTehManisHangat.Text * QtyTehManisHangat.Text
TotalTehManisHangat.Text = i
Dim j = g + h + i
TotalMinuman.Text = j
Dim k = RpKlepon.Text * QtyKlepon.Text
TotalKlepon.Text = k
Dim l = RpKueApe.Text * QtyKueApe.Text
TotalKueApe.Text = l
Dim m = RpMarCok.Text * QtyMarCok.Text
TotalMarCok.Text = m
Dim n = RpMarKe.Text * QtyMarKe.Text
TotalMarKe.Text = n
Dim o = k + l + m + n
TotalCuciMulut.Text = o
Dim p = f + j + o
Total.Text = p
Dim ssr As String = String.Empty
Dim rND As Random = New Random()
Dim q As Integer = rND.Next(1, 11)
Dim x As Integer = 1
For Each r As CheckBox In GroupBox1.Controls
If x <= q Then
Dim str As String = "Checkbox : " & x
r.Name = str
If r.Checked = True Then
ssr &= r.Text & ", "
End If
End If
Next
Dim MyChar() As Char = {","}
Dim NewString As String = ssr.TrimEnd(MyChar)
makanan.Text = "" & NewString
Dim ssr1 As String = String.Empty
Dim rND1 As Random = New Random()
Dim i1 As Integer = rND1.Next(1, 11)
Dim x1 As Integer = 1
For Each c1 As CheckBox In GroupBox2.Controls
If x1 <= i1 Then
Dim str1 As String = "Checkbox : " & x1
c1.Name = str1
If c1.Checked = True Then
ssr1 &= c1.Text & ", "
End If
End If
Next
Dim MyChar1() As Char = {","}
Dim NewString1 As String = ssr1.TrimEnd(MyChar1)
minuman.Text = "" & NewString1
Dim ssr2 As String = String.Empty
Dim rND2 As Random = New Random()
Dim i2 As Integer = rND2.Next(1, 11)
Dim x2 As Integer = 1
For Each c2 As CheckBox In GroupBox3.Controls
If x2 <= i2 Then
Dim str2 As String = "Checkbox : " & x2
c2.Name = str2
If c2.Checked = True Then
ssr2 &= c2.Text & ", "
End If
End If
Next
Dim MyChar2() As Char = {","}
Dim NewString2 As String = ssr2.TrimEnd(MyChar2)
cucimulut.Text = "" & NewString2
End Sub
- Button Hitung
Private Sub Hitung_Click(sender As Object, e As EventArgs) Handles Hitung.Click
Kembalian.Text = Bayar.Text - Total.Text
End Sub
- CheckBox Cetak
Private Sub Cetak_CheckedChanged(sender As Object, e As EventArgs) Handles Cetak.CheckedChanged
If Cetak.Checked = True Then
Cetak.Text = "Ya"
ListOrder.Items.Add(" Restoran Lama Saji ")
ListOrder.Items.Add("")
ListOrder.Items.Add("Kasir yang melayani : " + Kasir.Text)
ListOrder.Items.Add("Tanggal Pemesanan : " + tanggal.Text)
ListOrder.Items.Add("Makanan : " + makanan.Text)
ListOrder.Items.Add("Minuman : " + minuman.Text)
ListOrder.Items.Add("Cuci Mulut : " + cucimulut.Text)
ListOrder.Items.Add("Total Harga : " + Total.Text)
ListOrder.Items.Add("Bayar : " + Bayar.Text)
ListOrder.Items.Add("Kembalian : " + Kembalian.Text)
Else
Cetak.Text = "Tidak"
ListOrder.Items.Clear()
End If
End Sub
- Button Word
Private Sub ButtonWord_Click(sender As Object, e As EventArgs) Handles ButtonWord.Click
Dokumennya = Appnya.Documents.Open("D:\Doc Kuliah\Report.docx")
Dokumennya.Bookmarks("kasir").Select()
Appnya.Selection.TypeText(Kasir.Text)
Dokumennya.Bookmarks("tanggal").Select()
Appnya.Selection.TypeText(tanggal.Text)
Dokumennya.Bookmarks("food").Select()
Appnya.Selection.TypeText(makanan.Text)
Dokumennya.Bookmarks("drink").Select()
Appnya.Selection.TypeText(minuman.Text)
Dokumennya.Bookmarks("dessert").Select()
Appnya.Selection.TypeText(cucimulut.Text)
Dokumennya.Bookmarks("total").Select()
Appnya.Selection.TypeText(Total.Text)
Dokumennya.Bookmarks("bayar").Select()
Appnya.Selection.TypeText(Bayar.Text)
Dokumennya.Bookmarks("kembalian").Select()
Appnya.Selection.TypeText(Kembalian.Text)
SaveFileDialog1.Filter = "WORD File|*.docx"
SaveFileDialog1.DefaultExt = "*.docx"
SaveFileDialog1.ShowDialog()
Dokumennya.SaveAs2(SaveFileDialog1.FileName)
MsgBox("Sukses")
Appnya.Visible = True
End Sub
- Button Excel
Private Sub ButtonExcel_Click(sender As Object, e As EventArgs) Handles ButtonExcel.Click
DokumenExcel = AppExcel.Workbooks.Open("D:\Doc Kuliah\Report.xlsx")
AppExcel.Range("C7").Value = Kasir.Text
AppExcel.Range("D7").Value = tanggal.Text
AppExcel.Range("E7").Value = makanan.Text
AppExcel.Range("F7").Value = minuman.Text
AppExcel.Range("G7").Value = cucimulut.Text
AppExcel.Range("H7").Value = Total.Text
AppExcel.Range("I7").Value = Bayar.Text
AppExcel.Range("J7").Value = Kembalian.Text
SaveFileDialog1.Filter = "EXCEL File|*.xlsx"
SaveFileDialog1.DefaultExt = "*.xlsx"
SaveFileDialog1.ShowDialog()
DokumenExcel.SaveAs(SaveFileDialog1.FileName)
MsgBox("Sukses")
AppExcel.Visible = True
End Sub
Private Sub Kembali_Click(sender As Object, e As EventArgs) Handles Kembali.Click
Form_utama.Visible = True
Me.Hide()
End Sub
- Button Hapus
Private Sub Hapus_Click(sender As Object, e As EventArgs) Handles Hapus.Click
Kasir.Text = "-Pilih-"
CheckBox1.Checked = False
CheckBox2.Checked = False
CheckBox3.Checked = False
CheckBox4.Checked = False
CheckBox5.Checked = False
CheckBox6.Checked = False
CheckBox7.Checked = False
CheckBox8.Checked = False
CheckBox9.Checked = False
CheckBox10.Checked = False
CheckBox11.Checked = False
Total.Text = ""
Bayar.Text = ""
Kembalian.Text = ""
Cetak.Checked = False
ListOrder.Items.Clear()
End Sub
- Button Kembali
Private Sub Kembali_Click(sender As Object, e As EventArgs) Handles Kembali.Click
Form_utama.Visible = True
Me.Hide()
End Sub
Ini dia saat Debugnya :
Terimakasih atas do'a dan support nya dari teman-teman kelas 04TPLP001 yang telah membantu saya dalam mengerjakan tugas kali ini.