0% found this document useful (0 votes)
29 views43 pages

Colony Welfare Society Management With MySQL

report

Uploaded by

prthmjain2
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
29 views43 pages

Colony Welfare Society Management With MySQL

report

Uploaded by

prthmjain2
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 43

CERTIFICATE

It is to be Certified that the project entitled ‘Car


Rental Management System’ submitted by
Sudhanshu Juneja class 12th- D for the A.I.S.S.C.E.
2023 C.B.S.E. Board Practical Examination in
computer science, embodies the original work done
by the candidate. The candidate carried out his work
sincerely.

We have carefully gone through the contents


of the project & are fully satisfied with the work
carried out by him,

It is further certified that the candidate has


completed all the prescribed requirements governing
the syllabus of C.B.S.E. Sr. Sec Board.

Signature
Signature
1
Gulshan Sir Dr.
Urmila Vajpai
( PGT Computer Science )
( Principal )

Acknowledgement

In the 'odyssey' of 'life' the reverie to


subjugate the zenith of goal to many known &
unknown hands obtrude me learnt souls put me on
right path & enlightened with their knowledge &
experience. I shall ever remain grateful to them.
Words are inadequate to express my sincere &
deepest sense of gratitude to my guide & teacher
Gulshan Sir for his benevolent guidance, constructive
counsel, & meticulous supervision, constant
inspirations & wholehearted encouragement
throughout the year.

2
At last I shall heartily thank to my
parents & for their love, care, concern & lots of
inspirations.

Sudhanshu Juneja
Class : 12th – D
Sacred Hearts Sr. Sec.
Public School

3
Introduction to Project
The Car Rental Management System is a comprehensive software solution designed to automate
and manage the end-to-end operations of a car rental business. From customer reservations and vehicle
tracking to billing and reporting, the system integrates various functionalities to ensure a seamless and
organized workflow.
It caters to the dynamic requirements of the industry, providing real-time insights and control over
the fleet, bookings, and financial aspects of the business.

 DISPLAY CARS DETAILS


 SEARCHING CARS
 EDIT CARS RECORDS
 DELETE CARS RECORDS
 BILL RECORD
 GENERATION PAYMENT SLIP

OBJECTIVE

4
During the past several decades’ personnel function has been transformed from a relatively obscure
record keeping staff to central and top level management function. There are many factors that have
influenced this transformation like technological advances, professionalism, and general
recognition of human beings as most important resources.

 A computer based “Car Rental Management System” is designed to handle the primary
activities of the Car Rental Management System to maintain the records of the MEMBERS in an
efficient way which save the time.

 This project intends to introduce more user friendliness in the various activities such as addition
of records, editing the information and updation, maintenance, and searching the records.

 Similarly, record maintenance and updation can also be accomplished by using the
identification of the MEMBER with all the details being automatically generated. These details are
also being promptly automatically updated in the master file thus keeping the record absolutely up-
to-date.

 The entire information has maintained in the database or Files and whoever wants to retrieve
can’t retrieve, only authorization user can retrieve the necessary information which can be easily be
accessible from the file.

ADVANTAGE:

I have designed the given proposed system in the Python to automate the process of “Car
Rental Management System” because it is an Object Oriented Language and good for application
softwares. This project is useful for the maintaining the records of the Car Rental Management.

The following steps that give the detailed information of the need of proposed system are:

Performance: During past several decades, the records are supposed to be manually
handled for all activities. The manual handling of the record is time consuming and highly prone to
error. To improve the performance of the “Car Rental Management System”, the computerized
system is to be undertaken. This project is fully computerized and user friendly.

Efficiency: The basic need of this software is efficiency. The software should be efficient so that
whenever a user performs his/her work the records are updated automatically. This record will be
useful for other transactions instantly.

5
Security: Security is the main criteria for the proposed system. Since illegal access may corrupt the
database. So security has to be given in this project.

Future Scope and Further Enhancement of the Application

This project can be used in the Car Rental Management System after adding some more useful
modules in the project.

So there are many things for future enhancement of this project. The future enhancements that
are possible in the project are as follows.

 In the area of data security and system security.


 Provide more online tips and help.
 Providing facility to share the system for multiple users
 By including the features to maintain the expenditure of the department.

Hardware and Software


Requirement

Hardware Required

Hardware Minimum requirements

Computer Intel® or compatible Pentium 333 MHz or higher.

6
Memory
64 MB Minimum; 128 MB Recommended
(RAM)

Hard disk 1 GB for the database and the client software. This
space requirement may increase with the increase in records.

VGA or higher resolution. 800x600 or higher resolution


Monitor
required for the SQL Server graphical tools

Pointing
Microsoft Mouse or compatible
device

Required for installation purposes only. During the life


time of this software it is not at all required. However, it
CD-ROM drive
is recommended to use CD-RWs to take periodical
backups.

Software Required

Software Description

Operating
Microsoft Windows or DOS or Linux or Unix
System

Python
Anaconda / Python 3.7
Interpreter

MS – Office /
Word Processor for Documentation
Open Office

7
Introduction to Python Programming

Python is a high-level, interpreted, interactive and object oriented-scripting language. Python was
designed to be highly readable which uses English keywords frequently where as other languages use
punctuation and it has fewer syntactical constructions than other languages.

 Python is interpreted: This means that it is processed at runtime by the interpreter and
you do not need to compile your program before executing it. This is similar to PERL and PHP.
8
 Python is Interactive: This means that you can actually sit at a Python prompt and
interact with the interpreter directly to write your programs.

 Python is Object-Oriented: This means that Python supports Object-Oriented style or


technique of programming that encapsulates code within objects.

 Python is Beginner's Language: Python is a great language for the beginner programmers
and supports the development of a wide range of applications, from simple text processing to
WWW browsers to games.

History of Python:
Python was developed by Guido van Rossum in the late eighties and early nineties ( February 1991 ) at
the National Research Institute for Mathematics and Computer Science in the Netherlands.

Python is derived from many other languages, including ABC, Modula-3, C, C++, Algol-68,
SmallTalk, and UNIX shell and other scripting languages.

Python is now maintained by a core development team at the institute, although Guido van
Rossum still holds a vital role in directing its progress.

Python is named after British TV Show – “Monty Python’s Flying Circus”.

Python's feature highlights include:


 Easy-to-learn: Python has relatively few keywords, simple structure, and a clearly defined
syntax. This allows the student to pick up the language in a relatively short period of time.

 Easy-to-read: Python code is much more clearly defined and visible to the eyes.

 Easy-to-maintain: Python's success is that its source code is fairly easy-to-maintain.

 A broad standard library: One of Python's greatest strengths is the bulk of the library is
very portable and cross-platform compatible on UNIX, Windows, and Macintosh.

 Interactive Mode: Support for an interactive mode in which you can enter results from a
terminal right to the language, allowing interactive testing and debugging of snippets of code.

 Portable: Python can run on a wide variety of hardware platforms and has the same interface
on all platforms.

 Extendable: You can add low-level modules to the Python interpreter. These modules enable
programmers to add to or customize their tools to be more efficient.

 Databases: Python provides interfaces to all major commercial databases.

 GUI Programming: Python supports GUI applications that can be created and ported to many
system calls, libraries, and windows systems, such as Windows MFC, Macintosh, and the X
Window system of Unix.

 Scalable: Python provides a better structure and support for large programs than shell
scripting.

9
Apart from the above mentioned features, Python has a big list of good features, few are listed below:

 Support for functional and structured programming methods as well as OOP.

 It can be used as a scripting language or can be compiled to byte-code for building large
applications.

 Very high-level dynamic data types and supports dynamic type checking.

 Supports automatic garbage collection.

 It can be easily integrated with C, C++, COM, ActiveX, CORBA, and Java.

Some Minus Features of Python:


 Not the fastest Language

 Lessor Libraries than C, Java, Perl.

 Not strong on type - binding

 Not easily convertible

MySQL
MySQL is an open-source relational database management system (RDBMS). Its name is a combination of
"My", the name of co-founder Michael Widenius's daughter, and "SQL", the abbreviation for Structured
Query Language.
MySQL is free and open-source software under the terms of the GNU General Public License, and is also
available under a variety of proprietary licenses. MySQL was owned and sponsored by
the Swedish company MySQL AB, which was bought by Sun Microsystems (now Oracle Corporation). In
2010, when Oracle acquired Sun, Widenius forked the open-source MySQL project to create MariaDB.

Sometime, it is important to store the information entered by the user into the database for further use.
After storing the information into the database, later we can retrieve those information from that
database. The latest version of MySQL is one of the world’s most popular databases. It is open source,
reliable, compatible with all major hosting providers, cost-effective, and easy to manage. Many
organizations are leveraging the data security and strong transactional support offered by MySQL to
secure online transactions and enhance customer interactions. However, enterprises using MySQL are
presented with several challenges when their apps experience exponential growth and they need
additional scale.

Along with understanding why MySQL is the go-to solution for high-growth environments, it is equally
important to understand the challenges that can cripple your business operations. Here are 5 major reasons
to use MySQL along with its most common challenges:

5 REASONS TO CHOOSE MYSQL

Secure Money Transactions


MySQL transactions work as a single unit, which means unless and until every individual operational stage
is successfully completed, the transaction is not cleared. So, if an operation fails at any stage, the entire
transaction happening within that group fails. MySQL ensures that financial transactions have data
integrity, so customers can make worry-free transactions online.

10
On-Demand Scalability
MySQL comes with the advantage of unmatched flexibility that facilitates efficient management of deeply
embedded applications, even in gigantic data centers that stack tremendous amounts of mission-critical
information. It enables complete customization to cater to the unique requirements of eCommerce businesses
with a much smaller footprint.

High Availability
Consistent availability is the stalwart feature of MySQL – enterprises that deploy it can enjoy round-the-
clock uptime. MySQL comes with a wide variety of cluster servers and master-slave replication
configurations that enable instant failover for uninterrupted access.

Rock-Solid Reliability
Protecting sensitive business information is the primary concern of every enterprise. MySQL ensures data
security with exceptional data protection features. Powerful data encryption prevents unauthorized viewing
of data and SSH and SSL supports ensure safer connections. It also features a powerful mechanism that
restricts server access to authorized users and has the ability to block users even at the man-machine level.
Finally, the data backup feature facilitates point-in-time recovery.

Quick-Start Capability
You can go from software download to complete installation in just 15 minutes. MySQL is exceptionally
quick, regardless of the underlying platform. It features self-management capabilities like auto restart, spass
expansion and automatic configuration changes for ease of management. MySQL enables real-time
performance monitoring for timely troubleshooting of operational issues from a single workstation.

5 CHALLENGES OF SCALING MYSQL

Long Development Time


Scaling frameworks that cannot be optimized with master/slave setups requires extensive development time.
Replication lag further complicates app logic because it disrupts the data consistency between the slave and
the master. Finally, MySQL server modifications need constant coordination between database teams and
apps.

Replication
MySQL servers often run into replication conflicts during a manual failover when multi-master setups are
involved.

Database Logging Costs


Database logging is expensive and so it remains disabled most of the time. As a result, organizations lack
real-time visibility into slow logs, which delays troubleshooting.

Query Caches
MySQL server query cache is of little help when handling a high volume of workload, because cache
invalidation cannot be controlled.

High Connection Churn


If your apps rely on a LAMP stack, they tend to have a high volume of user sessions running concurrently
and, consequently, they experience a high connection churn. So most of your valuable server resources are
exhausted on connection management.

11
Modules Imported in the Projects
12
And Their Functions
Other than Python Standard Library modules, some other modules are imported in the
project to perform some specific task. These are :

 random
 randint() – To access random value

 os
 remove( ) – To remove a file
 rename( ) – To rename a file

 datetime
 today( ) – To return current system date

 sys
 exit( ) – To terminate execution of the program

13
# ************** Project on Car Rental Management System *****************

import sys
import os
import datetime
import random
import mysql.connector as mc

14
#print text slowly
def print_slow(t,s=0.03):
for y in t:
sys.stdout.write(y)
sys.stdout.flush()
time.sleep(s)
print('')

#display title
def title(t):
col,lin=os.get_terminal_size()
print('\n' + '='*(col+30) + '\n' +
' '*int((col-len(t)-31)/4)+
'DATE : '+datetime.datetime.now().strftime("%d-%m-%y")+
' '*int((col-len(t)-31)/4)+
'# '+t+' #'+
' '*int((col-len(t)-31)/4)+
'TIME - '+ datetime.datetime.now().strftime("%H:%M")+
' '*int((col-len(t)-31)/4)+
'\n' + '='*(col+30)+'\n')

#to print a heading


def heading(t):
col,lin=os.get_terminal_size()
print('-'*int((col-len(t)-4)/2) + '\ '+t+' /' \
+'-'*(int((col-len(t)-4)/2)+30)+'\n')

#standardising lengths of strings


def cut(s,n):
s=str(s)
if len(s)>n:
return(s[:n])
elif len(s)==n:
return s
else:
return s+' '*(n-len(s))

#=================================================================
============

#MAIN MENU
def main_menu():
os.system('cls')
title(com_name)
heading('MAIN MENU')
print('''\
\t1 --> Admin Portal
\t2 --> Customer Portal
\t3 --> Credits
\n\tEnter --> Exit
''')
ch=input('\n\tEnter the choice: ')
if ch=='1':

15
admin_authentication()
elif ch=='2':
customer_portal()
elif ch=='3':
credit()
main_menu()
else:
program_end()
return

#CUSTOMER PORTAL
def customer_portal():
os.system('cls')
title(com_name)
heading('CUSTOMER PORTAL')
print('''\
\t1 --> View Cars
\t2 --> Rent Cars
\t3 --> Return Cars
\n\tEnter --> Back
''')
ch=input('\tEnter the choice: ')
if ch=='1':
view_cars_customer()
elif ch=='2':
rent_cars()
elif ch=='3':
return_cars()
else:
main_menu()
return

#RENT CARS
def rent_cars():
os.system('cls')
title(com_name)
heading('CUSTOMER PORTAL')
heading('RENT CARS')

#printing available cars


cur=cn.cursor()
cur.execute("select car_no,car_class,model_name,car_color,capacity,\
daily_rent from cars where car_status='AVAILABLE' order by Car_Class;")
l=cur.fetchall()
if len(l)==0:
print_slow('\n\n\t\tSORRY! ALL CARS ARE CURRENTLY RENTED!!')
print_slow('\n\t\tRedirecting to Customer Portal... Press Enter')
input()
customer_portal()
print('\tAVAIABLE CARS:\n')
print('')
sp=[15,15,20,15,15,15]
z='+'
for y in sp:

16
z=z+'-'*(y+1)+'+'
print(z)
time.sleep(0.03)
print('| ',cut('CAR_NO',15),'| ',\
cut('CAR_CLASS',15),'| ',\
cut('MODEL_NAME',20),'| ',\
cut('CAR_COLOR',15),'| ',\
cut('CAPACITY',15),'| ',\
cut('DAILY_RENT',15),'| ',sep="")
time.sleep(0.03)
print(z)
time.sleep(0.03)
for y in range(0,len(l)):
print('| ',end='')
for x in range(0,len(l[y])):
print(cut(l[y][x],sp[x]),end='')
print('| ',end='')
print('')
time.sleep(0.03)
print(z)

#obtaining details & validation


cust_name=input('\n\tEnter your Full Name: ') #full name
cust_no=input('\tEnter your Phone Number: ') #phone number

cur=cn.cursor() #car_nos
cur.execute("select car_no from cars where car_status='AVAILABLE'")
l=cur.fetchall()
while True:
cars=input('\tEnter the car_nos of the cars you wish to rent \
separated by "," with no spaces: ')
cars=cars.split(',')
z='valid'
for y in cars:
x=(int(y),)
if x not in l:
z='invalid'
if z=='invalid':
print_slow("\n\tPlease enter valid and available car_nos...\n")
continue
break

while True: #days


days=int(input('\tEnter the no. of days you wish to borrow the car \
including today (max 15): '))
if days in range(1,16):
days=int(days)
break
print_slow("\n\tPlease enter valid no. of days...\n")

while True: #driver


driver=input('\tWill you need a driver (y/n) \
[ Rs. 500 per day per car ]: ')
if driver.lower() in ['y','n']:

17
break
print_slow('\n\tPlease enter valid answer...\n')

#unique rent_id generation


rent_id=random.randint(1000,10000)
cur=cn.cursor()
cur.execute('select rent_id from rentings;')
l=cur.fetchall()
x=(rent_id,)
while x in l:
x=random.randint(1000,10000)
rent_id=x[0]

#dates
rent_date=datetime.datetime.now()
return_date = rent_date + datetime.timedelta(days=days)
rent_date=rent_date.strftime("%d-%m-%y")
return_date=return_date.strftime("%d-%m-%y")

#receipt table and preparing for renting


print_slow('\n\tRedirecting to Receipt Table....Press Enter')
input()

os.system('cls')
title(com_name)
heading('CUSTOMER PORTAL')
heading('RECEIPT TABLE')

print('\n')
col,lin=os.get_terminal_size()
L=[]
n=30
print(' '*n+'+'+'='*(col-2*n-2)+'+')
L.append(com_name+' : RENT RECEIPT')
L.append('='*(col-2*n-2))
L.append('RENT-ID : '+str(rent_id))
L.append('CUSTOMER NAME: '+cust_name.upper())
L.append('-'*(col-2*n-2))
L.append('RENT DATE: '+rent_date)
L.append('RETURN DATE: '+return_date)
L.append('DAYS RENTED: '+str(days))
L.append('-'*(col-2*n-2))
L.append('-:PROJECTED RENT:-')

car_and_rent=[]
total=0
for car_no in cars:
cur=cn.cursor()
cur.execute('select daily_rent from cars where car_no={};'\
.format(car_no))
x=cur.fetchall()
x=x[0][0]
rent=x*days
total=total+(x*days)

18
L.append('CAR NO.'+str(y)+' --> '+str(x)+' * '+str(days)+' = '+\
str(x*days))
if driver=='y':
L.append('DRIVER --> 500 * '+str(days)+' = '+str(days*500))
rent=rent+(days*500)
total=total+(days*500)
car_and_rent.append({'car_no':car_no,'rent':rent})

L.append('-'*(col-2*n-2))
L.append('TOTAL :- Rs.'+str(total))
L.append('-'*(col-2*n-2))
L.append('Please print this receipt and take it to our')
L.append(com_name+' shop to get the cars')
L.append('-'*(col-2*n-2))
L.append('(: HAVE A NICE DAY :)')

for y in L:
sp=' '*n
d1=' '*int((col-2*n-len(y)-2)/2)
d2=' '*( col-2*n-2-len(y) - int((col-2*n-len(y)-2)/2) )
print(sp+'|'+d1+y+d2+'|')
time.sleep(0.03)
print(' '*n+'+'+'='*(col-2*n-2)+'+')
print('')

#confirmation
print_slow('\n\tEnter y when you have shown this receipt and taken \
the cars')
print_slow('\tEnter n to cancel the renting')
an=input('\tAnswer : ')
if an=='y':
pass
else:
print_slow('\n\tRenting Cancelled....')
print_slow('\n\tRedirecting to Customer Portal.... Press Enter')
input()
customer_portal()
return

#renting the cars


cur=cn.cursor()
for y in car_and_rent:
q="insert into rentings values('{}','{}','{}','{}','{}','{}','{}'\
,'{}');".format(rent_id,cust_name,cust_no,y['car_no'],rent_date,return_date\
,driver,y['rent'])
cur.execute(q)
q="update cars set rent_id={},car_status='{}' where car_no={};"\
.format(rent_id,'RENTED',y['car_no'])
cur.execute(q)
cn.commit()
print_slow('\n\tCARS RENTED.... Press Enter')
input()

#important note

19
os.system('cls')
title(com_name)
heading('CUSTOMER PORTAL')
heading('IMPORTANT NOTE')
print('')
print_slow('''
\t\tTHE CUSTOMER HAS TO TAKE THE RECEIPT TO THE OFFICE TO GET THE
CARS!
\t\tTHE PRICE OF FUEL IS NOT INCLUDED IN THE RECEIPT!

\t\tTHE CARS CAN BE RETURED EARLIER, RENT WILL BE ADJUSTED!


\t\tDELAYED REUTURNS WILL RESULT IN PENALTY!

\t\tIF ANY VEHICLE IS DAMAGED DUE TO CARELESSNESS OF CUSTOMER


THE
\t\tCUSTOMER IS RESPONSIBLE TO PAY THE REPAIR EXPENSES!
''',0.004)

print_slow('\t\tRedirecting to Customer Portal.... Press Enter')


input()
customer_portal()
return

#RETURN CARS
def return_cars():
os.system('cls')
title(com_name)
heading('CUSTOMER PORTAL')
heading('RETURN CARS')
rent_id=int(input('\n\tEnter the RENT_ID : '))

#validating
cur=cn.cursor()
cur.execute('select rent_id from rentings;')
l=cur.fetchall()
x=(rent_id,)
if x not in l:
print_slow('\n\tThis RENT_ID does not exist, enter again...')
time.sleep(0.5)
return_cars()
print_slow('\tRedirecting to Bill Table.... Press Enter')
input()

#bill table
os.system('cls')
title(com_name)
heading('CUSTOMER PORTAL')
heading('BILL TABLE')

#obtaining everything required for bill


cur=cn.cursor()
cur.execute('select cust_name,car_no,date_rented,driver,Cust_Phone_no \
from rentings where rent_id={};'.format(rent_id))
l=cur.fetchall()

20
cust_name=l[0][0]
driver=l[0][3]
phone=l[0][4]

#dates
rent_date = datetime.datetime.strptime(l[0][2],'%d-%m-%y')
return_date = datetime.datetime.now()
days = return_date-rent_date
days = days.days+1
rent_date = rent_date.strftime('%d-%m-%y')
return_date = return_date.strftime('%d-%m-%y')

#rent
car_and_drent=[]
for y in l:
for x in range(0,len(y)):
if x==1:
car_no=y[x]
cur=cn.cursor()
cur.execute('select daily_rent from cars where car_no={};'\
.format(car_no))
rent=(cur.fetchall())[0][0]
t={'car_no':car_no,'rent':rent}
car_and_drent.append(t)
del t

#printing the bill


print('\n')
col,lin=os.get_terminal_size()
L=[]
n=30
total=0

print(' '*n+'+'+'='*(col-2*n-2)+'+')
L.append(com_name+' : BILL')
L.append('='*(col-2*n-2))
L.append('RENT-ID : '+str(rent_id))
L.append('CUSTOMER NAME: '+cust_name.upper())
L.append('-'*(col-2*n-2))
L.append('RENT DATE: '+rent_date)
L.append('RETURN DATE: '+return_date)
L.append('DAYS RENTED: '+str(days))
L.append('-'*(col-2*n-2))
L.append('-:RENT TO BE PAID:-')

for y in car_and_drent:
L.append('CAR NO.'+str(y['car_no'])+' --> '+str(y['rent'])\
+' * '+str(days)+' = '+str(y['rent']*days))
total = total + y['rent']*days
if driver=='y':
L.append('DRIVER --> 500 * '+str(days)+' = '+str(days*500))
total = total + days*500
L.append('-'*(col-2*n-2))
L.append('TOTAL :- Rs.'+str(total))

21
L.append('-'*(col-2*n-2))
L.append('Kindly pay this amount')
L.append('And return the cars back')
L.append('-'*(col-2*n-2))
L.append('THANK YOU FOR CHOOSING US')

for y in L:
sp=' '*n
d1=' '*int((col-2*n-len(y)-2)/2)
d2=' '*( col-2*n-2-len(y) - int((col-2*n-len(y)-2)/2) )
print(sp+'|'+d1+y+d2+'|')
time.sleep(0.03)

print(' '*n+'+'+'='*(col-2*n-2)+'+')
print('')

#confirmation
print_slow('\n\n\tEnter y when you have paid the bill & completed the \
return')
print_slow('\tEnter n to cancel the return')
an=input('\tAnswer : ')
if an!='y':
print_slow('\tReturn Cancelled....')
prin_slow('\tRedirecting to Customer Portal.... Press Enter')
input()
customer_portal()
return

#updating sales table


for y in car_and_drent:
car=y['car_no']
ear=(y['rent'])*days
cur=cn.cursor()
q="insert into sales values('{}','{}','{}','{}','{}','{}');"\
.format(rent_id,car,cust_name,phone,return_date,ear)
cur.execute(q)
cn.commit()

#returning
cur=cn.cursor()
cur.execute('delete from rentings where rent_id={};'.format(rent_id))
cur=cn.cursor()
cur.execute("update cars set car_status='{}', rent_id={} where \
rent_id={};".format('AVAILABLE','NULL',rent_id))
cn.commit()
print_slow('\tCARS RETURNED....')
print_slow('\tRedirecting to Customer Portal.... Press Enter')
input('')
customer_portal()
return

#VIEW CARS CUSTOMER


def view_cars_customer():
os.system('cls')

22
title(com_name)
heading('CUSTOMER PORTAL')
heading('VIEW CARS')

cur=cn.cursor()
cur.execute('select car_class,model_name,car_color,\
capacity,daily_rent,car_status from cars order by Car_Class;')
l=cur.fetchall()
if len(l)==0:
print_slow('\n\tNo cars available in the store! Press enter to go \
back!')
input()
customer_portal
return

#printing table
print('')
sp=[15,20,15,15,15,15]
z='+'
for y in sp:
z=z+'-'*(y+1)+'+'
print(z)
time.sleep(0.03)
print('| ',cut('CAR_CLASS',15),'| ',\
cut('MODEL_NAME',20),'| ',\
cut('CAR_COLOR',15),'| ',\
cut('CAPACITY',15),'| ',\
cut('DAILY_RENT',15),'| ',\
cut('CAR_STATUS',15),'| ',sep="")
time.sleep(0.03)
print(z)
time.sleep(0.03)
for y in range(0,len(l)):
print('| ',end='')
for x in range(0,len(l[y])):
print(cut(l[y][x],sp[x]),end='')
print('| ',end='')
print('')
time.sleep(0.03)
print(z)
input('\n\tPress ENTER to go back')
customer_portal()
return

#ADMIN AUTHENTICATION
def admin_authentication():
os.system('cls')
title(com_name)
heading('ADMIN AUTHENTICATION')
Pass=getpass.getpass("\tEnter Password: ")

#password
cur=cn.cursor()
cur.execute('select * from admins')

23
l=cur.fetchall()
passwd=l[0][0]
if passwd==Pass:
print_slow('\n\tAccess Granted ..... Press Enter')
input('')
admin_portal()
else:
print_slow('\n\tAccess Denied ..... Press Enter')
input('')
main_menu()
return

#ADMIN PORTAL
def admin_portal():
os.system('cls')
title(com_name)
heading('ADMIN PORTAL')
print('''\
\t1 --> Open Garage
\t2 --> View Current Rentings
\t3 --> View Sales Table
\n\tEnter --> Back
''')
ch=input('\tEnter the choice: ')
if ch=='1':
garage()
elif ch=='2':
view_current_rentings()
elif ch=='3':
sales_table()
else:
main_menu()
return

#VIEW CURRENT BOOKINGS


def view_current_rentings():
os.system('cls')
title(com_name)
heading('ADMIN PORTAL')
heading('CURRENT RENTINGS')

cur=cn.cursor()
cur.execute('select * from rentings order by return_date;')
l=cur.fetchall()
if len(l)==0:
print_slow('\n\tNo cars rented currently!, Press enter to go back')
input()
admin_portal()
return

#printing table
sp=[10,20,15,10,15,15,10,10]
z='+'
for y in sp:

24
z=z+'-'*(y+1)+'+'
print(z)
time.sleep(0.03)
print('| '+cut('RENT_ID',10)+\
'| '+cut('CUSTOMER_NAME',20)+\
'| '+cut('PHONE NUMBER',15)+\
'| '+cut('CAR_NO',10)+\
'| '+cut('DATE_RENTED',15)+\
'| '+cut('RETURN_DATE',15)+\
'| '+cut('DRIVER',10)+\
'| '+cut('TOTAL_RENT',10)+\
'| ',sep='')
time.sleep(0.03)
print(z)
time.sleep(0.03)
for y in range(0,len(l)):
print('| ',end='')
for x in range(0,len(l[y])):
print(cut(l[y][x],sp[x]),end='')
print('| ',end='')
print('')
time.sleep(0.03)
print(z)
input('\n\tPress ENTER to go back')
admin_portal()
return

#SALES TABLE
def sales_table():
os.system('cls')
title(com_name)
heading('ADMIN PORTAL')
heading('SALES TABLE')

cur=cn.cursor()
cur.execute('select * from sales order by return_date;')
l=cur.fetchall()
if len(l)==0:
print_slow('\n\tNo sales to show!, Press enter to go back')
input()
admin_portal()
return

#printing table
sp=[15,15,20,15,15,15]
z='+'
for y in sp:
z=z+'-'*(y+1)+'+'
print(z)
time.sleep(0.03)
print('| '+cut('RENT_ID',15)+\
'| '+cut('CAR_NO',15)+\
'| '+cut('CUST_NAME',20)+\
'| '+cut('PHONE_NUMBER',15)+\

25
'| '+cut('RETURN_DATE',15)+\
'| '+cut('SALES',15)+\
'| ',sep='')
time.sleep(0.03)
print(z)
time.sleep(0.03)
for y in range(0,len(l)):
print('| ',end='')
for x in range(0,len(l[y])):
print(cut(l[y][x],sp[x]),end='')
print('| ',end='')
print('')
time.sleep(0.03)
print(z)
input('\n\tPress ENTER to go back')
admin_portal()
return

#GARAGE
def garage():
os.system('cls')
title(com_name)
heading('ADMIN PORTAL')
heading('GARAGE')
print('''\
\t1 --> View Cars
\t2 --> Add Car
\t3 --> Remove Car
\n\tEnter --> Back
''')
ch=input('\tEnter the choice: ')
if ch=='1':
view_cars_admin()
elif ch=='2':
add_car()
elif ch=='3':
remove_car()
else:
admin_portal()
return

#VIEW CARS ADMIN


def view_cars_admin():
os.system('cls')
title(com_name)
heading('ADMIN PORTAL')
heading('GARAGE')
heading('VIEW CARS')

cur=cn.cursor()
cur.execute('select * from cars order by Car_Class;')
l=cur.fetchall()
if len(l)==0:
print_slow('\n\tGarage empty! Press enter to go back!')

26
input()
garage()
return

#printing table
print('')
sp=[10,15,20,15,10,15,15,10]
z='+'
for y in sp:
z=z+'-'*(y+1)+'+'
print(z)
time.sleep(0.03)
print('| ',cut('CAR_NO',10),'| ',\
cut('CAR_CLASS',15),'| ',\
cut('MODEL_NAME',20),'| ',\
cut('CAR_COLOR',15),'| ',\
cut('CAPACITY',10),'| ',\
cut('DAILY_RENT',15),'| ',\
cut('CAR_STATUS',15),'| ',\
cut('RENT_ID',10),'| ',sep="")
time.sleep(0.03)
print(z)
time.sleep(0.03)
for y in range(0,len(l)):
print('| ',end='')
for x in range(0,len(l[y])):
print(cut(l[y][x],sp[x]),end='')
print('| ',end='')
print('')
time.sleep(0.03)
print(z)
input('\n\tPress ENTER to go back to Garage')
garage()
return

#ADD CAR
def add_car():
os.system('cls')
title(com_name)
heading('ADMIN PORTAL')
heading('GARAGE')
heading('ADD CAR')

#fetching details
car_no=int(input('\tEnter the car number: '))
cur=cn.cursor()
cur.execute('select car_no from cars;')
l=cur.fetchall()
x=(car_no,)
if x in l:
print_slow('\n\tThe car_no you entered is already in use..Enter again')
time.sleep(0.5)
add_car()
car_class=input('\tEnter the car class: ')

27
model_name=input('\tEnter the model name: ')
car_color=input('\tEnter the car color: ')
capacity=int(input('\tEnter the capacity: '))
daily_rent=int(input('\tEnter the daily rent: '))

#adding
q="insert into cars(car_no,car_class,model_name,car_color,capacity,\
daily_rent) values('{}','{}','{}','{}','{}','{}');".format(car_no,\
car_class.upper(),model_name.upper(),car_color.upper(),capacity,daily_rent)
cur=cn.cursor()
cur.execute(q)
print_slow('\n\tCAR ADDED..... \n')
cn.commit()
print_slow('\n\tRedirecting to Garage.... Press Enter')
input('')
garage()
return

#REMOVE CAR
def remove_car():
os.system('cls')
title(com_name)
heading('ADMIN PORTAL')
heading('GARAGE')
heading('REMOVE CAR')

#printing cars
print("\t You can only remove the cars which are'nt rented\n")
cur=cn.cursor()
cur.execute('select car_no,car_class,model_name,car_color,\
capacity, daily_rent, car_status from cars order by Car_Class;')
l=cur.fetchall()
print('')
sp=[15,15,20,15,15,15,15]
z='+'
for y in sp:
z=z+'-'*(y+1)+'+'
print(z)
time.sleep(0.03)
print('| ',cut('CAR_NO',15),'| ',\
cut('CAR_CLASS',15),'| ',\
cut('MODEL_NAME',20),'| ',\
cut('CAR_COLOR',15),'| ',\
cut('CAPACITY',15),'| ',\
cut('DAILY_RENT',15),'| ',\
cut('CAR_STATUS',15),'| ',sep="")
time.sleep(0.03)
print(z)
time.sleep(0.03)
for y in range(0,len(l)):
print('| ',end='')
for x in range(0,len(l[y])):
print(cut(l[y][x],sp[x]),end='')
print('| ',end='')

28
print('')
time.sleep(0.03)
print(z)

#validating car_no
cur=cn.cursor()
cur.execute("select car_no from cars where car_status='AVAILABLE';")
l=cur.fetchall()
if len(l)==0:
print_slow('\n\tNo cars can be removed currently!, Press enter to go\
back')
input()
garage()
return
c_no=input('\n\tEnter the car_no of the car to be remove: ')
x=(int(c_no),)
if x not in l:
print_slow('\n\tPlease enter valid car_no...')
time.sleep(0.5)
remove_car()

#confirmation
s=input('\tPlease confirm if you want to delete this car (y/n): ')
if s=='y':
pass
else:
print_slow('\n\tRedirecting to Garage....Press Enter')
input()
garage()
return

#removing
cur=cn.cursor()
q='delete from cars where Car_no={};'.format(c_no)
cur.execute(q)
print_slow('\n\tCAR DELETED.....')
cn.commit()
print_slow('\n\tRedirecting to Garage....Press Enter')
input()
garage()

#=================================================================
===========
#PRINT CREDITS
def credit():
os.system('cls')
x=input('\tPRESS ENTER TO READ LICENSE & ACKNOWLEDGEMENT OR
ENTER ANYTHIG \
TO GO BACK: ')
if x=='':
os.system('cls')
time.sleep(0.5)
print_slow(

29
'''

LICENSE & ACKNOWLEDGEMENT

THIS PROGRAM IS MADE AS A PROTOTYPE.../

THANK YOU !!! :)

''',0.005)
input('\n\tPress Enter to go back')
os.system('cls')
return

#PRINT START SCREEN


def start(t):
os.system('cls')
col,row=os.get_terminal_size()
row=row-1

t1='connecting to car servers'


t2='logging in to car servers'
dot='.'*int((col-10-len(t)-len(t1)-len(t2))/4)
s='|#'+dot + t1 + dot+'#| '+t+' |#'+dot + t2 + dot+'#|'
l=len(s)

a1=r" _____ "


a2=r" __/__|__\__ "
a3=r" / _ CAR _ \ "
a4=r"'--(_)---(_)--'"

w1=r'__ _____ _ ___ ___ __ __ ___ '


w2=r'\ \ / / __| | / __/ _ \| \/ | __|'
w3=r' \ \/\/ /| _|| |_| (_| (_) | |\/| | _| '
w4=r' \_/\_/ |___|____\___\___/|_| |_|___|'

sp=' '*int((l-len(a4)-len(w3))/2)
w1=sp+w1+sp
w2=sp+w2+sp
w3=sp+w3+sp
w4=sp+w4+sp

n=int((row-9)/2)-1
for y in range(0,l+1):
os.system('cls')
for x in range(n):
print(s[:y])
print("")
print("")
print(w1[0:y]+a1)
print(w2[0:y]+a2)
print(w3[0:y]+a3)
print(w4[0:y]+a4)

30
print("="*l)
print("")
print("")
for x in range(n):
print(s[:y])
time.sleep(0.02)
input('')
os.system('cls')
return

#PRINT END SCREEN


def end(t):
os.system('cls')
col,row=os.get_terminal_size()
row=row-1

t1=' thank you '


t2='logging off'
dot='.'*int((col-10-len(t)-len(t1)-len(t2))/4)
s='|#'+dot + t1 + dot+'#| '+t+' |#'+dot + t2 + dot+'#|'
l=len(s)

a1=r" _____ "


a2=r" __/__|__\__ "
a3=r" / _ car _ \ "
a4=r"'--(_)---(_)--'"

w1=r" ___ ___ ___ ___ _____ _____ "


w2=r" / __|/ _ \ / _ \| \ | _ ) \ / / __|"
w3=r"| (_ | (_) | (_) | |) | | _ \\ V /| _| "
w4=r" \___|\___/ \___/|___/ |___/ |_| |___|"

sp=' '*(int((l-len(a4)-len(w3))/2)-2)
w1=sp+w1+sp
w2=sp+w2+sp
w3=sp+w3+sp
w4=sp+w4+sp
ws=' '*len(w3)

n=int((row-9)/2)-1
for y in range(l,-1,-1):
os.system('cls')
for x in range(n):
print(s[:y])
print("")
print('')
print(ws[0:y]+a1+w1[y:])
print(ws[0:y]+a2+w2[y:])
print(ws[0:y]+a3+w3[y:])
print(ws[0:y]+a4+w4[y:])
print("="*l)
print("")
print('')
for x in range(n):

31
print(s[:y])
time.sleep(0.02)
input('')
os.system('cls')
return

#=================================================================
============

#PROGRAM END
def program_end():
cn.commit()
cn.close()
#end screen
end(com_name)
return

#PROGRAM START
os.system('mode con lines=200 cols=200')
os.system('COLOR 70')

#START SCREEN
com_name='CAR RENTALS'
start(com_name)

#SQL OBTAINING PASSWORD


while True:
os.system('cls')
title(com_name)
heading('SQL - PASSWORD')
print("\n\n\n\t\tEnter your computer's MY_SQL password : ",end='')
paas=getpass.getpass('')

try:
cn=mc.connect(host='localhost',user='root',passwd=paas,database='CAR')
except:
print_slow('\n\t\tConnection Failed... Enter password again..',0.02)
time.sleep(0.5)
continue
break

main_menu()

#******************************code finishes here ****************************

32
Enter Password of Your MySQL Client : pass
--------------------------------------------------------------------------------------------------------------
*********************** W E L C O M E **************************

CAR RENTAL MANAGEMENT SYSTEM

DEVELOPED BY:

Sudhanshu Juneja

XII-D

Sacred Hearts Sr. Sec. Public School

Bareilly

|#......connecting to car servers......#| CAR RENTALS |#......logging in to car servers.....#|

====DATE : 23-12-23 # CAR RENTALS # TIME - 20:06=====

--------------------------------------------\ SQL - PASSWORD /--------------------------------------

Enter your computer's MY_SQL password :pass

---------\ MAIN MENU /--------

1 --> Admin Portal

2 --> Customer Portal

3 --> Credits

Enter --> Exit

Enter the choice:

33
-----\ ADMIN AUTHENTICATION /-----
Enter Password:1289

Access Granted ..... Press Enter -------

-----\ ADMIN PORTAL /----

1 --> Open Garage


2 --> View Current Rentings
3 --> View Sales Table

Enter --> Back

Enter the choice:1

---\ GARAGE /---

1 --> View Cars


2 --> Add Car
3 --> Remove Car

Enter --> Back

Enter the choice:1

---\ VIEW CARS /---

Press ENTER to go back to Garage

---\ GARAGE /---

1 --> View Cars


2 --> Add Car
3 --> Remove Car

Enter --> Back


34
Enter the choice:2
---\ ADD CAR /---

Enter the car number: 1321


Enter the car class: SUV
Enter the model name: Skoda Kushaq
Enter the car color: black
Enter the capacity: 5
Enter the daily rent: 1700

CAR ADDED.....

Redirecting to Garage.... Press Enter

---\ GARAGE /---

1 --> View Cars


2 --> Add Car
3 --> Remove Car

Enter --> Back

Enter the choice:3

---\ REMOVE CAR /---

You can only remove the cars which are'nt rented

Enter the car_no of the car to be remove:1321


Please confirm if you want to delete this car (y/n): y

CAR DELETED.....

Redirecting to Garage....Press Enter

35
---\ GARAGE /---

1 --> View Cars


2 --> Add Car
3 --> Remove Car

Enter --> Back

Enter the choice: Enter

---\ ADMIN PORTAL /---

1 --> Open Garage


2 --> View Current Rentings
3 --> View Sales Table

Enter --> Back

Enter the choice: 2

---\ CURRENT RENTINGS /---

Press ENTER to go back

---\ ADMIN PORTAL /---

1 --> Open Garage


2 --> View Current Rentings
3 --> View Sales Table

Enter --> Back

Enter the choice:3

---\ SALES TABLE /---

Press ENTER to go back 36


---\ ADMIN PORTAL /---

1 --> Open Garage


2 --> View Current Rentings
3 --> View Sales Table

Enter --> Back

Enter the choice: Enter

---\ MAIN MENU /---

1 --> Admin Portal


2 --> Customer Portal
3 --> Credits

Enter --> Exit

Enter the choice:2

---\ CUSTOMER PORTAL /---

1 --> View Cars


2 --> Rent Cars
3 --> Return Cars

Enter --> Back

Enter the choice:1

---\ VIEW CARS /---

37
Press ENTER to go back
---\ CUSTOMER PORTAL /---

1 --> View Cars


2 --> Rent Cars
3 --> Return Cars

Enter --> Back

Enter the choice:2

---\ RENT CARS /---

AVAIABLE CARS:

Enter your Full Name: Sudhanshu Juneja

Enter your Phone Number: 9087526436

Enter the car_nos of the cars you wish to rent separated by "," with no spaces: 1304

Enter the no. of days you wish to borrow the car including today (max 15): 3

Will you need a driver (y/n) [ Rs. 500 per day per car ]: y

Redirecting to Receipt Table....Press Enter

38
---\ RECEIPT TABLE /---

Enter y when you have shown this receipt and taken the cars
Enter n to cancel the renting
Answer : y

CARS RENTED.... Press Enter

---\ IMPORTANT NOTE /---

THE CUSTOMER HAS TO TAKE THE RECEIPT TO THE OFFICE TO GET


THE CARS!
THE PRICE OF FUEL IS NOT INCLUDED IN THE RECEIPT!

THE CARS CAN BE RETURED EARLIER, RENT WILL BE ADJUSTED!


DELAYED REUTURNS WILL RESULT IN PENALTY!

IF ANY VEHICLE IS DAMAGED DUE TO CARELESSNESS OF CUSTOMER


THE
CUSTOMER IS RESPONSIBLE TO PAY THE REPAIR EXPENSES!
Redirecting to Customer Portal.... Press Enter

---\ CUSTOMER PORTAL /---

1 --> View Cars


2 --> Rent Cars
3 --> Return Cars

Enter --> Back 39


Enter the choice: 3
---\ RETURN CARS /---

Enter the RENT_ID : 2878


Redirecting to Bill Table.... Press Enter

---\ BILL TABLE /---

Enter y when you have paid the bill & completed the return
Enter n to cancel the return
Answer : y
CARS RETURNED....
Redirecting to Customer Portal.... Press Enter

---\ CUSTOMER PORTAL /---

1 --> View Cars


2 --> Rent Cars
3 --> Return Cars

Enter --> Back

Enter the choice: Enter

---\ MAIN MENU /---

1 --> Admin Portal


2 --> Customer Portal
3 --> Credits

Enter --> Exit


40
Enter the choice: 3
PRESS ENTER TO READ LICENSE & ACKNOWLEDGEMENT OR ENTER
ANYTHIG TO GO BACK:

LICENSE & ACKNOWLEDGEMENT

THIS PROGRAM IS MADE AS A PROTOTYPE.../

THANK YOU !!! :)

Press Enter to go back ---

---\ MAIN MENU /---

1 --> Admin Portal


2 --> Customer Portal
3 --> Credits

Enter --> Exit

Enter the choice: Enter

_____ ___ ___ ___ ___ _____ _____


__/ __ | __ \__ / __|/ _ \ / _ \| \ | _ ) \ / / __|
/ _ car _ \ | (_ | (_) | (_) | |) | | _ \\ V /| _|
' - -(_)- - -(_) - - ' \___|\___/ \___/|___/ |___/ |_| |___|
===============================================================

41
Bibliography
42
Books Referred

 Dive into Python

 Python Developer's Handbook

 Python 2.1 Bible

Web Sites Referred

 www.google.com

 www.studytonight.com

 www.pythonprogramming.com

43

You might also like