Skip to content

Commit f066fd2

Browse files
committed
Fixed bugs and completed admin panel and functions
1 parent da92cf4 commit f066fd2

File tree

5 files changed

+44
-7
lines changed

5 files changed

+44
-7
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@ __pycache__/
22
firsttime.txt
33
cred.dat
44
links.txt
5-
tempCodeRunnerFile.py
5+
tempCodeRunnerFile.py
6+
start program.bat

adminpanel.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import hireemployee
22
import fireemployee
33
import editemployee
4+
import showemployee
45

56
def ap():
67
print("\nWelcome Admin!!")
@@ -10,6 +11,7 @@ def ap():
1011
print("\n1.Hire Employee")
1112
print("2.Fire Employee")
1213
print("3.Change employee data")
14+
print("4.Show employee table")
1315
print("\nInput 0 to quit.")
1416
a=input("Enter choice:")
1517
if a=='1':
@@ -18,6 +20,8 @@ def ap():
1820
fireemployee.ap2()
1921
elif a=='3':
2022
editemployee.ap3()
23+
elif a=='4':
24+
showemployee.ap4()
2125
elif a=='0':
2226
print("Quit Admin Panel.")
2327
break

editemployee.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@ def ap3():
5757
f2()
5858

5959
def f2():
60+
global cur
61+
global conn
6062
global emp_no
6163
global birth_date
6264
global hire_date
@@ -130,7 +132,7 @@ def f2():
130132
import traceback
131133
traceback.print_exc()
132134
else:
133-
if age(birth_date)>=20:
135+
if age(birth_date)>=20 and age(birth_date)<=60:
134136
if age(birth_date)-age(hire_date)>=20:
135137
try:
136138
cur.execute("update employees set birth_date='{}' where emp_no={}".format(birth_date,emp_no))
@@ -147,7 +149,11 @@ def f2():
147149
print(birth_date,": birth_date")
148150
print(hire_date,":hire date you entered")
149151
else:
150-
print("Employee must be atleast 20 years of age!!")
152+
if age(birth_date)<20:
153+
print("Employee must be atleast 20 years of age!!")
154+
else:
155+
print("Maximum age is 60 years!!!")
156+
print("\nwrong input\n")
151157
if a == '3':
152158
while True:
153159
first_name=input("Enter first name (max 15 char): ")
@@ -264,7 +270,7 @@ def f2():
264270
if age(birth_date)-age(hire_date)>=20:
265271
break
266272
else:
267-
print("Employee must atleast be 20 years of age!!")
273+
print("Employee must atleast be 20 years of age when hired!!")
268274

269275
cur.close()
270276
conn.close()

hireemployee.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,10 +77,14 @@ def ap1():
7777
import traceback
7878
traceback.print_exc()
7979
else:
80-
if age(birth_date)>=20:
80+
if age(birth_date)>=20 and age(birth_date)<=60:
8181
break
8282
else:
83-
print("Employee must be atleast 20 years of age!!")
83+
if age(birth_date)<20:
84+
print("Employee must be atleast 20 years of age!!")
85+
else:
86+
print("Maximum age is 60 years!!!")
87+
print("\nwrong input\n")
8488
#Employee name
8589
while True:
8690
first_name=input("Enter first name (max 15 char): ")
@@ -155,7 +159,9 @@ def ap1():
155159
import traceback
156160
traceback.print_exc()
157161
else:
158-
if age(birth_date)-age(hire_date)>=20:
162+
if age(hire_date)>60:
163+
print("Employee must be below 60 years of age!!")
164+
elif age(birth_date)-age(hire_date)>=20:
159165
break
160166
else:
161167
print("Employee must atleast be 20 years of age!!")

showemployee.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import mysql.connector
2+
import pickle
3+
def ap4():
4+
cred = open("cred.dat","rb")
5+
dat=pickle.load(cred)
6+
cred.close()
7+
Passwo=dat[0]
8+
Databa=dat[1]
9+
conn=mysql.connector.connect(host="localhost",user="root",password=Passwo,database=Databa)
10+
cur=conn.cursor()
11+
cur.execute("select * from employees")
12+
results=cur.fetchall()
13+
print("---------------------------------------------------------------------------------------")
14+
print("|","%7s"%"EMP_NO","|","%11s"%"BIRTH_DATE","|","%16s"%"FIRST_NAME","|","%16s"%"LAST_NAME","|","%7s"%"GENDER","|","%11s"%"HIRE_DATE","|")
15+
for row in results:
16+
print("---------------------------------------------------------------------------------------")
17+
print("|","%7s"%row[0],"|","%11s"%row[1],"|","%16s"%row[2],"|","%16s"%row[3],"|","%7s"%row[4],"|","%11s"%row[5],"|")
18+
cur.close()
19+
conn.close()
20+
print("---------------------------------------------------------------------------------------")

0 commit comments

Comments
 (0)