Skip to content

Commit 3d45535

Browse files
committed
Sorted code to different modules
1 parent 248706e commit 3d45535

File tree

4 files changed

+202
-183
lines changed

4 files changed

+202
-183
lines changed

accounttype.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import adminpanel
12
def acctype():
23
while True:
34
print("--------------Account Selector Menu--------------")
@@ -10,7 +11,7 @@ def acctype():
1011
if a=='1':
1112
b=input("\nEnter admin password:")
1213
if b=="admin123":
13-
return 1
14+
adminpanel.ap()
1415
else:
1516
print("\nWrong password!\n")
1617

adminpanel.py

Lines changed: 36 additions & 180 deletions
Original file line numberDiff line numberDiff line change
@@ -1,184 +1,40 @@
1-
from datetime import date
2-
3-
def age(birthdate):
4-
today = date.today()
5-
age = today.year - birthdate.year - ((today.month, today.day) < (birthdate.month, birthdate.day))
6-
return age
7-
8-
def ap1():
9-
print("-------------Hire Employee Process-------------")
10-
11-
#Employee number
12-
while True:
13-
emp_no=input("Enter emp_no (max 5 int): ")
14-
if len(emp_no) <= 5:
15-
try:
16-
emp_no=int(emp_no)
17-
print("Done OK")
18-
except ValueError:
19-
print("emp_no should be an integer!!")
20-
else:
21-
break
22-
else:
23-
print("Maximum length is 5!")
24-
#Employee Birth date
25-
while True:
26-
while True:
27-
year=input("Enter birth year (4 int): ")
28-
if len(year) == 4:
29-
try:
30-
year=int(year)
31-
print("Done OK")
32-
except ValueError:
33-
print("year should be an integer!!")
34-
else:
35-
break
36-
else:
37-
print("Year consists of 4 integers!!")
38-
39-
while True:
40-
month=input("Enter birth month (2 int) (01 to 12): ")
41-
if len(month) == 2:
42-
try:
43-
month=int(month)
44-
print("Done OK")
45-
except ValueError:
46-
print("month should be an integer!!")
47-
else:
48-
break
49-
else:
50-
print("Month consists of 2 integers!!")
51-
52-
while True:
53-
day=input("Enter birth day (2 int) : ")
54-
if len(day) == 2:
55-
try:
56-
day=int(day)
57-
print("Done OK")
58-
except ValueError:
59-
print("Date should be an integer!!")
60-
else:
61-
break
62-
else:
63-
print("Date consists of 2 integers!!")
64-
65-
try:
66-
birth_date=date(year,month,day)
67-
except ValueError:
68-
import traceback
69-
traceback.print_exc()
70-
else:
71-
if age(birth_date)>=20:
72-
break
73-
else:
74-
print("Employee must be atleast 20 years of age!!")
75-
#Employee name
76-
while True:
77-
first_name=input("Enter first name (max 15 char)")
78-
if len(first_name)<= 15:
79-
break
80-
else:
81-
print("Max 15 characters")
82-
83-
while True:
84-
last_name=input("Enter last name (max 15 char)")
85-
if len(last_name)<= 15:
86-
break
87-
else:
88-
print("Max 15 characters")
89-
#Employee Gender
1+
import pickle
2+
import mysql.connector
3+
import hireemployee
4+
5+
def cursor():
6+
cred = open("cred.dat","rb")
7+
dat=pickle.load(cred)
8+
cred.close()
9+
Passwo=dat[0]
10+
Databa=dat[1]
11+
query=mysql.connector.connect(host="localhost",user="root",password=Passwo,database=Databa)
12+
return query.cursor()
13+
14+
def ap2():
15+
print("ap2")
16+
17+
def ap3():
18+
print("ap3")
19+
20+
def ap():
21+
print("\nWelcome Admin!!")
22+
9023
while True:
91-
print("1.Male")
92-
print("2.Female")
93-
a=input("Enter choice (1 or 2):")
94-
if a== '1':
95-
gender='M'
96-
break
24+
print("\n---------------------Admin Panel-----------------------")
25+
print("\n1.Hire Employee")
26+
print("2.Fire Employee")
27+
print("3.Change employee data")
28+
print("\nInput 0 to quit.")
29+
a=input("Enter choice:")
30+
if a=='1':
31+
hireemployee.ap1()
9732
elif a=='2':
98-
gender='F'
33+
ap2()
34+
elif a=='3':
35+
ap3()
36+
elif a=='0':
37+
print("Quit Admin Panel.")
9938
break
10039
else:
101-
print("Wrong input!!")
102-
#Employee hire date
103-
while True:
104-
while True:
105-
hyear=input("Enter hire year (4 int): ")
106-
if len(hyear) == 4:
107-
try:
108-
hyear=int(hyear)
109-
print("Done OK")
110-
except ValueError:
111-
print("year should be an integer!!")
112-
else:
113-
break
114-
else:
115-
print("Year consists of 4 integers!!")
116-
117-
while True:
118-
hmonth=input("Enter hire month (2 int) (01 to 12): ")
119-
if len(hmonth) == 2:
120-
try:
121-
hmonth=int(hmonth)
122-
print("Done OK")
123-
except ValueError:
124-
print("month should be an integer!!")
125-
else:
126-
break
127-
else:
128-
print("Month consists of 2 integers!!")
129-
130-
while True:
131-
hday=input("Enter hire day (2 int) (01 to 31): ")
132-
if len(hday) == 2:
133-
try:
134-
hday=int(hday)
135-
print("Done OK")
136-
except ValueError:
137-
print("Date should be an integer!!")
138-
else:
139-
break
140-
else:
141-
print("Date consists of 2 integers!!")
142-
143-
try:
144-
hire_date=date(hyear,hmonth,hday)
145-
except ValueError:
146-
import traceback
147-
traceback.print_exc()
148-
else:
149-
if age(birth_date)-age(hire_date)>=20:
150-
break
151-
else:
152-
print("Employee must atleast be 20 years of age!!")
153-
154-
155-
print("=========== Final Data ===========")
156-
print(emp_no,
157-
birth_date,
158-
first_name,
159-
last_name,
160-
gender,
161-
hire_date)
162-
ap1()
163-
164-
# def ap():
165-
# print("\nWelcome Admin!!")
166-
167-
# while True:
168-
# print("\n---------------------Admin Panel-----------------------")
169-
# print("\n1.Hire Employee")
170-
# print("2.Fire Employee")
171-
# print("3.Change employee data")
172-
# print("\nInput 0 to quit.")
173-
# a=input("Enter choice:")
174-
# if a=='1':
175-
# ap1()
176-
# elif a=='2':
177-
# ap2()
178-
# elif a=='3':
179-
# ap3()
180-
# elif a=='0':
181-
# print("Quit Admin Panel.")
182-
# break
183-
# else:
184-
# print("Wrong input!(1,2,3)")
40+
print("Wrong input!(1,2,3)")

0 commit comments

Comments
 (0)