Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 37

KENDRIYA VIDYALAYA

KALPETTA
DEPARTMENT OF COMPUTER
SCIENCE 2019-20

ACADEMIC PROJECT ON SHOP MANAGEMENT SYSTEM

SUBMITTED BY:

NAME : MANU KRISHNAN

REG NO: 24633441

1|Page
CERTIFICATE
Certified to be the bonafide record of project work done by
MANU KRISHNAN K (Roll no.24633441) of Class XII of
Kendriya Vidyalaya, Kalpetta during the year 2019-20.

Teacher in Charge: Principal:

Submitted for AISSCE, 2020 Computer Science Practical


Examination, held in computer Laboratory at Kendriya
Vidyalaya, Kalpetta.

Signature of External Examiners:

Date:

2|Page
ACKNOWLEDGEMENT
I would like to express a deep sense of thanks & gratitude to
Mrs.Aneesa N Ali for guiding me immensely through the
course of the project. Her constructive advice & constant
motivation has been responsible for the successful
completion of this project.
My sincere thanks go to Dr.S S Dakua , Principal, Kendriya
Vidyalaya, Kalpetta , for his co-ordination in extending every
possible support for the completion of this project.
I thank my parents for their constant motivation and support.
I also thank my classmates for their timely help and support
for the completion of this project.
Last but not the least, I would like to thank all those who
directly or indirectly helped me towards the completion of
this project.

3|Page
CONTENTS
S.No TOPIC PAGE NO
1. Abstract 5

2. Coding 6-21

3. MySql Table structures 22-23

4. Output 24-35

5. Conclusion 36

6. Bibliography 37

4|Page
ABSTRACT

THIS PROGRAM IS DESIGNED TO KEEP RECORDS OF


STOCK IN A COMPUTER ACCESSORY SHOP AND MANAGE
SALES, ORDERS AND PURCHASE DETAILS OF THE STOCK.
This program also provides the user the permission to add
sale details, user details ,product details and order details.
THE PROGRAM PROVIDES THE FOLLOWING SERVICES:

 ADD, MODIFY, VIEW PURCHASE DETAILS, SALES


DETAILS, PRODUCT DETAILS AND ORDER DETAILS.

5|Page
CODING

import os

import mysql.connector

import datetime

now = datetime.datetime.now()

def product_mgmt():

while True:

print("\t\t\t 1. Add New Product")

print("\t\t\t 2. List Product")

print("\t\t\t 3. Update Product")

print("\t\t\t 4. Delete Product")

print("\t\t\t 5. Back (Main Menu)")

p = int(input("\t\t Enter Your Choice :"))

if p == 1:

add_product()

if p == 2:

search_product()

if p == 3:

update_product()

if p == 4:

6|Page
delete_product()

if p == 5:

break

def purchase_mgmt():

while True:

print("\t\t\t 1. Add Order")

print("\t\t\t 2. List Order")

print("\t\t\t 3. Back (Main Menu)")

o = int(input("\t\t Enter Your Choice :"))

if o == 1:

add_order()

if o == 2:

list_order()

if o == 3:

break

def sales_mgmt( ):

while True:

print("\t\t\t 1. Sale Items")

print("\t\t\t 2. List Sales")

print("\t\t\t 3. Back (Main Menu)")

s = int (input("\t\t Enter Your Choice :"))

7|Page
if s == 1:

sale_product()

if s == 2:

list_sale()

if s == 3:

break

def user_mgmt():

while True:

print("\t\t\t 1. Add user")

print("\t\t\t 2. List user")

print("\t\t\t 3. Back (Main Menu)")

u = int(input("\t\t Enter Your Choice :"))

if u == 1:

add_user()

if u == 2:

list_user()

if u == 3:

break

def create_database():

8|Page
mydb = mysql.connector.connect(host="localhost", user="root",password="123456",
database="MPS_Inv")

mycursor = mydb.cursor()

print(" Creating PRODUCT table")

sql = "CREATE TABLE if not exists product(pcode int(4) PRIMARY KEY, pname char(30) NOT
NULL, price float(8,2), pqty int(4), pcat char(30));"

mycursor.execute(sql)

print("PRODUCT table created")

print("Creating ORDER table")

sql = "CREATE TABLE if not exists orders(orderid int(4)PRIMARY KEY, orderdate DATE,pcode
char(30) NOT NULL , pprice float(8,2),pqty int(4), supplier char(50), pcat char(30));"

mycursor.execute(sql)

print("ORDER table created")

print("Creating SALES table")

sql = "CREATE TABLE if not exists sales(salesid int(4) PRIMARY KEY,salesdate DATE,pcode
char(30) references product(pcode),pprice float(8,2), pqty int(4),Total double(8,2));"

mycursor.execute(sql)

print("SALES table created")

print("Creating USER table")

sql = "CREATE TABLE if not exists user (uid char(6) PRIMARY KEY,uname char(30) NOT NULL,
upwd char(30));"

mycursor.execute(sql)

print("USER table created")

9|Page
def list_database():

mydb = mysql.connector.connect(host="localhost",
user="root",password="123456",database="MPS_Inv")

mycursor = mydb.cursor()

sql = "show tables;"

mycursor.execute(sql)

for i in mycursor:

print(i)

def add_order():

mydb = mysql.connector.connect(host="localhost", user="root",password="123456",


database="MPS_Inv")

mycursor = mydb.cursor()

now = datetime.datetime.now()

sql = "INSERT INTO orders (orderid, orderdate, pcode,pprice, pqty, supplier,pcat) values
(%s,%s,%s,%s,%s,%s,%s);"

code = int(input("Enter product code :"))

oid = now.year+now.month+now.day+now.hour+now.minute+now.second

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

price = float(input("Enter Product unit price: "))

cat = input("Enter product category: ")

supplier = input("Enter Supplier details: ")

val = (oid, now, code, price, qty, supplier, cat)

mycursor.execute(sql, val)

10 | P a g e
mydb.commit()

def list_order():

mydb = mysql.connector.connect(host="localhost", user="root", password="123456",


database="MPS_Inv")

mycursor = mydb.cursor()

sql = "SELECT * from orders;"

mycursor.execute(sql)

print("\t\t\tORDER DETAILS")

print("-"*85)

print("orderid date productcode price qty supplier category")

print("-" * 85)

for i in mycursor:

print(i[0], "\t", i[1], "\t", i[2], "\t", i[3], "\t", i[4], "\t", i[5], "\t", i[6])

print("-" * 85)

def db_mgmt( ):

while True:

print("\t\t\t 1. Database creation")

print("\t\t\t 2. List Database")

print("\t\t\t 3. Back (Main Menu)")

p = int(input("\t\t Enter Your Choice :"))

11 | P a g e
if p == 1:

create_database()

if p == 2:

list_database()

if p == 3:

break

def add_product():

mydb = mysql.connector.connect(host="localhost", user="root",


password="123456",database="MPS_Inv")

mycursor = mydb.cursor()

sql = "INSERT INTO product(pcode,pname,price,pqty,pcat) values (%s,%s,%s,%s,%s)"

code = int(input("\t\t Enter product code :"))

search = "SELECT count(*) FROM product WHERE pcode=%s;"

val = (code,)

mycursor.execute(search,val)

for x in mycursor:

cnt = x[0]

if cnt == 0:

name = input("\t\t Enter product name :")

qty = int(input("\t\t Enter product quantity :"))

price = float(input("\t\t Enter product unit price :"))

cat = input("\t\t Enter Product category :")

val = (code,name,price,qty,cat)

12 | P a g e
mycursor.execute(sql,val)

mydb.commit()

else:

print("\t\t Product already exist")

def update_product():

mydb = mysql.connector.connect(host="localhost", user="root", password="123456",


database="MPS_Inv")

mycursor = mydb.cursor()

code = int(input("Enter the product code :"))

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

sql = "UPDATE product SET pqty=pqty+%s WHERE pcode=%s;"

val = (qty,code)

mycursor.execute(sql,val)

mydb.commit()

print("\t\t Product details updated")

def delete_product():

mydb = mysql.connector.connect(host="localhost", user="root", password="123456",


database="MPS_Inv")

mycursor=mydb.cursor()

code = int(input("Enter the product code :"))

sql = "DELETE FROM product WHERE pcode = %s;"

val = (code,)

13 | P a g e
mycursor.execute(sql, val)

mydb.commit()

print(mycursor.rowcount,"record(s) deleted");

def search_product():

while True:

print("\t\t\t 1. List all product")

print("\t\t\t 2. List product code wise")

print("\t\t\t 3. List product category wise")

print("\t\t\t 4. Back (Main Menu)")

s = int(input("\t\t Enter Your Choice :"))

if s == 1:

list_product()

if s == 2:

code=int(input(" Enter product code :"))

list_prcode(code)

if s == 3:

cat=input("Enter category :")

list_prcat(cat)

if s == 4:

break

14 | P a g e
def list_product():

mydb = mysql.connector.connect(host="localhost", user="root",


password="123456",database="MPS_Inv")

mycursor = mydb.cursor()

sql = "SELECT * from product"

mycursor.execute(sql)

print("\t\t\t\t PRODUCT DETAILS")

print("\t\t", "-" * 55)

print("\t\t code\t name\t\tprice\tquantity\tcategory")

print("\t\t", "-" * 55)

for i in mycursor:

print("\t\t", i[0], "\t", i[1], "\t", i[2], "\t", i[3], "\t\t", i[4])

print("\t\t", "-" * 55)

def list_prcode(code):

mydb = mysql.connector.connect(host="localhost", user="root", password="123456",


database="MPS_Inv")

mycursor = mydb.cursor()

sql = "SELECT * from product WHERE pcode=%s"

val = (code,)

mycursor.execute(sql, val)

print("\t\t\t\t PRODUCT DETAILS")

print("\t\t", "-" * 47)

print("\t\t code name price quantity category")

15 | P a g e
print("\t\t", "-" * 47)

for i in mycursor:

print("\t\t", i[0], "\t", i[1], "\t", i[2], "\t", i[3], "\t", i[4])

print("\t\t", "-" * 47)

def sale_product():

mydb = mysql.connector.connect(host="localhost", user="root", password="123456",


database="MPS_Inv")

mycursor = mydb.cursor()

pcode = input("Enter product code: ")

sql = "SELECT count(*) from product WHERE pcode=%s;"

val = (pcode,)

mycursor.execute(sql,val)

for x in mycursor:

cnt = x[0]

if cnt != 0 :

sql = "SELECT * from product WHERE pcode=%s;"

val = (pcode,)

mycursor.execute(sql, val)

for x in mycursor:

print(x)

price = int(x[2])

pqty = int(x[3])

16 | P a g e
qty = int(input("Enter no of quantity :"))

if qty <= pqty:

total = qty * price

print("Collect Rs. ", total)

sql = "INSERT into sales values(%s,%s,%s,%s,%s,%s)"

val = (int(cnt)+1,datetime.datetime.now(),pcode,price,qty,total)

mycursor.execute(sql,val)

sql = "UPDATE product SET pqty=pqty-%s WHERE pcode=%s"

val = (qty, pcode)

mycursor.execute(sql, val)

mydb.commit()

else:

print("Quantity not available")

else:

print("Product is not available")

def list_sale():

mydb = mysql.connector.connect(host="localhost", user="root", password="123456",


database="MPS_Inv")

mycursor = mydb.cursor()

sql = "SELECT * FROM sales"

mycursor.execute(sql)

print("\t\t\t\t SALES DETAILS")

17 | P a g e
print("-" * 80)

print("Sales ID Date ProductCode Price \tQuantity Total")

print("-" * 80)

for x in mycursor:

print(x[0], "\t", x[1], "\t", x[2], "\t\t", x[3], "\t\t", x[4], "\t\t", x[5])

print("-" * 80)

def list_prcat(cat):

mydb = mysql.connector.connect(host="localhost", user="root",password="123456",


database="MPS_Inv")

mycursor = mydb.cursor()

print(cat)

sql="SELECT * from product WHERE pcat =%s"

val = (cat,)

mycursor.execute(sql, val)

clrscr()

print("\t\t\t\t PRODUCT DETAILS")

print("\t\t", "-" * 55)

print("\t\t code\t name\t\tprice\tquantity\tcategory")

print("\t\t", "-" * 55)

for i in mycursor:

print("\t\t", i[0], "\t", i[1], "\t", i[2], "\t", i[3], "\t\t", i[4])

18 | P a g e
print("\t\t", "-" * 55)

def add_user():

mydb = mysql.connector.connect(host="localhost", user="root", password="123456",


database="MPS_Inv")

mycursor = mydb.cursor()

uid = input("Enter user id :")

name = input("Enter Name :")

password = input("Enter Password :")

sql = "INSERT INTO user values (%s,%s,%s);"

val = (uid, name, password)

mycursor.execute(sql, val)

mydb.commit()

print(mycursor.rowcount, "user created")

def list_user():

mydb = mysql.connector.connect(host="localhost", user="root", password="123456",


database="MPS_Inv")

mycursor = mydb.cursor()

sql = "SELECT uid, uname from user"

mycursor.execute(sql)

clrscr()

print("\t\t\tUSER DETAILS")

19 | P a g e
print("\t\t", "-" * 27)

print("\t\t UID\t\tname")

print("\t\t", "-" * 27)

for i in mycursor:

print("\t\t", i[0], "\t", i[1])

print("\t\t", "-" * 27)

def clrscr():

print("\n"*5)

while True:

clrscr()

print("\t\t\t STOCK MANAGEMENT")

print("\t\t\t ****************\n")

print("\t\t 1. PRODUCT MANAGEMENT")

print("\t\t 2. PURCHASE MANAGEMENT")

print("\t\t 3. SALES MANAGEMENT")

print("\t\t 4. USER MANAGEMENT")

print("\t\t 5. DATABASE SETUP")

print("\t\t 6. EXIT\n")

n = int(input("Enter your choice :"))

if n == 1:

product_mgmt()

if n == 2:

20 | P a g e
os.system('cls')

purchase_mgmt()

if n == 3:

sales_mgmt()

if n == 4:

user_mgmt()

if n == 5:

db_mgmt()

if n == 6:

break

21 | P a g e
MYSQL TABLE STRUCTURES
TABLE PRODUCT

TABLE ORDERS

22 | P a g e
TABLE SALES

TABLE USER

23 | P a g e
OUTPUT

24 | P a g e
25 | P a g e
26 | P a g e
27 | P a g e
28 | P a g e
29 | P a g e
30 | P a g e
31 | P a g e
32 | P a g e
33 | P a g e
34 | P a g e
35 | P a g e
CONCLUSION

This was an amazing, interesting and innovative project. We


enjoyed doing this project. We have tried to bring out some
previous knowledge along with some newly learned concepts
using interface of python with MySql.
This project helped me to understand more about these
python concepts. We have used basic ideas of python in
some of the important and frequent events around us. This
project really give us an idea about how a programming
language, when mastered can help us sort many of the hefty
time consuming tasks with ease.
I hope I was successful in doing my project.

36 | P a g e
BIBLIOGRAPHY
 Computer Science with python - Sumita Arora
 Computer Science with python - Preeti Arora
 Geeksforgeeks.org
 Stackoverflow.com

37 | P a g e

You might also like