Professional Documents
Culture Documents
_________________________________________________________________________________________
DEVELOPED BY:
Lakshya Soni
INDEX
S No. Description Page No.
1. Certificate 3
2. Acknowledgement & References 4
3. Introduction to Python 5
4. Introduction to Pandas 7
5. Introduction to Matplotlib 9
6. Source Code 11
7. Output Screen 16
8. Hardware & Software Requirement 20
CERTIFICATE
This is to certify that Sales Management System Informatics
Practices project is developed by Lakshya Soni, Rishabh
Khoal and Mansi Saini under my supervision in the computer
lab of All Saints’ Sr. Sec. School in the session 2023-2024. The
work done by them is original.
Sharon Amus
Informatics Teacher
Date: 8/12/2023
ACKNOWLEDGEMENT
INTRODUCTION TO PYTHON
**Introduction to Python Programming**
**2. ** **Versatility:**
Introduction to Pandas
**Introduction to Pandas: Data Manipulation with Python**
Pandas has robust support for time series data. It includes functionalities for
resampling, time zone handling, and date range generation. These features
make Pandas a preferred choice for working with time-stamped data, common
in financial, scientific, and business applications.
Introduction to Matplotlib
**8. Extensibility:**
Matplotlib is extensible, enabling users to create custom plots and
visualizations. Additionally, the library supports various backends, allowing
users to choose the most suitable rendering environment for their specific
needs, whether it's generating static images or interactive plots.
1. **Imports:**
- `pandas` is used for data manipulation and analysis.
- `date` from the `datetime` module is used to handle date-related operations.
- `csv` is used to read and write CSV files.
- `matplotlib.pyplot` is used for plotting graphs.
3. **User Functions:**
- `user()`: Provides options for checking products, buying a product, canceling an
order, or exiting.
- `cproducts()`: Lists available products.
- `buy()`: Takes input for buying a product and adds the order to the orders CSV file.
- `cancel()`: Takes input for canceling an order and removes the order from the
orders CSV file.
4. **Manager Functions:**
- `manager()`: Provides options for adding products, showing products, deleting
products, checking orders, showing sales graphs, or exiting.
- `add()`: Takes input for adding a new product and adds it to the products CSV file.
- `products()`: Lists available products.
- `delete()`: Takes input for deleting a product and removes it from the products CSV
file.
- `coders()`: Lists the orders.
- `sales_plot()`: Generates a bar chart showing total sales for each product.
5. **Sales Graph:**
- Loads orders and products data from CSV files using pandas.
- Groups products by name and calculates the total sales.
- Generates a bar chart using matplotlib to visualize the total sales for each product.
6. **Execution:**
Source Code
import pandas as pd
from datetime import date
import csv
import matplotlib.pyplot as plt
def main():
print("1. User 2. Manager ")
c= input('Enter Choice : ')
if c=="1":
user()
elif c=='2':
p= input('Enter Password : ')
if p== '3443':
manager()
else:
print("Incorrect Password")
main()
else:
main()
def user():
print('1. Check Products. 2. Buy a Product. 3. Cancel Order. 4.Exit.')
c = input('Enter Choice : ')
if c== '1':
cproducts()
elif c =='2':
buy()
elif c=='3':
cancel()
elif c=='4':
main()
else:
user()
def cproducts():
l=r'D:\Sales Managment System\products.csv'
with open(l,'r')as cf:
cw = csv.reader(cf)
cd = pd.DataFrame(cw)
print('|-------------------------------------|')
for i in cd.index:
x=list(cd.loc[i])
print('PID : ',i)
print('NAME : ',x[0])
print('COST : ',x[1])
print('REMARKS : ',x[2])
print('|-------------------------------------|')
cf.close()
user()
def buy():
p=input('Product ID: ')
n=input('Your Name : ')
a=input('Address : ')
t = date.today()
row = [p,n,a,t]
print('Kindly Pay On Delivery')
ol =r'D:\Sales Managment System\oders.csv'
with open(ol,'a+',newline='')as cf:
cw = csv.writer(cf)
cw.writerow(row)
cf.close()
user()
def cancel():
p=input('Product ID : ')
n = input('Your Name : ')
a = input('Address : ')
t= input('Date')
row=[p,n,a,t]
l = r'D:\Sales Managment System\oders.csv'
with open(l,'r+')as cf:
cw = csv.reader(cf)
cd = pd.DataFrame(cw)
for i in cd.index:
x = list(cd.loc[i])
if row== x:
cd.drop([i],inplace=True)
cf.close
with open(l,'w',newline='') as cf:
cw=csv.writer(cf)
for i in cd.index:
x = list(cd.loc[i])
cw.writerow(x)
cf.close()
user()
def manager():
print('1. Add Products. 2. Show Products. 3. Delete. 4. Check Order.
5. Show Sales Graph. 6.exit')
c=input('Enter Choice : ')
if c == '1':
add()
elif c=='2':
products()
elif c=='3':
delete()
elif c=='4':
coders()
elif c=='5':
sales_plot()
elif c=='6':
main()
else:
manager()
def add():
n=input('Name : ')
c = input('Cost : ')
d = input('Details : ')
row = [n,c,d]
l=r'D:\Sales Managment System\products.csv'
with open(l,'a+',newline='')as cf:
cw =csv.writer(cf)
cw.writerow(row)
cf.close()
manager()
def products():
l=r'D:\Sales Managment System\products.csv'
with open(l,'r')as cf:
cw= csv.reader(cf)
cd= pd.DataFrame(cw)
print('|-------------------------------------|')
for i in cd.index:
x = list(cd.loc[i])
print('PID : ',i)
print('NAME : ',x[0])
print('COST : ',x[1])
print('REMARKS : ',x[2])
print('|-------------------------------------|')
cf.close()
manager()
def delete():
d = int(input('Enter PID : '))
l= r'D:\Sales Managment System\products.csv'
with open(l,'r+')as cf:
cw = csv.reader(cf)
cd = pd.DataFrame(cw)
cd.drop([d],inplace=True)
cf.close()
with open(l,'w',newline='') as cf:
cw = csv.writer(cf)
for i in cd.index:
x = list(cd.loc[i])
cw.writerow(x)
cf.close()
manager()
def coders():
l=r'D:\Sales Managment System\oders.csv'
with open(l,'r')as cf:
cw = csv.reader(cf)
cd = pd.DataFrame(cw)
print('|-------------------------------------|')
for i in cd.index:
x = list(cd.loc[i])
print('PID : ',x[0])
print('NAME : ',x[1])
print('ADDRESS : ',x[2])
print('DATE : ',x[3])
print('|-------------------------------------|')
cf.close()
manager()
def sales_plot():
# Load the orders CSV data with tab delimiter and set the column names
# Load the orders CSV data with tab delimiter and set the column names
orders_df = pd.read_csv(r'D:\Sales Managment System\oders.csv', delimiter='\t',
names=["Product ID", "Name", "Address", "Date"])
# Group the DataFrame by the `Name` column and sum the `Cost` column
total_sales = products_df.groupby('Name')['Cost'].sum()
main()
Output Screens:
User Login
2. Buy a Product:
3. Cancel Order:
Manager Login
1. Password Verification :
2. Adding Products :
4. Delete a Product:
Hardware Requirement:
Pentium 3/4/Core 2 Duo/Dual core/Pentium/i3/i5/i7, 256
MB RAM
2 MB free space on Hard Disk Colour
Monitor/LCD