CS Project
CS Project
CS Project
HAMLA, MUMBAI
पि.एम श्री केन्द्रीय विद्यालय आईएनएस
हमला, मुंबई
COMPUTER SCIENCE
Investigatory Project
STOCK MANAGEMENT SYSTEM
ROLL NO : 12115
NAME :
CLASS : XII-A
1
PM SHRI KENDRIYA VIDYALAYA I.N.S. HAMLA, MUMBAI
पि.एम श्री केन्द्रीय विद्यालय आईएनएस हमला, मुंबई
Certificate
This is to certify that (Name) Roll.no 12115 has successfully completed the project synopsis Work entitled STOCK
MANAGEMENT in the subject Computer Science (083) laid down in the regulations of CBSE for the purpose of Practical
2
SER DESCRIPTION PAGE NO
01 ACKNOWLEDGEMENT 04
05
02 STATEMENT ABOUT THE PROJECT
METHODOLOGY
05 10
TABLE OF CONTENTS [ T O C ]
ACKNOWLEDGEMENT
3
Apart from the efforts of me, the success of any project depends largely on the encouragement and
guidelines of many others. I take this opportunity to express my gratitude to the people who have been
instrumental in the successful completion of this project.
I express deep sense of gratitude to almighty God for giving me strength for the successful completion of
the project.I express my heartfelt gratitude to my parents for constant encouragement while carrying out this
project.
I gratefully acknowledge the contribution of the individuals who contributed in bringing this project up to this
level, who continues to look after me despite my flaws, I express my deep sense of gratitude to the luminary The
Principal, MRS. MUDHULIKA MITRA of MISHRA KENDRIYA VIDYALAYA, INS HAMLA ,MUMBAI, who has
been continuously motivating and extending their helping hand to us. My sincere thanks to Mrs. SAVITA
SHARMA (PGT),COMPUTER SCIENCE TEACHER, A guide, Mentor all the above a friend,who critically
reviewed my project and helped in solving each and every problem, occurred during implementation of the
project
The guidance and support received from all the members who contributed and who are contributing to this
project, was vital for the success of the project. I am grateful for their constant support and help.
The project is totally built at administrative end and only administrator is guaranteed the access. The
purpose of the project is to build an application program to reduce the manual work for managing the sales,
discounts, stock, and payments. It tracks all the details about stocks, products, and inventory; it also prints
various reports as per input given by the user.
Advantages:-
5
WHY IS THE PARTICULAR TOPIC CHOSEN?
The purpose of choosing this project is to computerise the data storage in MYSQL database using python.
The concepts discussed in this project will help us to make own application and add functionally to the
same.
This will be very handy when we are trying to create a customized application that is suited for our
personal needs. Over the decades computers and stock have developed gradually, changed with time, taste and
trend. But nobody knew that a time will come when both these fields will complement each other so well. Today
stock management has reached new heights by computer aided methods of design. As a result of which,
computer industry has got its new customer. Computer technology is making waves in the stock management
zone.
6
OBJECTIVES AND SCOPE OF THE PROJECT
The objective of this project is to let the students apply the programming knowledge into a real world
situation/problem and exposed the students how programming skills helps in developing a good software.
Apply object oriented programming principles effectively when developing small to medium sized projects.
Students will demonstrate a breadth of knowledge in computer science, as exemplified in the areas of
Students will demonstrate ability to conduct a research or applied Computer Science project, requiring writing
The purpose of the project is to build an application program to reduce the manual work for managing the
7
METHODOLOGY
MODULES USED :
MODULES:
The OS modules in python provides a way of using operating system dependent functionality . The
functions that OS module provides allow you to interface with the underlying operating system that python is
running on – be that Window, mac.
DATETIME :
The datetime module in python is used to access the current date and time of data entered in hardware,
operating system .
8
FUNCTIONS
To Add product():
To Edit product():
To Delete product():
To Search product():
To Purchase product():
To View purchase():
9
This function is used to view purchase.
This function is used to access all functions by entering their respective number.
10
SOFTWARE SPECIFICATION:-
Operating System : Windows 10
Platform : Python IDLE 3.9
Database : MySQL
Languages : Python
Python : Frontend
MySQL : Backend
HARDWARE SPECIFICATION:-
Device name : DESKTOP-87F5TAS
11
Source code :-
#Stock management
#This will help us to keep a track on our stocks
import os
import mysql.connector as sqltor
import datetime
now=datetime.datetime.now()
#############################################################
#In below funtion we modify the data
def product_mgmt():
while True:
print("\t\t\t 1.Add NewProduct")
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:
delete_product()
if p==5:
break
###############################################################
#From here also the stocks would be modified acc. to sale
12
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
#############################################################
#This will keep a track of items available
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 :"))
if s == 1:
sale_product()
if s == 2:
list_sale()
if s == 3:
break
#############################################################
#This will keep details of the employee
def user_mgmt():
while True:
print("\t\t\t 1. Add user")
print("\t\t\t 2. List user")
13
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
#############################################################
#This is a backend process where tables are created
def create_table():
mydb = sqltor.connect(host="localhost", user="root",\
password="", database="stockmanagement")
mycursor = mydb.cursor()
print("Creating PRODUCT table")
sql = ("CREATE TABLE if not exists product(pcode int(4),\
pname char(30) NOT NULL,pprice float(8,2),pqty int(4),\
pcat char(30));")
mycursor.execute(sql)
print("PRODUCT table created")
print("Creating ORDERS table")
sql =("CREATE TABLE if not exists orders(orderid int(4),\
orderdate DATE,pcode char(30) NOT NULL,pprice float(8,2),\
pqty int(4),supplier char(50),pcat char(30));")
mycursor.execute(sql)
print("ORDERS table created")
print("Creating SALES table")
sql =("CREATE TABLE if not exists sales(salesid int(4),\
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(30),\
uname char(30) NOT NULL,upwd char(30));")
mycursor.execute(sql)
14
print("USER table created")
#############################################################
#With the help of this we will be able to see the tables created
def list_tables():
mydb = sqltor.connect(host="localhost", user="root", \
password="",database="stockmanagement")
mycursor = mydb.cursor()
sql = "show tables;"
mycursor.execute(sql)
for i in mycursor:
print(i)
#############################################################
#This will keep information of the product and the name of supplier
def add_order():
mydb = sqltor.connect(host="localhost", user="root", \
password="", database="stockmanagement")
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)
mydb.commit()
#############################################################
#This function will list the order which is given
def list_order():
15
mydb=sqltor.connect(host="localhost", user="root", \
password="", database="stockmanagement")
mycursor = mydb.cursor()
sql=("SELECT * from orders")
mycursor.execute(sql)
print("\t\t\t\t\t\t\t ORDERS DETAILS")
print("-"*95)
print("orderid\t date \t\t pdt_code \t price \t quantity \t supplier \t\t category")
print("-" * 95)
for i in mycursor:
print(i[0], "\t", i[1], "\t", i[2], "\t\t", \
i[3], "\t", i[4], "\t\t", i[5], "\t", i[6])
print("-" * 95)
#############################################################
def db_mgmt( ):
while True:
print("\t\t\t 1. Table creation")
print("\t\t\t 2. List Tables")
print("\t\t\t 3. Back (Main Menu)")
p = int(input("\t\t Enter Your Choice :"))
if p == 1:
create_table()
if p == 2:
list_tables()
if p == 3:
break
#############################################################
#Product details are inserted with the help of function
def add_product():
mydb = sqltor.connect(host="localhost", user="root",\
password="",database="stockmanagement")
mycursor = mydb.cursor()
sql =("INSERT INTO product(pcode,pname,pprice,pqty,pcat) \
16
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)
mycursor.execute(sql,val)
mydb.commit()
else:
print("\t\t Product already exist")
#############################################################
#Help us to update the quantity of exisiting product
def update_product():
mydb = sqltor.connect(host="localhost", user="root",password="", database="stockmanagement")
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")
#############################################################
#With this function we will delete the product from the table
def delete_product():
mydb = sqltor.connect(host="localhost", user="root",password="", database="stockmanagement")
17
mycursor=mydb.cursor()
code = int(input("Enter the product code :"))
sql = "DELETE FROM product WHERE pcode = %s;"
val = (code,)
mycursor.execute(sql, val)
mydb.commit()
print(mycursor.rowcount,"record(s) deleted")
#############################################################
#This will search the product as you want it to be displayed
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
#############################################################
def list_product():
mydb = sqltor.connect(host="localhost", user="root",password="",database="stockmanagement")
mycursor = mydb.cursor()
sql =("SELECT * from product")
mycursor.execute(sql)
print("\t\t\t\t PRODUCT DETAILS")
18
print("\t\t", "-" * 60)
print("\t\t code \t name \t price \t quantity \t category")
print("\t\t", "-" * 60)
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", "-" * 60)
#############################################################
def list_prcode(code):
mydb = sqltor.connect(host="localhost", user="root",password="", database="stockmanagement")
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", "-" * 60)
print("\t\t code \t name \t price \t quantity \t category")
print("\t\t", "-" * 60)
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", "-" * 60)
############################################################
def sale_product():
mydb = sqltor.connect(host="localhost", user="root",password="", database="stockmanagement")
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 :
19
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])
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),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 = sqltor.connect(host="localhost", user="root",
password="", database="stockmanagement")
mycursor = mydb.cursor()
sql = "SELECT * FROM sales"
mycursor.execute(sql)
print("\t\t\t\t SALES DETAILS")
print("-" * 90)
print("Sales_ID \t Date \t\t Prd_Code \tPrice \t\t\
Quantity \t Total")
print("-" * 90)
for x in mycursor:
20
print(x[0], "\t\t", x[1], "\t", x[2], "\t\t", x[3],
"\t\t", x[4], "\t\t", x[5])
print("-" * 90)
#############################################################
def list_prcat(cat):
mydb = sqltor.connect(host="localhost", user="root",
password="", database="stockmanagement")
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", "-" * 60)
print("\t\t code \t name \t price \t quantity \t category")
print("\t\t", "-" * 60)
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", "-" * 60)
#############################################################
def add_user():
mydb = sqltor.connect(host="localhost", user="root",
password="", database="stockmanagement")
mycursor = mydb.cursor()
uid = input("Enter emaid 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()
21
print(mycursor.rowcount, "user created")
#############################################################
def list_user():
mydb = sqltor.connect(host="localhost", user="root",
password="", database="stockmanagement")
mycursor = mydb.cursor()
sql = "SELECT uid, uname from user"
mycursor.execute(sql)
clrscr()
print("\t\t\t\t USER DETAILS")
print("\t\t", "-" * 40)
print("\t\t UID \t\t\t\t Name ")
print("\t\t", "-" * 40)
for i in mycursor:
print("\t\t", i[0], "\t", i[1])
print("\t\t", "-" * 40)
#############################################################
def clrscr():
print("\n"*5)
while True:
clrscr()
print("\t\t\t STOCK MANAGEMENT")
print("\t\t\t *****************\n")
print("\t\t 1. DATABASE SETUP")
print("\t\t 2. PRODUCT MANAGEMENT")
print("\t\t 3. PURCHASE MANAGEMENT")
print("\t\t 4. SALES MANAGEMENT")
print("\t\t 5. USER MANAGEMENT")
print("\t\t 6. EXIT\n")
n = int(input("Enter your choice :"))
if n == 1:
db_mgmt()
if n == 2:
22
product_mgmt()
if n == 3:
os.system('cls')
purchase_mgmt()
if n == 4:
sales_mgmt()
if n == 5:
user_mgmt()
if n == 6:
break
#Program Over!!!
#The above program can be used in grocery shop
23
Output:-
1:-idle output
(AMD64)] on win32
=RESTART:C:\Users\ACER\Desktop\stock_management-20241220T041304Z001\
stock_management\stockmanagement.py
24
STOCK MANAGEMENT
*****************
1. DATABASE SETUP
2. PRODUCT MANAGEMENT
3. PURCHASE MANAGEMENT
4. SALES MANAGEMENT
5. USER MANAGEMENT
6. EXIT
25
Enter your choice :1
1. Table creation
2. List Tables
26
SALES table created
1. Table creation
2. List Tables
('orders',)
('product',)
('sales',)
27
('user',)
1. Table creation
2. List Tables
STOCK MANAGEMENT
*****************
1. DATABASE SETUP
2. PRODUCT MANAGEMENT
28
3. PURCHASE MANAGEMENT
4. SALES MANAGEMENT
5. USER MANAGEMENT
6. EXIT
1.Add NewProduct
2.List Product
3.Update Product
4.Delete Product
29
5.Back(Main Menu)
1.Add NewProduct
2.List Product
3.Update Product
30
4.Delete Product
5.Back(Main Menu)
1.Add NewProduct
2.List Product
31
3.Update Product
4.Delete Product
5.Back(Main Menu)
1.Add NewProduct
32
2.List Product
3.Update Product
4.Delete Product
5.Back(Main Menu)
33
PRODUCT DETAILS
------------------------------------------------------------
------------------------------------------------------------
------------------------------------------------------------
34
3. List product category wise
PRODUCT DETAILS
------------------------------------------------------------
------------------------------------------------------------
------------------------------------------------------------
35
1. List all product
PRODUCT DETAILS
------------------------------------------------------------
------------------------------------------------------------
36
5 Olive Oil 100.0 60 Food
------------------------------------------------------------
PRODUCT DETAILS
------------------------------------------------------------
37
------------------------------------------------------------
------------------------------------------------------------
38
3. List product category wise
1.Add NewProduct
2.List Product
3.Update Product
4.Delete Product
5.Back(Main Menu)
39
1 record(s) deleted
1.Add NewProduct
2.List Product
3.Update Product
4.Delete Product
5.Back(Main Menu)
40
4. Back (Main Menu)
PRODUCT DETAILS
------------------------------------------------------------
------------------------------------------------------------
41
4 Pasta 20.0 80 Food
------------------------------------------------------------
1.Add NewProduct
2.List Product
3.Update Product
42
4.Delete Product
5.Back(Main Menu)
STOCK MANAGEMENT
*****************
1. DATABASE SETUP
2. PRODUCT MANAGEMENT
3. PURCHASE MANAGEMENT
43
4. SALES MANAGEMENT
5. USER MANAGEMENT
6. EXIT
1.Add Order
2.List Order
3.Back(Main Menu)
44
Enter product quantity : 2
1.Add Order
2.List Order
3.Back(Main Menu)
ORDERS DETAILS
45
----------------------------------------------------------------------------------
-------------
----------------------------------------------------------------------------------
-------------
46
5 2023-10-05 005 100.0 60 Supplier E Food
----------------------------------------------------------------------------------
--------
1.Add Order
2.List Order
3.Back(Main Menu)
STOCK MANAGEMENT
*****************
1. DATABASE SETUP
47
2. PRODUCT MANAGEMENT
3. PURCHASE MANAGEMENT
4. SALES MANAGEMENT
5. USER MANAGEMENT
6. EXIT
1. Sale Items
2. List Sales
48
SALES DETAILS
----------------------------------------------------------------------------------
--------
----------------------------------------------------------------------------------
--------
49
5 2023-10-05 005 100.0 1 100.0
----------------------------------------------------------------------------------
--------
1. Sale Items
2. List Sales
STOCK MANAGEMENT
*****************
1. DATABASE SETUP
50
2. PRODUCT MANAGEMENT
3. PURCHASE MANAGEMENT
4. SALES MANAGEMENT
5. USER MANAGEMENT
6. EXIT
1. Add user
2. List user
51
Enter emaid id :006
1 user created
1. Add user
2. List user
USER DETAILS
----------------------------------------
52
UID Name
----------------------------------------
user001 Alice
user002 Bob
user003 Charlie
user004 Diana
user005 Eve
006 abc
----------------------------------------
1. Add user
53
2. List user
STOCK MANAGEMENT
****************
1. DATABASE SETUP
2. PRODUCT MANAGEMENT
3. PURCHASE MANAGEMENT
4. SALES MANAGEMENT
5. USER MANAGEMENT
54
6. EXIT
2.sql output:-
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 40
Server version: 5.5.16-log MySQL Community Server (GPL)
Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
55
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> select*orders;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to
your MySQL server version for the right syntax to use near 'orders' at line 1
mysql> SELECT * FROM orders;
+---------+------------+-------+--------+------+------------+------+
56
| orderid | orderdate | pcode | pprice | pqty | supplier | pcat |
+---------+------------+-------+--------+------+------------+------+
| 2116 | 2024-12-20 | 6 | 56.00 | 2 | adfco | food |
| 1 | 2023-10-01 | 001 | 30.00 | 50 | Supplier A | Food |
| 2 | 2023-10-02 | 002 | 10.00 | 200 | Supplier B | Food |
| 3 | 2023-10-03 | 003 | 40.00 | 150 | Supplier C | Food |
| 4 | 2023-10-04 | 004 | 20.00 | 80 | Supplier D | Food |
| 5 | 2023-10-05 | 005 | 100.00 | 60 | Supplier E | Food |
+---------+------------+-------+--------+------+------------+------+
6 rows in set (0.00 sec)
57
| 4 | Pasta | 20.00 | 80 | Food |
+-------+-------+--------+------+-------+
5 rows in set (0.00 sec)
mysql>
58
BIBLIOGRAPHY:-
python.org
Code Academy
tutorialsPoint.com
PythonChallenge.com
LearnPython.org
layak.in
59
60