Skip to content

Commit bb1963c

Browse files
committed
Started creation of admin panel
1 parent 12a4aa1 commit bb1963c

File tree

3 files changed

+190
-7
lines changed

3 files changed

+190
-7
lines changed

accounttype.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,26 +5,26 @@ def acctype():
55
print("2.Employee.")
66
print("3.Client.")
77
print("Enter 0 to end process.")
8-
a=int(input("\nEnter your account type:"))
8+
a=input("\nEnter your account type:")
99

10-
if a==1:
10+
if a=='1':
1111
b=input("\nEnter admin password:")
1212
if b=="admin123":
1313
return 1
1414
else:
1515
print("\nWrong password!\n")
1616

17-
elif a==2:
17+
elif a=='2':
1818
b=input("\nEnter employee password:")
1919
if b=="emp123":
2020
return 2
2121
else:
2222
print("\nWrong password!\n")
2323

24-
elif a==3:
24+
elif a=='3':
2525
return 3
2626

27-
elif a==0:
27+
elif a=='0':
2828
print("\nShutting down the program.")
2929
break
3030

adminpanel.py

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

setup.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
TABLES = {}
99
TABLES['employees'] = (
1010
"CREATE TABLE `employees` ("
11-
" `emp_no` int(5) NOT NULL AUTO_INCREMENT,"
11+
" `emp_no` int(5) NOT NULL ,"
1212
" `birth_date` date NOT NULL,"
1313
" `first_name` varchar(15) NOT NULL,"
1414
" `last_name` varchar(15) NOT NULL,"
@@ -20,7 +20,7 @@
2020

2121
TABLES['clients'] = (
2222
"CREATE TABLE `clients` ("
23-
" `acc_no` int(5) NOT NULL AUTO_INCREMENT PRIMARY KEY,"
23+
" `acc_no` int(5) NOT NULL PRIMARY KEY,"
2424
" `acc_type` enum('S','C') NOT NULL,"
2525
" `first_name` varchar(15) NOT NULL,"
2626
" `last_name` varchar(15) NOT NULL,"

0 commit comments

Comments
 (0)