Sie sind auf Seite 1von 67

Table of Contents

Introduction .................................................................................................................... 3 Screen Designs ................................................................................................................ 4 Input Designs .............................................................................................................. 4 Output Screen Design................................................................................................ 15 User Manual ................................................................................................................. 21 User Login ................................................................................................................ 21 User Register............................................................................................................. 22 Forget Password ........................................................................................................ 23 Change Password ...................................................................................................... 24 Admin Edit................................................................................................................ 25 Student Register ........................................................................................................ 26 Search ....................................................................................................................... 27 Update/Delete ........................................................................................................... 28 Delete Expired User .................................................................................................. 29 Critical Assessment ....................................................................................................... 30 Conclusion .................................................................................................................... 31 Printout of the Source Code........................................................................................... 32 Splash Screen ............................................................................................................ 32 User Login ................................................................................................................ 33 Forgotten Password ................................................................................................... 35 Change Your Password ............................................................................................. 37 User Register............................................................................................................. 39 Admin Edit................................................................................................................ 44 MDI (Multiple Document Interface) .......................................................................... 52 Student Register ........................................................................................................ 55 Parking Lot ............................................................................................................... 57 Search ......................................................................... Error! Bookmark not defined. Update/Delete ............................................................. Error! Bookmark not defined. About ........................................................................................................................ 63 1

Crystal Report ........................................................................................................... 64 References .................................................................................................................... 65 Appendix Section .......................................................................................................... 66 Work Breakdown Structure ....................................................................................... 66

Introduction
There is a lot of different parking system in the world whereby our objective of the whole project is to produce a different type of parking system for the management of UCTI as the construction of a three storey car park has completed which can accommodate 90 cars in total and each level would have 30 parking spaces. Students would be able to rent a parking lot by using this parking system. Each of the group members Eugene Chan Zhirong, Foo Shu Ying and Lim Yi Sing has their own task of work. This includes producing the registration system to handle the registration of students for each available car park for each semester by registering their student ID, car number, and date of registration and so on. After that, we would also need to set the duration of the car park for the student to park at their particular spot for 150 days by locating the parking space ID. Each students information would be stored in a database table created by us using Visual Basic framework and SQL database structure. By creating the database, we would also create relationships between each of the different tables which include students, parking spaces as well as users. This parking system would be used by the parking administrative office to register students who wishes to park at the car park.

Screen Designs
Input Designs

10

11

12

13

14

Output Screen Design

Multiple Document Interface (MDI) form

Login page

15

Forgotten Password

Parking lot condition Level 1 Level 3

16

Admin Editor

New admin register

17

Password changer

New Student Registration

18

Update and delete information

Search Student form 19

About the application

Crystal Reporter

20

User Manual
User Login

First of all, user would need to go through the login page in order to log into the application main page. The initial first start-up of the program should be empty database. User will need to register in order to login. If the database is empty and there are no registered users in the database, the login page would be as follow:

As shown in the above picture, the Cancel button would automatically be changed to Register button. After the first user register, the first registered user would be automatically assigned as the Admin.

21

User Register

It is advisable to complete the recruitment system before starting the access of the system. Recruitment can be done by clicking the add button and fill in the information specified. Once the users clicked save, the information that input by the user will store into the database. Please note that only administrator has the right to access the staff registration and check it. You may also browse through the record and update the record that has been outdated or delete the information that is no longer needed.

22

Forget Password

If the user forgotten his/her password, the user are allowed to click on the Forgotten Username/Password, and then the user are allow to input his/her email address. After that, an email will be send to the individuals email.

23

Change Password

Password changing for the admin user is possible in this application. If the current user wants to change his/her password, the user would only need to go to the toolbar and choose admin control to change password. However, if the user wants to change the other user password, the current would need to go to the admin control and choose edit all admin, after that, he/she would need to click on set password in order to change, but that doesnt mean the user are allow to change the password straight away, he/she would need to input the old password first and then input the new password in order to change.

24

Admin Edit

As for editing the admin, user are allow to edit the admin through the toolbar and choosing Edit all admin, after that, a window will pop up as AdminEdit. In this window, users are allowed to add new user, edit user and delete the user. However, the current user would not be able to delete his/her record as the admin or moderator.

25

Student Register

Before you are able to make any registration, you must first choose the parking lot from the MDI, and then input all the information of the student including Student ID, First Name, Last Name, Contact Number, E-mail Address and Car Number. After that, only the student would be able to register. 26

Search

Users are allowed to search the students registered through the database by using the search form as shown above in order to update the details. User would need to only input the Student ID of the student, then all the details of the student would be shown in the group box.

27

Update/Delete

When user want to update the student information, user can update here. User just need to click the update button, then can update the student information. Besides, user just clicks the delete button, and then the student information will be deleted.

28

Delete Expired User


When the user is expired, we will use this function to delete it. This is because we dont want waste the database space. This can save the database space. When we found that the database has expired user, we will delete it.

29

Critical Assessment
In our new system, we realize that problem in our new system does exists. One of the major problems would be the crystal report. All works well when running the program on the development machine but when the program is deployed to another computer, the crystal report will not be able to generate. We had tried to solve this problem, but it seems that there were no solutions to solve this problem.

30

Conclusion
As for our conclusion, we had found that Visual Basic is a very well organized application. We had learned a lot during producing the parking system using Visual Basic. As we are the learners of using Visual Basic, we found that in the programming world, its all about creating a program that is stable. However, error do occurs during the process of creating the program, but we had gone through lots of havocs and trying to resolve each of the problems that occur during the producing time. It is a very good experience for us to produce such a program with all our hard work.

31

Printout of the Source Code


Splash Screen
Public NotInheritable Class SplashScreen1 'TODO: This form can easily be set as the splash screen for the application by going to the "Application" tab ' of the Project Designer ("Properties" under the "Project" menu). Private Sub SplashScreen1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load 'Set up the dialog text at runtime according to the application's assembly information. 'TODO: Customize the application's assembly information in the "Application" pane of the project ' properties dialog (under the "Project" menu). 'Application title If My.Application.Info.Title <> "" Then ApplicationTitle.Text = My.Application.Info.Title Else 'If the application title is missing, use the application name, without the extension ApplicationTitle.Text = System.IO.Path.GetFileNameWithoutExtension(My.Application.Info.AssemblyName) End If 'Format the version information using the text set into the Version control at design time as the ' formatting string. This allows for effective localization if desired. ' Build and revision information could be included by using the following code and changing the ' Version control's designtime text to "Version {0}.{1:00}.{2}.{3}" or something similar. See ' String.Format() in Help for more information. ' ' Version.Text = System.String.Format(Version.Text, My.Application.Info.Version.Major, My.Application.Info.Version.Minor, My.Application.Info.Version.Build, My.Application.Info.Version.Revision) Version.Text = System.String.Format(Version.Text, My.Application.Info.Version.Major, My.Application.Info.Version.Minor) 'Copyright info Copyright.Text = My.Application.Info.Copyright End Sub Private Sub SplashScreen1_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing 'Hold the form on screen approximately 5 second before closed System.Threading.Thread.Sleep(7000) End Sub Private Sub ApplicationTitle_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ApplicationTitle.Click End Sub End Class

32

User Login
'Project: Login Form for Car Park registration system 'Programmer: Spencerlim 'Date Finish: 26 September 2010 'Status: Stable and Running Well (DONE) 'Description: This program will allow user to login Apiit Car Park System;Navigate to Register new admin form and Forgotten username/password form ' In case of wrond match of username and password, the application will shut down immediately ' When user forget password or username , there is a link will open up the form of forgotten U.P. ' When validation successful, user allowed to enter System Imports System.Data.OleDb Public Class Login Dim cnn As OleDbConnection Dim cmd As OleDbCommand Dim dr As OleDbDataReader Dim str As String Private Sub Login_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing 'prompt confirmation with message alert sound when the program closing MessageBeep(AlertExclamation) Dim ConfirmExit As New MisCode Dim answer As String answer = ConfirmExit.ConfirmExit If answer = False Then 'if not close then clear all box e.Cancel = True txtPassword.Clear() With txtUsername .Clear() .Focus() End With End If End Sub Private Sub Login_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load Dim CheckAdminExist As New MisCode 'before start check whether admin is exist CheckAdminExist.CheckAdminExist() 'if yes the hide register box If AdminExist = 1 Then btnRegister.Hide() btnCancel.Show() Else 'if no hide cancel box btnRegister.Show() btnCancel.Hide() End If End Sub Private Sub Loginbtn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLogin.Click 'connection start here

33

cn.Open() 'command to select password row from the users table when the username is matched with username textbox input cmd = New OleDbCommand("select [userid], [username], [password], [userfname], [userlname], [position] from [users] where [username] ='" & txtUsername.Text & "'", cn) dr = cmd.ExecuteReader dr.Read() 'if dr has a row mean the password for the username is exist If dr.HasRows Then 'if data table at column 1 is matched with password textbox input If dr(2) = txtPassword.Text Then 'then hide the login form and display main page 'and retrieve important data for use inside the program userid = dr(0).ToString LoginID = dr(1).ToString ResetPass = dr(2).ToString FirstName = dr(3).ToString LastName = dr(4).ToString position = dr(5) cn.Close() Me.Hide() MasterMDI.Show() Else 'else pop up a massage box with massage invalid password MsgBox("Invalid password") cn.Close() End If Else 'if no row mean invalid username MsgBox("Invalid user name") cn.Close() End If End Sub Private Sub registerbtn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnRegister.Click 'show register form RegisterForm.Show() End Sub Private Sub ForgotpwdLink_LinkClicked(ByVal sender As System.Object, ByVal e As System.Windows.Forms.LinkLabelLinkClickedEventArgs) Handles LnkForgotten.LinkClicked MessageBeep(AlertExclamation) 'show username or password forgotten form ForgottenUP.Show() End Sub Private Sub btnCancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCancel.Click Me.Close() End Sub End Class

34

Forgotten Password
'Project: Admin Forgotten Username Password Email Sender form for CarPark Registration Application 'Programmer: Spencerlim 'Date Finish: 1 October 2010 'Status: Done 'Description: When the user forgotten username and password, this program will execute and sent the information to user Imports System.Net.Mail Imports System.Net.Mail.MailMessage Imports System.Net.NetworkCredential Imports System.Text.RegularExpressions Public Class ForgottenUP Private Sub btnSubmit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSubmit.Click Dim retriever As New MisCode mailto = txtEmail.Text 'Get some function from MisCode retriever.RetrieveUP() 'Gmail Basic Setting Const GmailPort As Integer = 587 Const U As String = "spencerlys@gmail.com" Const P As String = "visualbasic" 'Email Content Dim Mail As MailMessage Dim smtp As SmtpClient Dim From As String = "carparkdepart@apiit.com" Dim Receiver As String = mailto Dim Subject As String = "APIIT CAR PARK ADMIN USERNAME PASSWORD RETRIEVER " 'Message include Username and password Dim MailBody As String = "Your Username and Password are " & UsernameRetrieve & " and " & PasswordRetrieve & vbNewLine & "Please Reset Immediately for security purpose. " Dim Body As String = MailBody.ToString 'line up setting Mail = New MailMessage(From, Receiver, Subject, Body) 'most important of mailing system -- Smtp smtp = New SmtpClient("smtp.gmail.com", GmailPort) 'Enable SSL connection smtp.EnableSsl = True smtp.DeliveryMethod = SmtpDeliveryMethod.Network 'use to login gmail smtp.Credentials = New System.Net.NetworkCredential(U, P) Try 'send mail here and receive error inside catch smtp.Send(Mail) MsgBox("E-mail has been suceessfully send to " & Receiver, MsgBoxStyle.OkOnly, "success") Catch ex As SmtpFailedRecipientException 'need to verify what problem easily...mainly will cause by recipient exception MsgBox(ex.Message) Catch ex As SmtpException 'and also smtp exception MsgBox(ex.Message) Catch ex As Exception

35

'rest of error will call up this MsgBox(ex.Message) End Try End Sub Private Sub txtEmail_Validating(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles txtEmail.Validating Dim success As String Dim email As String Dim MailVerify As New MisCode email = txtEmail.Text 'cancel any previous error ErrorProvider1.SetError(txtEmail, "") 'assign the value email to email address check function and return value to success success = MailVerify.EmailAddressCheck(email) 'cancel the event when the email is failed to past the fomat test If success = False Then e.Cancel = True ErrorProvider1.SetError(txtEmail, "Please input a valid Email address") End If 'http://www.homeandlearn.co.uk/net/nets9p5.html End Sub Private Sub ForgottenUP_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load End Sub End Class

36

Change Your Password


'Project: Password Changing Form For Car Park Admin System 'Programmer: Spencerlim 'Date Finish: 2 October 2010 'Status: Stable and Running Well (DONE) 'Description: This main form is used to allow user change their password for security purpose Imports System.Data Imports System.Data.OleDb Public Class ChangeNewPass Private Sub btnChangePass_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnChangePass.Click If keyWord = "adminedit" Then temp = "" temp = LoginID LoginID = "" LoginID = LoginIdX LoginIdX = "" LoginIdX = temp tempX = ResetPass ResetPass = "" ResetPass = ResetPassX ResetPassX = "" ResetPassX = tempX tempX = "" End If 'check if field is empty If txtOldPass.Text.Trim = "" Or txtNewPass.Text.Trim = "" Then MsgBox("There are an Empty fields.", MsgBoxStyle.Exclamation + MsgBoxStyle.OkOnly, "Error") Exit Sub End If 'check if both field is same If Not txtNewPass.Text = txtNewConfirm.Text Then MsgBox("Please re-input New Password or New Confirm Password" & vbNewLine & "Both of Them should be the same", MsgBoxStyle.Exclamation + MsgBoxStyle.OkOnly, "Error") Exit Sub End If ' check if old password is correct If Not txtOldPass.Text = ResetPass Then MsgBox("Invalid Old Password.", MsgBoxStyle.Exclamation + MsgBoxStyle.OkOnly, "Error") Exit Sub End If 'update the new password Dim dbCommand As New OleDbCommand Dim strsql As String = "UPDATE [users] SET " & "[password]='" & txtNewPass.Text & "' " & "where [username]='" & LoginID & "'" dbCommand.CommandText = strsql.ToString dbCommand.Connection = cn dbCommand.Connection.Open() dbCommand.ExecuteNonQuery() dbCommand.Connection.Close() MessageBeep(AlertAsterix)

37

MsgBox("Password for username = " & LoginID & vbNewLine & "has been successfully Changed.", MsgBoxStyle.OkOnly, "Success!") Me.Close() If keyWord = "adminedit" Then temp = "" temp = LoginID LoginID = "" LoginID = LoginIdX LoginIdX = "" LoginIdX = temp tempX = ResetPass ResetPass = "" ResetPass = ResetPassX ResetPassX = "" ResetPassX = tempX tempX = "" keyWord = "NULL" End If End Sub Private Sub ChangeNewPass_FormClosed(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosedEventArgs) Handles Me.FormClosed MasterMDI.Text = "Apiit Car Park Administration" End Sub Private Sub ChangeNewPass_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load MasterMDI.Text = "Change New Password || Apiit Car Park Administration" End Sub End Class

38

User Register
'Project: Admin Register form for CarPark Registration Application 'Programmer: Spencerlim 'Date Finish: 23 September 2010 'Status: DONE 'Description: This program will register admin/ moderator for Apiit Car Park System ' ' ' as moderator ' ' This is to protect the admin user data will not delete accidently by other user Only admin can delete moderator We aspect that the carpark department is not incharge by one admin only and The system By ease admin department manage application user, we create this to allow them to register The first member should automatically assign as position 1 ( Admin ) and the rest will assign should protected by authentication

Imports System.Data Imports System.Data.OleDb Public Class RegisterForm

'----------------------------------------VALIDATING INPUT--------------------------------------------------------------------------Private Sub txtusername_validation(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles txtUsername.Validating 'cancel any previous error ErrorProvider1.SetError(txtUsername, "") 'check for any empty string If txtUsername.Text = String.Empty Then 'cancel the event e.Cancel = True ErrorProvider1.SetError(txtUsername, "Required Field") End If End Sub Private Sub txtPassword_Validating(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles txtPassword.Validating 'cancel any previous error ErrorProvider2.SetError(txtPassword, "") 'check for any empty string

39

If txtPassword.Text = String.Empty Then 'cancel the event e.Cancel = True ErrorProvider2.SetError(txtPassword, "Required Field") 'password and username should not be the same ElseIf txtPassword.Text = txtUsername.Text Then e.Cancel = True ErrorProvider2.SetError(txtPassword, "Password Should not same as Username") End If End Sub Private Sub txtFName_Validating(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles txtFName.Validating 'cancel any previous error ErrorProvider3.SetError(txtFName, "") 'check for any empty string If txtFName.Text = String.Empty Then 'cancel the event e.Cancel = True ErrorProvider3.SetError(txtFName, "Required Field") End If End Sub Private Sub txtLName_Validating(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles txtLName.Validating 'cancel any previous error ErrorProvider4.SetError(txtLName, "") 'cancel the event If txtLName.Text = String.Empty Then e.Cancel = True ErrorProvider4.SetError(txtLName, "Required Field") End If End Sub Private Sub txtEmail_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtEmail.TextChanged 'register button will be enable when the text of email textbox is changing btnRegister.Enabled = True End Sub

40

Private Sub txtEmail_Validating(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles txtEmail.Validating Dim email As String Dim success As String Dim EmailValidate As New MisCode email = txtEmail.Text 'cancel any previous error ErrorProvider5.SetError(txtEmail, "") 'assign the value email to email address check function and return value to success success = EmailValidate.EmailAddressCheck(email) 'cancel the event when the email is failed to past the fomat test If success = False Then e.Cancel = True ErrorProvider5.SetError(txtEmail, "Please input a valid Email address") End If 'http://www.homeandlearn.co.uk/net/nets9p5.html End Sub '----------------------------------------VALIDATING INPUT--------------------------------------------------------------------------Private Sub btnRegister_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnRegister.Click Dim CheckAdmin As New MisCode Dim usern, passw, fname, lname, emailre As String Dim uid, pos As Integer Dim cmmd As New OleDbCommand 'assign text input from user into variable usern = txtUsername.Text passw = txtPassword.Text fname = txtFName.Text lname = txtLName.Text emailre = txtEmail.Text CheckAdmin.CheckAdminExist() 'when the situation max row is less than 1 (no user) If AdminExist = 1 Then 'it is not less than 1 so increase by 1 and set position to 2 ( moderator ) uid = MaxRows + 1 pos = 2

41

Else 'user id set to 1 and position set to 1 ( Admin ) uid = 1 pos = 1 End If Try 'try to insert data to table Dim strsql As String = "insert into users values (" _ & uid & ",'" _ & usern & "','" _ & passw & "','" _ & fname & "','" _ & lname & "','" _ & emailre & "'," _ & pos & ")" cmmd.CommandText = strsql cmmd.Connection = cn cmmd.Connection.Open() cmmd.ExecuteNonQuery() cmmd.Connection.Close() ' MessageBox.Show("record saved Successfully") MsgBox("New Admin Registered") 'reset the form by call back the reset click event Me.Close() Catch ex As Exception 'mostly cause by repeat input MsgBox("Please Don't Repeat register the same user") btnreset_Click(sender, e) End Try End Sub Private Sub btnreset_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnreset.Click 'clear username textbox and point cursor to textbox With txtUsername .Clear() .Focus() End With

42

'clear form and reset the register button to click disable txtPassword.Clear() txtFName.Clear() txtLName.Clear() txtEmail.Clear() btnRegister.Enabled = False End Sub Private Sub RegisterForm_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing 'assign e.cancel event will not affect the close button e.Cancel = False End Sub Private Sub RegisterForm_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load End Sub End Class

43

Admin Edit
'Project: Admin or Staff Editor 'Programmer: Spencerlim 'Date Finish: 4 October 2010 'Status: Done 'Description: Admin or Staff editor form to edit information of staff and assign user to admin or moderator ' Include new staff registration form and password changing connect as well Imports System.Text.RegularExpressions Imports System.Data Imports System.Data.OleDb Public Class AdminEdit 'prepare the required variable Dim dtset As New DataTable Dim dtcheck As New DataTable Dim RowIndex As Integer Private Sub UpdateBox() Try 'to fill in the data useridX = dtset.Rows(RowIndex)(0) txtUName.Text = dtset.Rows(RowIndex)(1) LoginIdX = txtUName.Text ResetPassX = dtset.Rows(RowIndex)(2) txtFName.Text = dtset.Rows(RowIndex)(3) txtLName.Text = dtset.Rows(RowIndex)(4) txtEmail.Text = dtset.Rows(RowIndex)(5) If dtset.Rows(RowIndex)(6) = 1 Then rbAdmin.Checked = True rbModer.Checked = False Else rbAdmin.Checked = False rbModer.Checked = True End If btnEditAdmin.Enabled = True btnDeleteAdmin.Enabled = True btnChangePass.Enabled = True btnClose.Text = "Close"

44

Catch 'if the data is empty, remove them.. txtUName.Text = "" txtFName.Text = "" txtLName.Text = "" txtEmail.Text = "" rbAdmin.Checked = False rbModer.Checked = False btnEditAdmin.Enabled = False btnDeleteAdmin.Enabled = False btnChangePass.Enabled = False btnSave.Enabled = False btnClose.Text = "Close" End Try End Sub Private Sub ClearBox() With txtUName .Clear() .Focus() End With txtUName.Clear() txtFName.Clear() txtLName.Clear() txtEmail.Clear() rbAdmin.Checked = False rbModer.Checked = False btnClose.Text = "Close" End Sub Private Sub UpdateRecord() 'prepare and get the data Dim dataAdapter As New OleDb.OleDbDataAdapter(strUser, cn) dtset.Clear() dataAdapter.Fill(dtset) dataAdapter.Dispose() 'in case of error out of index, reset with this line If RowIndex > MaxRows Then RowIndex = MaxRows

45

End If 'prevent case of rubish from somewhere of application If RowIndex <= 0 Then RowIndex = 0 End If 'update the field UpdateBox() 'Enable all button btnFirst.Enabled = True btnPrev.Enabled = True btnLast.Enabled = True btnNext.Enabled = True 'if there is no record, disable button to go backward If RowIndex <= 0 Then btnFirst.Enabled = False btnPrev.Enabled = False End If 'if row index is more than or equal to maxrow, disable button to go forward If RowIndex >= MaxRows Then btnLast.Enabled = False btnNext.Enabled = False End If End Sub Private Sub AdminEdit_Deactivate(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Deactivate MasterMDI.Text = "Apiit Car Park Administration" End Sub Private Sub AdminEdit_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load ClearBox() UpdateRecord() End Sub Private Sub AdminEdit_Activated(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Activated MasterMDI.Text = "Staff Detail Information Editor || Apiit Car Park Administration" UpdateRecord() End Sub

46

Private Sub btnFirst_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnFirst.Click 'move to the first record RowIndex = 0 UpdateBox() btnFirst.Enabled = False btnPrev.Enabled = False btnLast.Enabled = True btnNext.Enabled = True End Sub Private Sub btnPrev_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnPrev.Click 'move back one If RowIndex > 0 Then RowIndex -= 1 End If UpdateBox() If RowIndex <= 0 Then btnFirst.Enabled = False btnPrev.Enabled = False End If btnLast.Enabled = True btnNext.Enabled = True End Sub Private Sub btnLast_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLast.Click 'move to the last record RowIndex = MaxRows UpdateBox() btnFirst.Enabled = True btnPrev.Enabled = True btnLast.Enabled = False btnNext.Enabled = False End Sub Private Sub btnNext_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnNext.Click 'move forward

47

If RowIndex < MaxRows Then RowIndex += 1 End If UpdateBox() If RowIndex >= MaxRows Then btnLast.Enabled = False btnNext.Enabled = False End If btnFirst.Enabled = True btnPrev.Enabled = True End Sub Private Sub btnNewAdmin_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnNewAdmin.Click RegisterForm.MdiParent = MasterMDI RegisterForm.Show() Me.Close() End Sub Private Sub btnSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSave.Click If keyWord = "edit" Then If rbAdmin.Checked Then position = 1 ElseIf rbModer.Checked Then position = 2 End If Dim strAdmin As New OleDbCommand strAdmin.CommandText = "UPDATE [users] SET " & "[userfname]='" & txtFName.Text & "'," & "[userlname]='" & txtLName.Text & "'," & "[email]='" & txtEmail.Text & "'," & "[position]=" & position & " " & "where [username]='" & txtUName.Text & "'" strAdmin.Connection = cn strAdmin.Connection.Open() strAdmin.ExecuteNonQuery() strAdmin.Connection.Close() MsgBox("Information Saved", MsgBoxStyle.OkOnly, "Updated info of " & txtUName.Text) txtFName.ReadOnly = True txtLName.ReadOnly = True txtEmail.ReadOnly = True

48

btnFirst.Enabled = True btnPrev.Enabled = True btnNext.Enabled = True btnLast.Enabled = True btnClose.Enabled = True btnSave.Enabled = False btnClose.Text = "Close" keyWord = "NULL" End If End Sub Private Sub btnEditAdmin_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnEditAdmin.Click txtFName.ReadOnly = False txtLName.ReadOnly = False txtEmail.ReadOnly = False btnDeleteAdmin.Enabled = False btnNewAdmin.Enabled = False btnEditAdmin.Enabled = False btnChangePass.Enabled = False btnFirst.Enabled = False btnPrev.Enabled = False btnNext.Enabled = False btnLast.Enabled = False btnSave.Enabled = True btnClose.Text = "Cancel" keyWord = "edit" End Sub Private Sub btnDeleteAdmin_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDeleteAdmin.Click tempY = userid userid = "" userid = useridX useridX = "" useridX = tempY tempY = "" 'alert if user deleting their own record or higher authority record If txtUName.Text = LoginID Then

49

MsgBox("You are unable to delete You own Record.", MsgBoxStyle.Critical + MsgBoxStyle.OkOnly, "Error") Exit Sub ElseIf userid = 1 Then MsgBox("Unable To remove the Main Admin.", MsgBoxStyle.Critical + MsgBoxStyle.OkOnly, "Error") Exit Sub End If 'prompt confirmation and remove the user MessageBeep(AlertExclamation) If MsgBox("Are you sure?", MsgBoxStyle.YesNo, "Prompt") = MsgBoxResult.Yes Then Dim dbCommand As New OleDbCommand dbCommand.CommandText = "Delete From [users] WHERE username='" & CStr(txtUName.Text) & "'" dbCommand.Connection = cn dbCommand.Connection.Open() dbCommand.ExecuteNonQuery() dbCommand.Connection.Close() MessageBeep(AlertAsterix) MsgBox("Record has been successfully deleted.", MsgBoxStyle.OkOnly, "Record Deleted") ClearBox() UpdateRecord() RowIndex = MaxRows UpdateBox() End If tempY = userid userid = "" userid = useridX useridX = "" useridX = tempY tempY = "" End Sub Private Sub btnChangePass_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnChangePass.Click 'prompt confirmation and reset the password MessageBeep(AlertExclamation) keyWord = "adminedit"

50

Me.Close() ChangeNewPass.Show() End Sub Private Sub btnClose_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClose.Click If btnClose.Text = "Cancel" Then ClearBox() UpdateRecord() UpdateBox() btnPrev.Enabled = True btnFirst.Enabled = True btnNext.Enabled = True btnLast.Enabled = True btnNewAdmin.Enabled = True btnEditAdmin.Enabled = True btnDeleteAdmin.Enabled = True txtUName.ReadOnly = True txtFName.ReadOnly = True txtLName.ReadOnly = True txtEmail.ReadOnly = True btnChangePass.Enabled = True btnSave.Enabled = False btnClose.Text = "Close" Else Me.Close() End If End Sub End Class

51

MDI (Multiple Document Interface)


'Project: Multiple Document Interface 'Programmer: Spencerlim 'Date Finish: 1 October 2010 'Status: Waiting to connect with all window form 'Description: MDI to hold all window form of the system and give an interface to display fullname and datetime Imports System.Windows.Forms Public Class MasterMDI Private Sub MasterMDI_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load 'set to show current time while program load CurrentTime.Text = Now 'show who is the person login FullName.Text = "Logged in as " & FirstName & " " & LastName If position = 1 Then EditAllAdminToolStripMenuItem.Enabled = True Else EditAllAdminToolStripMenuItem.Enabled = False End If ParkingLot.MdiParent = Me ParkingLot.Show() End Sub Private m_ChildFormNumber As Integer 'Set the timer to show current time Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TimerDisplay.Tick CurrentTime.Text = Now() End Sub Private Sub ParkingLotToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ParkingLotToolStripMenuItem.Click 'Display parking lot button view ParkingLot.MdiParent = Me ParkingLot.Show() End Sub

52

Private Sub AboutToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AboutToolStripMenuItem.Click BoxAbout.MdiParent = Me BoxAbout.Show() End Sub Private Sub SearchToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SearchToolStripMenuItem.Click searchStudent.MdiParent = Me searchStudent.Show() End Sub Private Sub ChangePasswordToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ChangePasswordToolStripMenuItem.Click ChangeNewPass.MdiParent = Me ChangeNewPass.Show() End Sub Private Sub EditAllAdminToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles EditAllAdminToolStripMenuItem.Click If position = 1 Then AdminEdit.MdiParent = Me AdminEdit.Show() End If End Sub '-----------------------------------------------------------AUTO GENERATED FROM MVS------------------------------------------------------------------------------------------------------------------Private Sub CascadeToolStripMenuItem_Click(ByVal sender As Object, ByVal e As EventArgs) Handles CascadeToolStripMenuItem.Click Me.LayoutMdi(MdiLayout.Cascade) End Sub Private Sub TileVerticalToolStripMenuItem_Click(ByVal sender As Object, ByVal e As EventArgs) Handles TileVerticalToolStripMenuItem.Click Me.LayoutMdi(MdiLayout.TileVertical) End Sub Private Sub TileHorizontalToolStripMenuItem_Click(ByVal sender As Object, ByVal e As EventArgs) Handles TileHorizontalToolStripMenuItem.Click Me.LayoutMdi(MdiLayout.TileHorizontal) End Sub

53

Private Sub CloseAllToolStripMenuItem_Click(ByVal sender As Object, ByVal e As EventArgs) Handles CloseAllToolStripMenuItem.Click ' Close all child forms of the parent. For Each ChildForm As Form In Me.MdiChildren ChildForm.Close() Next End Sub Private Sub ExitToolsStripMenuItem_Click(ByVal sender As Object, ByVal e As EventArgs) Handles ExitToolStripMenuItem.Click Me.Close() End Sub Private Sub StatusBarToolStripMenuItem_Click(ByVal sender As Object, ByVal e As EventArgs) Handles StatusBarToolStripMenuItem.Click Me.StatusStrip.Visible = Me.StatusBarToolStripMenuItem.Checked End Sub End Class

54

Student Register
'Project: New Student Register form for CarPark Registration Application 'Programmer: Shu Ying, Foo 'Date Finish: 1 September 2010 'Status: Stable and Running Well (DONE) 'Description: This form purposely used to add new student Imports System.Data.OleDb Public Class AddStudent Dim con As OleDbConnection Dim cmd As New OleDbCommand Dim ds As New DataSet Dim da As OleDbDataReader Dim sql As String Dim cmmd As New OleDbCommand Private Sub btnRegister_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnRegister.Click Dim status As String = "assigned" ' Calculate what day of the week is 36 days from this instant. Dim today As System.DateTime Dim duration As System.TimeSpan Dim expiry As System.DateTime today = Now.ToShortDateString duration = New System.TimeSpan(90, 0, 0, 0, 0) expiry = today.Add(duration) expiry = expiry.ToShortDateString Dim strsql As String = "insert into [Students] values ('" & txtStudentID.Text & "','" & txtFName.Text & "','" & txtLName.Text & "','" & txtCNumber.Text & "','" & txtEmail.Text & "','" & txtCarNumber.Text & "','" & today & "','" & expiry & "')" Dim strPKsql As String = "insert into [ParkingSpaces] values ('" & txtParkingLot.Text & "','" & status & "','" & txtStudentID.Text & "','" & userid & "')" Try cmmd.CommandText = strPKsql cmmd.Connection = cn cmmd.Connection.Open() cmmd.ExecuteNonQuery()

55

cmmd.Connection.Close() Catch ex As exception msgbox("Add data into Parking table error") End Try Try cmmd.CommandText = strsql cmmd.Connection = cn cmmd.Connection.Open() cmmd.ExecuteNonQuery() cmmd.Connection.Close() Catch ex As Exception msgbox("Add data into student table error") End Try ' MessageBox.Show("record saved Successfully") MsgBox("Registration Successful.", MsgBoxStyle.Information, "Success") Me.Close() ParkingLot.Close() ParkingLot.Show() End Sub Private Sub AddStudent_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load txtParkingLot.Text = ParkingID End Sub End Class

56

Parking Lot
'Project: Parking Lot Button View and Add 'Programmer: Spencerlim 'Date Finish: 23 September 2010 'Status: waiting for other 3 form to connect (new, update, delete) 'Description: This form use to display all 90 button from 3 level of parking bay ' While user click on button, value pass to variable and start up specify form Imports System.ComponentModel Imports System.Data Imports System.Data.OleDb Public Class ParkingLot 'create control array button Dim btn1(30) As Button Dim btn2(30) As Button Dim btn3(30) As Button Dim assigned1, assigned2, assigned3 As Integer Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Me.MdiParent = MasterMDI Dim i, j As Integer '---------------------------------------------------------------------------------------------CREATE ARRAY BUTTON-----------------------------------------------------------------------------------------j=1 For i = 1 To 30 'create new button in loop for 30 times btn1(i) = New Button() If (i > 0 And i <= 10) Then 'first 10 locate at left 50 and top 10 with space between two button of 35 btn1(i).Location = New Point(50, 10 + (j * 35)) ElseIf (i > 10 And i <= 20) Then 'next 10 locate at left 200 and top 10 with space between two button of 35 btn1(i).Location = New Point(200, 10 + (j * 35)) ElseIf (i > 20 And i <= 30) Then 'last 10 locate at left 350 and top 10 with space between two button of 35 btn1(i).Location = New Point(350, 10 + (j * 35))

57

End If

If i < 10 Then 'for the first nine name with L100X, X is array number btn1(i).Text = "L100" & (i).ToString ElseIf i >= 10 And i <= 30 Then 'for next twenty one name with L10XX, X is array number btn1(i).Text = "L10" & (i).ToString End If 'batch setting up btn1 array With btn1(i) 'set their size into 100 long and 30 height .Size = New Size(100, 30) 'disabled autosized .AutoSize = False 'default color to color of available .BackColor = Color.PaleGreen 'align text of the button to middlecenter .TextAlign = ContentAlignment.MiddleCenter 'set the font style .Font = New Font("calibri", 11) 'add handle to receive click event AddHandler .Click, AddressOf Me.btn1_Click End With 'for this 30 button throw into tab 1 If (i > 0 And i <= 30) Then Tab1.Controls.Add(btn1(i)) End If '--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------If j = 10 Then j=0 End If j += 1 Next For i = 1 To 30 btn2(i) = New Button()

58

If (i > 0 And i <= 10) Then btn2(i).Location = New Point(50, 10 + (j * 35)) ElseIf (i > 10 And i <= 20) Then btn2(i).Location = New Point(200, 10 + (j * 35)) ElseIf (i > 20 And i <= 30) Then btn2(i).Location = New Point(350, 10 + (j * 35)) End If If i < 10 Then btn2(i).Text = "L200" & (i).ToString ElseIf i >= 10 And i <= 30 Then btn2(i).Text = "L20" & (i).ToString End If With btn2(i) .Size = New Size(100, 30) .AutoSize = False .BackColor = Color.PaleGreen .TextAlign = ContentAlignment.MiddleCenter .Font = New Font("calibri", 11) AddHandler .Click, AddressOf Me.btn2_Click End With If (i > 0 And i <= 30) Then Tab2.Controls.Add(btn2(i)) End If '--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------If j = 10 Then j=0 End If j += 1 Next For i = 1 To 30 btn3(i) = New Button() If (i > 0 And i <= 10) Then btn3(i).Location = New Point(50, 10 + (j * 35)) ElseIf (i > 10 And i <= 20) Then btn3(i).Location = New Point(200, 10 + (j * 35)) ElseIf (i > 20 And i <= 30) Then

59

btn3(i).Location = New Point(350, 10 + (j * 35)) End If If i < 10 Then btn3(i).Text = "L300" & (i).ToString ElseIf i >= 10 And i <= 30 Then btn3(i).Text = "L30" & (i).ToString End If With btn3(i) .Size = New Size(100, 30) .AutoSize = False .BackColor = Color.PaleGreen .TextAlign = ContentAlignment.MiddleCenter .Font = New Font("calibri", 11) AddHandler .Click, AddressOf Me.btn3_Click End With If (i > 0 And i <= 30) Then Tab3.Controls.Add(btn3(i)) End If If j = 10 Then j=0 End If j += 1 Next 'http://stackoverflow.com/questions/2304817/visual-basic-2008-control-arrays 'http://msdn.microsoft.com/en-us/library/aa289500%28v=vs.71%29.aspx '---------------------------------------------------------------------------------------------CREATE ARRAY BUTTON-----------------------------------------------------------------------------------------'---------------------------------------------------------------------------------------------CHECK ASSIGNED PARKING SLOT---------------------------------------------------------------------------------Dim cmmd As New OleDbCommand Dim dr As OleDbDataReader Dim sqltxt As String = "Select [ParkingSpaceID] From [ParkingSpaces] Where Status='assigned'" cmmd.CommandText = sqltxt cmmd.Connection = cn cmmd.Connection.Open() dr = cmmd.ExecuteReader 'reset the value

60

assigned1 = assigned2 = assigned3 = 1 If dr.HasRows Then Do While (dr.Read()) For i = 1 To 30 'if row exist else if btn text is equal to parking space id If dr("ParkingSpaceID") = btn1(i).Text Then 'change the color and add 1 to assigned btn1(i).BackColor = Color.OrangeRed assigned1 += 1 End If If dr("ParkingSpaceID") = btn2(i).Text Then btn2(i).BackColor = Color.OrangeRed assigned2 += 1 End If If dr("ParkingSpaceID") = btn3(i).Text Then btn3(i).BackColor = Color.OrangeRed assigned3 += 1 End If Next Loop End If dr.Close() cmmd.ExecuteNonQuery() cmmd.Connection.Close() 'Default tab when form load Me.TabControl1.SelectedTab.Name = "Tab1" '30 button minus variable stored value lblAvailable.Text = "Parking lots available at Current Level = " & (30 - assigned1) '---------------------------------------------------------------------------------------------CHECK ASSIGNED PARKING SLOT---------------------------------------------------------------------------------End Sub Private Sub TabControl1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles TabControl1.SelectedIndexChanged 'when the tab is changing the value is changing If Me.TabControl1.SelectedTab.Name = "Tab2" Then lblAvailable.Text = "Parking lots available at Current Level = " & (30 - assigned2) ElseIf Me.TabControl1.SelectedTab.Name = "TabPage1" Then

61

lblAvailable.Text = "Parking lots available at Current Level = " & (30 - assigned1) ElseIf Me.TabControl1.SelectedTab.Name = "TabPage3" Then lblAvailable.Text = "Parking lots available at Current Level = " & (30 - assigned3) End If End Sub

Private Sub btn1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Click 'receive the property text of sender ParkingID = (sender.Text()) 'if it is unavailable If sender.BackColor = Color.OrangeRed Then UpdateOrDelete.Show() 'if it is available ElseIf sender.BackColor = Color.PaleGreen Then AddStudent.Show() End If End Sub Private Sub btn2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Click ParkingID = (sender.Text()) If sender.BackColor = Color.OrangeRed Then UpdateOrDelete.Show() ElseIf sender.BackColor = Color.PaleGreen Then AddStudent.Show() End If End Sub Private Sub btn3_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Click ParkingID = (sender.Text()) If sender.BackColor = Color.OrangeRed Then UpdateOrDelete.Show() ElseIf sender.BackColor = Color.PaleGreen Then AddStudent.Show() End If End Sub 'http://www.vb-helper.com/howto_net_control_arrray.html 'http://www.devasp.net/net/articles/display/433.html End Class

62

About
'Project: About box with info combine from assembly information 'Programmer: Spencerlim 'Date Finish: 1 october 2010 'Status: Done 'Description: To display information from assembly information Public NotInheritable Class BoxAbout Private Sub AboutBox1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load ' Set the title of the form. Dim ApplicationTitle As String If My.Application.Info.Title <> "" Then ApplicationTitle = My.Application.Info.Title Else ApplicationTitle = System.IO.Path.GetFileNameWithoutExtension(My.Application.Info.AssemblyName) End If Me.Text = String.Format("About {0}", ApplicationTitle) ' Initialize all of the text displayed on the About Box. ' TODO: Customize the application's assembly information in the "Application" pane of the project ' properties dialog (under the "Project" menu). Me.LabelProductName.Text = My.Application.Info.ProductName Me.LabelVersion.Text = String.Format("Version {0}", My.Application.Info.Version.ToString) Me.LabelCopyright.Text = My.Application.Info.Copyright Me.LabelCompanyName.Text = My.Application.Info.CompanyName Me.TextBoxDescription.Text = My.Application.Info.Description End Sub Private Sub OKButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OKButton.Click Me.Close() End Sub End Class

63

Crystal Report
Public Class CrystalReporter Private Sub CrystalReportViewer1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CrystalReportViewer1.Load Dim Reporter As New CrystalReport CrystalReportViewer1.ReportSource = Reporter CrystalReportViewer1.Refresh() End Sub Private Sub CrystalReporter_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load End Sub End Class

64

References
Home and Learn, 2009, Visual Basic. Net Programming for Beginners: How to Create Function in VB. Net [online], Available from http://www.homeandlearn.co.uk/net/nets9p5.html, [Accessed 9th August 2010]. Stack Overflow Internet Services, Inc., 2010, Visual Basic 2008 Control Array [online], Available from http://stackoverflow.com/questions/2304817/visual-basic-2008control-arrays, [Accessed 9th August 2010]. Matthew A. Stoecker, 2010, Creating Control Arrays in Visual Basic.Net and Visual C#.Net [online], Available from http://msdn.microsoft.com/enus/library/aa289500%28v=vs.71%29.aspx, [Accessed 9th August 2010]. Rocky Mountain Computer Consulting, Inc., 1997-2010, VB Helper [online], Available from http://www.vb-helper.com/howto_net_control_arrray.html, [Accessed 9th August 2010]. DevASP.Net, 2002-2010, Creating a Control Array in VB [online], Available from http://www.devasp.net/net/articles/display/433.html, [Accessed 10th August 2010]. Bradley, J. C. and Millspaugh, A. C., 2008, Advanced Programming Using Visual Basic 2008, New York: McGraw-Hill Companies, Inc.

65

Appendix Section
Work Breakdown Structure
Name
Foo Shu Ying

Task / Description / Responsibility

Signature

Compilation
y y Cover Page Table of Contents

All Members Foo Shu Ying All Members

Conclusion Work Breakdown Structure References

Main Document
Eugene Chan Zhirong All Members Introduction Screen Design y y All Members Foo Shu Ying Eugene Chan Zhirong Foo Shu Ying Input Screen Design Output Screen Design

User Mamual Critical Assesment Printout of the Source Code Appendix Section

Systems
Lim Yi Sing (Leader) New Admin/Masterstage y Register 66

y Foo Shu Ying Eugene Chan Zhirong Foo Shu Ying Eugene Chan Zhirong Lim Yi Sing (Leader)

Login

New Student Register Delete Update Search Report y y Crystal Report Calculation

Lim Yi Sing (Leader)

Parking Slot y y Assign Release

Foo Shu Ying

Database

67

Das könnte Ihnen auch gefallen