You are on page 1of 145

UNIVERSITY OF HERTFORDSHIRE

Faculty of Engineering and Information Sciences BSc Honours Computer Science (Online)

3COM0119-Final Project Report

Final Report

Jaguar Classic Car Company

Hevylen Seenan Student Number: 08174464

Project Supervisor: Mohammed Banie Amin

Date: August 2009

Abstract
In this Project it will concentrate mainly on using Oracle 10g and visual web developer 2008. We will talk about different ways to connect with the database in order to select, insert, update and delete. We are also going to see how to generate primary key with code behind and find out while using only the objects such as details view etc, to do the insert, delete, search and update, it has a big disadvantage of using them compared with using textboxes with a button to manipulate data from interface to the back end. The report will show how to go through different stages whilst designing and implementing the database and interface. It also shows the uses of diagrams such as atomic ERD, Use cases and snap shots of the interfaces showing the responses from the system. The report will also consist of some important snap shots of coding. After the design and implementation there will be the evaluation part where it will be discuss what actually the system can do or not and finally the Research part.

Contents Page No
Introduction Requirement Gathering and Analysis Designing the Database Designing the Interface Implementation Implementation of Database Implementation of Interface Testing and Evaluation Research Conclusion Bibliography Appendices Appendix A Appendix B Appendix C Appendix D Appendix E Appendix F Appendix G Appendix H Appendix 1 Appendix 2 Appendix 3 Demonstration Scripts
2

3 4 5-10 11-20

21-22 23-51 52-60 61-66 67 68

69 70 71 72 73-75 76-80 81-127 128-138 139 140 141 142-144

Introduction
The application is based on a garage system which was previously a manual paper-base system and is mainly used by administrative and managerial staff at the head quarter and in the workshops. According to certain privileges the staffs can access certain pages to do their tasks. The workshop manager will be the one which has the more privilege to access most of the pages. The system can take a maximum of ten cars per workshop and keep a record of all the history of every car that has been admitted or requested for a cost estimate. The system can also keep a track of each account every month, comparing the estimated cost with the actual cost, during the repairing period for a cost estimate. It can also calculate the cost for an invoice for a particular cost estimate and give the totals. The system can select, insert, update and delete records successfully from the database. The system can generate primary keys from the interface to the database.

Requirement Gathering And Analysis


As the system will have different type of users which are Administrator, workshop Manager, secretary, Mechanic, secretary and Head Office staff it will need to allow specific access to staff according to their level of privilege they have. So the system will need to have a login system for authentication in order to allow access. The system will only accept all types of Jaguar car. It will have a capacity of holding only a maximum of ten cars at a time. The system should not allow producing a cost estimate without having the details about the customer and car. The system should allow editing the cost estimate if a customer does not agree on the price, it may be in the form of reducing the number of jobs from the cost estimate list or change the price of the material cost alternatively a new cost estimate for the same customer will be issued. Administrator will be able to access only specific pages where it can reset the password of the staff or create a new staff entry and give a password to that particular staff. A workshop manger will be able to insert new details, update, delete and search customer from the system. The manager should also be able to insert details about a particular car and force the user to select the type or model of the car from a list so that not every type of car, make or model can be entered into the system. The manager should be able to insert any number of jobs for a specific car, give the description of the fault and the labor and material cost for it. The manager should be able to calculate the total cost which include material cost, labor cost, tax on labor, labor cost after tax and the grand total so that an invoice can be issued. Workshop manager should be able to locate information about each car and how the restoration is proceeding and which mechanic is working on it. The manager should be able to select a particular car and month so that he will know what jobs are still not yet finish. He also need to know how long the restoration will take, comparing the actual cost against the cost estimate, what work is outstanding and what contracted work are currently being undertaken. He should be able to look at information about suppliers and their records of delivery. As a manager he will need to send monthly accounts report to the head office and know what bills are outstanding. Secretary will need to know the spare capacity of the workshop. He /she will need to know the outstanding balances and enter and update records and contact suppliers. Mechanics will need to be able to update specific records as they complete various parts of the work and be able to add some new job during the process of restoration as some fault may be discover at a later stage.
4

Designing the Database


Since I designed the database for the IPR, I have made some changes whilst I was creating the interface. What I have realized when creating the interface that I needed to go back and forth to modified the back end as according to some specifications or requirement it may seems fine when designing the database but when it come to the interface for manipulation of the data at the front it is totally a different story. This will be discussing further in the implementation part. While designing my ERD I have met with many difficult issues such as cost estimate with details of each job and the total cost itself as shown in the case study. Initially I thought that I should record for example all the total cost of labour and materials in a table for a specific cost estimate and same I was thinking about storing the total of cost of each job for a month in a different table. But finally I found out that these are only calculation and you can do it through a query at any time. So for example if you want to know what was the total cost of labour of Job 1 in January then you just need to query the tables. I will need to create dynamic table which are views, so that it can read from updated data from different tables. Labour One of the main issue about whether labour cost and material cost should be already in the database so that when the user want to give a cost estimate to a customer, he or she wont need to think how much it will cost and the system will already know for a particular fault this will cost such amount. There are some advantages and disadvantages regarding this idea one of the main advantage which I have described above is that user will not need to know how much it will cost, there will be less human mistake and more accuracy as the cost is already pre-defined in the database. But the disadvantages are for instance what happen if the labour cost or material cost for a specific job or parts changes. It would be just easy to update the table where the costs are located but another issue arises where while doing this you will end up losing some previous data. For example if one customer got a cost estimate two months ago about doing a full service for the price of 150 which include 100 material cost and 50 for labour cost and the job has already been done. Now assuming that the customer has not yet settled his account and is left with the whole amount due and in the mean time the price of full servicing (material cost ad labour cost) has increased to 200. So on the database the price will change from 150 to 200 and therefore the customer will owe 200 now instead of 150 which is totally wrong as it was already agreed on a certain price. So to my understanding it is better to let the user to insert the cost, whether it is labour or material, manually as it would be more flexible and it wont matter if the cost changes at any point but there are more risk that the user make a mistake and give a wrong cost estimate. But we assume that they know the price as it will only the manager of the workshop who will be able to do such task and on top of that they will need to have an updated price list. There could be another possibility instead of a hard copy
5

these data could be inserted into another table, but for this project we are going to assume that they have a hard copy of the price list.

Identifying the Entities with Atomic Entity Relation


Works in Location

Staff

I am assuming that One Staff works in only one location.

Car

Repair by

Staff

Another assumption is that One Car is assigned to one Staff, which is one of the criteria needed at a later stage where the manager will want to know which staff is working on which Car. But on the other hand one Staff can be assigned many cars. Initially I thought that it was a one to many relationships but another factor that we will need to consider is that the same car can come multiple times in different occasions to make repairs and its not necessarily that the same staff will repair it again, it can be assigned to a different staff. So the relationship between these two entities will be Many to Many. This many to many relationship can be broken down by creating another entity which I will call Car_History1.

Customer

Owns

Car

One Customer can own one or more cars, but one car could have been owned by different customers in the past. So it is a many to many relationship. For Example Last month a customer brought his car in the garage for repair and just after that he/she sold it to another customer, so ownership has changed but by coincident the new owner bring in
6

the same car for repairing in the same garage so the car will be related to two different owner, In other words I will need to create another entity which I will call it Car_History1. So I am going to break the many to many relationships at a later stage.

Car

has

CostEstimate

One Car can have at least one cost estimate otherwise the car would not exist in the database and can have more than one as may be the customer do not want to proceed with all the repairs or another option is that the car had a cost estimate in the past meaning that this car has been in the garage and has a History or has just ask for a cost estimate but not admitted in the garage. So one car can have many cost estimates and one cost estimate will be for only one car.

CostEstimate

include

Car_Job

One Cost Estimate will include one or more jobs.

Car_Job

Consist of

JobAccount

A job can take more than one month to be repaired.

Customer

have 7

Car_History1

Because of Relation between Car and Customer is many to many and Car and staff is the same as well, I am introducing the new Entity which is Car_History1 and eliminate the two many to many relationship. This above diagram shows that one customer can have many cars_History1 but one car_History1 can be owned by only one customer at a time.

Car_History1

Consist of

Car

One Car can have many Car_History1 but one car_History1 is for one specific car only.

Staff

Repair

0..*

Car_History1

One Staff can be responsible for zero to many Cars in the car_History1 but one Car in the car_History1 can be assigned to only one Staff at a given time.

Once we have all the possible main entities we need to find appropriate attributes, shown in Appendix A, for them to be included in the Entity Relationship Diagram which is shown in Appendix B. You will notice that there has been an introduction of two more entities namely Model and Job in Appendix C (Schema). Reason being that one of the requirements is that the system will accept only a certain type of model in the workshop, so if the model does not exist in the database a car cannot be admitted. If in future the workshop can accept other types of cars then simply we just need to add it in the database. For the Job_Title there may be a situation that one staff can have more than one role in the company. For example a workshop manager is a manager but he or she can be a mechanic as well so there is a many to many relation between staff and job as one staff can have many job_Title and many Staff can have the same Job_Title. So in that case there will be a need to create another entity which is Role which will be weak entity.
8

Instead of having: Staff-> ( Staff_ID, Name, Password, Job_ID*) Job-> ( Job_ID, Job_Title ) I will have: Staff-> ( Staff_ID, Name, Password) Role-> (Staff_ID*, Job_ID*) Job-> ( Job_ID, Job_Title ) Because a car has many car_History1 and one car_History1 is for one cost estimate only Which is a 1:1 relation a decision was made to remove the cost estimate as an entity and put it as an attribute which will be the primary key of Car_History1, leaving the car_History_no as a non-primary key attribute which the name is going to change to estimate_no where it will play a role at a later stage for the generating of primary key which is Cost_Estimate_No and add the date that the cost estimate has been made. Another attribute which has been added in the Car_History1 is the location_code which on the database side has nothing related to the location_no from location table but still will be using location table data from the interface which will be explain in the implementation of the interface part later for the generating partly for primary key of Car_History1. In the Car_job table there will be also an introduction of another attribute which will be call serial_no also going to play a role for generating the primary key which is Job_no. Although it does not make any sense for now the reason to include these three attributes, location_Code, estimate_no and serial_no, in Car_History1 and Car_job table respectively you will find out that there will be a need to come back to the database and add these three attributes at a later stage. So attributes for the Car_History entity will be as follows: Car_History1-> ( Cost_Estimate_No, estimate_no, Date_OfCostEstimate, Reg_No*, Admission_Date, Discharge_Date, Description, Mileage, Customer_ID*, Allocated_Staff*, Location_code)

In the Appendix D the final schema is shown where all the primary keys are in bold format and the foreign keys followed by an asterix (*) after having done some further modification.

In the Appendix E, I have shown the data type of each attributes belonging to different tables also I have wrote the sql statements to create the tables (Appendix F) which is in Oracle 10g. The reason behind choosing Oracle is that it is one of the powerful tools for creating a database although some people prefer to use Microsoft SQL Server. Oracle will allow me to be able to create tables, views. Oracles will give me an opportunity in the future as concerning real actual life most of the database designer are using oracle on the market.

10

Designing the Interface


As different type of users will need to access the system there will need a login page for different type of privileges. So login page will need to be by default the first page.

Use case diagram 1 Use Case element Use case number Use case name Use case Description Primary Actor Pre condition Accessing the system 1 login Staff should be able to access the system according to the privileges that they have depending on their job title. Administrator Administrator should register the staff first before accessing the system.

11

A workshop manager should be able to search a customer from the database by inserting all the data in appropriate text boxes. If the customer does not exist he should be able to insert new customer. It may happen that the customer does exist but some of his or her details have changed so the manager would need to be able to update the customers details.

Use case Diagram 2 Use-case Element Use-case Number Use-case Name Description Primary Actor Pre-condition Record Customer Details 2 Customer Details The customer of a customer is needed to be entered in the system so that there is a record of his or her name, address and contact no. Manager The details of customer must not be in the database so that the details can be entered.

12

So far as the vehicle is concern the manager will also need to be able to verify if whether the car registration number which will be about to insert is already in the system or not. If the vehicle does or does not exist the system should be able to give a message in order to prompt the user what to do. There will be no need of updating the vehicle as the way the database is, it store all the car details in a separate table no matter which is the current owner of the vehicle.

Use case Diagram 3 Use Case element Use case number Use case name Use case Description Primary Actor Pre condition Record Car Details 3 Car details The car details need to be entered in the system so that there can be a record of the registration number, engine capacity, chassis number and the model. Manager The car must not be in the system so that its details can be entered. The user must search for the car and if it does exist then the system will not allow entering data about the said car.

13

As a manager he or she will need to be able to enter data about a brief description of the faults of the vehicle concerned where a unique cost estimate number will be issued for this vehicle and customer at a particular time but before this happen the manager will need to make sure that both car and customer exist in the database.

Use case Diagram 4 Use Case element Use case number Use case name Use case Description Primary Actor Pre condition Generate cost estimate number 4 Cost estimate number As one car may have multiple faults, all these faults will be recorded to one cost estimate which will be a brief description of all the possible faults and will belong to one customer and a particular car. Manager The user will need to search for the car and customer details if they does exist, and if it is the case then a cost estimate can be created.

14

A manager should be able to admit and discharge a car. One of the requirements is to allow only a maximum of ten cars in a garage at a time. The system should automatically stop allowing admitting a car in particular garage if there are ten cars already, then the system should be able to display a message to inform the user. If the manager want to discharge a car which the jobs have already been completed then he or she will be able to do that but the system will need to ask for confirmation to delete just in case that a car was wrongly selected.

Use case Diagram 5 Use Case element Use case number Use case name Use case Description Primary Actor Pre condition Car Admittance 5 Admit a car The manager should be able to admit a car which already have a cost estimate or can create a cost estimate and admit a car at the same time Manager The number of car admitted in the specific garage should not exceed more than ten otherwise the system will reject the admittance.

Use Case element Use case number Use case name Use case Description Primary Actor Pre condition

Car Discharge 6 Discharge a car The manager should be able to discharge a car Manager All the faults for this car should be solved and the system will ask for confirmation before discharge.
15

After a manager has entered the brief description of the faults he will be able to insert precise details for each job belonging to a particular cost estimate number where the system will allow him to insert manually the labour and Material cost.

Use case Diagram 6 Use Case element Use case number Use case name Use case Description Job details 7 Insert specific job details As one cost estimate number contains many jobs the manager should be able to insert every single detail of each job where it will consist of the description of the jobs and the cost which include Material and labour costs. Manager In order to insert specific details a cost estimate number should be already exist.

Primary Actor Pre condition

16

The manager will also need to get access to a page where it can generate a sort of invoice where it will be able to calculate the total, tax etc as shown in appendix 2.

Use case Diagram 7

Use Case element Use case number Use case name Use case Description Primary Actor Pre condition

Invoice 8 Generate invoice Invoice should be generated for a particular cost estimate number Manager Job details should be entered meaning for each cost estimate and every jobs related to that cost estimate and also the cost which include the labour and material cost should be available so that an invoice can be generated.

17

Either a manager or a mechanic should be able to insert the progress of each job if it is carried out for more than one month and should be able to enter the status of a job either not started, incomplete or complete. Workshop Managers and Mechanics should be able to add new job to existing account during the course of repairing a car as they may find other new faults.

Use case Diagram 8 Use Case element Use case number Use case name Use case Description Primary Actor Pre condition New jobs 9 Adding new car jobs If in the course of repairing they may find some further faults and they will need to be able to insert new car jobs Manager and Mechanics Cost estimate must be exist so that they can add further jobs

Use Case element Use case number Use case name Use case Description

Progress of repair 10 Insert progress of car jobs Every month there is a need to enter the progress of the faults belonging to a particular car which is the cost estimate number if the faults cannot be sorted at one go. The users must insert the amount
18

Primary Actor Pre condition

spent on Material and/or labour cost for that month Manager and mechanics The job need to be exist so that there can be a follow up.

Administrator will only be able to create an account for a staff where he will give them their user Id and password for login purposes and also enter their job title. If just in case that staffs need to reset their password the administrator will be able to do that on behalf of them. An administrator, before creating an account for a user, should be able to verify that the user Id is already taken by somebody and the system should be able to guide the administrator to type another user Id.

Use case Diagram 9

Use Case element Use case number Use case name Use case Description Primary Actor Pre condition

Staff Account 11 Create staff account Staff should be registered so that they can access the system Administrator If the staff has not been registered they cannot access the system.
19

Use Case element Use case number Use case name Use case Description Primary Actor Pre condition

Resetting a users password 12 Reset staff password The staff may have forgot their password or they want to change their password for security reason Administrator The staff should be already registered in the system so that password can be change.

Tree Map Diagram


Login Page

Manager Master Page

Mechanics Master Page

Administrator Master Page

Secretary Master Page

Head quarters Master Page

Welcome page Car Details Customer Car History Car Job Car Account Job Invoice

Welcome page Job Account New Job

Welcome page New Staff Reset Password

Welcome page

Monthly Account Discharge Car The above diagram shows a view of the way the users will be able to access certain pages and some wont.
20

Implementation of Database
As it has been describe in the Appendix E, all the data definition for every attributes has been described with their data type whether it is a primary key, foreign key, combination primary key or null able or not null. All the data definition has been separated in different table format with the name of the table that will be created. In the Appendix F the entire tables has been created by using these coding in oracle 10g according to what has been described in the data definition in Appendix E. You will also observe that for customer table the primary key is of type number. This is because a sequence and a trigger was created to generate auto primary key as every time a customer is created there will be no need to enter the primary key and the only way of doing it is to define the primary key attribute as an integer or a number. But there are other options to generate an autonumber without having anything to do with the database refer to research chapter in Auto Number. As per the Appendix F referring to Job_Account table I have created a combination primary key which consists of five attributes which three of them are the date that is day, month and year. I could simply define a one attribute which could be of type date but I thought that it would be better to break it so that it becomes easier to query the table. Referring to the Appendix 3 from the project, in order to get a similar outcome there will be a need of a combination of data from car_job and job_account tables. So a view has been created named monthly_job_account. The main idea about this view is to get all the possible data arrange them in a certain order and which will allow the adding up of the cost whether it is labour or material to get the cost to date. The picture below gives you an idea of how it work.

21

As you can see for example where Job_No = A/1/1 the labour cost estimate is 70 and this job has been carried out for three months where the labour_to_date keep on adding from the previous labour_this_month. If you want to filter this view it will be possible for instance if you want to find all the jobs that belong to a specific cost estimate number for a particular month it will be possible. There was a possibility of generated auto number for other tables such as Job_Account and Car_Job but because of the complexity of their primary key for Example A/1/8 there is another way of doing through the front end coding which will be explain in details in the implementation of the interface part.

22

Implementation of the interface


A default page named Login1 has been created so that the user will have to login into the system in order to get access.

Picture 1a Five panels have been created in the same page of the login1 so that depending on what the user type in the user name and password only one of the panel will be visible and the login as shown in the picture above will be invisible on one condition that the user successfully login. Otherwise a message will be displayed to prompt the user to login again. See Appendix G for more details about the coding. Depending on what they have login as, the user will be force to go to another default page, the welcome page, which inherits from one particular master page. So each Master page has its own welcome page. So the user will not be able to jump from one master page to another, meaning that a Mechanic for example, will not be able to access a workshop managers page. The following code is to authenticate the user if the user give the right user id and password then user variable will contain a value

Picture 1b

23

If the variable user is null the jobtitle will also get a null value Depending of the variable user the jobtitle will have a value, as in picture 1c

Picture 1c And depending on the value of the jobtitle only one panel will be visible as shown in the coding below in picture 1d. If jobtitle has no value a message will appear.

Picture 1d

24

As an Administrator before inserting a new staff, he will be able to verify whether the userid which is about to insert already exist as shown in diagram below. If it does exist then a message will appear.

Picture 1e The code below check if the staff id exist or not and pass it variable staff

If the userid does not exist then it will allow details to be entered as picture below.

Picture 1f

25

An administrator can reset a password for any staff as shown in picture 2a

Picture 2a As soon the reset password button is click the system will check if both password are the same and will display the message as in picture below, otherwise it will display a message to retype the new password.

Picture 2b

Picture 2c The above code check if the user have entered exact password in both text and call the updatePassword method as shown in Picture 2d. If the password in both texts is not the same then a message will appear and clear both textboxes.
26

Picture 2d

27

As a manager you will need to insert new customer if he or she does not exist in the database. You will be able to search the customer through the search customer button by typing the name of the customer in the text box. If the customer already exists but need to be update, you can simply edit the text from the text boxes and click on update data. The picture shows how the form will be initially.

Picture 3a There is an option of deleting a customer from the database but the system will ask the user for confirmation as describe in the picture below.

Picture 3b

28

If the user presses yes which is equivalent to 6 the system will display a message whether the data has been deleted or not. Else there will be a display message for cancelation. The code in Picture 3e shows how it work

Picture 3e Here is the snapshot of the delete method in Picture 3f

Picture 3f

29

If the user wants to insert a new customer a message will prompt him if he wants to go ahead as shown below. Notice that no primary key is given to that new customer as it is auto generating the number as explained in the database implementation part.

Picture 3h The confirmation message is just to make sure that the user really wants to do this action otherwise he can cancel before the data goes into the database as shown in picture 3i.

Picture 3i

30

The manager will need to search for the car that he is about to enter. If the car already exists a message will appear to inform the user else a message as in the picture 4a and 4b will appear to inform the user that the car does not exist.

Picture 4a

Picture 4b

31

As soon as the user click ok on the message all the text boxes and dropdown list will appear enable the user to insert the data through the insert button as shown in Picture 4c.

Picture 4c The code in picture 4d shows how the details of a car are entered in the database. If successful a message will appear else another message will inform of the error.

After having inserted all the data there will be a next button which will appear allowing you to insert another car if you wish. For the Model drop down list, it is base on a select query from the Model table where it will allow the model that they repair in the garage only to selected. So if the company decides to repair another model they can do so by entering a new model in the database and it will appear in the interface automatically due to the query sitting behind this drop down list.
32

In order to give a cost estimate or before admitting a car, it need to be in the system first and need to have a cost estimate number where it will describe the brief description of faults of the car as shown in appendix 1 of the project which will be done by the manager. The cost estimate number will be auto generated from the code. The picture 5a shows how it looks like.

Picture 5a When giving the brief description and after clicking on the insert car history the system will ask the user what he wants to do. He can cancel the process or give only cost estimate where the customer just want to have a quotation or give the quotation and admit the car in the same day if there are enough space in the garage which is in the picture below.

33

Picture 5b

Picture 5c As described in picture 5c if the user presses yes then it will call space available method to check for space. As every car which is about to enter in the database will have and admission date and if it is null or the registration number exist then the system will display a refuse message.

If the user click yes and the car is already in the garage the system will display a message as in picture below. This can happen if the user has wrongly selected a car. The system will prompt the user to click a message box where the Insert next will appear and will clear all the textboxes

34

Picture 5c If the regNoCount is greater than zero, that is if a particular car is already in the table, then the message as in picture 5c will appear else it will call the enterData method as shown in picture 5d and 5e

Picture 5d The following picture shows how a user successfully admit a car

Picture 5e

35

If any of the garage has already got ten cars for repair then the system does not allow the manager to insert the 11th car unless he discharge a car which has already been repaired. The picture 5e shows the example. In picture 5f shows that if the value is equal to or more than ten then the message as in picture 5e will appear else the system will call the enterData method.

Picture 5e

Picture 5f

36

Regarding the Cost estimate number (example A/2/09) which is the primary key for the table carHistory1 there are three steps in order to generate it. First you will need to get the garage id for example (A or B etc.. ) , then you will need to get the last number of estimate_no (see the query below) which is an attribute from the car_history1 table purposely added to do this function and add one to it so that you get the next value and the last step is to get the last two digit of the actual year from the computer system.

Query to get the last estimate number for particular garage and year

maxNum will get the maximum number of estimate_no

As maxNum need to get the next value

The first character of the cost estimate number will be from a dropdown list and assign it to drpLocation variable.

The last which is the year will be as follows.

And finally all these variables are concatenated with each other as follows.

37

After having created a cost estimate number, the user which is normally the manager will be able to insert any number of jobs to that particular cost estimate number. But the mechanics will also be able to access this similar page to add more job number if required. Picture 6a shows the form where the job is entered

Picture 6a As each job number and the cost estimate number together, will be unique as a combine primary key. We need to create the job number using the cost estimate number. The following code in picture 6b shows how to get part of job no from the cost estimate

Picture 6b Basically after this code if the cost estimate was A/2/08 , then this piece of code will take only A/2/ and assign it to the primaryKey variable which will be our job_no temporarily.

38

I have an attribute name serial_no in the Car_job table in the database (see query for serial_no). Its role is to increment by one for every job_no you add to a particular cost estimate. After having the temporary primaryKey and the serial_no value which is assign to maxNum variable, shown in picture 6c and concatenate them together the full Job_no value is generated as circled in picture 6d Query for getting the maximum value of serial_no depending on the temporary value for the variable primaryKey and the cost estimate number

As seen in the code in Picture 6c the maxNum get the value of the above query and add one to it to get the value for the next job number

Picture 6c

Picture 6d

39

For example if the job_no got the value A/2/1 for cost estimate number A/2/08, Where A will be the garage, 2 will be the 2nd car in garage A in year 2008, then for the next year you will have another job with the same number but with different cost estimate number which can be A/2/09 and that is why in the database cost estimate number and job number are combination primary key. Whatever the value inserted in the textboxes are converted into integer before passing them to the query by using the following code in picture 6e

Picture 6e After the user has inserted detail about a particular job then a message box will appear for information only, see picture 6f

Picture 6f

40

The code is as follows:

If in case an error occurs then it will display the second message. After having inserted all the jobs for a particular cost estimate, some of the job may take several months to complete. The form job_Account is being used for this purpose as shown in picture 7a

Picture 7a The user will have to enter the registration number and click on search. If the vehicle exists a list of cost estimate will appear he will need to select one. After having selected from the cost estimate the user will have to select one job number and click on check status button. All my registration number in the database are in uppercase then what ever the user is going to type should be in uppercase. The code below will show you how to convert a lowercase to uppercase

41

The dropdown list for cost estimate will get all the cost estimate of that particular registration number inserted in the textbox. Here is the query sitting behind the cost estimate dropdown list which is generated by web developer

After getting the list of cost estimate number the user will need to select from one of them and a list of job number will appear from dropdown list of job number by using the query generated from web developer below.

There could be a certain number of scenarios may happen. The job number has not been inserted for this month, then the system will allow to be insert but if job number has been inserted already the system will not allow to insert again but will give the option of updating the data. Another situation is if a Job has completed then the system will not allow inserting cost for material and labour but will allow insertion with their value zero and status will remain complete as every month whether a job has been completed or not till all the job belonging to a cost estimate has not yet finish the manager will need to keep updating the data for every single job. This code below is going to be use to know which job has been completed or not so that it will be according to the above paragraph.

If the status is C this will give zero to labour and material

42

The code below will check if a job number has already been entered for a specific month and year

If a job has already been entered for a particular month where status was I (Incomplete) and later in the same month the job became Complete the system will allow the update (see query below for the select and the update) but not the insert.

As I have split my date into day, month and year in my database I will need to get the values for these attributes from the date of the system itself. The code below shows how it has been done.

43

If a job number is not complete and has not yet entered any data for the actual month then a panel containing textboxes and buttons etc will appear as the picture 7b. And if there is no error the system will display a message box. If ever a mistake has occurred while entering the cost it can be changed immediately by using the update button.

44

Picture 7b

45

As the manager will be able to create an invoice as per Appendix 2, the job_invoice form will be able to be use as an invoice where it will list all the jobs from a cost estimate and give the totals and so on. The form looks like the picture 8a below.

Picture 8a

Initially you will have only a textbox which will allow you to enter the registration (see picture 8b). If the registration is valid, a list of cost estimate belonging to that car will be listed where the user will be able to select one cost estimate from the drop down list else a message to inform the user that the car does not exist in the system as shown in picture 8c

Picture 8b
46

Picture 8c The code below checks if the vehicle is registered in the system else it will display a message.

All the calculation in picture 8a is using the query as follows:

47

The manager will need to be able to select a cost estimate number and the month so that a list of job will appear with their cost for a specific month and should also be able to get the total labour and material for him to compare with the estimated value referring to Appendix 3.

Picture 9a Whatever is going to be typed in the textbox will be converted into uppercase

Picture 9b As soon as the user click on the button search it will call the method toUppercase and make the panel1 which contain the two drop down list visible and call the method checkVehicle to check if the vehicle is registered in the system, if it is not the case, the checkVehicle method will make the panel1 not visible as shown in picture 9c.

Picture 9c
48

Once the vehicle is recognized in the system the button show total will be accessible so that panel2 which contain all the total cost can be displayed. The following query will be able to get the required total cost from the database depending on both dropdown lists.

As each separate total cost is going to be in different labels, the following code is going to assign values to them. Else a message will appear in case of error.

If the manager wants to see for another cost estimate, he will need to click on the clear button as shown below.

49

When a manager is discharging a vehicle from a garage he is just updating the database by adding the date in the discharge_dateandTime attribute but not deleting as we may need for reference at any time. The following code shows how the update is done.

The code behind the drop down list will be as follows:

By using this query above the dropdown list will get only the vehicles which have admission date and discharge date is null. As the system will accept unique registration no for the ten car admitted in a garage this query below will do for discharging a car where regNo will refer to only one registration.

When the user select a registration from the list and click on discharge regNo button a message will appear to ask the user to confirm as it can happen that a registration has been selected by mistake as shown in Picture 10a below.

Picture 10a

50

The code below show how it works:

If the user click ok then the system call the dischargeCar method and display message else a cancellation message will appear.

51

Testing and Evaluation


Login The start page of the project is login and whatever the user is going to type, the system will be able to read and compare it from the database and direct the user to a specific page depending of their privilege (see picture L2) and if the user wrongly entered the data a message will appear in the login form as shown in Picture L1 below.

Picture L1

Picture L2 After clicking on the page the system direct the user to a particular page as in picture L3, and can browse all the pages in the Manager Master page.

52

Picture L3
Issues for Login Page

Regarding the logout there is a security issue where after a staff has logout it call the login page and if the browser is still on, anybody can click back on the browser menu and get in the page where the user was login. The idea of the logout was if the user click backs button on the history browser the system should always call the login page, which it is doing, first and until the user does not type the userid and password the system should not allow user to get through. I could have simply used the Web site Administration Tool but I wanted to create my own login. Administrator Administrator can create an account for the staff and give them certain privilege. He can also change the password of any staff on demand. Instead of the administrator only can change the password I should have given also the staff the option of changing the password themselves as they would have more control on their account but not the same way as the administrator does.

53

Manager The Manager is the one who have the access to most of the pages in the system. The manager is able to search, insert, update and delete customer in the database through the interface. If the user wants to insert data and if one of the texts is missing, a message will appear as in the picture M1 below and will not insert in the database.

Picture M1 If the Manager is trying to update a customer and if some data is missing another message will appear as in picture M2.

Picture M2

54

If the user want to delete a customer a message will appear to ask for confirmation yes or no, see picture M3. If it is no then another message will appear to inform the user of the cancel transaction.

Picture M3

If the user is about to insert a data in the database the system will ask for a confirmation as shown in picture M4.

Picture M4

55

Issues with the customer page

The problem that I am having is when I insert a new customer in the database it does not appear in the dropdown list immediately although its Autopostback is true and it appear in the database. Manager before entering a new car details in the system is able to check first whether the car exist or not as shown in Picture M5.

Picture M5

After having check the car registration number the system allows the user to enter the data by making all the other textboxes and dropdown list visible and a message will appear to inform the user that it has been successfully inserted in the database (see Picture M6).

Picture M6

56

Further details can be inserted in the database through the Car History page. The manager is able to insert a brief description of the faults in general, assign the car to be repaired by a particular staff, get the name of the customer from the customer table and select which garage it is going to be repaired. But first of all let see about the primary key which is auto generated in the coding. If there was a last cost estimate number A/20/08 in year 2008 as soon as the year changes to 2009 from the system the counter estimate_no, which is an attribute in the Car_History1 table, start from 1 again but as the year changes from 2008 to 2009 the first cost estimate number in 2009 will be A/1/09. So the middle value will never increment infinitely and come back to 1 every year and the cost estimate number will always be unique no matter what happen. Another thing that you can notice is that although Location table has no direct relation with Car_History1 table there is an attribute call Location_code from car_history1, which get the value of the primary key (Location_No) of the location table through the values of dropdown list of location code shown in Picture M7 below. As this dropdown list is running a query to get all the Location_No from Location Table.

Picture M7 After inserting all the data the system will provide the user with three choices (see Picture M8). If the user click on No then the system will generate a cost estimate number, insert all the data in the database excluding the admission and discharge date as shown in picture M10 with a message displayed. If the user selects cancel, then no data will be entered in the database. A message will inform the user of the cancellation.

57

Picture M8

Picture M9 The only issue about the picture M10 is that I did not create an option if a customer comes in the garage where he already have a cost estimate and want to admit a car although I could have done it . The query to update the data for admission would have been like this: Update car_history1 set admission_dateandtime = to_date('" & day & "', 'dd/mm/yyyy hh24:mi:ss')where reg_no ='" & regNo & "'"

58

In the command text from the coding and Instead of having created a discharge form it would have been better if there was an option of discharge and admission in the same page.

Picture M10 After the brief description the user can insert all the tasks that need to be carried out for that particular car. Each job will be added with a auto generate primary key to a cost estimate through the CarJob page as shown below.

An example of the job number of a job can be A/3/1 partly from the cost estimate number and the increment number which is serial_no from the table car_job. Although the job number can be repeated for different cost estimate, because of the combination primary key of job number and cost estimate number, both of them together will be unique.

59

Regarding the Appendix 2 all the calculation for the invoice was possible in the job invoice page as shown below

Picture M11

According to Appendix 3 of the project the user should be able to get the details of all jobs for a car being repaired for a particular month. The monthly account job does similar task as shown below in Picture M12

Picture M12

60

Research
Why choosing oracle compare to other DBMS?

The main reason of choosing Oracle is that it is more demanding on the market and as visual web developer is from Microsoft it seems to be easier to work with SQL server but I knew that there must be a way of using oracle with a Microsoft product and wanted to know how to do that. As it is my first web application that I have created, I just thought that by using visual web developer 2008, it will help me in achieving my tasks. I found out that by using VB language it help me to create my coding much better compare to what I expected initially. I found out that when designing a database it is not always necessary to normalise tables the reason being, I experience in the course of my project that, whilst doing an ERD itself, some of the parts which is supposed to be doing in the Normalised Form is already been solved. For example Car, Customer and Staff are related to Car History. Or on the other hands that some entities which have been identified earlier had to be removed and placed as an attribute such as cost estimate, where one Car will have many Car History, but car History will have one cost estimate at a time which in other words it will be a 1:1 relationship. So if cost estimate change Car History change even it is about the same car. When creating a database it all depend on the person creating it as there many various ways to come to a Solution and also the way it is being interpreted. I also notice that creating a database without a relation between tables is possible as everything can be manage from the front end in the coding. For example the Car_History1 table has an attribute call Location_code which has nothing to do with the location_no attribute which is a primary key in location table but both of them are sharing the same data. If these two tables were in a relation then the primary key location_no from location table would have been a foreign key in car_history1 table as location_code, meaning that if the value in location_no (primary key) in location table does not exist then it will not be possible to insert a value in the car_history1 table without the value being exist in the location table. Similarly think about these two tables has got no relation but there is a DropdownList which is running a query, Select Location_no from Location, to get all the values of location_no (Primary key of Location table), It is possible to get the selected value from the dropdownList and pass it to a variable in our coding as shown in the example Picture 11d. There are different ways for generating primary keys for example it is possible to use Sequence and Trigger in oracle
61

In order to generate an automatic primary key you will need to create a sequence referring to Appendix F for creating customer table which is named cust_seq. Its role is to define the minimum value, start value, interval between the values that is by using increment by and the cache where it will cache up to a certain values for performance. In the project while creating the sequence there was no values stated and by doing this the sequence get the default values for example start value, increment and minimum value will be 1, the maximum value will be 99999 and the cache will be 20. Assuming you have a table name testing with idnumber and of type number and name of type varchar2(20) You can create a sequence as follows: Create Sequence test_seq MinValue 1 Start with 1 Increment by 1 Cache 20; And while inserting the value in the table you will need to write the following code: Insert into testing (idnumber,name) values (test_seq.nextVal, hevylen) What it does is that every time you insert a data it will check the last number and increment it by one. But there is another way of doing it without writing test_seq.nextVal in the insert command by using trigger. Trigger is a procedure that is stored in a database. It does the same action but you will not need to type the test_seq.nextVal every time. Below is an example of trigger which will be name test_trigg which is going to use the testing table and the test_seq sequence.

create or replace trigger test_trigg before insert on testing for each row when(new.id is null) begin select test_seq.nextval
62

into :new.id from dual; end; So every time you are inserting a new data it triggers automatically and gives an auto number to the data. The disadvantage of using this above technique is that you can only use integer but as in my situation I wanted to have a combination of string and integer it was not possible to apply it. I found my own way of doing by adding an attribute of type number in the tables that I needed to auto generate primary key. I made sure that every time that the system is about to insert a new data it will increment the variable inside the code by one and using this value I concatenate it with other values which I get for example year and the garage code (A, B) etc to get the primary key for example A/1/09. Initially, when starting the implementation of the interface I was trying to use the toolbox under Data such as GridView, DetailsView etc to make the connection with the database which was easy in a way as there was nothing to write in the code behind and it was all auto generated code from the IDE. But I found out that there was lots of things that I wanted to do was impossible by using these techniques. For example if you want to insert data in a detail view and you want to convert the text in uppercase before inserting them in the database it will be not possible where when using simple textboxes and code behind it can be possible to create a method just to convert the text into uppercase in the textboxes.
Using of the Master page in ASP.NET

The main advantage of using a master page is that it allows the developers to create a consistent layout for the pages they are creating. The master page defines all the pages or certain specific pages of how they will look and feel as well as their behaviors. It allows the developer to make changes at one place and all the pages which inherit from that master page will be affected.
Connection with the database

As this project is using Oracle and Visual web developer we need to know how to make connection between these two. The first step is to add a reference to the project as shown in Picture 11a and select Oracle.DataAccess so that we can import Oracle.DataAccess.Client as shown in picture 11b
63

Picture 11a

Picture 11b To connect with the database, you will need to create a connection object

Depending on what you want to do whether it is a select, Insert, Update or Delete query you will always need a connection object.

64

The following code shows how to implement a select query.


Creating a new object of oracle command Writing the actual query

Executing the Query

Allow Access to the data Closing and disposing the connection Get the value & initialise it to a variable

Picture 11c

The following code below shows part of an implementation of an insert query:

65

Picture 11d Compare to the select query you will have ExecuteNonQuery() instead of ExecuteReader() and will be using Parameters to pass the value to the query or you can concatenate the value you want to pass though the query directly as shown below.

Same will apply to the update query

66

Conclusion
Initially it was hard to implement the interface as I could not connect with the database in my coding and I was force to use the tools from the toolbox in the data section such as details view. I did not have control on the way I wanted to manipulate specific text boxes in the details view and this delayed the whole project and thats why I could not do all the requirements from the projects as the materials was quite hard to get. It was really a challenge and I have been working on lots of pressure to reach where I have achieved. If there would have more time I would have done a better application and a better project report.

67

Bibliography
Database Systems, Design Implementation and Management, 7th edition By Peter Rob & Carlos Coronel. Database Management System, 3rd edition, By Rama Krishnan Gehrke PDF Document using oracle with visual studio Author Oracle Corporation, Title Oracle Database 2 Day Plus Developer Guide Oracle database 10g Express edition for windows Author Steve Bobrowski, Published 2006 Oracle database 10g SQL Master Author Jason Price, Published 2004 Beginning ASP.NET 3.5 in C# and VB Author Emar Spaanjaars, Beginning Visual Basic 2005 Databases Author Thearon Willis, Published by Wiley Publishing, Inc. Practical software development using UML and JAVA Author Timothy C.Leith bridge, Robert Laganie. Software Project Management, 4th edition By Bob Hughes and Mike Cotterell Project Management for Information system 4th edition By James cadle and Donald Yeates

68

Appendices
Appendix A

Selecting appropriate attributes. Location-> ( Location_ID ,Name ,Address) Location will have a Name where it will consist of either Head Quarters or other Workshops name and also it will have an address for each location. Staff-> ( Staff_ID, Name, Job_Title, Password) Staff will consist of all the list of staff. Because of different level of privilege that a user need to access the web site I have included a Password attribute. Job_Title will need to be in a different table. Customer-> ( Customer_ID, Name, Address, Tel_No ) Customer will have all the list of customers for the company. Car-> ( Reg_No, Model, Engine_Capacity, Chassis_No) Car will have a list of cars which has visited or enquired about a cost estimate. Car_History1-> ( reg_no, Admission_Date, Discharge_Date, Description, Mileage) Because a Car could came in the workshop in several occasions with different owners and one customer can own many cars, so there is the many to many relation between car and customer, that why I have introduced car_ History1 entity which will have the registration number and the admission date, which means that at a particular time one car is owned by only one customer. Cost_Estimate-> ( Cost_Estimate_No, Date) Cost estimate will have only Cost_Estimate_No and the Date it has been created. One car can have many cost estimate. Car_Job-> ( Job_No, Description, Labour_Cost, Material_Cost) One will have its own description Job_Account-> (Job_No, Month, Status, Labour_This_Month, Material_This_Month)

69

Appendix B

70

Appendix C

Schema Location-> ( Location_ID ,Name ,Address) Staff-> ( Staff_ID, Name, Password, Job_ID*,Location_ID*) Job-> ( Job_ID, Job_Title ) Customer-> ( Customer_ID, Name, Address, Tel_No ) Car-> ( Reg_No, Engine_Capacity, Chassis_No, , Model_ID*) Model-> (Model_ID, Model_Name) Car_History1-> ( Car_History_no, Reg_No*, Admission_Date, Discharge_Date, Description, Mileage, Customer_ID*, Staff_ID*) Cost_Estimate-> ( Cost_Estimate_No, Date, Car_History_no* ) Car_Job-> ( Job_No, Description, Labour_Cost, Material_Cost, Cost_Estimate_No*) Job_Account-> (Job_No*, Month, Status, Labour_This_Month, Material_This_Month)

71

Appendix D

My final Schema will be as follows: Location-> ( Location_ID ,Name , Street _Address, Town, Post_Code) Staff-> ( Staff_ID, Name, Password, Location_ID*) Job-> ( Job_ID, Job_Title ) Role-> (Staff_ID*, Job_ID*) Customer-> ( Customer_ID, Name, Street _Address, Town, Post_Code, Tel_No ) Model-> (Model_ID, Model_Name) Car-> ( Reg_No, Engine_Capacity, Chassis_No, , Model_ID*) Car_History1-> ( Cost_Estimate_No, estimate_no, Date_OfCostEstimate, Reg_No*, Admission_Dateandtime, Discharge_Dateandtime, Description, Mileage, Customer_ID*,Allocated_Staff*,location_code*) Car_Job-> ( Job_No, Cost_Estimate_No*, serial_no, Description, Labour_Cost, Material_Cost,) Job_Account-> (Job_No*, Cost_Estimate_No*, Day, Month, Year, Status, Labour_This_Month, Material_This_Month)

72

Appendix E

Data Definition Location ATTRIBUTE NAME Location_ID Name Street_Address Town Post_code DATA TYPE Varchar2(10) Varchar2(15) Varchar2(40) Varchar2(30) Varchar2(12)

Primary key Not null Not null Not null Not null

Staff ATTRIBUTE NAME Staff_ID Name Password Location_ID DATA TYPE Varchar2(10) Varchar2(50) Varchar2(20) Varchar2(10)

Primary key Not null Not null Foreign Key, not null

Job ATTRIBUTE NAME Job_ID Job_Title DATA TYPE Varchar2(10) Varchar2(50)

Primary key Foreign key, Not null

Role ATTRIBUTE NAME Job_ID Staff_ID DATA TYPE Varchar2(10) Varchar2(10)

Foreign key, Not null Foreign key, Not null

Customer ATTRIBUTE NAME DATA TYPE Customer_ID Number(10,0) Primary key Name Varchar2(50) Not null Street_Address Varchar2(40) Not null Town Varchar2(30) Not null Post_Code Varchar2(12) Not null Tel_No Varchar2(11) I left the Attribute Tel_no null able as some customer may not have a telephone number or that they do not wish to be contact through the phone 73

Model ATTRIBUTE NAME Model_ID Model_Name DATA TYPE Varchar2(10) Varchar2(25)

Primary key Not null

Car ATTRIBUTE NAME Reg_No Engine_Capacity Chassis_No Model_ID DATA TYPE Varchar2(10) Varchar2(7) Varchar2(30) Varchar2(10)

Primary Key Not null Not null Foreign key Not null

Car_History1 ATTRIBUTE NAME DATA TYPE Cost_Estimate_No Varchar2(10) Primary key Estimate_no Number(10,0) Not null Date_OfCostEstimate TimeStamp(0) Not null Reg_No Varchar2(10) Foreign Key, Not Null Admission_DateAndTime TimeStamp(0) Discharge_DateAndTime TimeStamp(0) Description Varchar2(200) Not Null Mileage Number(7,0) Customer_ID Number(10,0) Foreign key, Not null Allocated_Staff Varchar2(10) Foreign Key, Not null Location_code Varchar2(1) Not Null Admission and discharge date can be null able as it may happen that a customer ask for a cost estimate and nothing else.

Car_Job ATTRIBUTE NAME DATA TYPE Job_No Varchar2(10) Primary Key Description Varchar2() Not null Labour_Cost Number(9) Material_Cost Number(9) Not null Cost_Estimate_No Varchar2(10) Foreign Key, Not null Labor cost can be null able as some job will be repaired by contractors so only material cost will be charge 74

Job_Account ATTRIBUTE NAME DATA TYPE Job_No Varchar2(10) Primary &Foreign Key Month Varchar2() Primary Key Labour_This_Month Number(9) Material_This_Month Number(9) Status Varchar2(1) Not Null In this case both labor and material cost will be null able as if the status of a job has not yet started then there will be no expenses for this particular job for this particular month.

75

Appendix F (Queries for creating the tables)

create table Location(Location_No VARCHAR2(10) NOT NULL, Name VARCHAR2(15) NOT NULL, Street_Address VARCHAR2(40) NOT NULL, Town VARCHAR2(30) NOT NULL, Post_Code VARCHAR2(12)NOT NULL, Primary Key(Location_No));

create table Staff(Staff_ID VARCHAR2(10)NOT NULL, Name VARCHAR2(50) NOT NULL, password VARCHAR2(20), Location_No VARCHAR2(10)NOT NULL, Primary Key(staff_ID), Foreign key(Location_No)references Location(Location_No));

create table Job(Job_ID VARCHAR2(10)NOT NULL, Job_Title VARCHAR2(50) NOT NULL, Primary Key(Job_ID));

create table Role(Job_ID VARCHAR2(10)NOT NULL, Staff_ID VARCHAR2(10) NOT NULL, Foreign Key(Job_ID)references Job(Job_ID), Foreign Key(Staff_ID)references staff(Staff_ID));

76

create table Customer(Customer_ID INT NOT NULL, Name VARCHAR2(50) NOT NULL, Street_Address VARCHAR2(40)NOT NULL, Town VARCHAR2(30)NOT NULL, Post_Code VARCHAR2(12)NOT NULL, Tel_No VARCHAR2(11), Primary Key(Customer_ID));

create sequence cust_seq;

create or replace trigger cust before insert on Customer for each row when(new.Customer_id is null) begin select cust_seq.nextval into :new.Customer_id from dual; end;

create table Model(Model_ID VARCHAR2(10)NOT NULL, Model_Name VARCHAR2(25) NOT NULL, Primary Key(Model_ID));

77

create table Car(Reg_No VARCHAR2(10)NOT NULL, Engine_Capacity VARCHAR2(7) NOT NULL, Chassis_No VARCHAR2(30) NOT NULL, Model_ID VARCHAR2(10) NOT NULL, Primary Key(Reg_No), Foreign key(Model_ID)references Model(Model_ID));

create table Car_History1(Cost_Estimate_No VARCHAR2(10)NOT NULL, Estimate_No INT NOT NULL, Date_OfCostEstimate timestamp(0)NOT NULL, Reg_No VARCHAR2(10) NOT NULL, Admission_DateAndTime timestamp(0), Discharge_DateAndTime timestamp(0), Description VARCHAR2(200) NOT NULL, Mileage Number(7), Customer_ID NUMBER(10) NOT NULL, Allocated_Staff VARCHAR2(10) NOT NULL, Location_code VARCHAR2(1) NOT NULL, Primary Key(Cost_Estimate_No), Foreign key(Customer_ID)references Customer(Customer_ID), Foreign key(Reg_No)references Car(Reg_No), Foreign key(Allocated_Staff)references staff(Staff_ID));

create table Car_Job(Job_No VARCHAR2(10)NOT NULL, Serial_No INT NOT NULL, 78

Description VARCHAR2(100) NOT NULL, Labour_Cost NUMBER(9), Material_Cost NUMBER(9) NOT NULL, Cost_Estimate_No VARCHAR2(10) NOT NULL, Primary Key(Job_No,Cost_Estimate_No), Foreign key(Cost_Estimate_No)references Car_History1 (Cost_Estimate_No));

create table Job_Account(Job_No varchar2(10)NOT NULL, Day varchar2(2) NOT NULL, Month VARCHAR2(2) NOT NULL, YEAR varchar2(4) NOT NULL, Cost_Estimate_No VARCHAR2(10) NOT NULL, Labour_This_Month NUMBER(9), Material_This_Month NUMBER(9), Status VARCHAR2(1)NOT NULL, Primary Key(Job_No,Cost_Estimate_No,Day,Month,Year), Foreign key(Job_No,Cost_Estimate_No)references car_Job(Job_No,Cost_Estimate_No));

create view monthly_Job_account as select j.description,ja.job_no,ja.status,ja.labour_this_month, sum(ja.Labour_this_month) over (partition by ja.cost_estimate_no,ja.job_no order by ja.month) Labour_To_date, j.labour_cost,ja.material_this_month, sum(ja.Material_this_month)over (partition by ja.cost_estimate_no,ja.job_no order by ja.month) Material_To_Date,

79

j.material_cost,ja.month,j.cost_estimate_no from car_job j,job_account ja where j.job_no = ja.Job_no and j.cost_estimate_no = ja.cost_estimate_no order by j.job_no,ja.month

80

Appendix G (All these coding are my own which is in visual basic Language) Note : I have not included the auto generated codes created by the IDE Appendix G.1 (Login1 page) Appendix G.2 to G.9 is for Manager Appendix G.10 to G.11 is for Mechanics Appendix G.12 to G.13 is for Administrator For testing purposes I have change all the Data Source to Local Host. Appendix G.1 (Login1 page)
Imports Oracle.DataAccess.Client Partial Class Login1 Inherits System.Web.UI.Page Public oradb As String = "Data Source = Kavinyan; User ID=project2; password= password;" Protected Sub LinkButton1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles LinkButton1.Click Dim user As String Dim userId As String = TextBox1.Text Dim pass As String = TextBox2.Text user = "" Dim jobTitle As String jobTitle = "" Dim StaffName As String StaffName = "" Dim lblMessage As String lblMessage = "Not a valid UserName or password, Please try again" 'creating the connection Dim conn As New OracleConnection() conn.ConnectionString = oradb Try 'open the connection conn.Open() Dim cmd As New OracleCommand cmd.Connection = conn 'this query is to check whether the user is a staff or not cmd.CommandText = "select staff_id from staff where password = '" & pass & "' and staff_id ='" & userId & "'" cmd.CommandType = Data.CommandType.Text

81

Dim dr As OracleDataReader = cmd.ExecuteReader() dr.Read() 'pass the value to the variable user user = dr.Item("staff_id") Catch ex As Exception End Try 'close the connection conn.Close() conn.Dispose() Dim conn1 As New OracleConnection() conn1.ConnectionString = oradb Try conn1.Open() Dim cmd1 As New OracleCommand cmd1.Connection = conn1 'Check what the job title of the user if he or she is a staff cmd1.CommandText = "select job_title from job where job_id in (select job_id from role where staff_id in (select staff_id from staff where staff_id= '" & user & "'))" cmd1.CommandType = Data.CommandType.Text Dim dr As OracleDataReader = cmd1.ExecuteReader() dr.Read() 'pass the value to variable job_title jobTitle = dr.Item("job_title") Catch ex As Exception End Try conn1.Close() conn1.Dispose() Dim conn2 As New OracleConnection() conn2.ConnectionString = oradb Try conn2.Open() Dim cmd2 As New OracleCommand cmd2.Connection = conn2 'get the name of the user for display purposes cmd2.CommandText = "select name from staff where staff_id = '" & user & "'" cmd2.CommandType = Data.CommandType.Text Dim dr As OracleDataReader = cmd2.ExecuteReader() dr.Read() 'pass the value to variable staffName StaffName = dr.Item("name") Catch ex As Exception End Try conn2.Close()

82

conn2.Dispose() lblMessage = "Not a valid UserName or password, Please try again" 'Depending on the job Title of the user only one of the panel will be visible 'Else a message will prompt the user to login again If jobTitle = "Workshop manager" Then Panel1.Visible = False Panel2.Visible = True lblNameP2.Text = StaffName lblJobTitleP2.Text = jobTitle ElseIf jobTitle = "Mechanics" Then Panel1.Visible = False Panel3.Visible = True lblNameP3.Text = StaffName lblJobTitleP3.Text = jobTitle ElseIf jobTitle = "Administrator" Then Panel1.Visible = False Panel4.Visible = True lblNameP4.Text = StaffName lblJobTitleP4.Text = jobTitle ElseIf jobTitle = "Head Office" Then Panel1.Visible = False Panel5.Visible = True lblNameP5.Text = StaffName lblJobTitleP5.Text = jobTitle ElseIf jobTitle = "secretery" Then Panel1.Visible = False Panel6.Visible = True lblNameP6.Text = StaffName lblJobTitleP6.Text = jobTitle Else lblLoginMessage.Text = lblMessage End If End Sub Protected Sub logOutButton5_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles logOutButton5.Click Session("User") = User Session.Abandon() Panel1.Visible = True Panel2.Visible = False End Sub End Class

83

Appendix G.2 (Customer Page)


Imports Oracle.DataAccess.Client Imports System Partial Class Manager_Customer Inherits System.Web.UI.Page Public name As String Public street As String Public town As String Public postCode As String Public telNo As String Public oradb As String = "Data Source = Kavinyan; User ID=Project2; password= password;" Public custList As String Protected Sub DropDownList1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles DropDownList1.SelectedIndexChanged btnDelete.Visible = True End Sub Protected Sub btnClear_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnClear.Click myClear() End Sub Protected Sub btnInsert_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnInsert.Click myInsertCust() End Sub Protected Sub btnSearch_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSearch.Click mySearchCustomer() End Sub Protected Sub btnDelete_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnDelete.Click myDeleteCust() End Sub 'allow the user to delete a customer but need to confirm first 'the user have the option of aborting the delete Protected Sub myDeleteCust() Dim mess As String mess = "Do you want to delete the customer" Dim res As Integer res = MsgBox(mess, MsgBoxStyle.YesNo, "Delete Item")

84

If res = 6 Then 'calling the delete method mydelete() ElseIf res = 7 Then MsgBox("Deleted Aborted", MsgBoxStyle.OkOnly, "Delete Abort") btnDelete.Visible = True End If End Sub Protected Sub LinkButton1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles lbtnDelete.Click myDeleteCust() End Sub 'the actual delete to the database Protected Sub mydelete() Dim drp As String Dim conn1 As New OracleConnection() conn1.ConnectionString = oradb drp = DropDownList1.SelectedValue drp = "Delete from customer where Customer_id =" & drp Try conn1.Open() Dim cmd2 As New OracleCommand cmd2.Connection = conn1 cmd2.CommandText = drp cmd2.ExecuteNonQuery() MsgBox("One item is deleted successfully", MsgBoxStyle.OkOnly, "Delete Item") Catch ex As Exception MsgBox("Delete could not be performed", MsgBoxStyle.Information, "Warning") End Try End Sub 'Allow insert new customer in the database Protected Sub myInsert() name = txtname.Text street = txtAddress.Text town = txtTown.Text postCode = txtPostCode.Text telNo = txtTelephone.Text Dim conn As New OracleConnection() conn.ConnectionString = oradb Try conn.Open() Dim cmd As New OracleCommand cmd.Connection = conn cmd.CommandText = "Insert into Customer (name, street_address, town,post_code,tel_no)values (:name, :street_address,:town,:post_code,:tel_no)" cmd.Parameters.Add(":name", name)

85

cmd.Parameters.Add(":street_address", street) cmd.Parameters.Add(":town", town) cmd.Parameters.Add(":post_code", postCode) cmd.Parameters.Add(":tel_no", telNo) Dim res As Integer res = MsgBox("Are you sure you want to Insert this data", MsgBoxStyle.YesNo, "Confirmation") If res = 6 Then cmd.ExecuteNonQuery() cmd.CommandType = Data.CommandType.Text Else MsgBox("You have cancelled your last transaction", MsgBoxStyle.OkOnly, "Information") End If 'if any mistake happen it will give this message below Catch ex As Exception MsgBox("Incorrect data entered or Some Data missing", MsgBoxStyle.Information, "Warning") End Try conn.Close() conn.Dispose() End Sub Protected Sub myInsertCust() 'if any textboxes is left blank message will prompt the user If txtname.Text = "" Or txtAddress.Text = "" Or txtTown.Text = "" Or txtPostCode.Text = "" Or txtTelephone.Text = "" Then MsgBox("Data missing, please check if all the fields contain values", MsgBoxStyle.OkOnly, "Insert Denied") Else 'otherwise call the myInsert method myInsert() End If End Sub Protected Sub LinkButton3_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles lbtnInsertNew.Click myInsertCust() End Sub Protected Sub myClear() DropDownList1.Visible = False btnDelete.Visible = False lblSelectCust.Visible = False clearText() End Sub 'clear all the text boxes Protected Sub clearText() txtname.Text = "" txtAddress.Text = "" txtTown.Text = "" txtPostCode.Text = "" txtTelephone.Text = "" End Sub Protected Sub LinkButton5_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles lbtnClear.Click myClear() End Sub

86

Protected Sub lbtnSearchCustomer_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles lbtnSearchCustomer.Click mySearchCustomer() End Sub 'search for customer Protected Sub mySearchCustomer() txtname.Text = name txtAddress.Text = street txtTown.Text = town txtPostCode.Text = postCode txtTelephone.Text = telNo custList = DropDownList1.SelectedValue If DropDownList1.Visible = False Then MsgBox("The name is not recognise please select a customer first", MsgBoxStyle.Exclamation, "Warning") Else Dim conn As New OracleConnection() conn.ConnectionString = oradb Try conn.Open() Dim cmd As New OracleCommand cmd.Connection = conn cmd.CommandText = "select name, street_address,town, post_code,tel_no from customer where customer_id = '" & custList & "'" cmd.CommandType = Data.CommandType.Text Dim dr As OracleDataReader = cmd.ExecuteReader() dr.Read() name = dr.Item("name") street = dr.Item("street_address") town = dr.Item("town") telNo = dr.Item("tel_no") postCode = dr.Item("post_code") 'display in the appropriate text boxes txtname.Text = name txtAddress.Text = street txtTown.Text = town txtTelephone.Text = telNo txtPostCode.Text = postCode Catch ex As Exception End Try conn.Close() conn.Dispose() End If btnInsert.Visible = False End Sub

87

Protected Sub lbtnUpdate_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles lbtnUpdate.Click myUpdate() End Sub Protected Sub myUpdate() custList = DropDownList1.SelectedValue 'passing the values to the variables name = txtname.Text street = txtAddress.Text town = txtTown.Text telNo = txtTelephone.Text postCode = txtPostCode.Text Dim conn As New OracleConnection() conn.ConnectionString = oradb Try conn.Open() Dim cmd As New OracleCommand cmd.Connection = conn 'update the data in the database cmd.CommandText = "update customer set name = :name,street_address = :street,town = :town,tel_no = :tel_no,post_code = :postCode where customer_id = " & custList & "" cmd.Parameters.Add(":name", name) cmd.Parameters.Add(":Street_address", street) cmd.Parameters.Add(":town", town) cmd.Parameters.Add(":post_code", postCode) cmd.Parameters.Add(":tel_no", telNo) cmd.ExecuteNonQuery() cmd.CommandType = Data.CommandType.Text MsgBox("Customer successfully updated", MsgBoxStyle.Information, "Update") ' initialise the varialbes to blank name = "" street = "" town = "" postCode = "" telNo = "" Catch ex As Exception 'message appear if data in the text boxes are missing MsgBox("Make sure that all the text is completed", MsgBoxStyle.Information, "Error") End Try conn.Close() conn.Dispose() End Sub Protected Sub lbtnSelect_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles lbtnSelect.Click DropDownList1.Visible = True lblSelectCust.Visible = True End Sub Protected Sub btnNew_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnNew.Click btnNew.Visible = False

88

clearText() btnInsert.Visible = True End Sub End Class

Appendix G.3 (Car Details Page)


Imports Oracle.DataAccess.Client Partial Class Manager_CarDetails Inherits System.Web.UI.Page Public txtReg_no As String 'Public text1 As String Public oradb As String = "Data Source = Kavinyan; User ID=Project2; password= password;" Protected Sub toUppercase() 'changing the text to uppercase 'as i need all the car registration number to be in uppercase txtReg_no = TextBox1.Text txtReg_no = txtReg_no.ToUpper() TextBox1.Text = txtReg_no

End Sub Protected Sub btnInsert_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnInsert.Click 'initialising all the variables from the objects (text boxes and drop down list) ' txtReg_no = TextBox1.Text Dim txtEngine As String = TextBox2.Text Dim txtChassis As String = TextBox3.Text Dim Model As String = DropDownList1.Text Dim conn As New OracleConnection() conn.ConnectionString = oradb 'inserting the values into the database by passing them to the insert command Try conn.Open() Dim cmd As New OracleCommand cmd.Connection = conn cmd.CommandText = "Insert into car (reg_no, engine_capacity, chassis_no,model_id)values (:reg_no, :engine_capacity,:chassis_no,:model_id)" cmd.Parameters.Add(":reg_no", txtReg_no) cmd.Parameters.Add(":engine_capacity", txtEngine) cmd.Parameters.Add(":chassis_no", txtChassis) cmd.Parameters.Add(":model_id", Model) cmd.ExecuteNonQuery() cmd.CommandType = Data.CommandType.Text 'if inserted successfully a message will appear

89

MsgBox("Car Details has been successfully entered", MsgBoxStyle.Information, "CarDetails inserted") Catch ex As Exception 'else this message below will appear MsgBox("Incorrect data entered or Some Data missing") End Try conn.Close() conn.Dispose() 'close and dispose the connection btnNext.Visible = True btnInsert.Visible = False btnSearch.Visible = False End Sub Protected Sub btnSearch_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSearch.Click 'check if the registration number is in the database toUppercase() Dim registration As String = "" ' initialise the variable Dim conn As New OracleConnection() conn.ConnectionString = oradb Try conn.Open() Dim cmd As New OracleCommand cmd.Connection = conn 'check if registration number exist cmd.CommandText = "select reg_no from car where reg_no = '" & txtReg_no & "'" cmd.CommandType = Data.CommandType.Text Dim dr As OracleDataReader = cmd.ExecuteReader() dr.Read() registration = dr.Item("reg_no") Catch ex As Exception If registration = "" Then MsgBox("This vehicle is not registered in the system", MsgBoxStyle.Information, "Registration") btnInsert.Visible = True TextBox2.Visible = True TextBox3.Visible = True DropDownList1.Visible = True TextBox2.Text = "" TextBox3.Text = "" End If End Try If registration = TextBox1.Text Then 'if registration exist then this message appear MsgBox("This Vehicle is registered in our system", MsgBoxStyle.Information, "Registered") btnNext.Visible = True End If conn.Close() conn.Dispose() End Sub

90

Protected Sub btnNext_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnNext.Click TextBox1.Text = "" TextBox2.Visible = False TextBox3.Visible = False DropDownList1.Visible = False btnNext.Visible = False btnSearch.Visible = True End Sub Protected Sub btnCancel_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnCancel.Click TextBox1.Text = "" TextBox2.Text = "" TextBox3.Text = "" DropDownList1.Visible = False TextBox2.Visible = False TextBox3.Visible = False btnInsert.Visible = False End Sub End Class

91

Appendix G.4 (Car History Page)


Imports Oracle.DataAccess.Client Partial Class Manager_CarHistory Inherits System.Web.UI.Page 'Declaration of public variables Public admissiondate As String Public res As Integer Public drpRegNo As String Public day As String Public drpLocation As String Public oradb As String = "Data Source = Kavinyan; User ID=project2; password= password;" Public regNoCount As Integer Public maxNum As Integer Public primarykey As String = "" Public year As String Dim year1 As String 'This method will check is there is any space in any particular garage Protected Sub SpaceAvailable() Dim drpRegNo As String = DropDownList1.Text Dim drpLocation As String = DropDownList4.Text admissiondate = "" Dim countAdmission As Integer Dim countDischarge As Integer day = Date.Now.ToString Dim conn6 As New OracleConnection() conn6.ConnectionString = oradb Try conn6.Open() Dim cmd6 As New OracleCommand cmd6.Connection = conn6 'It get the number car that has been admitted which include those which have already been discharge if there is any 'from a particular garage cmd6.CommandText = "select count (Admission_dateandtime) from(car_history1)where location_code = '" & drpLocation & "'" cmd6.CommandType = Data.CommandType.Text Dim dr6 As OracleDataReader = cmd6.ExecuteReader() dr6.Read() 'get the number from the database countAdmission = dr6.Item("count(Admission_dateandtime)") Catch ex As Exception End Try Dim conn1 As New OracleConnection() conn1.ConnectionString = oradb Try conn1.Open()

92

Dim cmd1 As New OracleCommand cmd1.Connection = conn1 'it will count all the car that has already been discharge only from a particular garage cmd1.CommandText = "select count (Discharge_dateandtime) from(car_history1)where location_code = '" & drpLocation & "'" cmd1.CommandType = Data.CommandType.Text Dim dr As OracleDataReader = cmd1.ExecuteReader() dr.Read() 'get the number of discharge car countDischarge = dr.Item("count(Discharge_dateandtime)") Catch ex As Exception End Try conn1.Close() conn1.Dispose() duplicateData() If (countAdmission - countDischarge) >= 10 Then 'if the gap of number of total admission and total discharge exceed ten 'then system will display the above message MsgBox("Sorry, the Garage can only take a maximum of TEN car at a time!", MsgBoxStyle.OkOnly, "Garage Full") Else enterData() End If If regNoCount > 0 Then 'if the count for the same car exceed 0 which is one the message below will be display MsgBox("Sorry this car is already admitted in garage '" & drpLocation & "' and is not yet discharged", MsgBoxStyle.OkOnly, "Car Already In") Else enterData() End If End Sub Protected Sub duplicateData() 'this duplicatedata method check if a particular car has an admission date and the discharge date is null 'reason for that is we want to know whether the car is presently in a garage already. Dim conn As New OracleConnection() conn.ConnectionString = oradb Try conn.Open() Dim cmd As New OracleCommand cmd.Connection = conn

93

cmd.CommandText = "select Count (reg_no) from car_history1 where reg_no = '" & drpRegNo & "' and discharge_dateandtime is NULL and admission_dateandtime is not NULL " cmd.CommandType = Data.CommandType.Text Dim dr As OracleDataReader = cmd.ExecuteReader() dr.Read() regNoCount = dr.Item("Count(reg_no)") Catch ex As Exception End Try conn.Close() conn.Dispose() End Sub Protected Sub generatePrimaryKey() 'This variable primarykey describe how its value will be 'by using three other variables 'The drpLocation will get the value either A or B 'maxNum will be the last number from estimate no in the database and add 1 to the maxNumber 'which become the next maxNum 'The year will be getting it straight from the system date primarykey = drpLocation & "/" & maxNum & "/" & year End Sub 'Allowing data to be entered in the database depending on certain conditions Protected Sub enterData() 'drpLocation = DropDownList4.Text day = Date.Now.ToString Dim Dim Dim Dim txtDescription As String = TextBox5.Text txtMileage As String = TextBox4.Text drpCustName As String = DropDownList2.Text drpStaff As String = DropDownList3.Text

generatePrimaryKey() 'if user want to admit a car res will = 6 but it need to satisfy the condition in spaceAvailable method first If res = 6 Then 'Its just to display the date for the user when admission is done lblAdmissionDate.Text = day 'pass the date to the admissiondate variable do be inserted into the database admissiondate = lblAdmissionDate.Text ElseIf res = 7 Then 'If user does not want to admit a car then admission date will be null admissiondate = "" End If

94

Dim conn As New OracleConnection() conn.ConnectionString = oradb Try conn.Open() 'Inserting all the data in the car_history1 Dim cmd As New OracleCommand Dim textCommand As String textCommand = "Insert into car_history1 (cost_estimate_no,estimate_no,Date_ofcostestimate,reg_no,Admission_date andTime,description,mileage,customer_id,Allocated_staff,Location_code) values ( '" & primarykey & "',:estimate_no,to_date('" & day & "', 'dd/mm/yyyy hh24:mi:ss'),:reg_no,to_date('" & admissiondate & "', 'dd/mm/yyyy hh24:mi:ss'),:description,:mileage,:customer_id,:Allocated_staff,:Locat ion_code)" cmd.Connection = conn cmd.CommandText = textCommand cmd.Parameters.Add(":estimate_no", maxNum) cmd.Parameters.Add(":reg_no", drpRegNo) cmd.Parameters.Add(":description", txtDescription) cmd.Parameters.Add(":mileage", txtMileage) cmd.Parameters.Add(":customer_id", drpCustName) cmd.Parameters.Add(":Allocated_staff", drpStaff) cmd.Parameters.Add(":Location_code", drpLocation) cmd.ExecuteNonQuery() cmd.CommandType = Data.CommandType.Text Catch ex As Exception 'if any error occurs the system will display this message MsgBox("incorrect data entered" & ex.ToString, MsgBoxStyle.YesNo, "Incorrect Data") End Try conn.Close() conn.Dispose() End Sub Protected Sub LinkButton1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles LinkButton1.Click 'calling incrementNum incrementNum() 'assigning the selected value from dropdownlist to variable drpRegNo drpRegNo = DropDownList1.Text res = MsgBox("You are about to Admit Car: " & drpRegNo & ", Click NO button if you just want to enter data and CANCEL to cancel ", MsgBoxStyle.YesNoCancel, "Car Admission") If res = 6 Then SpaceAvailable() If admissiondate = "" Or regNoCount > 0 Then 'call the refuse message if the admissiondate is null or count for the regNo is > 0 admittanceRefuseMsg()

95

Else : admittanceMsg() End If ElseIf res = 7 Then enterData() costEstimateMsg() ElseIf res = 2 Then cancelMsg() End If ClearAll.Visible = True LinkButton1.Visible = False End Sub Protected Sub ClearAll_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles ClearAll.Click LinkButton1.Visible = True ClearAll.Visible = False TextBox5.Text = "" TextBox4.Text = "" End Sub Protected Sub cancelMsg() MsgBox("You have cancel the transaction", MsgBoxStyle.Information, "Info") End Sub Protected Sub costEstimateMsg() MsgBox("A cost estimate Number has been issued", MsgBoxStyle.OkOnly, "Cost Estimate") End Sub Protected Sub admittanceMsg() MsgBox("Car Number " & drpRegNo & " Successfully admitted", MsgBoxStyle.OkOnly, "Car History") End Sub Protected Sub admittanceRefuseMsg() MsgBox("Car Number " & drpRegNo & " could not be admitted", MsgBoxStyle.OkOnly, "Car History") End Sub Protected Sub incrementNum() 'get the year only from the system year1 = Date.Now.Year.ToString Dim T As Integer = 2 'as year is a four digit number 'we want to get the two last digit for example '09' year = Right$(year1, T) 'assign the value from dropdownlist4 to variable drplocation drpLocation = DropDownList4.Text Dim conn As New OracleConnection() conn.ConnectionString = oradb Try conn.Open() Dim cmd As New OracleCommand cmd.Connection = conn

96

'will get the last estimate_no already in the database cmd.CommandText = "select max(estimate_no) from car_history1 where location_code = '" & drpLocation & "' and cost_estimate_no like'%" & year & "'" cmd.CommandType = Data.CommandType.Text Dim dr As OracleDataReader = cmd.ExecuteReader() dr.Read() 'assigning the last number to maxNum maxNum = dr.Item("max(estimate_no)") Catch ex As Exception End Try conn.Close() conn.Dispose() 'add 1 to maxNum so that the new value of maxNum will increase by one maxNum = maxNum + 1 End Sub End Class

97

Appendix G.5 (Car job Page)

Imports Oracle.DataAccess.Client Partial Class Manager_CarJob Inherits System.Web.UI.Page Public labourCost As Integer Public MaterialCost As Integer Public description As String = "" Public costEstimateNo As String = "" Public primaryKey As String = "" Public maxNum As Integer Public oradb As String = "Data Source = Kavinyan; User ID=project2; password= password;" Protected Sub lbtnInsert_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles lbtnInsert.Click lbtnInsert.Visible = False lbtnNextJob.Visible = True checkTextValue() maxNumber() insertJobDetails() End Sub Protected Sub getPrimaryKey() Dim k As Long 'getting the costEstimateNo from the dropDownList drpEstimate 'K will get the position of the last '/' k = InStrRev(costEstimateNo, "/") 'assign primaryKey with a temporary value depending on the value of k by cutting the costestimate If k > 0 Then primaryKey = Left$(costEstimateNo, k) End Sub Protected Sub maxNumber() getPrimaryKey() Dim conn7 As New OracleConnection() conn7.ConnectionString = oradb Try conn7.Open() Dim cmd10 As New OracleCommand cmd10.Connection = conn7 'getting the maximum value of serial_no depending on the Job_no and cost estimate cmd10.CommandText = "select max(serial_no) from car_job where job_no like'" & primaryKey & "%' and cost_estimate_no = '" & costEstimateNo & "'"

98

cmd10.CommandType = Data.CommandType.Text Dim dr As OracleDataReader = cmd10.ExecuteReader() dr.Read() 'assigning maxNum with the result of "max(serial_no)" maxNum = dr.Item("max(serial_no)") Catch ex As Exception End Try conn7.Close() conn7.Dispose() 'adding one to the actual maxNum so that the next primary which is about to be inserted 'can be increase by one maxNum = maxNum + 1 End Sub Protected Sub insertJobDetails() Dim conn As New OracleConnection() conn.ConnectionString = oradb 'concatenating the temporary value of primarykey with the maxNum 'to get a full value for primary key primaryKey = primaryKey & maxNum Try conn.Open() Dim cmd As New OracleCommand Dim textCommand As String 'inserting all the values in the car_job table textCommand = "Insert into car_job (job_no,serial_no,description,Labour_cost,Material_cost,Cost_Estimate_n o) values (:job_no,:serial_no ,:Description,:labour_cost,:Material_cost,:Cost_estimate_no)" cmd.Connection = conn cmd.CommandText = textCommand cmd.Parameters.Add(":job_no", primaryKey) cmd.Parameters.Add(":serial_no", maxNum) cmd.Parameters.Add(":Description", description) cmd.Parameters.Add(":labour_cost", labourCost) cmd.Parameters.Add(":Material_cost", MaterialCost) cmd.Parameters.Add(":Cost_estimate_no", costEstimateNo) cmd.ExecuteNonQuery() cmd.CommandType = Data.CommandType.Text 'display a message when insertion is successfull MsgBox("Job detail has been successfully entered", MsgBoxStyle.Information, "Data Entered") Catch ex As Exception 'if any erro occurs MsgBox("incorrect data entered" & ex.ToString, MsgBoxStyle.YesNo, "Incorrect Data") End Try

99

conn.Close() conn.Dispose() End Sub Protected Sub checkTextValue() description = txtDescriptionJob.Text Dim labCst As String = txtLabourCost.Text Dim MtrlCst As String = txtMaterialCost.Text costEstimateNo = drpEstimate.Text 'converting the value from the textboxes to integer MaterialCost = Integer.Parse(MtrlCst) labourCost = Integer.Parse(labCst) End Sub Protected Sub lbtnNextJob_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles lbtnNextJob.Click txtDescriptionJob.Text = "" txtLabourCost.Text = "" txtMaterialCost.Text = "" lbtnInsert.Visible = True lbtnNextJob.Visible = False End Sub End Class

100

Appendix G.6 (Job account page)


Imports Oracle.DataAccess.Client Partial Class Manager_JobAccount Inherits System.Web.UI.Page Public oradb As String = "Data Source = Kavinyan; User ID=project2; password= password;" Public jobNo As String Public status As String Public labour As Integer Public material As Integer Public day As String Public month As String Public year As String Public checkJob_no As String Public checkStatus As String Public text1 As String Public lab As Boolean = False Protected Sub getDate() Dim wholeDate As String Dim dayAndMonth As String Dim dat As String 'getting the date and time from the system and assigning to dat variable dat = Date.Now.ToString 'as the first part of the date and time take only 10 character including the two "/" 'the integer value is always going to be 10 'that's why i have hardcoded it wholeDate = Left$(dat, 10) 'as i want to split the date to get value for day, month and year 'read the first two character from wholedate and assign it to day day = Left$(dat, 2) 'read the last four character from the wholedate and assign it to year year = Right$(wholeDate, 4) 'as month is in the middle of wholeDate 'get the the first five character from the wholeDate first 'assign it to daAndMonth dayAndMonth = Left$(dat, 5) 'then get the last two character from dayAndMonth 'assign it to month month = Right$(dayAndMonth, 2) End Sub Protected Sub checkExistingData()

101

'This method check whether a job_no exist in a particular month and year Dim conn As New OracleConnection() conn.ConnectionString = oradb Try conn.Open() Dim cmd10 As New OracleCommand cmd10.Connection = conn cmd10.CommandText = "select job_no from Job_account where job_no = '" & jobNo & "' and month = '" & month & "' and year = '" & year & "'" cmd10.CommandType = Data.CommandType.Text Dim dr As OracleDataReader = cmd10.ExecuteReader() dr.Read() checkJob_no = dr.Item("job_no") Catch ex As Exception End Try conn.Close() conn.Dispose() End Sub Protected Sub jobStatus() 'This method will check the status of a job_no for a particular month and year 'and assign it to the checkStatus variable Dim conn As New OracleConnection() conn.ConnectionString = oradb Try conn.Open() Dim cmd As New OracleCommand cmd.Connection = conn cmd.CommandText = "select status from Job_account where job_no= '" & jobNo & "'and month= '" & month & "'and year='" & year & "'" cmd.CommandType = Data.CommandType.Text Dim dr As OracleDataReader = cmd.ExecuteReader() dr.Read() checkStatus = dr.Item("status") Catch ex As Exception End Try conn.Close() conn.Dispose() End Sub Protected Sub btnSubmit_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSubmit.Click insert()

102

End Sub Protected Sub insert() getDate() jobNo = drpJobNo.Text If status <> "C" Then status = drpStatus.Text Else txtLabour.Text = 0 txtMaterial.Text = 0 End If labour = Integer.Parse(txtLabour.Text) material = Integer.Parse(txtMaterial.Text) checkExistingData() Dim res As Integer 'if the jobNo not equals to checkJob_no then call insertData method If checkJob_no = jobNo Then 'if the checkJob_no equals to the jobNo you are about to insert 'then the message below will appear MsgBox("Sorry you cannot enter more than one entry per Month for the same Job_No", MsgBoxStyle.Information, "Error") res = MsgBox("Would you like to update the entry for this job_No instead?", MsgBoxStyle.YesNo, "Update Option") 'the system will give another option to update the job_no 'if the user accept it call the UpdateData method else it will clear the text boxes If res = 6 Then UpdateData() MsgBox("Your data has been successfully updated", MsgBoxStyle.Information, "Update") Else txtLabour.Text = "" txtMaterial.Text = "" txtLabour.Focus() lblStatus.Text = "" End If Else insertData() End If End Sub 'this method will update the job_no already exist in a particular month and year Protected Sub UpdateData() Dim conn As New OracleConnection() conn.ConnectionString = oradb conn.Open() Dim cmd As New OracleCommand cmd.Connection = conn cmd.CommandText = "update job_account set labour_this_month =" & labour & ",material_this_month =" & material & ",status ='" & status

103

& "', day='" & day & "' where job_no ='" & jobNo & "' and month = '" & month & "' and year = '" & year & "'" cmd.ExecuteNonQuery() cmd.CommandType = Data.CommandType.Text End Sub 'This method will be call if the job_no does not exist in a particular month and year 'it will insert all the data in the Job_Account table in the database Protected Sub insertData() Dim costEstimate As String Dim conn As New OracleConnection() conn.ConnectionString = oradb costEstimate = drpCostEst.Text Try conn.Open() Dim cmd As New OracleCommand Dim textCommand As String textCommand = "Insert into Job_Account (job_no,day,month,year,cost_estimate_no,labour_this_month,material_this _month,status) values ( :job_no,:day,:month,:year,:CostEstimate,:labour_this_month,:material_th is_month,:status)" cmd.Connection = conn cmd.CommandText = textCommand cmd.Parameters.Add(":job_no", jobNo) cmd.Parameters.Add(":day", day) cmd.Parameters.Add("month", month) cmd.Parameters.Add(":year", year) cmd.Parameters.Add(":CostEstimate", costEstimate) cmd.Parameters.Add(":labour_this_month", labour) cmd.Parameters.Add(":material_this_month", material) cmd.Parameters.Add(":status", status) cmd.ExecuteNonQuery() cmd.CommandType = Data.CommandType.Text MsgBox("Cost for Job No: " & jobNo & " has been entered for this month ", MsgBoxStyle.Information, "Cost for Job No") Catch ex As Exception MsgBox("incorrect data entered" & ex.ToString, MsgBoxStyle.YesNo, "Incorrect Data") End Try conn.Close() conn.Dispose() End Sub Protected Sub btnUpdate_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnUpdate.Click 'this button will allow the user to update data Dim res As Integer res = MsgBox("Are you sure you want to update the data", MsgBoxStyle.YesNo, "Update") If res = 6 Then UpdateData() ElseIf res = 7 Then

104

MsgBox("Transaction cancelled", MsgBoxStyle.Information, "Cancel") End If End Sub Protected Sub chkShowTable_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles chkShowTable.CheckedChanged 'this is just an option if the user want to see the table If chkShowTable.Checked Then GridAppendix2.Visible = True Else GridAppendix2.Visible = False End If End Sub Protected Sub toUppercase() 'changing the text to uppercase 'as i need all the car registration number to be in uppercase text1 = txtRegNo.Text text1 = text1.ToUpper() txtRegNo.Text = text1 End Sub Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click toUppercase() End Sub

Protected Sub Button2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnCheckStatus.Click 'getting the status of the job_no Dim conn As New OracleConnection() Dim conn1 As New OracleConnection jobNo = drpJobNo.Text conn.ConnectionString = oradb 'getting the value of status if it is 'C' Try conn.Open() Dim cmd10 As New OracleCommand cmd10.Connection = conn cmd10.CommandText = "select status from Job_account where job_no = '" & jobNo & "' and status ='C'" cmd10.CommandType = Data.CommandType.Text Dim dr As OracleDataReader = cmd10.ExecuteReader() dr.Read() status = dr.Item("status") Catch ex As Exception

105

End Try conn.Close() conn.Dispose() Try 'if the status = C then it will display complete 'else status will be blank and will go in the if condition conn1.ConnectionString = oradb conn1.Open() If status = "" Then Dim cmd11 As New OracleCommand cmd11.Connection = conn1 cmd11.CommandText = "select status from Job_account where job_no = '" & jobNo & "' and status ='I'" cmd11.CommandType = Data.CommandType.Text Dim dr1 As OracleDataReader = cmd11.ExecuteReader() dr1.Read() status = dr1.Item("status") 'if status is not 'I' then status = 'N' and display "NOT STARTED" If status = "" Then status = "N" lblStatus.Text = "NOT STARTED" Else lblStatus.Text = "INCOMPLETE" End If Else lblStatus.Text = "COMPLETED" End If Catch ex As Exception End Try conn1.Close() conn1.Dispose() 'if the status is not 'C' then panel2 will be visible as to allow the job details for the actual month to be inserted If status = "N" Or status = "I" Then Panel2.Visible = True End If 'if the status is already completed 'user will not have access to the textboxes inorder to enter the amount 'instead the amount will = 0 'by using checkStatus will know if the job_no have already a status jobStatus() If checkStatus = "" And status = "C" Then insert() End If End Sub Protected Sub btnNextJob_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnNextJob.Click

106

Panel2.Visible = False lblStatus.Text = "" End Sub End Class

Appendix G.7 (Job Invoice page)


Imports Oracle.DataAccess.Client Partial Class Manager_JobCost Inherits System.Web.UI.Page Public costEst As String Public lcost As String = "" Public mcost As String = "" Public vat As String = "" Public afterVat As String = "" Public grand As String = "" Public oradb As String = "Data Source = Kavinyan; User ID=project2; password= password;" Public check As String = "" Public text1 As String

Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click toUppercase() Panel1.Visible = True checkVehicle() GridView1.Visible = True End Sub Protected Sub toUppercase() text1 = TextBox1.Text text1 = text1.ToUpper() TextBox1.Text = text1 clearLabel() End Sub 'it will check whether the vehicle entered in the text box exist in the database Protected Sub checkVehicle() Dim conn As New OracleConnection() conn.ConnectionString = oradb Try conn.Open() Dim cmd As New OracleCommand cmd.Connection = conn cmd.CommandText = "select reg_no from car where reg_no='" & TextBox1.Text & "'" cmd.CommandType = Data.CommandType.Text Dim dr As OracleDataReader = cmd.ExecuteReader() dr.Read() check = dr.Item("reg_no") 'if check does not contain any value then it will go in the catch exception

107

Catch ex As Exception MsgBox("This vehicle is not registered in the system", MsgBoxStyle.Exclamation, "No cost") Panel1.Visible = False End Try conn.Close() conn.Dispose() End Sub Protected Sub btnCalculate_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnCalculate.Click 'calculation of the total cost using the data in the database costEst = drpCostest.Text Dim conn As New OracleConnection() conn.ConnectionString = oradb Try conn.Open() Dim cmd As New OracleCommand cmd.Connection = conn cmd.CommandText = "select sum(LABOUR_COST),sum(MATERIAL_COST),((17.5/100)*sum(Labour_cost)) ,(sum(LABOUR_COST)((17.5/100)*sum(Labour_cost))),(sum(MATERIAL_COST)+(sum(LABOUR_COST)((17.5/100)*sum(Labour_cost))))from(car_job)where cost_estimate_no = '" & costEst & "'" cmd.CommandType = Data.CommandType.Text Dim dr As OracleDataReader = cmd.ExecuteReader() dr.Read() lcost = dr.Item("sum(LABOUR_COST)") mcost = dr.Item("sum(MATERIAL_COST)") vat = dr.Item("((17.5/100)*sum(Labour_cost))") afterVat = dr.Item("(sum(LABOUR_COST)((17.5/100)*sum(Labour_cost)))") grand = dr.Item("(sum(MATERIAL_COST)+(sum(LABOUR_COST)((17.5/100)*sum(Labour_cost))))") Catch ex As Exception End Try lblLabour.Text = lcost lblMaterial.Text = mcost lblVat.Text = vat lblAfterVat.Text = afterVat lblGrand.Text = grand conn.Close() conn.Dispose() Panel2.Visible = True End Sub Protected Sub drpCostest_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles drpCostest.SelectedIndexChanged clearLabel()

108

'I wanted to display a message when the gridview does not appear. 'If GridView1.Visible = False Then ' MsgBox("There is no job entered yet for this cost estimate ", MsgBoxStyle.Information, "Info") 'End If End Sub Protected Sub clearLabel() lblLabour.Text = "" lblMaterial.Text = "" lblVat.Text = "" lblAfterVat.Text = "" lblGrand.Text = "" End Sub Protected Sub btnNext_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnNext.Click Panel1.Visible = False Panel2.Visible = False TextBox1.Text = "" GridView1.Visible = False clearLabel() End Sub End Class

109

Appendix G.8 (Monthly Account page)


Imports Oracle.DataAccess.Client Partial Class Manager_monthlyAccount Inherits System.Web.UI.Page Public RegNo As String Public oradb As String = "Data Source = Kavinyan; User ID=project2; password= password;" Public check As String = "" Protected Sub btnSearch_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSearch.Click 'calling the toUppercase method 'to change the content of the text into uppercase toUppercase() Panel1.Visible = True 'calling the checkVehicle method checkVehicle() If Panel1.Visible = True Then btnResult.Visible = True GridView1.Visible = True btnClear.Visible = True End If End Sub Protected Sub toUppercase() RegNo = TextBox1.Text RegNo = RegNo.ToUpper() TextBox1.Text = RegNo End Sub Protected Sub checkVehicle() 'check if the vehicle exist Dim conn As New OracleConnection() conn.ConnectionString = oradb Try conn.Open() Dim cmd As New OracleCommand cmd.Connection = conn cmd.CommandText = "select reg_no from car where reg_no='" & TextBox1.Text & "'" cmd.CommandType = Data.CommandType.Text Dim dr As OracleDataReader = cmd.ExecuteReader() dr.Read() check = dr.Item("reg_no") Catch ex As Exception MsgBox("This vehicle is not registered in the system", MsgBoxStyle.Exclamation, "No cost")

110

Panel1.Visible = False TextBox1.Text = "" End Try conn.Close() conn.Dispose() End Sub Protected Sub btnResult_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnResult.Click 'assigning the values from the calculation in the query to the labels Dim conn As New OracleConnection() conn.ConnectionString = oradb Try conn.Open() Dim cmd As New OracleCommand cmd.Connection = conn cmd.CommandText = "select sum(labour_this_month),sum(labour_to_date),sum(labour_cost),sum(materia l_this_month),sum(material_to_date),sum(material_cost) from(monthly_job_account)where month = '" & DropDownList1.SelectedValue & "'and cost_estimate_no = '" & DropDownList2.SelectedValue & "'" cmd.CommandType = Data.CommandType.Text Dim dr As OracleDataReader = cmd.ExecuteReader() dr.Read() lbllabourThisM.Text = dr.Item("sum(labour_this_month)") lblLabourToD.Text = dr.Item("sum(labour_to_date)") lblLabourEst.Text = dr.Item("sum(labour_cost)") lblMaterialThisM.Text = dr.Item("sum(material_this_month)") lblMaterialToD.Text = dr.Item("sum(material_to_date)") lblMaterialEst.Text = dr.Item("sum(material_cost)") 'if the vehicle has no cost estimate 'or one of the dropdown list has not been selected Catch ex As Exception MsgBox("Either the Cost estimate no or the Month has not been selected or this vehicle has no cost for this month ", MsgBoxStyle.Exclamation, "No cost") End Try conn.Close() conn.Dispose() Panel2.Visible = True End Sub Protected Sub btnClear_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnClear.Click Panel1.Visible = False Panel2.Visible = False GridView1.Visible = False TextBox1.Text = "" btnResult.Visible = False btnClear.Visible = False

111

End Sub End Class

Appendix G.9 (Discharge car)


Imports Oracle.DataAccess.Client Imports System Partial Class Manager_DischargeCar Inherits System.Web.UI.Page Public regNo As String Public oradb As String = "Data Source = Kavinyan; User ID=project2; password= password;" Protected Sub lbtnDischarge_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles lbtnDischarge.Click 'assign the selected values from the DropDownList1 to variable regNo regNo = DropDownList1.Text Dim res As Integer = MsgBox("Are you sure you want to discharge " & regNo & " Now", MsgBoxStyle.OkCancel, "Confirmation") 'if the user select ok then call the method dischargeCar otherwise do not select the dischargeCar method If res = 1 Then dischargeCar() MsgBox("Car registration Number " & regNo & " has been successfully Discharged", MsgBoxStyle.OkOnly, "Car Discharged") Else : MsgBox("You have have cancelled the transaction", MsgBoxStyle.OkOnly, "Cancellation") End If End Sub Protected Sub dischargeCar() Dim day As String Dim conn As New OracleConnection() conn.ConnectionString = oradb 'Getting the actual date and time of the system day = Date.Now.ToString Try conn.Open() Dim cmd As New OracleCommand cmd.Connection = conn 'update the table so that the discharge_dateandtime has got a date so that we the car has been discharge cmd.CommandText = "Update car_history1 set discharge_dateandtime = to_date('" & day & "', 'dd/mm/yyyy hh24:mi:ss')where reg_no ='" & regNo & "'" cmd.ExecuteNonQuery() cmd.CommandType = Data.CommandType.Text Catch ex As Exception End Try conn.Close() conn.Dispose() End Sub

112

End Class

Appendix G.10 (Job Account page)


Imports Oracle.DataAccess.Client Partial Class Mechanics_JobAccount Inherits System.Web.UI.Page Public oradb As String = "Data Source = Kavinyan; User ID=project2; password= password;" Public jobNo As String Public status As String Public labour As Integer Public material As Integer Public day As String Public month As String Public year As String Public checkJob_no As String Public checkStatus As String Public text1 As String Public lab As Boolean = False Protected Sub getDate() Dim wholeDate As String Dim dayAndMonth As String Dim dat As String 'getting the date and time from the system and assigning to dat variable dat = Date.Now.ToString 'as the first part of the date and time take only 10 character including the two "/" 'the integer value is always going to be 10 'that's why i have hardcoded it wholeDate = Left$(dat, 10) 'as i want to split the date to get value for day, month and year 'read the first two character from wholedate and assign it to day day = Left$(dat, 2) 'read the last four character from the wholedate and assign it to year year = Right$(wholeDate, 4) 'as month is in the middle of wholeDate 'get the the first five character from the wholeDate first 'assign it to daAndMonth dayAndMonth = Left$(dat, 5) 'then get the last two character from dayAndMonth 'assign it to month month = Right$(dayAndMonth, 2)

113

End Sub Protected Sub checkExistingData() 'This method check whether a job_no exist in a particular month and year Dim conn As New OracleConnection() conn.ConnectionString = oradb Try conn.Open() Dim cmd10 As New OracleCommand cmd10.Connection = conn cmd10.CommandText = "select job_no from Job_account where job_no = '" & jobNo & "' and month = '" & month & "' and year = '" & year & "'" cmd10.CommandType = Data.CommandType.Text Dim dr As OracleDataReader = cmd10.ExecuteReader() dr.Read() checkJob_no = dr.Item("job_no") Catch ex As Exception End Try conn.Close() conn.Dispose() End Sub Protected Sub jobStatus() 'This method will check the status of a job_no for a particular month and year 'and assign it to the checkStatus variable Dim conn As New OracleConnection() conn.ConnectionString = oradb Try conn.Open() Dim cmd As New OracleCommand cmd.Connection = conn cmd.CommandText = "select status from Job_account where job_no = '" & jobNo & "' and month = '" & month & "' and year = '" & year & "'" cmd.CommandType = Data.CommandType.Text Dim dr As OracleDataReader = cmd.ExecuteReader() dr.Read() checkStatus = dr.Item("status") Catch ex As Exception End Try conn.Close() conn.Dispose()

114

End Sub Protected Sub btnSubmit_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSubmit.Click insert() End Sub Protected Sub insert() getDate() jobNo = drpJobNo.Text 'this condition will allow change of status only if the status is not complete 'if it is complete then it will give material and labour cost = 0 If status <> "C" Then status = drpStatus.Text Else txtLabour.Text = 0 txtMaterial.Text = 0 End If labour = Integer.Parse(txtLabour.Text) material = Integer.Parse(txtMaterial.Text) checkExistingData() Dim res As Integer 'if the jobNo not equals to checkJob_no then call insertData method If checkJob_no = jobNo Then 'if the checkJob_no equals to the jobNo you are about to insert 'then the message below will appear MsgBox("Sorry you cannot enter more than one entry per Month for the same Job_No", MsgBoxStyle.Information, "Error") res = MsgBox("Would you like to update the entry for this job_No instead?", MsgBoxStyle.YesNo, "Update Option") 'the system will give another option to update the job_no 'if the user accept it call the UpdateData method else it will clear the text boxes If res = 6 Then UpdateData() MsgBox("Your data has been successfully updated", MsgBoxStyle.Information, "Update") Else txtLabour.Text = "" txtMaterial.Text = "" txtLabour.Focus() lblStatus.Text = "" End If Else insertData() End If End Sub 'this method will update the job_no already exist in a particular month and year Protected Sub UpdateData()

115

Dim conn As New OracleConnection() conn.ConnectionString = oradb conn.Open() Dim cmd As New OracleCommand cmd.Connection = conn cmd.CommandText = "update job_account set labour_this_month =" & labour & ",material_this_month =" & material & ",status ='" & status & "', day='" & day & "' where job_no ='" & jobNo & "' and month = '" & month & "' and year = '" & year & "'" cmd.ExecuteNonQuery() cmd.CommandType = Data.CommandType.Text End Sub 'This method will be call if the job_no does not exist in a particular month and year 'it will insert all the data in the Job_Account table in the database Protected Sub insertData() Dim costEstimate As String Dim conn As New OracleConnection() conn.ConnectionString = oradb costEstimate = drpCostEst.Text Try conn.Open() Dim cmd As New OracleCommand Dim textCommand As String textCommand = "Insert into Job_Account (job_no,day,month,year,cost_estimate_no,labour_this_month,material_this _month,status) values ( :job_no,:day,:month,:year,:CostEstimate,:labour_this_month,:material_th is_month,:status)" cmd.Connection = conn cmd.CommandText = textCommand cmd.Parameters.Add(":job_no", jobNo) cmd.Parameters.Add(":day", day) cmd.Parameters.Add("month", month) cmd.Parameters.Add(":year", year) cmd.Parameters.Add(":CostEstimate", costEstimate) cmd.Parameters.Add(":labour_this_month", labour) cmd.Parameters.Add(":material_this_month", material) cmd.Parameters.Add(":status", status) cmd.ExecuteNonQuery() cmd.CommandType = Data.CommandType.Text MsgBox("Cost for Job No: " & jobNo & " has been entered for this month ", MsgBoxStyle.Information, "Cost for Job No") Catch ex As Exception MsgBox("incorrect data entered" & ex.ToString, MsgBoxStyle.YesNo, "Incorrect Data") End Try conn.Close() conn.Dispose() End Sub

116

Protected Sub btnUpdate_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnUpdate.Click 'this button will allow the user to update data Dim res As Integer Dim res As Integer res = MsgBox("Are you sure you want to update the data", MsgBoxStyle.YesNo, "Update") If res = 6 Then UpdateData() ElseIf res = 7 Then End If End Sub Protected Sub chkShowTable_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles chkShowTable.CheckedChanged 'this is just an option if the user want to see the table If chkShowTable.Checked Then GridAppendix2.Visible = True Else GridAppendix2.Visible = False End If End Sub Protected Sub toUppercase() 'changing the text to uppercase 'as i need all the car registration number to be in uppercase text1 = txtRegNo.Text text1 = text1.ToUpper() txtRegNo.Text = text1 End Sub Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click toUppercase() End Sub Protected Sub Button2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnCheckStatus.Click 'getting the status of the job_no Dim conn As New OracleConnection() Dim conn1 As New OracleConnection jobNo = drpJobNo.Text conn.ConnectionString = oradb 'getting the value of status if it is 'C' Try conn.Open() Dim cmd10 As New OracleCommand cmd10.Connection = conn cmd10.CommandText = "select status from Job_account where job_no = '" & jobNo & "' and status ='C'"

117

cmd10.CommandType = Data.CommandType.Text Dim dr As OracleDataReader = cmd10.ExecuteReader() dr.Read() status = dr.Item("status") Catch ex As Exception End Try conn.Close() conn.Dispose() Try 'if the status = C then it will display complete 'else status will be blank and will go in the if condition conn1.ConnectionString = oradb conn1.Open() If status = "" Then Dim cmd11 As New OracleCommand cmd11.Connection = conn1 cmd11.CommandText = "select status from Job_account where job_no = '" & jobNo & "' and status ='I'" cmd11.CommandType = Data.CommandType.Text Dim dr1 As OracleDataReader = cmd11.ExecuteReader() dr1.Read() status = dr1.Item("status") 'if status is not 'I' then status = 'N' and display "NOT STARTED" If status = "" Then status = "N" lblStatus.Text = "NOT STARTED" Else lblStatus.Text = "INCOMPLETE" End If Else lblStatus.Text = "COMPLETED" End If

Catch ex As Exception End Try conn1.Close() conn1.Dispose() If status = "N" Or status = "I" Then Panel1.Visible = True End If 'if the status is already completed 'user will not have access to the textboxes inorder to enter the amount 'instead the amount will = 0

118

'by using checkStatus will know if the job_no have already a status jobStatus() If checkStatus = "" And status = "C" Then insert() End If End Sub Protected Sub btnNextJob_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnNextJob.Click Panel1.Visible = False txtRegNo.Text = "" lblStatus.Text = "" End Sub End Class

119

Appendix G.11 (New Job Page)


Imports Oracle.DataAccess.Client Partial Class Mechanics_newJob Inherits System.Web.UI.Page Public labourCost As Integer Public MaterialCost As Integer Public description As String = "" Public costEstimateNo As String = "" Public primaryKey As String = "" 'Public Location As String = "" Public maxNum As Integer Public oradb As String = "Data Source = Kavinyan; User ID=project2; password= password;" Protected Sub lbtnInsert_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles lbtnInsert.Click lbtnInsert.Visible = False lbtnNextJob.Visible = True checkTextValue() maxNumber() insertJobDetails() End Sub Protected Sub getPrimaryKey() 'getting the costEstimateNo from the dropDownList drpEstimate 'K will get the position of the last '/' Dim k As Long k = InStrRev(costEstimateNo, "/") 'assign primaryKey with a temporary value depending on the value of k by cutting the costestimate If k > 0 Then primaryKey = Left$(costEstimateNo, k) End Sub Protected Sub maxNumber() getPrimaryKey() Dim conn7 As New OracleConnection() 'Dim regNoCount As Integer conn7.ConnectionString = oradb Try conn7.Open() Dim cmd10 As New OracleCommand cmd10.Connection = conn7 'getting the maximum value of serial_no depending on the Job_no and cost estimate

120

cmd10.CommandText = "select max(serial_no) from car_job where job_no like'" & primaryKey & "%' and cost_estimate_no = '" & costEstimateNo & "'" cmd10.CommandType = Data.CommandType.Text Dim dr As OracleDataReader = cmd10.ExecuteReader() dr.Read() 'assigning maxNum with the result of "max(serial_no)" maxNum = dr.Item("max(serial_no)") Catch ex As Exception End Try conn7.Close() conn7.Dispose() 'adding one to the actual maxNum so that the next primary which is about to be inserted 'can be increase by one maxNum = maxNum + 1 End Sub Protected Sub insertJobDetails() Dim conn As New OracleConnection() conn.ConnectionString = oradb 'concatenating the temporary value of primarykey with the maxNum 'to get a full value for primary key primaryKey = primaryKey & maxNum Try conn.Open() Dim cmd As New OracleCommand Dim textCommand As String 'inserting all the values in the car_job table textCommand = "Insert into car_job (job_no,serial_no,description,Labour_cost,Material_cost,Cost_Estimate_n o) values (:job_no,:serial_no ,:Description,:labour_cost,:Material_cost,:Cost_estimate_no)" cmd.Connection = conn cmd.CommandText = textCommand cmd.Parameters.Add(":job_no", primaryKey) cmd.Parameters.Add(":serial_no", maxNum) cmd.Parameters.Add(":Description", description) cmd.Parameters.Add(":labour_cost", labourCost) cmd.Parameters.Add(":Material_cost", MaterialCost) cmd.Parameters.Add(":Cost_estimate_no", costEstimateNo) cmd.ExecuteNonQuery() cmd.CommandType = Data.CommandType.Text 'display a message when insertion is successfull MsgBox("Job detail has been successfully entered", MsgBoxStyle.Information, "Data Entered") Catch ex As Exception

121

'if any error occurs MsgBox("incorrect data entered" & ex.ToString, MsgBoxStyle.YesNo, "Incorrect Data") End Try conn.Close() conn.Dispose() End Sub Protected Sub checkTextValue() description = txtDescriptionJob.Text Dim labCst As String = txtLabourCost.Text Dim MtrlCst As String = txtMaterialCost.Text costEstimateNo = drpEstimate.Text 'converting the value from the textboxes to integer MaterialCost = Integer.Parse(MtrlCst) labourCost = Integer.Parse(labCst) End Sub Protected Sub lbtnNextJob_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles lbtnNextJob.Click txtDescriptionJob.Text = "" txtLabourCost.Text = "" txtMaterialCost.Text = "" lbtnInsert.Visible = True lbtnNextJob.Visible = False End Sub End Class

122

Appendix G.12 (New Staff page)


Imports Oracle.DataAccess.Client Partial Class Administrator_NewStaff Inherits System.Web.UI.Page 'i have declare oradb as public so that i will not need to type it every time Public oradb As String = "Data Source = Kavinyan; User ID=project2; password= password;" Public jobid As String = "" Public jobtitle As String = "" Protected Sub btnInsertStaff_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnInsertStaff.Click btnNext.Visible = True btnInsertStaff.Visible = False 'if the textbox name is left blank a message should appear and focus on the textbox If txtName.Text = "" Then MsgBox("You need to enter the name", MsgBoxStyle.Exclamation, "Name needed") txtName.Focus() btnInsertStaff.Visible = True btnNext.Visible = False End If 'if the textbox password is left blank another message should appear and focus on the textbox If txtPassword.Text = "" Then Dim res As Integer = MsgBox("You have left the password null, Do you need a password for this staff? ", MsgBoxStyle.YesNo, "Password Option") If res = 6 Then txtPassword.Focus() End If End If 'if all the required data is entered then call myInsert method myInsert() End Sub Protected Sub myInsert() Dim userId As String = txtStaffId.Text Dim name As String = txtName.Text Dim password As String = txtPassword.Text Dim locationList As String = DropDownList1.SelectedValue Dim conn As New OracleConnection() conn.ConnectionString = oradb

123

Try conn.Open() Dim cmd As New OracleCommand cmd.Connection = conn cmd.CommandText = "insert into staff (Staff_id, name,password,location_no) values (:staff_id,:name,:password,:location_id)" 'passing the values to the sql statement cmd.Parameters.Add(":staff_id", userId) cmd.Parameters.Add(":name", name) cmd.Parameters.Add(":password", password) cmd.Parameters.Add(":location_id", locationList) 'execute the statement cmd.ExecuteNonQuery() cmd.CommandType = Data.CommandType.Text 'call the getJobtitle of the user getJobTitle() 'this message will display the name of the user andhis job title MsgBox("You have successfully entered " & name & " as " & jobtitle, MsgBoxStyle.Information, "New staff") Catch ex As Exception End Try conn.Close() conn.Dispose() End Sub 'get the job title Protected Sub getJobTitle() Dim conn As New OracleConnection() conn.ConnectionString = oradb 'get the selected value from the drop down list and pass it to the variable jobid jobid = DropDownList2.SelectedValue Try conn.Open() Dim cmd As New OracleCommand cmd.Connection = conn cmd.CommandText = "select job_title from job where job_id = '" & jobid & "'" Dim dr As OracleDataReader = cmd.ExecuteReader() dr.Read() jobtitle = dr.Item("job_title") Catch ex As Exception End Try conn.Close() conn.Dispose() End Sub 'search if user id exist or not Protected Sub btnSearch_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSearch.Click Dim staff As String = "" Dim conn As New OracleConnection() conn.ConnectionString = oradb

124

Try conn.Open() Dim cmd As New OracleCommand cmd.Connection = conn cmd.CommandText = "select staff_id from staff where staff_id ='" & txtStaffId.Text & "'" Dim dr As OracleDataReader = cmd.ExecuteReader() dr.Read() staff = dr.Item("staff_id") Catch ex As Exception 'if the userid does not exist then all the options will appear to insert details about a staff MsgBox("This userId is valid and can be used", MsgBoxStyle.Information, "Unique UserId") btnInsertStaff.Visible = True txtName.Visible = True txtPassword.Visible = True DropDownList1.Visible = True DropDownList2.Visible = True btnSearch.Visible = False End Try 'if the userid is already taken by somebody then it display a message to prompt the user to type another one 'and clear the user id text box If staff = txtStaffId.Text Then MsgBox("UserId Already exist, please type another one", MsgBoxStyle.Information, "Staff_ID") txtStaffId.Text = "" End If conn.Close() conn.Dispose() End Sub Protected Sub btnNext_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnNext.Click 'call the notVisible method notVisible() End Sub Protected Sub btnCancel_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnCancel.Click btnInsertStaff.Visible = False 'call the notVisible method notVisible() End Sub Protected Sub notVisible() btnSearch.Visible = True txtStaffId.Text = "" btnNext.Visible = False txtName.Visible = False

125

txtPassword.Visible = False DropDownList1.Visible = False DropDownList2.Visible = False End Sub End Class

Appendix G.13 (Reset Password Page)


Imports Oracle.DataAccess.Client Partial Class Administrator_ResetPassword Inherits System.Web.UI.Page Public oradb As String = "Data Source = Kavinyan; User ID=project2; password= password;" Protected Sub btnResetPassword_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnResetPassword.Click 'check if textbox is blank If lblUserId.Text = "" Then MsgBox("Please select a name from the list First", MsgBoxStyle.Information, "Select name") btnResetPassword.Visible = True Else btnResetPassword.Visible = False 'allowing both textboxes for password to be visible in panel1 Panel1.Visible = True End If End Sub Protected Sub btnReset_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnReset.Click Panel1.Visible = False btnResetPassword.Visible = True If txtNewPass.Text = txtConfirmPass.Text Then 'call the updatePassword method updatePassword() MsgBox("Password has been succesfully changed", MsgBoxStyle.Information, "Password changed") Else 'in case an error occurs while typing MsgBox("Please check the password has been typed correctly", MsgBoxStyle.Exclamation, "Error in Password ") txtNewPass.Text = "" txtConfirmPass.Text = "" Panel1.Visible = True End If End Sub Protected Sub updatePassword() Dim userId As String = lblUserId.Text Dim password As String = txtConfirmPass.Text Dim conn As New OracleConnection() conn.ConnectionString = oradb Try conn.Open()

126

Dim cmd As New OracleCommand cmd.Connection = conn 'update the new password in the database cmd.CommandText = "update staff set password = '" & password & "' where staff_id = '" & userId & "'" cmd.ExecuteNonQuery() cmd.CommandType = Data.CommandType.Text Catch ex As Exception End Try conn.Close() conn.Dispose() End Sub Protected Sub DropDownList1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles DropDownList1.SelectedIndexChanged 'getting all the staff name from the drop down list and display the value in the label lblUserId.Text = DropDownList1.SelectedValue End Sub End Class

127

Appendix H (Populating the table in the database)

Insert into location values('l001','Head Office','LionFord road','Lionford','Lw3 7qw'); Insert into location values('A','Workshop A','Hampton court road','Catham','CN1 35H'); Insert into location values('B','Workshop B','Lion road','Panthercester','P2 4SR');

Insert into staff values ('s001','Paul Dixon','1234','l001'); Insert into staff values ('s002','Thomas Grey','1111','A'); Insert into staff values ('s003','Vincent Grimlin','1111','B'); Insert into staff values ('s004','ken Digan','1212','A'); Insert into staff values ('s005','hevlyn Thesmian','1212','A'); Insert into staff values ('s006','Richard Bramton','1212','A'); Insert into staff values ('s007','Ricardo Rafaelle','1313','B'); Insert into staff values ('s008','kelly Thomas','1313','B'); Insert into staff values ('s009','Margarrete King','1313','B'); Insert into staff values ('s010','Dillon Hince','1212','A'); Insert into staff values ('s011','Beatrice Seenan','1313','B');

Insert into Job values ('J001','Administrator'); Insert into Job values ('J002','Worshop manager'); Insert into Job values ('J003','Mechanics'); Insert into Job values ('J004','secretery'); Insert into Job values ('J005','Head Office');
128

Insert into Role values ('J001','s001'); Insert into Role values ('J002','s002'); Insert into Role values ('J003','s002'); Insert into Role values ('J002','s003'); Insert into Role values ('J003','s003'); Insert into Role values ('J003','s004'); Insert into Role values ('J003','s005'); Insert into Role values ('J003','s006'); Insert into Role values ('J003','s007'); Insert into Role values ('J003','s008'); Insert into Role values ('J003','s009'); Insert into Role values ('J004','s010'); Insert into Role values ('J004','s011');

Insert into Customer (name, street_address, town,post_code,tel_no) values ('Peter McLaven','22, Northenden lane', 'Hayes', 'UB6 42T','02082342234'); Insert into Customer (name, street_address, town,post_code,tel_no) values ('Richard Lynch','41, Grange road','Hayes','UB6 45S','02081218736'); Insert into Customer (name, street_address, town,post_code,tel_no) values ('Bradley Willson','67, Hillingdon road','Ealing','W5 2AH','02083847263'); Insert into Customer (name, street_address, town,post_code,tel_no) values ('Steve Baker','32, Hillcroft Creasent','Ealing','W5 2DF','02083458374'); Insert into Customer (name, street_address, town,post_code,tel_no) values ('Ben Sherman','54, Foxton Avenue','Ealing','W45 3AS','02087746562');

Insert into Model values ('XK 120','classic');


129

Insert into Model values ('XK 140','familly'); Insert into Model values ('XK 150','sport'); Insert into Model values ('MARK VII','hatchback'); Insert into Model values ('MARK VIII','familly'); Insert into Model values ('MARK 1X','sport'); Insert into Model values ('XJS 1000','saloon'); Insert into Model values ('XJS 1200','sport'); Insert into Model values ('XJS 1500','familly');

Insert into Car values ('P123FAN','1000cc','xac1234','XK 120'); Insert into Car values ('F917CDF','1000cc','wert42f','MARK VII');

Insert into Car values ('AW45','2000cc','asdlk2345gd','XJS 1500'); Insert into Car values ('DF876','3000cc','e21345vjh5','XJS 1200'); Insert into Car values ('BH421','2000cc','asdf3456','XK 120'); Insert into Car values ('DR546Y','2500cc','sdf4567g2e34','MARK VIII'); Insert into Car values ('GF453FR','1500cc','sd98gh3','XJS 1000'); Insert into Car values ('YR434SE','4000cc','kert87123f3de','MARK 1X'); Insert into Car values ('KN98TT','2000cc','dck339876bv','XK 140'); Insert into Car values ('N675FR','3000cc','wer231hy','XJS 1200'); Insert into Car values ('H67CF','2500cc','sdfg456','MARK VIII'); Insert into Car values ('NT86DH','2500cc','sdfg3456fed','MARK VIII'); Insert into Car values ('BT452XNX','2000cc','hg987vkmjh','XJS 1500'); Insert into Car values ('YR785DD','1000cc','mnhgfds5678','XK 120');
130

Insert into Car values ('G456TYN','2000cc','hg56ytf65','MARK VII'); Insert into Car values ('HR98WSR','2000cc','kjhgf4567','MARK VIII');

//the reason why i need lots of data is because the system run according to the actual time and date //so it pick up the date from the system and there is no way that you can insert a previous date through the interface

//intentionally i did not admit any car in workshop A for year 2009 //As i want to show the behavior of cost estimate number and job number when changing from one year to another

Insert into Car_History1 values ('A/1/08',1,to_timestamp('2008-01-04 12:21:00','YYYYMM-DD HH24:MI:SS'),'P123FAN',to_timestamp('2008-01-04 12:21:00','YYYY-MMDD HH24:MI:SS'),to_timestamp('2008-03-19 12:21:00','YYYY-MM-DD HH24:MI:SS'),'need a full service',123534,1,'s005','A'); Insert into Car_History1 values ('A/2/08',2,to_timestamp('2008-02-22 10:45:00','YYYYMM-DD HH24:MI:SS'),'F917CDF',to_timestamp('2008-02-22 12:21:00','YYYY-MMDD HH24:MI:SS'),to_timestamp('2008-05-01 12:21:00','YYYY-MM-DD HH24:MI:SS'),'electrical work ',23455,2,'s004','A'); Insert into Car_History1 values ('A/3/08',3,to_timestamp('2008-03-25 16:22:02','YYYYMM-DD HH24:MI:SS'),'YR434SE',to_timestamp('2008-04-21 12:21:00','YYYY-MMDD HH24:MI:SS'),to_timestamp('2008-07-21 12:21:00','YYYY-MM-DD HH24:MI:SS'),'engine problem',76543,3,'s002','A'); Insert into Car_History1 values ('A/4/08',4,to_timestamp('2008-05-12 13:21:00','YYYYMM-DD HH24:MI:SS'),'GF453FR',,,'full servicing to do',098745,4,'s002','A'); Insert into Car_History1 values ('A/5/08',5,to_timestamp('2008-07-16 14:38:00','YYYYMM-DD HH24:MI:SS'),'GF453FR',to_timestamp('2008-09-21 12:21:00','YYYY-MMDD HH24:MI:SS'),,'Engine problem',34576,4,'s004','A');

131

Insert into Car_History1 values ('A/6/08',6,to_timestamp('2008-08-25 16:22:00','YYYYMM-DD HH24:MI:SS'),'AW45',to_timestamp('2008-09-21 12:21:00','YYYY-MM-DD HH24:MI:SS'),,'Mot',345687,2,'s006','A'); Insert into Car_History1 values ('A/7/08',7,to_timestamp('2008-08-24 18:19:00','YYYYMM-DD HH24:MI:SS'),'BT452XNX',to_timestamp('2008-11-21 12:21:00','YYYYMM-DD HH24:MI:SS'),,'Mot',057356,3,'s005','A'); Insert into Car_History1 values ('A/8/08',8,to_timestamp('2008-08-09 11:13:00','YYYYMM-DD HH24:MI:SS'),'G456TYN',to_timestamp('2008-12-21 12:21:00','YYYY-MMDD HH24:MI:SS'),,'Exhaust',32446,5,'s004','A'); Insert into Car_History1 values ('A/9/08',9,to_timestamp('2008-09-16 13:23:00','YYYYMM-DD HH24:MI:SS'),'DF876',to_timestamp('2008-12-21 15:13:00','YYYY-MM-DD HH24:MI:SS'),,'electrical work',85645,2,'s002','A'); Insert into Car_History1 values ('A/10/08',10,to_timestamp('2008-09-25 12:29:00','YYYY-MM-DD HH24:MI:SS'),'NT86DH',to_timestamp('2008-11-21 12:21:00','YYYY-MM-DD HH24:MI:SS'),,'Radiator problem',465677,1,'s004','A'); Insert into Car_History1 values ('A/11/08',11,to_timestamp('2008-09-16 11:23:00','YYYY-MM-DD HH24:MI:SS'),'DR546Y',to_timestamp('2008-09-17 13:19:00','YYYY-MM-DD HH24:MI:SS'),,'engine problem',887656,2,'s006','A'); Insert into Car_History1 values ('A/12/08',12,to_timestamp('2008-11-27 14:24:00','YYYY-MM-DD HH24:MI:SS'),'KN98TT',to_timestamp('2008-12-21 14:22:00','YYYY-MM-DD HH24:MI:SS'),,'Mot',345674,4,'s005','A'); Insert into Car_History1 values ('A/13/08',13,to_timestamp('2009-11-15 14:24:00','YYYY-MM-DD HH24:MI:SS'),'F917CDF',to_timestamp('2008-12-28 12:21:00','YYYY-MM-DD HH24:MI:SS'),,'Wheel balaning needed with MoT',25901,4,'s005','A');

//for the sake of demonstration some of the cost estimate number will not have car job and Job_Account

//P123FAN// Insert into Car_Job values ('A/1/1',1,'need full service ',70,90,'A/1/08'); Insert into Car_Job values ('A/1/2',2,'New break pad ',35,20,'A/1/08');
132

Insert into Car_Job values ('A/1/3',3,'Repair exhaust ',35,70,'A/1/08'); //F917CDF// Insert into Car_Job values ('A/2/1',1,'need full service ',70,90,'A/2/08'); Insert into Car_Job values ('A/2/2',2,'change four tyres ',20,500,'A/2/08'); Insert into Car_Job values ('A/2/3',3,'Repair lights ',100,250,'A/2/08'); Insert into Car_Job values ('A/2/4',4,'Repair wheel ',60,100,'A/2/08'); Insert into Car_Job values ('A/2/5',5,'repair door ',10,20,'A/2/08'); //YR434SE// Insert into Car_job values ('A/3/1',1,'catalyst converter need change',60,120,'A/3/08')

//GF453FR// Insert into Car_job values ('A/5/1',1,'catalyst convertor need change',25,45,'A/5/08')

//AW45// Insert into Car_job values ('A/6/1',1,'Engine problem',75,120,'A/6/08')

//BT452XNX// Insert into Car_job values ('A/7/1',1,'Engine problem',30,90,'A/7/08')

//G456TYN// Insert into Car_job values ('A/8/1',1,'Engine problem',40,80,'A/8/08')

//DF876// Insert into Car_job values ('A/9/1',1,'Engine problem',35,135,'A/9/08')


133

//NT86DH//

Insert into Car_job values ('A/10/1',1,'Engine Problem',45,95,'A/10/08')

//DR546Y//

Insert into Car_job values ('A/11/1',1,'catalyst convertor need change',65,185,'A/11/08')

//KN98TT// Insert into Car_job values ('A/12/1',1,'MOT',65,120,'A/12/08') Insert into Car_job values ('A/12/2',2,'Repair Disk brakes',80,165,'A/12/08') Insert into Car_job values ('A/12/3',3,'Body work rear bumper',80,110,'A/12/08')

//F917CDF// Insert into Car_job values ('A/13/1',1,'Wheel Balancing',60,120,'A/13/08') Insert into Car_job values ('A/13/2',2,'Change four new tyres',60,210,'A/13/08') Insert into Car_job values ('A/13/3',3,'Electronic Window both front',80,180,'A/13/08')

Insert into Job_Account values ('A/1/1','28','01','2008','A/1/08',20,10,'I'); Insert into Job_Account values ('A/1/2','28','01','2008','A/1/08',0,0,'N'); Insert into Job_Account values ('A/1/3','28','01','2008','A/1/08',50,60,'C');

134

Insert into Job_Account values ('A/1/1','26','02','2008','A/1/08',30,40,'C'); Insert into Job_Account values ('A/1/2','26','02','2008','A/1/08',10,10,'I'); Insert into Job_Account values ('A/1/3','26','02','2008','A/1/08',0,0,'C');

Insert into Job_Account values ('A/1/1','19','03','2008','A/1/08',0,0,'C'); Insert into Job_Account values ('A/1/2','19','03','2008','A/1/08',25,10,'C'); Insert into Job_Account values ('A/1/3','19','03','2008','A/1/08',0,0,'C');

//next cost estimate

Insert into Job_Account values ('A/2/1','22','02','2008','A/2/08',10,20,'I'); Insert into Job_Account values ('A/2/1','12','03','2008','A/2/08',40,60,'I'); Insert into Job_Account values ('A/2/1','30','04','2008','A/2/08',20,30,'C');

Insert into Job_Account values ('A/2/2','28','02','2008','A/2/08',0,0','N'); Insert into Job_Account values ('A/2/2','15','03','2008','A/2/08',10,250,'I'); Insert into Job_Account values ('A/2/2','23','04','2008','A/2/08',10,250,'C');

Insert into Job_Account values ('A/2/3','10','02','2008','A/2/08',20,40,'I'); Insert into Job_Account values ('A/2/3','15','03','2008','A/2/08',30,50,'I'); Insert into Job_Account values ('A/2/3','10','04','2008','A/2/08',50,150,'C');

Insert into Job_Account values ('A/2/4','28','02','2008','A/2/08',0,0,'N'); Insert into Job_Account values ('A/2/4','16','03','2008','A/2/08',60,100,'C'); Insert into Job_Account values ('A/2/4','30','04','2008','A/2/08',0,0,'C');
135

Insert into Job_Account values ('A/2/5','28','02','2008','A/2/08',0,0,'N'); Insert into Job_Account values ('A/2/5','25','03','2008','A/2/08',10,20,'C'); Insert into Job_Account values ('A/2/5','30','04','2008','A/2/08',0,0,'C');

//next cost estimate Insert into Job_Account values ('A/3/1','13','05','2008','A/2/08',20,30,'I'); Insert into Job_Account values ('A/3/1','28','06','2008','A/2/08',0,0,'I'); Insert into Job_Account values ('A/3/1','21','07','2008','A/2/08',40,110,'C');

//next cost estimate Insert into Job_Account values ('A/12/1','26','01','2009','A/12/08',0,0,'N'); Insert into Job_Account values ('A/12/2','26','01','2009','A/12/08',0,0,'N'); Insert into Job_Account values ('A/12/3','26','01','2009','A/12/08',0,0,'N');

Insert into Job_Account values ('A/12/1','28','02','2009','A/12/08',0,0,'N'); Insert into Job_Account values ('A/12/2','28','02','2009','A/12/08',10,15,'I'); Insert into Job_Account values ('A/12/3','28','02','2009','A/12/08',0,0,'N');

Insert into Job_Account values ('A/12/1','27','03','2009','A/12/08',10,25,'I'); Insert into Job_Account values ('A/12/2','26','03','2009','A/12/08',11,25,'I'); Insert into Job_Account values ('A/12/3','29','03','2009','A/12/08',24,23,'I');

Insert into Job_Account values ('A/12/1','28','04','2009','A/12/08',13,53,'C'); Insert into Job_Account values ('A/12/2','26','04','2009','A/12/08',10,12,'I');
136

Insert into Job_Account values ('A/12/3','27','04','2009','A/12/08',10,10,'I');

Insert into Job_Account values ('A/12/1','26','05','2009','A/12/08',0,0,'C'); Insert into Job_Account values ('A/12/2','25','05','2009','A/12/08',25,10,'I'); Insert into Job_Account values ('A/12/3','29','05','2009','A/12/08',23,18,'I');

Insert into Job_Account values ('A/12/1','28','06','2009','A/12/08',0,0,'C'); Insert into Job_Account values ('A/12/2','26','06','2009','A/12/08',10,12,'I'); Insert into Job_Account values ('A/12/3','29','06','2009','A/12/08',0,0,'I');

Insert into Job_Account values ('A/12/1','28','07','2009','A/12/08',0,0,'C'); Insert into Job_Account values ('A/12/2','27','07','2009','A/12/08',10,12,'I'); Insert into Job_Account values ('A/12/3','30','07','2009','A/12/08',10,5,'I');

Insert into Job_Account values ('A/13/1','25','01','2009','A/13/08',0,0,'N'); Insert into Job_Account values ('A/13/2','24','01','2009','A/13/08',10,22,'I'); Insert into Job_Account values ('A/13/3','27','01','2009','A/13/08',15,10,'I');

Insert into Job_Account values ('A/13/1','23','02','2009','A/13/08',12,32,'I'); Insert into Job_Account values ('A/13/2','29','02','2009','A/13/08',10,5,'I'); Insert into Job_Account values ('A/13/3','28','02','2009','A/13/08',10,21,'I');

Insert into Job_Account values ('A/13/1','26','03','2009','A/13/08',20,11,'I'); Insert into Job_Account values ('A/13/2','29','03','2009','A/13/08',30,40,'C'); Insert into Job_Account values ('A/13/3','30','03','2009','A/13/08',10,23,'I');
137

Insert into Job_Account values ('A/13/1','28','04','2009','A/13/08',12,13,'I'); Insert into Job_Account values ('A/13/2','29','04','2009','A/13/08',0,0,'C'); Insert into Job_Account values ('A/13/3','26','04','2009','A/13/08',10,10,'I');

Insert into Job_Account values ('A/13/1','28','05','2009','A/13/08',15,20,'I'); Insert into Job_Account values ('A/13/2','29','05','2009','A/13/08',0,0,'C'); Insert into Job_Account values ('A/13/3','28','05','2009','A/13/08',30,40,'C');

Insert into Job_Account values ('A/13/1','25','06','2009','A/13/08',18,20,'I'); Insert into Job_Account values ('A/13/2','19','06','2009','A/13/08',0,0,'C'); Insert into Job_Account values ('A/13/3','23','06','2009','A/13/08',0,0,'C');

Insert into Job_Account values ('A/13/1','30','07','2009','A/13/08',10,10,'I'); Insert into Job_Account values ('A/13/2','29','07','2009','A/13/08',0,0,'C'); Insert into Job_Account values ('A/13/3','28','07','2009','A/13/08',0,0,'C');

138

139

140

141

Demonstration Script
Stage 1 Creating the database in Oracle 10g with Username = Project2 and password = password and tick appropriate checkboxes in the User Privileges as in Picture DS1.

Type in password for the password

Picture DS1 Stage 2 Create all the tables, Trigger, Sequence and View in the same order as it is in Appendix F. Stage 3 Insert all the data in the same order as it is in Appendix H

142

Stage 4 Open Microsoft Visual Web Developer 2008, select website and Start Options from the menu as shown below.

Select Specific page and browse for Login1.aspx and Click Apply and Ok so that it make the default page Login1.

143

Stage 5 In the coding for files with extension (.aspx.vb) you will see that all the Data Source has been changed to LocalHost where previously it was as in the coding below where I could test my interface in a network where my database and application is sitting in two different computers. This change to localhost has been done purposely as when you are going to create your database in any PC it will work fine. But if you want the database to be sitting in different place then you will need to give the Data Source the name of that computer where you are creating the database like in the coding below.

Stage 6 Run the application. If you want to login as a Workshop manager user id = s002 or user id = s003 and for both the password is 1111 AS a mechanics user id will user id = s004 and password = 1212 As an administrator user id = s001 and password = 1234 Another option is to login as an administrator and create a new staff and give the privilege and login as the new staff.

144

You might also like