0% found this document useful (0 votes)
79 views13 pages

Sales Management System

The document contains source code for a sales management system with Python and MySQL. It includes code to create databases and tables to store product and user data, a main menu interface to log in as a customer or admin, functionality for customers to view products and make purchases that update the database, and options for admins to view, add, and update product stock and add new products. The code also logs date and time of use and includes a registration window to add new users to a database table.

Uploaded by

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

Sales Management System

The document contains source code for a sales management system with Python and MySQL. It includes code to create databases and tables to store product and user data, a main menu interface to log in as a customer or admin, functionality for customers to view products and make purchases that update the database, and options for admins to view, add, and update product stock and add new products. The code also logs date and time of use and includes a registration window to add new users to a database table.

Uploaded by

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

SOURCE CODE

FILE NAME : TABLES

import mysql.connector as sql


conn= sql.connect(host='localhost', user = 'root',
password ='manager')
c1=conn.cursor()
c1.execute("create database "+name_of_database)
c1.execute('use {}'.format(puj))
c1.execute("create table stock (product_no int(10)
primary key,product_name varchar(30),cost_per_product
int(10),stock int(10),purchased int(10) );")
c1.execute("create table user(username
varchar(255),passwd varchar(255));")
conn.commit()

FILE NAME : MAIN.py

import mysql.connector as sql


conn= sql.connect(host='localhost', user = 'root',
password ='manager',database ='sms')
c1=conn.cursor()
chpasswd='d'
print('''+ +
/////////////////////////
/////////////////////////
welcome to Game Point
////////////////////////
///////////////////////
+ +''')
c1.execute('select product_no,product_name from
stock;')
peee=c1.fetchall()
peee1=list(peee)
print('''PRODUCT PRODUCT NAME
NO''')

for i in range(0,int(len(peee))):

1|Page
print(peee[i] )
it=0
bill=0
while 5>1:

print("==============================================
=============================================")
print("1. CUSTOMER")
print("2. ADMIN")
print("3.EXIT")
loggin=int(input('enter the
choice:'))
if loggin==1:
while 3>1:

print("==============================================
=============================================")

b=input('product number: ')

c1.execute('select product_name,cost_per_product from


stock where product_no =' + b)
data=
c1.fetchall()

data1=list(data[0])

print('product name :',

data1[0])
appr=
print('cost of the product :', data1[1] )
if
input('do you want to buy it (Y/N) :')

appr == 'y' or appr =='Y' :

c1.execute("update stock set stock = stock-1 where


product_no= " + b )

c1.execute("update stock set purchased = purchased+1


where product_no=" + b )

2|Page
bill+=int(data1[1])

it+=1

3|Page
print("bought successfully!!!!")

opn = input(" Do you want buy any other thing (Y/N) :


")

if opn == 'y' or opn == 'Y':

continue

elif opn=='n' or opn=='N':

break

elif appr =='n' or appr =='N':

opn = input(" Do you want buy any other thing (Y/N)


: ")

if opn == 'y' or opn == 'Y':

continue

elif opn == 'n' or opn =='N':

just=input('MODE OF PAYMENT (Cash/Card):')

print(' BILL')

print(''' GAME POINT


NUMBER OF ITEMS PURCHASED:''',it)

print('''GRAND TOTAL AMOUNT:''',bill)

print('''MODE OF PAYMENT:''',just)

print('''*******THANK YOU*******
*******PLEASE VIST AGAIN*******''')

break
else:

print('####invalid command####')

4|Page
break

conn.commit()

elif loggin==2:

print("1. veiw stock")

print("2. add stock")

print("3. Adding a new product")

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

if ch==1:

a=input('Enter the product number :')

c1.execute("select * from stock where


product_no="+a)

dt=c1.fetchall()

dt1=list(dt[0])

print("product name :",dt1[1])

print("cost per product:",dt1[2])

print("stock available:",dt1[3])

print(" Number items purchased :",dt1[4])

elif ch==2:

prdno=input("Enter the product number of the


product for which the stock is going to be
updated:")

upd_value=int(input("enter the number of new


stocks came:"))

5|Page
c1.execute("update stock set stock=stock+" +
str(upd_value) + " where product_no="+prdno)

conn.commit()

elif ch==3:

pno1=input('Enter the product number of new


product:')

pna=input('Enter the product name of the new


product:')

cst=input('Enter the cost of the product:')

stock12=input('Enter the number of stocks of the


new product arrived:')

pch='0'

c1.execute("insert into stock values(" + pno1


+','+'"'+pna+'"'+','+cst+','+stock12+','+pch+')')

print("Added sucessfully!!!!!!!")

conn.commit()
else:

print('####INVALID OPTION ####')

elif loggin== 3:
print("...QUITING... ")
break
else:
print("###INVALID OPTION####")

6|Page
FILE NAME: SALES MANAGEMENT SYSTEM

import mysql.connector as sql


import datetime
d_day=datetime.date.today()
d_time=datetime.datetime.now()
conn= sql.connect(host='localhost', user = 'root',
password ='manager',database ='sms')
c1=conn.cursor()
print("SALES MANAGEMENT SYSTEM")
print(d_day.day,"/",d_day.month,"/",d_day.year,"
",d_time.hour,":",d_time.minute,)
chpasswd='d'
while 5>1:
print("1.LOGIN")
print("2.REGISTER")
print("3.VEIW ALL USERS")
print("4.EXIT")
choice=int(input('ENTER THE
CHOICE:'))

print("==============================================
==============================")
if choice == 1:
us=input('USERNAME:')
ps=input('PASSWORD:')
c1.execute("select * from user where username =
'{}' and passwd = '{}'".format(us , ps))

data = c1.fetchall()

if any(data) :

import main

else:

print('''..SORRY..
WRONG.......USERNAME OR PASSWORD''')

elif choice == 2:
7|Page
print("==============================================
=============================================")
li=input('ENTER THE NEW USER ID:')
while 8>1:

li2=input('ENTER YOUR PASSWORD:')

li3=input('ENTER YOUR PASSWORD AGAIN(to confirm):')


if
li2== li3:

c1.execute("insert into user


values("+'"'+li+'",'+'"'+li3+'")')

print("ID has been successfully created:")

conn.commit()

break
elif choice ==3:

c1.execute("select username from user")


data = c1.fetchall()
for row in data :
print(row)
elif choice == 4:

print(".......................LOGGING...........OUT
................")
break
else:
print('please enter the right option')

8|Page
OUTPUT

MAIN WINDOW

LOGIN WINDOW

9|Page
CUSTOMER WINDOW

ADMIN WINDOW

10 | P a g e
REGISTER WINDOW

VEIW THE USERS WINDOW

11 | P a g e
EXIITING WINDOW

12 | P a g e
13 | P a g e

You might also like