You are on page 1of 54

Project In Database Management System

CAR RENTAL SYSTEM DOCUMENTATION

Submitted By: eric sang

Submitted To: isteducation

Car Rental System Analysis

A Car company rents a car. Car (Plate_no, Car_Name, Color, Speed, and rental) is identified by its Car_Id rents by a customer. Customer (Lastname, Firstname, Birthdate, Telephone_no, Cellphone_no and Address) is identified by a Cus_Id processed the transaction by the employee. Employee (Lastname, Firstname, Address, Position, Telephone_no, Cellphone_no and Birthdate) is identified by its Emp_Id.

Whenever a customer rents a car date_rented, amount, deposit and the no_of_days are kept. In returning the car the date_returned, date_rented and the who processed the transaction are recorded.

OVERVIEW OF THE FUNCTIONALITIES


This System will facilitate the functioning of a "typical" Rental Car store. Each type of car should have a different rental fee per day. Rental fee depends on number of day, brand and how fast the car runs. The system should have the following functionalities: Rent: The system equipped to answer Customer's inquiries about the availability and rental fee of various "types" of cars for certain dates in the future. When the customer makes a decision about the "Type" of car and the Dates, the system should be able to "Reserve" or "Earmark" the requested type of car for requested dates. The customer should be given a "Confirmation Number". Pick Up: The system process a Car Pick Up. Customer walks in and supplies either the confirmation number, or name. The system should pull up all the reservation information about this customer. The customer is then asked to supply a drivers license. Return: The system process a return. The system should record the date, time and processed by Depending on these parameters, the system calculate the final rental amount.

Name: Cabunot, Joana Marie Z. Address: San Roque, Z.C Birthday: November 5, 1989 Work Assigned: System Analyst (is responsible for researching, planning, coordinating and recommending software and system choices to meet an organization's business requirements) Contribution: bond papers, folder, venue, food, and latop

Name: Lubrico, Janen A. Address: San Roque, Z.C Birthday: July 9, 1990 Work Assigned: Programmer (who writes the code of this system.) Contribution: food, fare rate, and water

Name: Magallanes, Mary Cris G. Address: Baliwasan Z.C Birthday: December 25, 1990 Work Assigned: Error Corrector and detector (has great practical importance in maintaining data (information) integrity across noisy channels and less-than-reliable storage media.) Contribution: food ,venue, and fare rate

Name: Nahudan, Eiman S. Address: San Roque, Z.C Birthday: March 18, 1989

Work Assigned: System Designer (who designs the UI of the system.) Contribution: printing, free internet, food, and venue

CAR RENTAL SYSTEM ERD


N N

Cus_Id Deposit Date_rent No_of_days Amount Car_Id* Cus_Id* N N Lastname Firstname Birthdate Telephone_No Address N N Date_rented Date_returned Processed_By Car_Id * Cus_Id*

Car_Id Plate_no Car_name Brand Color Speed Rental

Car_Id* Emp_Id 1 Emp_Id Lastname

Firstname Address Position Birthdate Telephone_no Cellphone_no

CAR RENTAL SYSTEM TABLES


Car able
Car_Id Plate_no 1 KBA 900 2 KBC 567 3 KAY 123 4 KAY 435 5 KBP 123 Brand CRV RANGER TOYOTA adventure Color RED Speed 230 mph 200 300 300 500 1000 Rental 1 1 1 1 1 Status

BLUE 300 mph BLACK 250mph blue 550mph

HONDA CIVIC GREY 300 mph

Customer table
Cus_Id Lastname Firstname 1 Chep 2 Bacus 3 Colum 4 Asis 5 Aby 6 Guban Mercy Ricky Rany Shiella Carlo Jane Address EMBA westy Lroad Pland kplace nw Telephone_no 584641976 56624 65378 992 9919191 9912345 Cellphone_no 4545485 776 5464563 0918 0919 0905123456 Birthdate 12/25/1980 10/6/2008 9/30/2008 10/6/2008 3/18/1989 9/29/2008

Employee table
Emp_Id Lastname Firstname Address Telephone_no cellphone_no Birthdate Date_hired MyPosition JANEN FDGHDF 756765765 TWTWT 4545 5475456 4545 90512345 10/14/2008 10/6/2008 Cashier 9/30/2008 10/6/2008 12:00:00 cashier AM 12:00:00 manager AM 1 LUBRICO

2 TWIEUTIWRUT TIRUTIR 3 DACAY

SHEENAMAE TABUK 993

Employee table
Emp_Id Lastname Firstname Address Telephone_no cellphone_no Birthdate Date_hired MyPosition HAZEL CHCO 993 9076543221 10/22/2008 12:00:00 cashier AM 4 PANDAY

renttable
Car_Id Cus_Id Date_Rented No_of_days 1 2 10/15/2008 2 Amount 1500 Deposit 1500 2 Status

returntable
Lastname Firstname Plate_No Carname Magallanes Marycris QQQ 123 CRV Date_Rented 10/05/2008 Date_Returned 10/07/2008 Janen Process_by

CAR RENTAL SYSTEM USER INTERFACE

FORM USER AUTHENTICATION

FORM CARRENTAL

If you click Customer Profile, Customer Table will appear.

If you click new command Customer Entity form will appear.

Whenever you did not fill up the required information, this dialog box will appear.

When a record is successfully saved, this dialog box will appear.

When you click Edit command, this form will appear.

When a record is successfully updated, this dialog box will appear.

When we click the Search command, this form will appear.

A message box will appear if you want to continue to delete a record.

When a record is successfully deleted, this dialog box will appear.

If you click Employee Profile, Employee Table will appear.

If you click new command Employee Entity form will appear.

Whenever you did not fill up the required information, this dialog box will appear.

When a record is successfully dialog box will appear.

saved,

this

When you click Edit command, this form will appear.

When a record is successfully updated, this dialog box will appear.

When we click the Search command, this form will appear.

A message box will appear if you want to continue to delete a record.

When a record is successfully deleted, this dialog box will appear.

This form will appear whenever theres a transaction made or when you click the transaction menu bar.

Whenever theres a new transactions made, this form will appear.

Whenever you did not fill up the required information, this dialog box will appear.

When you click the transaction details at the menu bar, this form will appear.

CAR RENTAL SYSTEM CODES


FRMCARRENTAL Private Sub car_rent_Click() frmrenttbl.Show End Sub Private Sub logoutsub_Click() Unload Me frmlogin.Show End Sub

Private Sub mnucustomerprofile_Click() frmcustbl.Show End Sub

Private Sub mnuemployeeprofile_Click() frmemptbl.Show End Sub

Private Sub mnusearch_Click() 'frmsearch.Show End Sub

Private Sub mnutransaction_Click() 'frmrent.Show End Sub

Private Sub quitsub_Click() End End Sub

Private Sub retcars_Click() frmreturntbl.Show End Sub

FRMCUSTBL

Private Sub Command1_Click() cust_opt = 1

frmnewcust.Show (1) End Sub

Private Sub Command2_Click() Dim did

did = DataGrid1.Columns(0).Text If Not did = "" Then custid = did cust_opt = 2 frmnewcust.cmd_save.Caption = "Update" frmnewcust.Show (1) End If

End Sub

Private Sub Command3_Click() Dim pr

Call connectme conn.Open

pr = InputBox("Please Enter Any Key to Search!" & Chr(10) & Chr(13) & "CUS ID/LASTNAME/FIRSTNAME", "Searching...") If pr = "" Then

ElseIf Val(pr) >= 1 Then

query = "SELECT * FROM customertable WHERE Cus_Id=" & pr rs.Open query, conn

Set DataGrid1.DataSource = rs

ElseIf pr = "All" Or pr = "all" Then query = "SELECT * FROM customertable ORDER BY Lastname" rs.Open query, conn Set DataGrid1.DataSource = rs

Else query = "SELECT * FROM customertable WHERE Lastname LIKE '" & pr & "%' or Firstname LIKE '" & pr & "%' ORDER BY Lastname" rs.Open query, conn Set DataGrid1.DataSource = rs

End If

End Sub

Private Sub Command4_Click() Dim confirm Dim did

did = DataGrid1.Columns(0).Text

If Not did = "" Then confirm = MsgBox("This will delete the selected Record!..proceed anyway!", vbOKCancel + vbExclamation, "Warning!") If confirm = vbOK Then Call connectme conn.Open conn.Execute "DELETE FROM customertable WHERE Cus_Id=" & did

MsgBox "The Record was successfully Deleted!", vbInformation conn.Close Call myquery End If Else MsgBox "There are no records to delete!", vbCritical End If End Sub

Private Sub Command5_Click() Unload Me End Sub

Private Sub Form_Load()

Call myquery

''************ USER LEVEL

If userlevel = 3 Then Command1.Enabled = False Command2.Enabled = False Command4.Enabled = False Else Command1.Enabled = True Command2.Enabled = True Command4.Enabled = True End If

End Sub

Public Sub myquery() Call connectme conn.Open

query = "SELECT * FROM customertable ORDER BY Cus_Id desc" rs.Open query, conn Set DataGrid1.DataSource = rs

If Not rs.EOF Then rs.MoveLast reccnt.Caption = rs.RecordCount Else reccnt.Caption = 0 End If Call datgrid DataGrid1.MarqueeStyle = 3 End Sub

Public Sub datgrid() DataGrid1.Font.Size = 11 DataGrid1.Font.Name = "Arial" DataGrid1.HeadFont.Size = 11 DataGrid1.HeadFont.Bold = True DataGrid1.HeadFont.Name = "Arial" DataGrid1.Columns(0).Caption = "Cust ID" DataGrid1.Columns(0).Width = 1000 DataGrid1.Columns(1).Width = 3200

DataGrid1.Columns(2).Width = 3200 DataGrid1.Columns(3).Caption = "Telephone No." DataGrid1.Columns(3).Width = 1700 DataGrid1.Columns(4).Caption = "CellPhone No." DataGrid1.Columns(4).Width = 1600

End Sub

FRMEMPTBL

Private Sub Command1_Click() emp_opt = 1 frmnewemp.Show (1) End Sub

Private Sub Command2_Click() Dim did

did = DataGrid1.Columns(0).Text If Not did = "" Then empid = did emp_opt = 2 frmnewemp.cmd_save.Caption = "Update" frmnewemp.Show (1) End If

End Sub

Private Sub Command3_Click() Dim pr

Call connectme conn.Open

pr = InputBox("Please Enter Any Key to Search!" & Chr(10) & Chr(13) & "EMP ID/LASTNAME/FIRSTNAME", "Searching...") If pr = "" Then

ElseIf Val(pr) >= 1 Then

query = "SELECT * FROM employeetable WHERE Emp_Id=" & pr rs.Open query, conn Set DataGrid1.DataSource = rs

ElseIf pr = "All" Or pr = "all" Then query = "SELECT * FROM employeetable ORDER BY Lastname" rs.Open query, conn Set DataGrid1.DataSource = rs

Else query = "SELECT * FROM employeetable WHERE Lastname LIKE '" & pr & "%' or Firstname LIKE '" & pr & "%' ORDER BY Lastname" rs.Open query, conn Set DataGrid1.DataSource = rs

End If

End Sub

Private Sub Command4_Click() Dim confirm Dim did

did = DataGrid1.Columns(0).Text

If Not did = "" Then confirm = MsgBox("This will delete the selected Record!..proceed anyway!", vbOKCancel + vbExclamation, "Warning!") If confirm = vbOK Then Call connectme conn.Open conn.Execute "DELETE FROM employeetable WHERE Emp_id=" & did MsgBox "The Record was successfully Deleted!", vbInformation conn.Close Call myquery End If Else MsgBox "There are no records to delete!", vbCritical End If End Sub

Private Sub Command5_Click() Unload Me End Sub

Private Sub Form_Load()

Call myquery

''************ USER LEVEL

If userlevel = 1 Then Command1.Enabled = True Command2.Enabled = True Command4.Enabled = True

Else Command1.Enabled = False Command2.Enabled = False Command4.Enabled = False End If

End Sub

Public Sub myquery()

Call connectme

conn.Open

query = "SELECT * FROM employeetable ORDER BY Emp_Id desc" rs.Open query, conn Set DataGrid1.DataSource = rs

If Not rs.EOF Then rs.MoveLast reccnt.Caption = rs.RecordCount Else

reccnt.Caption = 0 End If Call datgrid DataGrid1.MarqueeStyle = 3

End Sub Public Sub datgrid() DataGrid1.Font.Size = 11 DataGrid1.Font.Name = "Arial" DataGrid1.HeadFont.Size = 11 DataGrid1.HeadFont.Bold = True DataGrid1.HeadFont.Name = "Arial" DataGrid1.Columns(0).Caption = "Emp ID" DataGrid1.Columns(0).Width = 1000 DataGrid1.Columns(4).Caption = "Telephone No." DataGrid1.Columns(4).Width = 1700 DataGrid1.Columns(5).Caption = "CellPhone No." DataGrid1.Columns(5).Width = 1600 DataGrid1.Columns(7).Caption = "Date Hired" DataGrid1.Columns(7).Width = 1600

End Sub

FRMLOGIN

Private Sub Command1_Click()

Call connectme conn.Open ssql = "SELECT * FROM myusers WHERE myusername='" & txt_user.Text & "' AND mypassword='" & txt_pass.Text & "'" rs.Open ssql, conn If Not rs.EOF Then With rs userlevel = !user_level myuser = txt_user.Text frmcarrental.Enabled = True Unload Me End With Else MsgBox "Invalid username and password !", vbCritical, "KRIN" txt_user.SetFocus frmcarrental.Enabled = False

End If

conn.Close

End Sub

Private Sub Command2_Click() End

End Sub

Private Sub Form_Load() frmcarrental.Show End Sub

FRMNEWCUST

Private Sub cmd_cancel_Click() Unload Me End Sub Private Sub clearfields() txt_Lastname.Text = "" txt_Firstname.Text = "" txt_Address.Text = "" txt_tp.Text = "" txt_cp.Text = "" txt_Position.Text = "" dtdatehired.Value = Now End Sub

Private Sub cmd_save_Click()

If txt_Lastname.Text = "" Then MsgBox "Please enter Customer Name", vbQuestion, "KRIN" txt_Lastname.SetFocus

ElseIf txt_Address.Text = "" Then

MsgBox "Please enter Address", vbQuestion, "KRIN" txt_Address.SetFocus

Else If cust_opt = 1 Then Call addrec MsgBox "Record was successfully saved!", vbInformation, "KRIN" Unload Me ElseIf cust_opt = 2 Then

Call editrec MsgBox "Record was successfully updated!", vbInformation, "KRIN"

End If Call frmcustbl.myquery End If End Sub

Private Sub Form_Load()

Dim rs1 As ADODB.Recordset Dim rs2 As ADODB.Recordset

Set rs1 = New ADODB.Recordset Set rs2 = New ADODB.Recordset

Call connectme

If cust_opt = 2 Then

conn.Open ssqlsub = "SELECT * FROM customertable WHERE Cus_Id=" & custid rs2.Open ssqlsub, conn

If Not rs2.EOF Then With rs2 txt_Lastname.Text = !lastname txt_Firstname.Text = !firstname dtbirthdate.Value = !Birthdate txt_tp.Text = !Telephone_no txt_cp.Text = !Cellphone_no txt_Address.Text = !Address

End With End If conn.Close End If

End Sub Public Sub addrec()

'******** save record Call connectme conn.Open conn.Execute "INSERT INTO customertable(Lastname,Birthdate,Telephone_no,Cellphone_no,Address) VALUES('" & txt_Lastname & "','" & txt_Firstname & "','" & dtbirthdate.Value & "','" & txt_tp.Text & "','" & txt_cp.Text & "','" & txt_Address.Text & "')"

End Sub Public Sub editrec()

'******** update record Call connectme conn.Open conn.Execute "UPDATE customertable set Firstname='" & txt_Firstname.Text & "', Lastname='" & txt_Lastname.Text & "',Birthdate='" & dtbirthdate.Value & "',Telephone_no='" & txt_tp.Text & "', Cellphone_no='" & txt_cp.Text & "', Address='" & txt_Address & "' WHERE Cus_Id=" & custid

End Sub

FRMNEWEMP

Private Sub cmd_cancel_Click() Unload Me End Sub Private Sub clearfields() txt_Lastname.Text = "" txt_Firstname.Text = "" txt_Address.Text = "" txt_tp.Text = "" txt_cp.Text = "" txt_Position.Text = "" dtdatehired.Value = Now End Sub

Private Sub cmd_save_Click()

If txt_Lastname.Text = "" Then MsgBox "Please enter Lastname", vbQuestion, "KRIN" txt_Lastname.SetFocus ElseIf txt_Firstname.Text = "" Then MsgBox "Please enter Firstname", vbQuestion, "KRIN" txt_Firstname.SetFocus

ElseIf txt_Address.Text = "" Then MsgBox "Please enter Address", vbQuestion, "KRIN" txt_Address.SetFocus

Else If emp_opt = 1 Then Call addrec MsgBox "Record was successfully saved!", vbInformation, "KRIN" Unload Me ElseIf emp_opt = 2 Then

Call editrec MsgBox "Record was successfully updated!", vbInformation, "KRIN"

End If Call frmemptbl.myquery End If End Sub

Private Sub Form_Load()

Dim rs1 As ADODB.Recordset Dim rs2 As ADODB.Recordset

Set rs1 = New ADODB.Recordset Set rs2 = New ADODB.Recordset

Call connectme

If emp_opt = 2 Then

conn.Open ssqlsub = "SELECT * FROM employeetable WHERE Emp_Id=" & empid rs2.Open ssqlsub, conn

If Not rs2.EOF Then With rs2 txt_Lastname.Text = !lastname txt_Firstname.Text = !firstname txt_Position.Text = !MyPosition dtbirthdate.Value = !Birthdate dtdatehired.Value = !Date_hired txt_tp.Text = !Telephone_no txt_cp.Text = !Cellphone_no txt_Address.Text = !Address

End With End If

conn.Close End If

End Sub Public Sub addrec()

'******** save record Call connectme conn.Open conn.Execute "INSERT INTO employeetable(Lastname,Firstname,MyPosition,Birthdate,Date_hired,Telephone_no,Cellphone_no,Address) VALUES('" & txt_Lastname & "','" & txt_Firstname & "', '" & txt_Position.Text & "', '" & dtbirthdate.Value & "','" & dtdatehired.Value & "','" & txt_tp.Text & "','" & txt_cp.Text & "','" & txt_Address.Text & "')"

End Sub Public Sub editrec()

'******** update record Call connectme conn.Open conn.Execute "UPDATE employeetable set Firstname='" & txt_Firstname.Text & "', Lastname='" & txt_Lastname.Text & "',Birthdate='" & dtbirthdate.Value & "',Date_hired='" & dtdatehired.Value & "',Telephone_no='" & txt_tp.Text & "', Cellphone_no='" & txt_cp.Text & "', Address='" & txt_Address & "', MyPosition='" & txt_Position.Text & "' WHERE Emp_Id=" & empid

End Sub

FRMNEWRENT

Private Sub cmd_cancel_Click() Unload Me

End Sub Private Sub clearfields() txt_Lastname.Text = "" txt_Firstname.Text = "" txt_Address.Text = "" txt_tp.Text = "" txt_cp.Text = "" txt_Position.Text = "" dtdatehired.Value = Now End Sub

Private Sub cmd_save_Click()

If txt_custid.Text = "" Then MsgBox "Please enter Custmer Information", vbQuestion, "KRIN" customer.SetFocus ElseIf txt_carid.Text = "" Then MsgBox "Please enter Car Information", vbQuestion, "KRIN" txt_plateno.SetFocus ElseIf txt_days.Text = "" Then MsgBox "Please enter No. of days!", vbQuestion, "KRIN" txt_days.SetFocus ElseIf txt_deposit.Text = "" Then MsgBox "Please enter Amount Deposit/Paid!", vbQuestion, "KRIN" txt_deposit.SetFocus

Else If rent_opt = 1 Then Call addrec

MsgBox "Record was successfully saved!", vbInformation, "KRIN" Unload Me ElseIf rent_opt = 2 Then

Call editrec MsgBox "Record was successfully updated!", vbInformation, "KRIN"

End If Call frmrenttbl.myquery End If End Sub

Private Sub customer_KeyPress(KeyAscii As Integer) If KeyAscii = 13 Then If Not customer.Text = "" Then ssqlsub = "SELECT * FROM customertable WHERE Customer_Name='" & Trim(customer.Text) & "'" rs.Open ssqlsub, conn If Not rs.EOF Then With rs txt_custid.Text = !Cus_Id txt_cp.Text = !Cellphone_no txt_tp.Text = !Telephone_no txt_Address.Text = !Address End With End If rs.Close End If

End If

End Sub

Private Sub Form_Load() Dim cus, car

Dim rs1 As ADODB.Recordset Dim rs2 As ADODB.Recordset Dim rs3 As ADODB.Recordset Set rs1 = New ADODB.Recordset Set rs2 = New ADODB.Recordset Set rs3 = New ADODB.Recordset

Call connectme conn.Open

If rent_opt = 2 Then

ssqlsub = " SELECT * FROM renttable WHERE Rent_Id=" & rentid rs2.Open ssqlsub, conn If Not rs2.EOF Then With rs2 cus = !Cus_Id car = !Car_Id

ssqlcus = "SELECT * FROM customertable WHERE Cus_Id=" & cus rs.Open ssqlcus, conn With rs txt_custid.Text = cus lastname.Text = !lastname

txt_cp.Text = !Cellphone_no txt_tp.Text = !Telephone_no txt_Address.Text = !Address End With

ssqlcar = "SELECT * FROM cartable WHERE Car_Id=" & car rs3.Open ssqlcar, conn With rs3 txt_carid = car txt_plateno.Text = !Plate_no txt_carname.Text = !Brand txt_color.Text = !Color txt_rental.Text = !Rental

End With txt_days.Text = !No_of_days txt_due.Text = !Amount txt_deposit.Text = !Deposit

End With End If End If

ssql2 = "SELECT lastname FROM customertable" rs1.Open ssql2, conn Set customer.RowSource = rs1 customer.ListField = rs1.Fields("lastname").Name

End Sub

Public Sub addrec()

'******** save record Call connectme conn.Open conn.Execute "INSERT INTO renttable(Cus_Id,Car_Id,Date_Rented,No_of_days,Amount,Deposit,Status) VALUES('" & txt_custid & "','" & txt_carid & "', '" & daterent.Value & "', '" & txt_days.Text & "','" & txt_due.Text & "','" & txt_deposit.Text & "','1')" conn.Execute "Update cartable set Status='2' WHERE Car_Id=" & txt_carid

End Sub Public Sub editrec()

'******** update record Call connectme conn.Open conn.Execute "UPDATE renttable set Cus_Id='" & txt_custid.Text & "', Car_id='" & txt_carid.Text & "',No_of_days='" & txt_days.Text & "', Amount='" & txt_due.Text & "',Deposit='" & txt_deposit.Text & "', Date_Rented='" & daterent.Value & "' WHERE Rent_Id=" & rentid

End Sub Private Sub txt_days_Change() If Not txt_days.Text = "" Then txt_due.Text = Val(txt_rental.Text) * Val(txt_days.Text) txt_due.Text = Format(txt_due.Text, "#########.00") End If End Sub

Private Sub txt_plateno_KeyPress(KeyAscii As Integer) If KeyAscii = 13 Then

If Not txt_plateno.Text = "" Then

ssqlsub = "SELECT * FROM cartable WHERE Plate_no='" & Trim(txt_plateno.Text) & "' AND Status='1'" rs.Open ssqlsub, conn If Not rs.EOF Then With rs txt_carid.Text = !Car_Id txt_carname.Text = !Brand txt_color.Text = !Color txt_rental.Text = !Rental End With Else MsgBox "The Car is not Available at the moment!", vbCritical Call clearme End If rs.Close End If

End If End Sub Public Sub clearme()

txt_carid.Text = "" txt_carname.Text = "" txt_color.Text = "" txt_rental.Text = "" End Sub

FRMRENTBL

Private Sub Command6_Click() frmlistcar.Show End Sub Private Sub Command1_Click() rent_opt = 2 frmnewrent.Show (1) End Sub

Private Sub Command2_Click() Dim did

did = DataGrid1.Columns(0).Text If Not did = "" Then rentid = did rent_opt = 1 frmnewrent.cmd_save.Caption = "Update" frmnewrent.Show (1) End If

End Sub

Private Sub Command3_Click() Dim pr

Call connectme conn.Open

pr = InputBox("Please Enter Any Key to Search!" & Chr(10) & Chr(13) & "PLATE NO./CUSTOMER ", "Searching...")

If pr = "" Then

ElseIf pr = "All" Or pr = "all" Then Call myquery Else rs.Open query, conn Set DataGrid1.DataSource = rs Call datgrid End If

End Sub

Private Sub Command4_Click() Dim confirm Dim did

did = DataGrid1.Columns(0).Text lastname = DataGrid1.Columns(1).Text firstname = DataGrid1.Columns(2).Text plateno = DataGrid1.Columns(3).Text carname = DataGrid1.Columns(4).Text daterent = DataGrid1.Columns(5).Text dateret = Format(Now, "mm/dd/yyyy") If Not did = "" Then confirm = MsgBox("This will RETURN the Car Now?..proceed anyway!", vbOKCancel + vbExclamation, "Warning!") If confirm = vbOK Then Call connectme conn.Open conn.Execute "Update cartable set Status='1' WHERE Plate_no='" & plateno & "'"

conn.Execute "Update renttable set Status='2' WHERE Rent_Id=" & did conn.Execute "Insert into returntable(Rent_Id,lastname,firstname,Plate_No,Carname,Date_Rented,Date_Returned,Process_by) VALUES ('" & did & "','" & lastname & "','" & firstname & "','" & plateno & "','" & carname & "','" & daterent & "','" & dateret & "','" & myuser & "')" MsgBox "The Return Transaction was successfully saved!", vbInformation conn.Close Call myquery End If Else MsgBox "There are no records to delete!", vbCritical End If End Sub

Private Sub Command5_Click() Unload Me End Sub

Private Sub Form_Load()

Call myquery

''************ USER LEVEL

If userlevel = 3 Then Command1.Enabled = False Command2.Enabled = False Command4.Enabled = False Else Command1.Enabled = True Command2.Enabled = True

Command4.Enabled = True End If

End Sub

Public Sub myquery()

Call connectme

conn.Open

query = "SELECT c.Rent_ID,a.lastname,a.firstname,b.Plate_No,b.Brand,c.Date_Rented,c.No_of_days FROM customertable a, cartable b, renttable c WHERE a.Cus_Id = c.Cus_Id AND b.Car_Id = c.Car_Id AND c.Status='1' ORDER BY c.Date_Rented DESC" rs.Open query, conn Set DataGrid1.DataSource = rs

If Not rs.EOF Then rs.MoveLast reccnt.Caption = rs.RecordCount Else reccnt.Caption = 0 End If Call datgrid DataGrid1.MarqueeStyle = 3

End Sub Public Sub datgrid() DataGrid1.Font.Size = 11

DataGrid1.Font.Name = "Arial" DataGrid1.HeadFont.Size = 11 DataGrid1.HeadFont.Bold = True DataGrid1.HeadFont.Name = "Arial" DataGrid1.Columns(0).Caption = "Rent ID" DataGrid1.Columns(0).Width = 1000 DataGrid1.Columns(1).Caption = "Lastname" DataGrid1.Columns(1).Width = 2000 DataGrid1.Columns(2).Caption = "Firstname" DataGrid1.Columns(2).Width = 2000 DataGrid1.Columns(3).Caption = "Plate NO." DataGrid1.Columns(3).Width = 1200 DataGrid1.Columns(4).Caption = "Car Name" DataGrid1.Columns(4).Width = 2400 DataGrid1.Columns(5).Caption = "Date Rented" DataGrid1.Columns(5).Width = 1200 DataGrid1.Columns(6).Caption = "No.Days" DataGrid1.Columns(6).Width = 1200

End Sub

FRMRETURNTBL

Private Sub Command1_Click() Call connectme conn.Open

query = "SELECT * FROM returntable WHERE Date_Returned='" & dtsearch.Value & "' ORDER BY lastname" rs.Open query, conn Set DataGrid1.DataSource = rs Call datgrid

End Sub

Private Sub Command3_Click() Dim pr

Call connectme conn.Open

pr = InputBox("Please Enter Any Key to Search!" & Chr(10) & Chr(13) & "LASTNAME/FIRSTNAME", "Searching...") If pr = "" Then ElseIf Val(pr) >= 1 Then

ElseIf pr = "All" Or pr = "all" Then query = "SELECT * FROM returntable ORDER BY Date_Returned DESC" rs.Open query, conn Set DataGrid1.DataSource = rs

Else query = "SELECT * FROM returntable WHERE Lastname LIKE '" & pr & "%' or Firstname LIKE '" & pr & "%'" rs.Open query, conn Set DataGrid1.DataSource = rs

End If

End Sub Private Sub Command5_Click() Unload Me End Sub

Private Sub Form_Load()

Call myquery

End Sub

Public Sub myquery()

Call connectme

conn.Open

query = "SELECT * FROM returntable ORDER BY Date_Returned desc" rs.Open query, conn Set DataGrid1.DataSource = rs

If Not rs.EOF Then rs.MoveLast reccnt.Caption = rs.RecordCount Else reccnt.Caption = 0 End If Call datgrid

DataGrid1.MarqueeStyle = 3

End Sub Public Sub datgrid() DataGrid1.Font.Size = 11 DataGrid1.Font.Name = "Arial" DataGrid1.HeadFont.Size = 11 DataGrid1.HeadFont.Bold = True DataGrid1.HeadFont.Name = "Arial" DataGrid1.Columns(0).Caption = "Ret. ID" DataGrid1.Columns(0).Width = 1000 DataGrid1.Columns(1).Width = 0 DataGrid1.Columns(2).Width = 3200

End Sub

FORM NEW CAR

Private Sub cmd_cancel_Click() Unload Me End Sub

Private Sub clearfields() txt_plate_no.Text = "" txt_brand.Text = "" txt_color.Text = ""

txt_speed.Text = "" txt_rental.Text = "" txt_status.Text = "" End Sub

Private Sub cmd_save_Click()

If txt_plate_no.Text = "" Then MsgBox "Please enter Plate no", vbQuestion, "KRIN" txt_plate_no.SetFocus

ElseIf txt_brand.Text = "" Then MsgBox "Please enter Brand", vbQuestion, "KRIN" txt_brand.SetFocus

Else If car_opt = 1 Then Call addrec MsgBox "Record was successfully saved!", vbInformation, "KRIN" Unload Me ElseIf car_opt = 2 Then

Call editrec MsgBox "Record was successfully updated!", vbInformation, "KRIN" Unload Me End If Call frmcartbl.myquery End If End Sub

Private Sub Form_Load()

Dim rs1 As ADODB.Recordset Dim rs2 As ADODB.Recordset

Set rs1 = New ADODB.Recordset Set rs2 = New ADODB.Recordset

Call connectme

If car_opt = 2 Then

conn.Open ssqlsub = "SELECT * FROM cartable WHERE Car_Id=" & carid rs2.Open ssqlsub, conn

If Not rs2.EOF Then With rs2 txt_plate_no.Text = !Plate_no txt_brand.Text = !Brand txt_color.Text = !Color txt_speed.Text = !Speed txt_rental.Text = !Rental txt_status.Text = !status

End With End If

conn.Close End If

End Sub Public Sub addrec()

'******** save record Call connectme conn.Open conn.Execute "INSERT INTO cartable(Plate_no, Brand, Color, Speed, Rental, Status) VALUES('" & txt_plate_no & "','" & txt_brand & "','" & txt_color & "','" & txt_speed.Text & "','" & txt_rental.Text & "','" & txt_status.Text & "')"

End Sub Public Sub editrec()

'******** update record Call connectme conn.Open conn.Execute "UPDATE cartable set Plate_no='" & txt_plate_no.Text & "',Brand='" & txt_brand.Text & "',Color='" & txt_color.Text & "', Speed='" & txt_speed.Text & "', Rental='" & txt_rental & "', Status='" & txt_status & "' WHERE Car_Id=" & carid

End Sub

Class Module

Global variable

Public userlevel Public myuser

Public rent_opt Public rentid Public emp_opt Public empid Public cust_opt Public custid Public car_opt Public carid Option Explicit Public conn As ADODB.Connection Public rs As ADODB.Recordset

Public Function connectme() Set conn = New ADODB.Connection Set rs = New ADODB.Recordset conn.CursorLocation = adUseClient conn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=databasecar.mdb;Persist Security Info=False" 'conn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Jet OLEDB:Database Password=;Data Source=databasecar.mdb; Persist Security Info=False"

End Function