0% found this document useful (0 votes)
3 views

final project

Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

final project

Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 37

ACKNOWLEDGMENT

I would like to express my special thanks of


gratitude to my teacher Mrs. Ritu Kapoor as
well as our principal Mrs. Anita Chaudhary
who gave me this golden opportunity to do
this wonderful project on the topic ‘Book
Store Management system’ ,which also
helped me in doing a lot of research and I
came to know about so many new things
SourceCode:

import mysql.connector

db=mysql.connector.connect(host="local

host",

user="root",

password="ashish",

database="book_store"

C = db.cursor()

#ADMINFUNCTION

def ADD():

book=str(input("Enter Book Name: "))

genre=str(input("Genre:"))

quantity=int(input("Enter quantity:"))

author=str(input("Enter author name:"))

publication=str(input("Enterpublicationhou

se:")) price=int(input("Enter the price:"))

C.execute("INSERT INTO available_books values('{}','{}',


{},'{}','{}',{})".format(book,genre,quantity,author,publication,price))

DB.commit() print("""+++++++++++++++++++++++

+SUCCESSFULLY
ADDED++++++++++++++++++++++++""")

n=int(input("""WantToContinu

e: Yes: 1

NO: 2

OPTION:""")

if n==1:
ADD()

if n==2:

Staff()

def NewStaff():

fname=str(input("EnterFullname

:"))

gender=str(input("Gender(M/F/O):"))

age=int(input("Age:"))

phno=int(input("Staff phone no.:"))

add=str(input("Address:"))

C.execute(("INSERT INTO staff_details values('{}','{}',{},


{},'{}')".format(fname,gender,age,phno,add)))

db.commit()

print("""+++++++++++++++++++++++++++++

+STAFFISSUCCESSFULLYADDED+

+++++++++++++++++++++++++++++""")

n=int(input("""WantToContinu

e: Yes: 1

NO: 2

OPTION:""")

if n==1:

NewStaff(

)if n==2:

Staff()
def RemoveStaff():

n=(input("StaffNametoRemove:"))

C.execute("DELETEFROMstaff_detailsWHEREName=('{}')".format(n

)) DB.commit()

print("AboveEmployeeispromotedtoCustomer")

n=int(input("""Want To Continue:

Yes: 1

NO: 2

OPTION:""")

if n==1:

RemoveStaff

()if n==2:

Staff()

def StaffDetailfS():

spl_statement="Select*fromstaff_detail

s"

C.execute(spl_statement)

output=C.fetchal

l() for x in

output:

print("******************************

******") print("Name of Employ:",

x[0]) print("Gender of Employ:",

x[1])print("Age of Employ:", x[2])

print("Phone No of Employ", x[3])

print("Address of Employ:", x[4])

print("*******************************

*****")
n=int(input("""WantToContinu

e: Yes: 1

NO: 2

OPTION:""")

if n==1:

StaffDetail

()if n==2:

Staff()

def SellRec():

C.execute("select*fromsell_rec

") for u in C:

print("*****************************************

****") print("Buyer Name: ",u[0])

print("BuyerMobileNumber:",u[1])

print("Book Purchased: ",u[2])

print("Quantity Brought: ",u[3])

print("Price of Book: ",u[4])

print("*****************************************

*****") n=int(input("""Want To Continue:

Yes: 1

NO: 2

OPTION:""")

if n==1:

SellRec(

)if n==2:

Staff()
def DelRec():

bb=input("Areyousure(Y/

N):").upper() if bb=="Y":

C.execute("deletefromsell_rec")

db.commit()

n=int(input("""WantToContinu

e: Yes: 1

NO: 2

OPTION:""")

if n==1:

DelRec(

)if n==2:

Staff()

def TotalIncome():

C.execute("selectsum(price)fromsell_re

c") for x in C:

print("Total Sell Till Date",x)

n=int(input("""WantToContinue:

Yes: 1

NO: 2

OPTION:""")

if n==1:

TotalIncome

()if n==2:

Staff()
def AvailablefS():

C.execute("select*fromavailable_booksorderby bookname")

for v in C:

print("*************************************************

***") print("Book Name: ",v[0])

print("Book Genre: ",v[1])

print("Book Available: ",v[2])

print("Book Author: ",v[3])

print("PublicationHouse:",v[

4]) print("Book Price:", v[5])

print("****************************************************")

n=int(input("""Want To Continue:

Yes: 1

NO: 2

OPTION:""")

if n==1:

AvailablefS

()if n==2:

Staff()

#***************************************BUYER
FUNCTION********************************************

def AvailablefU():

C.execute("select*fromavailable_booksorderby bookname")
for v in C:

print("*************************************************

***") print("Book Name: ",v[0])

print("Book Genre: ",v[1])

print("Book Available: ",v[2])

print("Book Author: ",v[3])

print("PublicationHouse:",v[

4]) print("Book Price:", v[5])

print("****************************************************")

n=int(input("""Want To Continue:

Yes: 1

NO: 2

OPTION:""")

if n==1:

AvailablefU

()if n==2:

Buyer()

def StaffDetailfU():

spl_statement="Select*fromstaff_detail

s"C.execute(spl_statement)

output=C.fetchal

l() for x in

output:

print("*******************************

*****") print("Name of Employ:",

x[0]) print("Gender of Employ:", x[1])


print("Age of Employ:", x[2])

print("PhoneNoofEmploy",x[3])

print("Address of Employ:", x[4])

print("*******************************

*****") n=int(input("""Want To

Continue:

Yes: 1

NO: 2

OPTION:""")

if n==1:

StaffDetailfU

()if n==2:

Buyer()

def Purchase():

print("AVAILABLEBOOKS...")

C.execute("select*fromavailable_Book

s")

for i in C:

print("*********************************************

*******") print("Book Name: ",i[0])

print("Book Genre: ",i[1])

print("Book Available: ",i[2])

print("Book Author: ",i[3])

print("PublicationHouse:",i[4]

) print("Book Price:", i[5])

print("****************************************************")
cusname=str(input("Entercustomername:"))

phno=int(input("Enter phone number:"))

book=str(input("Enter Book Name:"))

price=int(input("Enter the price:"))

n=int(input("Enter quantity:"))

C.execute("selectquantityfromavailable_bookswherebookname='"+book+

"'") k=C.fetchone()

if max(k)<n:

print(n,"Booksarenotavailable!!!!

") else:

C.execute("selectbooknamefromavailable_bookswherebookname='"+book+"'")

log=C.fetchone()

If log is not None:

C.execute("insert into Sell_rec values('"+cusname+"','"+str(phno)


+"','"+book+"','"+str(n)+"','"+str(price)+"')")

C.execute("updateAvailable_Bookssetquantity=quantity-'"+str(n)+"'where
BookName='"+book+"'")

db.commit() print("""++++++++++++

++++++++++

++BOOKHASBEEN SOLD++

++++++++++++++++++++++""")

else:

print("BOOKISNOT AVAILABLE!!!!!!!")

n=int(input("""WantToContinue:
Yes: 1

NO: 2

OPTION:""")

if n==1:

Purchase(

) if n==2:

Buyer()

def
UsingName():

o=input("EnterBookto search:")

C.execute("selectbooknamefromavailable_bookswherebookname='"+o+

"'") t=C.fetchone()

If t != None:

print("""++++++++++++++++++++

++BOOKISINSTOCK++

++++++++++++++++++++""")

else:

print("BOOKISNOTINSTOCK!!!!!!!")

n=int(input("""WantToContin

ue: Yes: 1

NO: 2

OPTION:""")

if n==1:
UsingName(

) if n==2:

Buyer()

def UsingGenre():

g=input("Entergenreto search:")

C.execute("selectgenrefromavailable_bookswheregenre='"+g+"'")

poll=C.fetchall()

if poll is not None:

print("""++++++++++++++++++++

++BOOKISIN STOCK++

++++++++++++++++++++""")

C.execute("select*fromavailable_bookswheregenre='"+g+"'")

for y in C:

print("*****************************************

**") print("Book Name: ",y[0])

print("Book Genre: ",y[1])

print("QuantityAvailable:",y

[2]) print("Book Author",

y[3]) print("Book

Publication: ",y[4])

print("Book Price: ", y[5])

print("*******************************************")

else:
print("BOOKSOFSUCHGENREARENOTAVAILABLE!!!!!!!!!")

n=int(input("""WantToContin

ue: Yes: 1

NO: 2

OPTION:""")

if
n==1:
UsingGenre()

if
n==2: Buyer()

def UsingAuthor():

o=input("EnterBook'sAuthorto search:")

C.execute("selectbooknamefromavailable_bookswhereAuthor='"+o

+"'") t=C.fetchone()

ift!= None:

print("""++++++++++++++++++++

++BOOKISINSTOCK++

++++++++++++++++++++""")

else:

print("BOOKISNOTINSTOCK!!!!!!!")

n=int(input("""WantToContin

ue: Yes: 1

NO:2
OPTION:"""))

if n==1:

UsingGenre

()if n==2:

Buyer()

def Staff():

print("""1:AddBooks

2. StaffDetails

3. SellRecord

4. TotalIncomeaftertheLatestReset

5. SeeAvailable Book

6. Exit""")

n=int(input("EnterYourChoice:"))

#ToAddBooksintothedatabas

e if n==1:

ADD()

#ChoiceForNewStaff,Firestaff,ViewSta

ff if n==2:

print("""1:Newstaffentry)

2:Remove staff

3:Existingstaffdetails""")

ch=int(input("Enteryourchoice:"))
#NEWSTAFF ENTRY

if ch==1:

NewStaff(

#REMOVE STAFF

if ch==2:

RemoveStaff(

#EXISTINGSTAFFDETAILS

if ch==3:

StaffDetail()

#ToSeeSellinghistroy&alteringi

t if n==3:

print("""1:Sellhistorydetail

s 2:Reset Sell

history""")

ty=int(input("Enteryourchoice:"))

if ty==1:

SellRec()

if ty==2:

DelRec()

#ToviewtotalTotalIncome
if n==4:

TotalIncome()

#ViewingAvailableBookAsSta

ff if n==5:

AvailablefS()

#Break

if n==6:

return

defBuyer():

#USERChoices

print("""1.PurchaseBooks

2.Search Books

3.AvailableBooks

4.StaffDetails

5. Exit""")

r=int(input("EnterYourChoice:"))

#TOPURCHASEBOOK

if r==1:

Purchase()
#SearchingofbooksusingName,Genre,Aut
hor

if r==2:

print("""1:Search by name

2:Search by genre

3:Searchbyauthor""")

l=int(input("SearchbyWhat:"))

#SearchingUsingNameofBoo

k if l==1:

UsingName()

#SearchingUsingGenreofBoo

k if l==2:

UsingGenre()

#SearchingUsingAuthorNam

if l==3:

UsingAuthor()

#ToSeeAvailableBoo
ks

if r==3:

AvailablefU()

#ToSeePresentStaffDetails
if r==4:

StaffDetail()

#MAINPROGRAM

print("**********************************************WelcomeToBook
Store***************************************************")

while 1:

a=int(input("""EnterasEmployee:1

EnterasUser:2

Exit : 3

Enter:"""))

if a==1:

Staff()

if a==2:

print('''''****************BOOKSHOP*********************

1.Signup

2.login''')

s=int(input("EnterYourChoice:"))

#Sign-Up

if s==1:
user_name=input("USERNAME(ex:abcd1234):")

password=input("PASSWORD: ")

C.execute("insertintosignupvalues('"+user_name+"','"+password+"')

") DB.commit()

print("SignUpCompleted")

#Log in

else:

user2=input("EnterYourUsername:")

C.execute("selectusernamefromSignupwhereusername='"+user2+"'

") b=C.fetchone()

b1=input("EnterYourPassword:")

C.execute("selectpasswordfromsignupwherepassword='"+b1+"'")

a2=C.fetchone()

ifa2isnotNone:

print("************************LoginSuccess********************")

Buyer(

)if

a==3:

break
DatabaseTable
1. TableSignupwithallentries.

2. Tableavailable_bookswithallentries.
3.Tablesell_recwithallentries.

4.Tablestaff_detailswithallentries.

5AlltablesunderDatabasebook_store.
Output
1. Home Screen:

2. AddBooks:
3. StaffDetails:
AddStaff details:

RemovalOfStaff:
4. SellingHistory
5. ViewingAvailableBooksasAdmin
6. ExitingAdminMenu
1. EnteringintoBuyer(User)Menu:

2. SignUp
3. Login

4. PurchasingaBook:
5. SearchingBooks:
:Using Name:

:Using Author:
:Using Genre:
39
BookStoreManagement

Reference
 Computer Science with Python Class XI by
Sumita Arora
ComputerSciencewithPythonTextbookforClass11:SumitaArora:Amazon.in: Books
 Computer Science with Python Class XII by
Sumita Arora
ProgressInComputerScienceWithPython...bySumitaArora(amazon.in)
 PythonIDLE
DownloadPython|Python.org
 MySQL
MySQL::MySQLDownloads

You might also like