Aplikasi Kasir Restoran

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 17

Aplikasi Kasir Restoran

Aplikasi Kasir ini dibuat menggunakan Visual Basic 2008 dan Data Base Microsoft
Acces 2007.
Berikut ini langkah-langkah pembuatanya,
Buka Visual Studio 2008 pilih new project lalu Windows form application

Sebelum design form buatlah terlebih dahulu modul

Copyright (c) 2015 http://arcatronik.blogspot.com


Lalu isi modul tersebut dengan syntax berikut :
Catatan, untuk public koneksi sesuaikan dengan nama data base yang nanti akan
kita buat.
Imports System.Data.Odbc
Imports System.Data
Imports System.Data.OleDb
Module Module1
Public OLECMD As OleDbCommand
Public OLERDR As OleDbDataReader
Public OLEDA As OleDbDataAdapter
Public CNN As OleDbConnection
Public DS As DataSet
Public KONEKSI As String = "Provider=Microsoft.ACE.OLEDB.12.0;Data
Source=|DataDirectory|\DBbella.accdb"
Public x As Integer
End Module

*Kemudian design form 1 untuk form login seperti berikut

Lalu isi syntax berikut :


Imports System.Data.OleDb
Imports System.Data.Odbc
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
CNN = New OleDbConnection(KONEKSI)
If CNN.State <> ConnectionState.Closed Then CNN.Close()
CNN.Open()

Copyright (c) 2015 http://arcatronik.blogspot.com


OLECMD = New OleDbCommand("SELECT * From login WHERE Username = '"
& TextBox1.Text & _
"' and Password = '" & TextBox2.Text &
"'", CNN)
OLERDR = OLECMD.ExecuteReader
If (OLERDR.Read()) Then
Form3.Show()
Me.Hide()
TextBox2.Text = ""
TextBox1.Focus()
Else
MsgBox("Username & Password Anda Salah!", MsgBoxStyle.OkOnly, _
"Login gagal")
TextBox1.Text = ""
TextBox2.Text = ""
TextBox1.Focus()
End If
End Sub
Private Sub LinkLabel1_LinkClicked(ByVal sender As System.Object, ByVal
e As System.Windows.Forms.LinkLabelLinkClickedEventArgs) Handles
LinkLabel1.LinkClicked
Me.Hide()
Form2.ShowDialog()
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button2.Click
End
End Sub
End Class

*Kemudian design form 2 untuk form Daftar user seperti berikut

Lalu isi syntax berikut :


Imports System.Data.OleDb
Imports System.Data.Odbc
Public Class Form2
Sub bersih()
TextBox1.Text = ""
TextBox2.Text = ""
TextBox3.Text = ""
TextBox4.Text = ""
TextBox5.Text = ""
End Sub

Copyright (c) 2015 http://arcatronik.blogspot.com


Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button2.Click
Call bersih()
Me.Hide()
Form1.Show()
Me.Close()
End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles Button1.Click
If TextBox1.Text = "" Or TextBox2.Text = "" Or TextBox3.Text = ""
Or TextBox4.Text = "" Or TextBox4.Text = "" Then
MsgBox("Isi data dengan benar!!", MsgBoxStyle.Exclamation,
"Kesalahan")
Exit Sub
End If
CNN = New OleDbConnection(KONEKSI)
If CNN.State <> ConnectionState.Closed Then CNN.Close()
CNN.Open()
OLECMD = New OleDbCommand("insert into login ([Nama],[Alamat],[No
Telp],[Username],[Password]) values ('" & _
TextBox1.Text & "','" & TextBox2.Text &
"','" & TextBox3.Text & "','" & TextBox4.Text & "','" & TextBox5.Text &
"')", CNN)

x = OLECMD.ExecuteNonQuery
If x = 1 Then
MsgBox("Anda Berhasil Mendaftar, Silahkan Login...",
MsgBoxStyle.Information, "Informasi")
Me.Hide()
Form1.Show()
Me.Close()
Else
MsgBox("Gagal Mendaftar !!!", MsgBoxStyle.Exclamation,
"Kesalahan")
End If
End Sub
End Class

*Kemudian design form 3 untuk form menu

Copyright (c) 2015 http://arcatronik.blogspot.com


Lalu isi syntax berikut :
Public Class Form3
Private Sub KeluarToolStripMenuItem1_Click(ByVal sender As
System.Object, ByVal e As System.EventArgs)
End
End Sub

Private Sub PilihMenuToolStripMenuItem_Click(ByVal sender As


System.Object, ByVal e As System.EventArgs) Handles
PilihMenuToolStripMenuItem.Click
Dim anak As New Form4
anak.MdiParent = Me
anak.Show()
End Sub

Private Sub PembayaranToolStripMenuItem_Click(ByVal sender As


System.Object, ByVal e As System.EventArgs) Handles
PembayaranToolStripMenuItem.Click
Dim anak As New Form5
anak.MdiParent = Me
anak.Show()
End Sub

Private Sub LihatDataToolStripMenuItem_Click(ByVal sender As


System.Object, ByVal e As System.EventArgs) Handles
LihatDataToolStripMenuItem.Click
Dim anak As New Form6
anak.MdiParent = Me
anak.Show()
End Sub

Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles Timer1.Tick
Label1.Text = Format(Now, "hh:mm:ss")
Label2.Text = Format(Now, "dd/MM/yyyy")
End Sub

Private Sub Form3_Load(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles MyBase.Load
Label1.Text = Format(Now, "hh:mm:ss")
Label2.Text = Format(Now, "dd/MM/yyyy")
End Sub

Private Sub KeluarToolStripMenuItem1_Click_1(ByVal sender As


System.Object, ByVal e As System.EventArgs) Handles
KeluarToolStripMenuItem1.Click
Me.Hide()
Form1.Show()
Me.Close()
End Sub

Private Sub TutupToolStripMenuItem_Click(ByVal sender As System.Object,


ByVal e As System.EventArgs) Handles TutupToolStripMenuItem.Click
End
End Sub
End Class

Copyright (c) 2015 http://arcatronik.blogspot.com


*Kemudian design form 4 untuk form Cek Harga

Lalu isi syntax berikut :


Imports System.Data.OleDb
Imports System.Data.Odbc
Public Class Form4
Sub bersih()
TextBox1.Text = ""
TextBox2.Text = ""
TextBox3.Text = ""
End Sub
Sub OpenDB()
Dim KONEKSI = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=|
DataDirectory|\DBbella.accdb"
CNN = New OleDbConnection(KONEKSI)
If CNN.State <> ConnectionState.Closed Then
CNN.Open()
End If
End Sub
Sub TampilTable1()
OLEDA = New OleDbDataAdapter("select * from Table1", CNN)
DS = New DataSet
OLEDA.Fill(DS, "Table1")
DataGridView1.DataSource = DS.Tables("Table1")
End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles Button1.Click
Call OpenDB()
Call TampilTable1()

End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles Button2.Click
CNN = New OleDbConnection(KONEKSI)

Copyright (c) 2015 http://arcatronik.blogspot.com


If CNN.State <> ConnectionState.Closed Then CNN.Close()
CNN.Open()
OLECMD = New OleDbCommand("select * from Table1 where [Kode] = '" &
TextBox1.Text & "'", CNN)
OLERDR = OLECMD.ExecuteReader
OLERDR.Read()

If OLERDR.HasRows Then
TextBox2.Text = OLERDR("Nama")
TextBox3.Text = OLERDR("Harga")
Else
MsgBox("Data Tidak Ditemukan….!", MsgBoxStyle.Exclamation,
"Perhatian")
End If

End Sub

Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles Button3.Click
If TextBox1.Text = "" Or TextBox2.Text = "" Or TextBox3.Text = ""
Then
MsgBox("Isi data dengan benar!!", MsgBoxStyle.Exclamation,
"Kesalahan")
Exit Sub
End If
CNN = New OleDbConnection(KONEKSI)
If CNN.State <> ConnectionState.Closed Then CNN.Close()
CNN.Open()
OLECMD = New OleDbCommand("Update Table1 Set [Nama]='" &
TextBox2.Text & "' ,[Harga]='" & TextBox3.Text & "' where [Kode] = '" &
TextBox1.Text & "'", CNN)
x = OLECMD.ExecuteNonQuery
If x = 1 Then
MsgBox("Data berhasil di ubah", MsgBoxStyle.Information,
"Informasi")
Call bersih()
Else
MsgBox("Gagal mengubah data", MsgBoxStyle.Exclamation,
"Kesalahan")
End If
End Sub

Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles Button4.Click
Call bersih()
End Sub
End Class

Copyright (c) 2015 http://arcatronik.blogspot.com


*Kemudian design form 5 untuk form pembayaran

Lalu isi syntax berikut :


Imports System.Data.OleDb
Imports System.Data.Odbc
Public Class Form5
Sub Hitung()
Dim totalbelanja As Long
totalbelanja = 0
For t As Integer = 0 To DataGridView2.Rows.Count - 1
totalbelanja = totalbelanja +
Val(DataGridView2.Rows(t).Cells(index:=4).Value)
Next
TextBox3.Text = totalbelanja
End Sub

Sub KodeOtomatis()
CNN = New OleDbConnection(KONEKSI)
If CNN.State <> ConnectionState.Closed Then CNN.Close()
CNN.Open()
OLECMD = New OleDbCommand("select * from Table3 order by [No
Transaksi] desc", CNN)
OLERDR = OLECMD.ExecuteReader
OLERDR.Read()

If Not OLERDR.HasRows Then


TextBox25.Text = "000001"
Else
TextBox25.Text = Val(Microsoft.VisualBasic.Mid(OLERDR.Item("No
Transaksi").ToString, 5, 3)) + 1

If Len(TextBox25.Text) = 1 Then
TextBox25.Text = "00000" & TextBox25.Text & ""

Copyright (c) 2015 http://arcatronik.blogspot.com


ElseIf Len(TextBox1.Text) = 2 Then
TextBox25.Text = "0000" & TextBox25.Text & ""
ElseIf Len(TextBox25.Text) = 3 Then
TextBox25.Text = "000" & TextBox25.Text & ""
End If
End If
TextBox2.Focus()
End Sub
Sub bersih()
TextBox1.Text = ""
TextBox2.Text = ""
TextBox3.Text = ""
TextBox4.Text = ""
End Sub
Sub OpenDB()
Dim KONEKSI = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=|
DataDirectory|\DBbella.accdb"
CNN = New OleDbConnection(KONEKSI)
If CNN.State <> ConnectionState.Closed Then
CNN.Open()
End If
End Sub
Sub TampilTable1()
OLEDA = New OleDbDataAdapter("select * from Table1", CNN)
DS = New DataSet
OLEDA.Fill(DS, "Table1")
DataGridView1.DataSource = DS.Tables("Table1")
End Sub
Sub TampilTable2()
OLEDA = New OleDbDataAdapter("select * from Table2", CNN)
DS = New DataSet
OLEDA.Fill(DS, "Table2")
DataGridView2.DataSource = DS.Tables("Table2")
End Sub

Private Sub Form5_Load(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles MyBase.Load
Call OpenDB()
Call TampilTable1()
Call TampilTable2()
ComboBox13.Items.Clear()
ComboBox13.Items.Add("M01")
ComboBox13.Items.Add("M02")
ComboBox13.Items.Add("M03")
ComboBox13.Items.Add("M04")
ComboBox13.Items.Add("M05")
ComboBox13.Items.Add("M06")
ComboBox13.Items.Add("M07")
ComboBox13.Items.Add("M08")
ComboBox13.Items.Add("M09")
ComboBox13.Items.Add("M10")
ComboBox13.Items.Add("M11")
ComboBox13.Items.Add("M12")
End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles Button1.Click
CNN = New OleDbConnection(KONEKSI)
If CNN.State <> ConnectionState.Closed Then CNN.Close()
CNN.Open()

Copyright (c) 2015 http://arcatronik.blogspot.com


OLECMD = New OleDbCommand("select * from Table1 where [Kode] = '" &
TextBox1.Text & "'", CNN)
OLERDR = OLECMD.ExecuteReader
OLERDR.Read()

If OLERDR.HasRows Then
TextBox2.Text = OLERDR("Nama")
TextBox7.Text = OLERDR("Harga")
Else
MsgBox("Data Tidak Ditemukan….!", MsgBoxStyle.Exclamation,
"Perhatian")
End If
End Sub

Private Sub Label10_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs)

End Sub

Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles Button5.Click
If TextBox1.Text = "" Or TextBox2.Text = "" Or TextBox7.Text = ""
Or TextBox8.Text = "" Then
MsgBox("Isi data dengan benar!!", MsgBoxStyle.Exclamation,
"Kesalahan")
Exit Sub
End If
CNN = New OleDbConnection(KONEKSI)
If CNN.State <> ConnectionState.Closed Then CNN.Close()
CNN.Open()
OLECMD = New OleDbCommand("insert into Table2 ([Kode],[Nama],
[Harga],[Qty],[Total Harga]) values ('" & _
TextBox1.Text & "','" & TextBox2.Text &
"','" & TextBox7.Text & "','" & TextBox8.Text & "','" & Val(TextBox7.Text *
TextBox8.Text) & "')", CNN)

x = OLECMD.ExecuteNonQuery
If x = 1 Then
Call TampilTable2()
TextBox1.Text = ""
TextBox2.Text = ""
TextBox7.Text = ""
TextBox8.Text = ""

Else
MsgBox("Gagal menghapus data", MsgBoxStyle.Exclamation,
"Kesalahan")
End If

End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles Button2.Click
If MsgBox("Ingin menghapus data ?", MsgBoxStyle.YesNo,
"Konfirmasi") = MsgBoxResult.Yes Then
CNN = New OleDbConnection(KONEKSI)
If CNN.State <> ConnectionState.Closed Then CNN.Close()
CNN.Open()
OLECMD = New OleDbCommand("Delete from Table2 Where [Kode] ='"
& TextBox6.Text & "'", CNN)
x = OLECMD.ExecuteNonQuery

Copyright (c) 2015 http://arcatronik.blogspot.com


If x = 1 Then
Call TampilTable2()
TextBox6.Text = ""

Else
MsgBox("Gagal menghapus data", MsgBoxStyle.Exclamation,
"Kesalahan")
End If
End If
End Sub

Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles Button3.Click
Call KodeOtomatis()
Call Hitung()
TextBox13.Text = Form3.Label2.Text
CNN = New OleDbConnection(KONEKSI)
If CNN.State <> ConnectionState.Closed Then CNN.Close()
CNN.Open()
OLECMD = New OleDbCommand("select * from login where [Username] =
'" & Form1.TextBox1.Text & "'", CNN)
OLERDR = OLECMD.ExecuteReader
OLERDR.Read()

If OLERDR.HasRows Then
TextBox14.Text = OLERDR("Nama")

Else
MsgBox("Kasir Tidak Ditemukan….!", MsgBoxStyle.Exclamation,
"Perhatian")
End If
End Sub

Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles Button4.Click
If TextBox25.Text = "" Or TextBox13.Text = "" Or ComboBox13.Text =
"" Or TextBox14.Text = "" Or TextBox3.Text = "" Or TextBox4.Text = "" Then
MsgBox("Isi data dengan benar!!", MsgBoxStyle.Exclamation,
"Kesalahan")
Exit Sub
End If
TextBox5.Text = Val(TextBox4.Text - TextBox3.Text)
CNN = New OleDbConnection(KONEKSI)
If CNN.State <> ConnectionState.Closed Then CNN.Close()
CNN.Open()
OLECMD = New OleDbCommand("insert into Table3 ([No Transaksi],
[Tanggal],[Meja],[Kasir],[Total Bayar]) values ('" & _
TextBox25.Text & "','" & TextBox13.Text &
"','" & ComboBox13.Text & "','" & TextBox14.Text & "','" & TextBox3.Text &
"')", CNN)

x = OLECMD.ExecuteNonQuery
If x = 1 Then
MsgBox("Terima Kasih Sudah Belanja,Kembalian Anda " &
TextBox5.Text, MsgBoxStyle.Information, "Informasi")
TextBox25.Text = ""
TextBox13.Text = ""
ComboBox13.Text = ""
TextBox14.Text = ""
TextBox3.Text = ""

Copyright (c) 2015 http://arcatronik.blogspot.com


TextBox4.Text = ""
TextBox5.Text = ""
Else
MsgBox("Gagal Mendaftar !!!", MsgBoxStyle.Exclamation,
"Kesalahan")
End If

End Sub
End Class

*kemudian design form 6 untuk form lihat data base

Lalu isi syntax berikut :


Imports System.Data.OleDb
Imports System.Data.Odbc
Public Class Form6
Sub OpenDB()
Dim KONEKSI = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=|
DataDirectory|\DBbella.accdb"
CNN = New OleDbConnection(KONEKSI)
If CNN.State <> ConnectionState.Closed Then
CNN.Open()
End If
End Sub
Sub Tampillogin()
OLEDA = New OleDbDataAdapter("select * from login", CNN)
DS = New DataSet
OLEDA.Fill(DS, "login")
DataGridView1.DataSource = DS.Tables("login")
End Sub
Sub TampilTable1()
OLEDA = New OleDbDataAdapter("select * from Table1", CNN)
DS = New DataSet
OLEDA.Fill(DS, "Table1")
DataGridView1.DataSource = DS.Tables("Table1")
End Sub

Copyright (c) 2015 http://arcatronik.blogspot.com


Sub TampilTable3()
OLEDA = New OleDbDataAdapter("select * from Table3", CNN)
DS = New DataSet
OLEDA.Fill(DS, "Table3")
DataGridView1.DataSource = DS.Tables("Table3")
End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles Button1.Click
Call OpenDB()
Call Tampillogin()
End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles Button2.Click
Call OpenDB()
Call TampilTable1()
End Sub

Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles Button3.Click
Call OpenDB()
Call TampilTable3()
End Sub

Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles Button4.Click
If TextBox1.Text = "" Then
MsgBox("Isi data dengan benar!!", MsgBoxStyle.Exclamation,
"Kesalahan")
Exit Sub
End If

If MsgBox("Ingin menghapus Data Transaksi ?", MsgBoxStyle.YesNo,


"Konfirmasi") = MsgBoxResult.Yes Then
CNN = New OleDbConnection(KONEKSI)
If CNN.State <> ConnectionState.Closed Then CNN.Close()
CNN.Open()
OLECMD = New OleDbCommand("Delete from Table3 Where [No
Transaksi] ='" & TextBox1.Text & "'", CNN)
x = OLECMD.ExecuteNonQuery
End If
If x = 1 Then
MsgBox("Data berhasil di hapus", MsgBoxStyle.Information,
"Informasi")
TextBox1.Text = ""
Else
MsgBox("Gagal menghapus data", MsgBoxStyle.Exclamation,
"Kesalahan")
End If
End Sub

Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles Button5.Click
If TextBox1.Text = "" Then
MsgBox("Username belum diisi!!", MsgBoxStyle.Exclamation,
"Kesalahan")
Exit Sub
End If

Copyright (c) 2015 http://arcatronik.blogspot.com


If MsgBox("Ingin menghapus Username ?", MsgBoxStyle.YesNo,
"Konfirmasi") = MsgBoxResult.Yes Then
CNN = New OleDbConnection(KONEKSI)
If CNN.State <> ConnectionState.Closed Then CNN.Close()
CNN.Open()
OLECMD = New OleDbCommand("Delete from login Where [Username]
='" & TextBox2.Text & "'", CNN)
x = OLECMD.ExecuteNonQuery
End If
If x = 1 Then
MsgBox("Username berhasil di hapus", MsgBoxStyle.Information,
"Informasi")
TextBox2.Text = ""
Else
MsgBox("Gagal menghapus Username", MsgBoxStyle.Exclamation,
"Kesalahan")
End If
End Sub

Private Sub Form6_Load(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles MyBase.Load

End Sub
End Class

Setelah semua form selesai save semua project dan beri nama TM Bella, sekarang
buat lah Data Base menggunakan Microsoft Acces seperti berikut :
Table login:

Copyright (c) 2015 http://arcatronik.blogspot.com


Table 1:

Table 2 :

Copyright (c) 2015 http://arcatronik.blogspot.com


Table 3 :

Setelah selesai, beri nama DBbella lalu save ke folder project VB tadi yang telah kita
buat, letakkan di dalam folder TM Bella/bin/Debug .
Jika di runing tampilan program akan seperti ini :

Copyright (c) 2015 http://arcatronik.blogspot.com


 Jika sobat ingin mendapatkan aplikasi jadinya, silahkan Contact me di
http://arcatronik.blogspot.com nanti saya kirim link downloadnya ke email
sobat.

 Jika sobat berkenan untuk donasi,cukup isi pulsa ke 085668336398 atau


klik semua iklan yang ada disini :
http://arcatronik.blogspot.com , Terima kasih...

Copyright (c) 2015 http://arcatronik.blogspot.com

You might also like