Parking System Code

VBCode for a simple parking system

Code:
Imports System.Data.OleDb
Public Class PrintReceipt1
 Dim provider As String
 Dim datafile As String
 Dim connString As String
 Dim myConnection As OleDbConnection = New OleDbConnection
 Private Sub RichTextBox1_TextChanged(sender As System.Object, e As System.EventArgs) Handles
RichTextBox1.TextChanged
 RichTextBox1.SelectionAlignment = HorizontalAlignment.Center
 RichTextBox1.SelectionFont = New Font("Courier New", 14)
 RichTextBox1.SelectionColor = Color.Blue
 End Sub
 Private Sub ComboBox1_SelectedIndexChanged(sender As System.Object, e As System.EventArgs)
Handles ComboBox1.SelectedIndexChanged
 Dim rightNow As DateTime = Date.Now.ToString("HH:mm tt")
 Select Case Me.ComboBox1.Text
 Case "1 Hour"
 TextBox5.Text = "₱40"
 TextBox8.Text = rightNow.AddHours(1)
 Case "2 Hours"
 TextBox5.Text = "₱80"
 TextBox8.Text = rightNow.AddHours(2)
 Case "3 Hours"
 TextBox5.Text = "₱120"
 TextBox8.Text = rightNow.AddHours(3)
 Case "4 Hours"
 TextBox5.Text = "₱160"
 TextBox8.Text = rightNow.AddHours(4)
 Case "5 Hours"
 TextBox5.Text = "₱200"
 TextBox8.Text = rightNow.AddHours(5)
 Case "6 Hours"
 TextBox5.Text = "₱240"
 TextBox8.Text = rightNow.AddHours(6)
 Case "7 Hours"
 TextBox5.Text = "₱280"
 TextBox8.Text = rightNow.AddHours(7)
 Case "8 Hours"
 TextBox5.Text = "₱320"
 TextBox8.Text = rightNow.AddHours(8)
 Case "9 Hours"
 TextBox5.Text = "₱360"
 TextBox8.Text = rightNow.AddHours(9)
 Case "10 Hours"
 TextBox5.Text = "₱400"
 TextBox8.Text = rightNow.AddHours(10)
 Case Else
 MsgBox("Please Enter Time!", vbOK, "Error")
 RichTextBox1.Text = ""
 ComboBox1.Text = ""
 End Select
 End Sub
 Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
 TextBox4.Text = Format(Now, "dd MMM yyyy")
 TextBox3.Text = Format(Now, "hh:mm:ss tt")
 provider = "Provider = Microsoft.ACE.OLEDB.12.0;Data Source="
 datafile = "C:\Users\Jason\Desktop\PrivateCarParkingSystem\ParkingSystem.accdb"
 connString = provider & datafile
 myConnection.ConnectionString = connString
 myConnection.Open()
 Dim str As String
 str = "Insert into
Parking([ParkingNumber],[PlateNumber],[Hour(s)],[TimeStarted],[EndTime],[ExactDate],[TotalAmount])
Values (?,?,?,?,?,?,?)"
 Dim cmd As OleDbCommand = New OleDbCommand(str, myConnection)
 cmd.Parameters.Add(New OleDbParameter("ParkingNumber", CType(TextBox1.Text, String)))
 cmd.Parameters.Add(New OleDbParameter("PlateNumber", CType(TextBox2.Text, String)))
 cmd.Parameters.Add(New OleDbParameter("Hour(s)", CType(ComboBox1.Text, String)))
 cmd.Parameters.Add(New OleDbParameter("TimeStarted", CType(TextBox3.Text, String)))
 cmd.Parameters.Add(New OleDbParameter("EndTime", CType(TextBox8.Text, String)))
 cmd.Parameters.Add(New OleDbParameter("ExactDate", CType(TextBox4.Text, String)))
 cmd.Parameters.Add(New OleDbParameter("TotalAmount", CType(TextBox5.Text, String)))
 If MsgBox("Data Added to DataBase!", vbInformation, "Success!") Then
 Try
 cmd.ExecuteNonQuery()
 cmd.Dispose()
 myConnection.Close()
 TextBox1.Clear()
 TextBox2.Clear()
 TextBox3.Clear()
 TextBox4.Clear()
 ComboBox1.Text = ""
 Catch ex As Exception
 MsgBox(ex.Message)
 End Try
 End If
 Dim rightNow As DateTime = Date.Now.ToString("HH:mm tt")
 PrintPreviewDialog1.ShowDialog()
 Close()
 Form1.Button2.Visible = False
 Form1.Label5.Visible = True
 Form1.Label4.Visible = True
 End Sub
 Private Sub Button2_Click(sender As System.Object, e As System.EventArgs) Handles Button2.Click
 Dim rightNow As DateTime = Date.Now.ToString("HH:mm tt")
 RichTextBox1.AppendText("" + TextBox7.Text & Environment.NewLine)
 RichTextBox1.AppendText("CAR PARKING SYSTEM IN SM MEGA MALL" + TextBox6.Text &
Environment.NewLine)
 RichTextBox1.AppendText("Parking Number: " + TextBox1.Text & Environment.NewLine)
 RichTextBox1.AppendText("Plate Number: " + TextBox2.Text & Environment.NewLine)
 RichTextBox1.AppendText("Time Started: " + TextBox3.Text & Environment.NewLine)
 RichTextBox1.AppendText("End Time: " + TextBox8.Text & Environment.NewLine)
 RichTextBox1.AppendText("Date: " + TextBox4.Text & Environment.NewLine)
 RichTextBox1.AppendText("Hour(s) to Stay: " + ComboBox1.Text & Environment.NewLine)
 RichTextBox1.AppendText("Total Amount: " + TextBox5.Text & Environment.NewLine)
 Form1.Label5.Text = TextBox8.Text
 If ComboBox1.Text = "1 Hour" Then
 TextBox5.Text = "₱40"
 TextBox8.Text = rightNow.AddHours(1)
 ElseIf ComboBox1.Text = "2 Hours" Then
 TextBox5.Text = "₱80"
 TextBox8.Text = rightNow.AddHours(2)
 ElseIf ComboBox1.Text = "3 Hours" Then
 TextBox5.Text = "₱120"
 TextBox8.Text = rightNow.AddHours(3)
 ElseIf ComboBox1.Text = "4 Hours" Then
 TextBox5.Text = "₱160"
 TextBox8.Text = rightNow.AddHours(4)
 ElseIf ComboBox1.Text = "5 Hours" Then
 TextBox5.Text = "₱200"
 TextBox8.Text = rightNow.AddHours(5)
 ElseIf ComboBox1.Text = "6 Hours" Then
 TextBox5.Text = "₱240"
 TextBox8.Text = rightNow.AddHours(6)
 ElseIf ComboBox1.Text = "7 Hours" Then
 TextBox5.Text = "₱280"
 TextBox8.Text = rightNow.AddHours(7)
 ElseIf ComboBox1.Text = "8 Hours" Then
 TextBox5.Text = "₱320"
 TextBox8.Text = rightNow.AddHours(8)
 ElseIf ComboBox1.Text = "9 Hours" Then
 TextBox5.Text = "₱360"
 TextBox8.Text = rightNow.AddHours(9)
 ElseIf ComboBox1.Text = "10 Hours" Then
 TextBox5.Text = "₱400"
 TextBox8.Text = rightNow.AddHours(10)
 ElseIf MsgBox("Please Insert Value!", vbOKOnly) Then
 TextBox1.Text = "1"
 TextBox2.Text = ""
 ComboBox1.Text = ""
 TextBox8.Text = ""
 RichTextBox1.Text = ""
 End If
 End Sub
 Private Sub Button6_Click(sender As System.Object, e As System.EventArgs) Handles Button6.Click
 If MsgBox("Are You sure to cancel this transaction?", 4 + 32, "Close Window") = vbYes Then
 Me.Close()
 End If
 End Sub
 Private Sub PrintReceipt1_Load(sender As System.Object, e As System.EventArgs) Handles
MyBase.Load

 Dim rightNow As DateTime = rightNow
 Console.WriteLine("RightNow: " & rightNow.ToString)
 ' ----- Add time values.
 Console.WriteLine("RightNow.AddHours(1): " & rightNow.AddHours(1))
 Console.WriteLine("RightNow.AddHours(2): " & rightNow.AddHours(2))
 Console.WriteLine("RightNow.AddHours(3): " & rightNow.AddHours(3))
 Console.WriteLine("RightNow.AddHours(4): " & rightNow.AddHours(4))
 Console.WriteLine("RightNow.AddHours(5): " & rightNow.AddHours(5))
 Console.WriteLine("RightNow.AddHours(6): " & rightNow.AddHours(6))
 Console.WriteLine("RightNow.AddHours(7): " & rightNow.AddHours(7))
 Console.WriteLine("RightNow.AddHours(8): " & rightNow.AddHours(8))
 Console.WriteLine("RightNow.AddHours(7): " & rightNow.AddHours(9))
 Console.WriteLine("RightNow.AddHours(10): " & rightNow.AddHours(10))
 TextBox1.Text = "1"
 TextBox4.Text = Format(Now, "dd MMM yyyy")
 TextBox3.Text = Format(Now, "hh:mm tt")
 End Sub
 Private Sub PrintDocument1_PrintPage(sender As System.Object, e As
System.Drawing.Printing.PrintPageEventArgs) Handles PrintDocument1.PrintPage
 Static fntHeadingFont As New Font("Courier New", 16, FontStyle.Bold)
 Dim sngCenterPage As Single
 sngCenterPage = Convert.ToSingle(e.PageBounds.Width / 2 -
e.Graphics.MeasureString(RichTextBox1.Text, fntHeadingFont).Width / 2)
 e.Graphics.DrawString(RichTextBox1.Text, fntHeadingFont, Brushes.Black, sngCenterPage, 2)
 End Sub
End Class
Public Class Form1
 Private Sub Button2_Click(sender As System.Object, e As System.EventArgs) Handles Button2.Click
 PrintReceipt1.Show()
 End Sub
 Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
 PrintReceipt2.Show()
 End Sub
 Private Sub Button3_Click(sender As System.Object, e As System.EventArgs) Handles Button3.Click
 PrintReceipt3.Show()
 End Sub
 Private Sub Button4_Click(sender As System.Object, e As System.EventArgs) Handles Button4.Click
 PrintReceipt4.Show()
 End Sub
 Private Sub Button5_Click(sender As System.Object, e As System.EventArgs) Handles Button5.Click
 PrintReceipt5.Show()
 End Sub
 Private Sub Button6_Click(sender As System.Object, e As System.EventArgs) Handles Button6.Click
 PrintReceipt6.Show()
 End Sub
 Private Sub Button7_Click(sender As System.Object, e As System.EventArgs) Handles Button7.Click
 PrintReceipt7.Show()
 End Sub
 Private Sub Button8_Click(sender As System.Object, e As System.EventArgs) Handles Button8.Click
 PrintReceipt8.Show()
 End Sub
 Private Sub Button9_Click(sender As System.Object, e As System.EventArgs) Handles Button9.Click
 PrintReceipt9.Show()
 End Sub
 Private Sub Button10_Click(sender As System.Object, e As System.EventArgs) Handles Button10.Click
 PrintReceipt010.Show()
 End Sub
 Private Sub Button11_Click(sender As System.Object, e As System.EventArgs) Handles Button11.Click
 PrintReceipt11.Show()
 End Sub
 Private Sub Button12_Click(sender As System.Object, e As System.EventArgs) Handles Button12.Click
 PrintReceipt12.Show()
 End Sub
 Private Sub Button13_Click(sender As System.Object, e As System.EventArgs) Handles Button13.Click
 PrintReceipt13.Show()
 End Sub
 Private Sub Button14_Click(sender As System.Object, e As System.EventArgs) Handles Button14.Click
 PrintReceipt14.Show()
 End Sub
 Private Sub Button15_Click(sender As System.Object, e As System.EventArgs) Handles Button15.Click
 PrintReceipt15.Show()
 End Sub
 Private Sub Parking1ToolStripMenuItem_Click(sender As System.Object, e As System.EventArgs)
 End Sub
 Private Sub DatabasesToolStripMenuItem_Click(sender As System.Object, e As System.EventArgs)
Handles DatabasesToolStripMenuItem.Click
 Databases.Show()
 End Sub
 Private Sub RecordsToolStripMenuItem_Click(sender As System.Object, e As System.EventArgs)
Handles RecordsToolStripMenuItem.Click
 End Sub
 Private Sub LogoutToolStripMenuItem_Click(sender As System.Object, e As System.EventArgs)
Handles LogoutToolStripMenuItem.Click
 If MessageBox.Show("Are You sure to close this transaction?", "Information",
MessageBoxButtons.YesNo, MessageBoxIcon.Question) = DialogResult.Yes Then
 LoginForm.Show()
 Me.Close()
 End If
 End Sub
 Private Sub JasonRoseToolStripMenuItem_Click(sender As System.Object, e As System.EventArgs)
 End Sub
 Private Sub AboutToolStripMenuItem_Click(sender As System.Object, e As System.EventArgs) Handles
AboutToolStripMenuItem.Click
 End Sub
 Private Sub ParkingNumber1ToolStripMenuItem_Click(sender As System.Object, e As
System.EventArgs) Handles ParkingNumber1ToolStripMenuItem.Click
 If MessageBox.Show("Are You Sure?", "Information", MessageBoxButtons.YesNo,
MessageBoxIcon.Information) = vbYes Then
 Button2.Visible = True
 Label5.Visible = False
 Label4.Visible = False
 End If
 End Sub
 Private Sub ParkingNumber2ToolStripMenuItem_Click(sender As System.Object, e As
System.EventArgs) Handles ParkingNumber2ToolStripMenuItem.Click
 If MessageBox.Show("Are You Sure?", "Information", MessageBoxButtons.YesNo,
MessageBoxIcon.Information) = vbYes Then
 Button1.Visible = True
 Label2.Visible = False
 Label3.Visible = False
 End If
 End Sub
 Private Sub ParkingNumber2ToolStripMenuItem1_Click(sender As System.Object, e As
System.EventArgs) Handles ParkingNumber2ToolStripMenuItem1.Click
 If MessageBox.Show("Are You Sure?", "Information", MessageBoxButtons.YesNo,
MessageBoxIcon.Information) = vbYes Then
 Button3.Visible = True
 End If
 End Sub
 Private Sub ParkingNumber2ToolStripMenuItem2_Click(sender As System.Object, e As
System.EventArgs) Handles ParkingNumber2ToolStripMenuItem2.Click
 If MessageBox.Show("Are You Sure?", "Information", MessageBoxButtons.YesNo,
MessageBoxIcon.Information) = vbYes Then
 Button4.Visible = True
 Label9.Visible = False
 Label8.Visible = False
 End If
 End Sub
 Private Sub ParkingNumber2ToolStripMenuItem3_Click(sender As System.Object, e As
System.EventArgs) Handles ParkingNumber2ToolStripMenuItem3.Click
 If MessageBox.Show("Are You Sure?", "Information", MessageBoxButtons.YesNo,
MessageBoxIcon.Information) = vbYes Then
 Button5.Visible = True
 Label10.Visible = False
 Label11.Visible = False
 End If
 End Sub
 Private Sub ParkingNumber2ToolStripMenuItem4_Click(sender As System.Object, e As
System.EventArgs) Handles ParkingNumber2ToolStripMenuItem4.Click
 If MessageBox.Show("Are You Sure?", "Information", MessageBoxButtons.YesNo,
MessageBoxIcon.Information) = vbYes Then
 Button6.Visible = True
 Label12.Visible = False
 Label13.Visible = False
 End If
 End Sub
 Private Sub ParkingNumber2ToolStripMenuItem5_Click(sender As System.Object, e As
System.EventArgs) Handles ParkingNumber2ToolStripMenuItem5.Click
 If MessageBox.Show("Are You Sure?", "Information", MessageBoxButtons.YesNo,
MessageBoxIcon.Information) = vbYes Then
 Button7.Visible = True
 Label14.Visible = False
 Label15.Visible = False
 End If
 End Sub
 Private Sub ParkingNumber2ToolStripMenuItem6_Click(sender As System.Object, e As
System.EventArgs) Handles ParkingNumber2ToolStripMenuItem6.Click
 If MessageBox.Show("Are You Sure?", "Information", MessageBoxButtons.YesNo,
MessageBoxIcon.Information) = vbYes Then
 Button8.Visible = True
 Label16.Visible = False
 Label17.Visible = False
 End If
 End Sub
 Private Sub ParkingNumber2ToolStripMenuItem7_Click(sender As System.Object, e As
System.EventArgs) Handles ParkingNumber2ToolStripMenuItem7.Click
 If MessageBox.Show("Are You Sure?", "Information", MessageBoxButtons.YesNo,
MessageBoxIcon.Information) = vbYes Then
 Button9.Visible = True
 Label18.Visible = False
 Label19.Visible = False
 End If
 End Sub
 Private Sub ParkingNumber2ToolStripMenuItem8_Click(sender As System.Object, e As
System.EventArgs) Handles ParkingNumber2ToolStripMenuItem8.Click
 If MessageBox.Show("Are You Sure?", "Information", MessageBoxButtons.YesNo,
MessageBoxIcon.Information) = vbYes Then
 Button10.Visible = True
 Label20.Visible = False
 Label21.Visible = False
 End If
 End Sub
 Private Sub ParkingNumber11ToolStripMenuItem_Click(sender As System.Object, e As
System.EventArgs) Handles ParkingNumber11ToolStripMenuItem.Click
 If MessageBox.Show("Are You Sure?", "Information", MessageBoxButtons.YesNo,
MessageBoxIcon.Information) = vbYes Then
 Button11.Visible = True
 Label22.Visible = False
 Label23.Visible = False
 End If
 End Sub
 Private Sub ParkingNumber12ToolStripMenuItem_Click(sender As System.Object, e As
System.EventArgs) Handles ParkingNumber12ToolStripMenuItem.Click
 If MessageBox.Show("Are You Sure?", "Information", MessageBoxButtons.YesNo,
MessageBoxIcon.Information) = vbYes Then
 Button12.Visible = True
 Label24.Visible = False
 Label25.Visible = False
 End If
 End Sub
 Private Sub ParkingNumber13ToolStripMenuItem_Click(sender As System.Object, e As
System.EventArgs) Handles ParkingNumber13ToolStripMenuItem.Click
 If MessageBox.Show("Are You Sure?", "Information", MessageBoxButtons.YesNo,
MessageBoxIcon.Information) = vbYes Then
 Button13.Visible = True
 Label26.Visible = False
 Label27.Visible = False
 End If
 End Sub
 Private Sub ParkingNumber14ToolStripMenuItem_Click(sender As System.Object, e As
System.EventArgs) Handles ParkingNumber14ToolStripMenuItem.Click
 If MessageBox.Show("Are You Sure?", "Information", MessageBoxButtons.YesNo,
MessageBoxIcon.Information) = vbYes Then
 Button14.Visible = True
 Label28.Visible = False
 Label29.Visible = False
 End If
 End Sub
 Private Sub ParkingNumber15ToolStripMenuItem_Click(sender As System.Object, e As
System.EventArgs) Handles ParkingNumber15ToolStripMenuItem.Click
 If MessageBox.Show("Are You Sure?", "Information", MessageBoxButtons.YesNo,
MessageBoxIcon.Information) = vbYes Then
 Button15.Visible = True
 Label30.Visible = False
 Label31.Visible = False
 End If
 End Sub
 Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
 Dim rightNow As DateTime = Date.Now.ToString("HH:mm tt")
 End Sub
 Private Sub Button16_Click(sender As System.Object, e As System.EventArgs)
 End Sub
 Private Sub OpenToolStripMenuItem_Click(sender As System.Object, e As System.EventArgs) Handles
OpenToolStripMenuItem.Click
 End Sub
End Class
 

Similar threads


Top Bottom