Aplikasi Parkir Aplikasi Parkir ini dibuat menggunakan Visual Studio 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
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Aplikasi Parkir
Aplikasi Parkir ini dibuat menggunakan Visual Studio 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 :
Imports System.Data.OdbcImports System.DataImports System.Data.OleDbModule 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|\DBzery.accdb" Public x As Integer
End Module
*Kemudian design form 1 untuk form login seperti berikut :
Lalu isi syntax berikut :
Imports System.Data.OleDbImports System.Data.OdbcPublic 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() OLECMD = New OleDbCommand("SELECT * From login WHERE username = '" & TextBox1.Text & _ "' and password = '" & TextBox2.Text & "'", CNN)
Copyright (c) 2015 http://arcatronik.blogspot.com
OLERDR = OLECMD.ExecuteReader If (OLERDR.Read()) Then Form5.Show() Me.Hide() TextBox1.Text = "" 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 Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click End End SubEnd Class
*Kemudian design form 2 untuk form Parkir masuk :
Copyright (c) 2015 http://arcatronik.blogspot.com
Lalu isi syntax berikut :
Imports System.Data.OleDbImports System.Data.OdbcPublic Class Form2 Sub KodeOtomatis() CNN = New OleDbConnection(KONEKSI) If CNN.State <> ConnectionState.Closed Then CNN.Close() CNN.Open() OLECMD = New OleDbCommand("select * from Table1 order by [No Antrian] desc", CNN) OLERDR = OLECMD.ExecuteReader OLERDR.Read()
If Not OLERDR.HasRows Then TextBox2.Text = "000001" Else TextBox2.Text = Val(Microsoft.VisualBasic.Mid(OLERDR.Item("No Antrian").ToString, 5, 3)) + 1
If Len(TextBox2.Text) = 1 Then TextBox2.Text = "00000" & TextBox2.Text & "" ElseIf Len(TextBox2.Text) = 2 Then TextBox2.Text = "0000" & TextBox2.Text & "" ElseIf Len(TextBox2.Text) = 3 Then TextBox2.Text = "000" & TextBox2.Text & "" End If End If TextBox3.Focus() End Sub Sub bersih() TextBox3.Text = "" ComboBox1.Text = "" 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 TextBox5.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 Table1 ([No Antrian],[No Plat Polisi],[Jenis Kendaraan],[Jam Masuk],[Operator],[Tanggal]) values ('" & _ TextBox2.Text & "','" & TextBox3.Text & "','" & ComboBox1.Text & "','" & TextBox4.Text & "','" & TextBox6.Text & "','" & TextBox1.Text & "')", CNN)
x = OLECMD.ExecuteNonQuery If x = 1 Then MsgBox("Data berhasil di simpan", MsgBoxStyle.Information, "Informasi") Call bersih() Call KodeOtomatis() Else
Copyright (c) 2015 http://arcatronik.blogspot.com
MsgBox("Gagal menyimpan data", MsgBoxStyle.Exclamation, "Kesalahan") End If End Sub
Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Call KodeOtomatis() TextBox4.Text = Format(Now, "HH:mm:ss") TextBox1.Text = Format(Now, "dd/MM/yyyy") ComboBox1.Items.Clear() ComboBox1.Items.Add("Motor") ComboBox1.Items.Add("Mobil") TextBox5.Text = 1000 End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick TextBox4.Text = Format(Now, "HH:mm:ss") TextBox1.Text = Format(Now, "dd/MM/yyyy") End Sub
End Class
*Kemudian design form 3 untuk form Parkir keluar :
Lalu isi syntax berikut :
Imports System.Data.OleDbImports System.Data.OdbcPublic Class Form3 Sub bersih() TextBox1.Text = "" TextBox2.Text = "" TextBox3.Text = "" TextBox4.Text = ""
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() OLECMD = New OleDbCommand("select * from Table1 where [No Antrian] = '" & TextBox2.Text & "'", CNN) OLERDR = OLECMD.ExecuteReader OLERDR.Read()
Else MsgBox("Data Tidak Ditemukan….!", MsgBoxStyle.Exclamation, "Perhatian") End If End Sub
Private Sub Form3_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load TextBox8.Text = "1000" TextBox2.Focus()
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click If TextBox1.Text = "" Then MsgBox("Silahkan Cari Data!!", MsgBoxStyle.Exclamation, "Kesalahan") Exit Sub End If Dim detik, menit, jam, second As Integer detik = DateDiff(DateInterval.Second, CDate(TextBox5.Text), CDate(TextBox6.Text)) menit = DateDiff(DateInterval.Minute, CDate(TextBox5.Text), CDate(TextBox6.Text)) jam = DateDiff(DateInterval.Hour, CDate(TextBox5.Text), CDate(TextBox6.Text)) jam = detik / 3600 menit = (detik Mod 3600) / 60 second = (detik Mod 3600) Mod 60
TextBox7.Text = jam & ":" & menit & ":" & second If jam > 3 Then
Copyright (c) 2015 http://arcatronik.blogspot.com
TextBox9.Text = 2000 If jam > 6 Then TextBox9.Text = 3000 End If Else TextBox9.Text = 1000 End If Label12.Text = TextBox3.Text Label13.Text = TextBox7.Text Label14.Text = TextBox9.Text End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click If TextBox2.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 [Jam Keluar]='" & TextBox6.Text & "' ,[Lama Parkir]='" & TextBox7.Text & "' ,[Biaya]='" & TextBox9.Text & "' Where [No Antrian]='" & TextBox2.Text & "'", CNN) x = OLECMD.ExecuteNonQuery If x = 1 Then MsgBox("Data berhasil di Simpan", MsgBoxStyle.Information, "Informasi") Call bersih() TextBox2.Focus() Else MsgBox("Gagal Menyimpan 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 If TextBox1.Text = "" Or TextBox2.Text = "" Or TextBox3.Text = "" Or TextBox4.Text = "" Or TextBox5.Text = "" Or TextBox6.Text = "" Or TextBox8.Text = "" Or TextBox10.Text = "" Then MsgBox("Isi data dengan benar!!", MsgBoxStyle.Exclamation, "Kesalahan") Exit Sub End If
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 Table1 Where [No Antrian] ='" & TextBox2.Text & "'", CNN) x = OLECMD.ExecuteNonQuery End If If x = 1 Then MsgBox("Data berhasil di hapus", MsgBoxStyle.Information, "Informasi") Call bersih() TextBox2.Focus()
Copyright (c) 2015 http://arcatronik.blogspot.com
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 Call bersih() End Sub
End Class
*Kemudian design form 4 untuk form Lihat data :
Lalu isi syntax berikut :
Imports System.Data.OleDbImports System.Data.OdbcPublic Class Form4 Sub OpenDB() Dim KONEKSI = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=|DataDirectory|\DBzery.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 Hitung()
Copyright (c) 2015 http://arcatronik.blogspot.com
Dim h As Integer h = DataGridView1.Rows.Count - 1 TextBox2.Text = h End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Call OpenDB() Call TampilTable1() Call Hitung() End Sub
Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged CNN = New OleDbConnection(KONEKSI) If CNN.State <> ConnectionState.Closed Then CNN.Close() CNN.Open() OLECMD = New OleDbCommand("select * from Table1 where [No Antrian] like'%" & TextBox1.Text & "%'", CNN) OLERDR = OLECMD.ExecuteReader OLERDR.Read()
If OLERDR.HasRows Then OLEDA = New OleDbDataAdapter("select * from Table1 where [No Antrian] like'%" & TextBox1.Text & "%'", CNN) DS = New DataSet OLEDA.Fill(DS, "Ketemu") DataGridView1.DataSource = DS.Tables("Ketemu") DataGridView1.ReadOnly = True End If End Sub
End Class
*Kemudian design form 5 untuk form Menu :
Copyright (c) 2015 http://arcatronik.blogspot.com
Lalu isi syntax berikut :
Public Class Form5 Private Sub ParkirMasukToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ParkirMasukToolStripMenuItem.Click Dim anak As New Form2 anak.MdiParent = Me anak.Show() End Sub
Private Sub ParkirKeluarToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ParkirKeluarToolStripMenuItem.Click Dim anak As New Form3 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 Form4 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 Form5_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Label1.Text = Format(Now, "HH:mm:ss")
Copyright (c) 2015 http://arcatronik.blogspot.com
Label2.Text = Format(Now, "dd/MM/yyyy") End Sub
Private Sub KeluarToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles KeluarToolStripMenuItem.Click End End Sub
End Class
Setelah semua form selesai save semua project dan beri nama TM Zery 1, sekarang buat lah Data Base menggunakan Microsoft Acces seperti berikut :
Table login:
Table1 :
Setelah selesai, beri nama DBzery lalu save ke folder project VB tadi yang telah kita buat, letakkan di dalam folder TM Zery 1/bin/Debug .
Copyright (c) 2015 http://arcatronik.blogspot.com
Jika di runing tampilan program akan seperti ini :
Silahkan mencoba...
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,boleh isi pulsa ke 085668336398 atau cukup klik semua iklan yang ada disini :