-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTimber_Management.py
280 lines (269 loc) · 18.5 KB
/
Timber_Management.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
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
import mysql.connector
mysql=mysql.connector.connect(host="localhost",user="root",passwd="mysql")
mycursor=mysql.cursor()
mycursor.execute("create database if not exists Timber_Management")
mycursor.execute("use Timber_Management")
mycursor.execute("create table if not exists Inventory(Pr_No int Primary key,Type_of_woods varchar(20),Length_ft char(10),Quantity int(10),Price_Per_Piece_Rs float(10))")
mycursor.execute("create table if not exists Employee(Em_No int Primary key,Name char(25),Age int(2),Contact varchar(10),Salary_Rs int(10))")
mycursor.execute("create table if not exists user_data(username varchar(30) primary key,password varchar(30) default'000')")
print("""
###################################
########(Timber - Management)#########@
########----------------------------------#########@@
####################################@@@
""")
while True:
print("""
Select User - - >
1.Admin
2.Manager Of Inventory
3.Employee
""")
a=int(input("Enter Your Choice - - >"))
if a==1:
print("Logging in as Admin ")
Pass=int(input("Enter Password - - >"))
if Pass==1234:#Default Password
print("""
---------------Welcome Admin !!---------------
""")
while True:
print("""
1.Acess Inventory
2.Acess Employee Table
3.Add User
4.Delete User
5.Logout
""")
b=int(input("Enter Your Choice - - > "))
if b==1:
print("""
1.Show Inventory
2.Make Entry
3.Delete Entry
""")
c=int(input("Enter your Choice - - >"))
if c==1:
mycursor.execute("select * from Inventory")
row=mycursor.fetchall()
for i in row:
b=0
v=list(i)
k=["Pr.No","Type of Wood","Length (Ft)","Quantity","Price Per Piece(Rs)"]
d=dict(zip(k,v))
print(d)
if c==2:
Pno=input("Enter Product No = ")
tw=input("Enter Type Of Wood = ")
Len=input("Enter the length = ")
qu=input("Enter the quantity = ")
pp=input("Enter Price per piece =")
mycursor.execute("Insert into Inventory value('"+Pno+"','"+tw+"','"+Len+"','"+qu+"','"+pp+"')")
mysql.commit()
if c==3:
Pno=input("Enter the Product Number - - >")
mycursor.execute("Select * from Inventory where Pr_No="+Pno+"")
row=mycursor.fetchall()
for i in row:
b=0
v=list(i)
k=["Pr.No","Types Of Wood","Length(Ft)","Quantity","Price Per Piece(Rs)"]
d=dict(zip(k,v))
print(d)
z=input("Are you sure u want to delete the above Entry? (y/n)")
if z=="y":
mycursor.execute("delete from Inventory where Pr_No="+Pno+"")
print("SUCCESSFULLY DELETED !!!!!!!!!!!")
else:
print("NOT DELETED!!!!!!!!!!")
if b==2:
print("""
1.Show List of Employee
2.Add Employee
3.Delete Employee
""")
c=int(input("Enter your choice - - >"))
if c==1:
mycursor.execute("select * from Employee")
row=mycursor.fetchall()
for i in row:
b=0
v=list(i)
k=["Em.No","Name","Age","Contact","Salary (Rs)"]
d=dict(zip(k,v))
print(d)
if c==2:
eno=input("Enter Employee No - - >")
name=input("Enter name of Employee - - > ")
age=input("Enter age of Employee - - > ")
con=input("Enter contact no - ->")
sal=input("Enter Salary - - >")
mycursor.execute("Insert into Employee value('"+eno+"','"+name+"','"+age+"','"+con+"','"+sal+"')")
mysql.commit()
print("SUCCESSFULLY ADDED")
if c==3:
eno=input("Enter the employee number - - >")
mycursor.execute("Select * from Employee where Em_No ="+eno+"")
row=mycursor.fetchall()
for i in row:
b=0
v=list(i)
k=["S.No","Name","Age","Contact","Salary (Rs)"]
d=dict(zip(k,v))
print(d)
print("Are you sure you want to delete the above Employee? (y/n)")
z=input()
if z=="y":
mycursor.execute("delete from Employee where Em_No="+eno+"")
print("SUCCESSFULLY DELETED")
else:
print("NOT DELETED")
if b==3:
print("Fill the asked detail : ")
u=input("ENTER YOUR PREFERRED USERNAME!!:")
p=input("ENTER YOUR PREFERRED PASSWORD (PASSWORD SHOULD BE STRONG!!!:")
mycursor.execute("insert into user_data values('"+u+"','"+p+"')")
mysql.commit()
if b==5:
break
else:
print("Sorry Wrong Password !!!")
if a==2:
un=input("ENTER THE USERNAME!!:")
ps=input("ENTER THE PASSWORD!!:")
mycursor.execute("select password from user_data where username='"+un+"'")
row=mycursor.fetchall()
for i in row:
x=list(i)
if x[0]==str(ps):
while(True):
print("--------------------------------Welcome Manager!!--------------------------------")
print("""
1.Employee Entry
2.Inventory Entry
3.Take Bill
4.Logout
""")
b=int(input("Enter Your Choice - - >"))
if b==1:
print("----Employee Entry----")
eno=input("Enter Employee No - - >")
name=input("Enter name of Employee - - > ")
age=input("Enter age of Employee - - > ")
con=input("Enter contact no - ->")
sal=input("Enter Salary - - >")
mycursor.execute("Insert into Employee value('"+eno+"','"+name+"','"+age+"','"+con+"','"+sal+"')")
mysql.commit()
print("SUCCESSFULLY ADDED")
if b==2:
print("----Inventory Entry----")
Pno=input("Enter Product No = ")
tw=input("Enter Type Of Wood = ")
Len=input("Enter the length = ")
qu=input("Enter the quantity = ")
pp=input("Enter Price per piece =")
mycursor.execute("Insert into Inventory value('"+Pno+"','"+tw+"','"+Len+"','"+qu+"','"+pp+"')")
mysql.commit()
if b==3:
print("--------Making Bill-------")
mycursor.execute("select * from Inventory")
row=mycursor.fetchall()
for i in row:
b=0
v=list(i)
k=["Pr.No","Type of Wood","Length (Ft)","Quantity","Price Per Piece(Rs)"]
d=dict(zip(k,v))
print(d)
Pno=input("Enter Product No - - > ")
re=int(input("Enter how quantity = "))
mycursor.execute("Select Pr_No from Inventory where Pr_No ="+Pno+"")
pn=mycursor.fetchone()
for j in pn:
p=j
mycursor.execute("Select Type_Of_Woods from Inventory where Pr_No ="+Pno+"")
wd=mycursor.fetchone()
for j in wd:
q=j
mycursor.execute("Select Length_ft from Inventory where Pr_No ="+Pno+"")
le=mycursor.fetchone()
for j in le:
r=j
mycursor.execute("Select Quantity from Inventory where Pr_No ="+Pno+"")
qu=mycursor.fetchone()
for j in qu:
s=j
mycursor.execute("Select Price_Per_Piece_Rs from Inventory where Pr_No ="+Pno+"")
pp=mycursor.fetchone()
for j in pp:
t=j
left=s-re
print(" --------------------------------TIMBER - BILL--------------------------------","\n",
"Product Number =",p,"\n",
"Type of woods - - >",q," Length in Feet - - >",r,"\n",
"Quantity of Woods - - >",re," Price Per Piece in Rs - - >",t,"\n",
" Total Price - - >> ", re*t ,"/- Rs")
change=(left,p)
query="update Inventory set Quantity=%s where Pr_No=%s"
mycursor.execute(query,change)
if b==4:
break
else:
print("Wrong Password / Invalid Username")
if a==3:
un=input("ENTER THE USERNAME!!:")
ps=input("ENTER THE PASSWORD!!:")
mycursor.execute("select password from user_data where username='"+un+"'")
row=mycursor.fetchall()
for i in row:
a=list(i)
if a[0]==str(ps):
while(True):
print("-----------Welcome ",un, "Employee------------")
print("""
1.Take Out Bill
2.Logout
""")
y=int(input("Enter Your Choice - - > "))
if y==1:
print("--------Making Bill-------")
mycursor.execute("select * from Inventory")
row=mycursor.fetchall()
for i in row:
b=0
v=list(i)
k=["Pr.No","Type of Wood","Length (Ft)","Quantity","Price Per Piece(Rs)"]
d=dict(zip(k,v))
print(d)
Pno=input("Enter Product No = ")
re=int(input("Enter how quantity = "))
mycursor.execute("Select Pr_No from Inventory where Pr_No ="+Pno+"")
pn=mycursor.fetchone()
for j in pn:
p=j
mycursor.execute("Select Type_Of_Woods from Inventory where Pr_No ="+Pno+"")
wd=mycursor.fetchone()
for j in wd:
q=j
mycursor.execute("Select Length_ft from Inventory where Pr_No ="+Pno+"")
le=mycursor.fetchone()
for j in le:
r=j
mycursor.execute("Select Quantity from Inventory where Pr_No ="+Pno+"")
qu=mycursor.fetchone()
for j in qu:
s=j
mycursor.execute("Select Price_Per_Piece_Rs from Inventory where Pr_No ="+Pno+"")
pp=mycursor.fetchone()
for j in pp:
t=j
left=s-re
print(" --------------------------------TIMBER - BILL--------------------------------","\n",
"Product Number =",p,"\n",
"Type of woods - - >",q," Length in Feet - - >",r,"\n",
"Quantity of Woods - - >",re," Price Per Piece in Rs - - >",t,"\n",
" Total Price - - >> ", re*t ,"/- Rs")
change=(left,p)
query="update Inventory set Quantity=%s where Pr_No=%s"
mycursor.execute(query,change)
if y==2:
break