-
Notifications
You must be signed in to change notification settings - Fork 0
/
sales_management2.py
163 lines (153 loc) · 3.71 KB
/
sales_management2.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
#Sales Management
import pandas as pd
from datetime import date
import csv
import os
import sys
def main():
print('1. User 2. Manager 3. Exit')
c = input('Enter choice : ')
if c == '1':
user()
elif c == '2':
p = input('Enter password : ')
if p == '1234':
manager()
else:
main()
else:
quit()
def user():
print('1. Check products 2. Buy 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():
I = r'enter_your_directory_here for products.csv'
with open(I,'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('REMARKS : ',x[2])
print('|----------------------------------------------------|')
cf.close()
user()
def buy():
p = input('Product ID : ')
n = input('Your name : ')
a = input('Your address : ')
t = date.today()
row = [p,n,a,t]
print('Kindly pay on delivery')
ol = r'enter_your_directory_here'
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('Your address : ')
t = input('Date : ')
row = [p,n,a,t]
l = r'enter_your_directory_here for orders.csv'
with open(l,'r+') as cf:
cw = csv.writer(cf)
cd = pd.read_csv(l)
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 2. Products 3. Delete 4.Check Orders 5.Exit')
c = input('Enter choice : ')
if c == '1':
add()
elif c == '2':
products()
elif c == '3':
delete()
elif c == '4':
corders()
elif c == '5':
main()
else:
manager()
def add():
n = input('Name : ')
c = input('Cost : ')
d = input('Details : ')
row = [n,c,d]
l = r'enter_your_directory_here for products.csv'
with open(l, 'a+', newline = '') as cf:
cw = csv.writer(cf)
cw.writerow(row)
cf.close()
manager()
def products():
l = r'enter_your_directory_here for 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'enter_your_directory_here for 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 corders():
l = r'enter_your_directory_here for orders.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()
main()