import sys
employeeList = {}
lstMenuOption = ('1', '2', '3', 'Q')
#i = 0 #loop count variable
validation = False #initialize validation check to "False"
menuSelection = None
numEmployees = None
num = 1
def main_menu():
print('-----------------------------------------------------')
print('(1) Add new employee(s)')
print('(2) View all employees in the database')
print("(3) Check employee's information")
print('(Q) Exit\n')
totalEmployees = len(employeeList) #Display number of employees in the databse
print('There are (%d) in the database' % totalEmployees)
print('-----------------------------------------------------')
option = input('Please select an option from the menu: ')
return option
def valid(option): #Function to validate menu selection
if (option.isnumeric() == True):
if option in lstMenuOption:
return True
elif (option.upper() == 'Q'):
global menuSelection
menuSelection = option.upper()
return True
elif (option.isnumeric() == False):
print('You have not entered a correct option.')
return False
def num_employees():
numEmployees = (input('Please enter the number of employee(s) you are entering (Q to Quit): '))
if (numEmployees.isnumeric() == True) and (int(numEmployees) < 0):
print('You have entered an invalid quantity\n')
elif (numEmployees.isnumeric() == False):
if (numEmployees.upper() == 'Q'):
exit()
else:
print('You have entered an invalid quantity')
return None
else:
numEmployees = int(numEmployees)
return numEmployees
#while (numEmployees > 0):
def add_employee(): #CPT 200: Functionality 1 part 1
employeeFName = input("Please Emter the Employee #%d's First Name:" % num)
employeeLName = input("Please Enter the Employee #%d's Last Name:" % num)
employeeSSN = input("Please Enter %s %s's SSN (123456789):" % (employeeFName, employeeLName))
employeePhone = input("Please Enter %s %s's Phone Number:" % (employeeFName, employeeLName))
employeeEmail = input("Please Enter %s %s's Email Address:" % (employeeFName, employeeLName))
employeeSalary = input("Please Enter %s %s's Salary:" % (employeeFName, employeeLName))
employeeFull = employeeFName + ' ' + employeeLName
print(" ")
employeeInfo = [employeeFName.capitalize(), employeeLName.capitalize(), employeeSSN, employeePhone, employeeEmail, employeeSalary]
#employeeList[employeeLName] = employeeInfo
return employeeFull.upper(), employeeInfo
def view_all_employees(): #Function to display all the keys of employeeList, Functionality 1 part 2
print('-----------------------------------------------------')
print('The following employees are currently in the database')
for key in employeeList.keys():
print(key)
print('-----------------------------------------------------')
def view_employee(): #Funtionality 1 part 2.5
print('-----------------------------------------------------')
empName = input('Please enter the name of the employee you want to view: ').upper()
if empName in employeeList:
record = employeeList[empName]
print('The employee record for %s is below' % empName)
print('First Name: %s' % record[0])
print('Last Name: %s' % record[1])
print('Employee SSN: %s' % record[2])
print('Employee Phone: %s' % record[3])
print('Employee Email: %s' % record[4])
print('Employee Salary: %s' % record[5])
else:
print('-----------------------------------------------------')
print('''That name is not in the database''')
print('-----------------------------------------------------')
main_menu()
while menuSelection == None:
while validation == False: #Menu option validation
menuSelection = main_menu()
validation = valid(menuSelection)
if menuSelection in lstMenuOption: #Menu option selection
while (menuSelection.isnumeric() == True):
if menuSelection == '1':
while numEmployees == None or numEmployees == 0:
numEmployees = num_employees()
for employee in range(0, numEmployees, 1):
employeeFull, employeeInfo = add_employee()
employeeList[employeeFull] = employeeInfo
numEmployees = numEmployees - 1
num = num + 1
if (numEmployees > 0):
print('Prepare to enter employee #%d' % num)
menuSelection = None #Reset check values to default
validation = False
break
if menuSelection == '2':
view_all_employees()
menuSelection = None #Reset check values to default
validation = False
break
if menuSelection == '3':
view_employee()
menuSelection = None
validation = False
break
else: #(menuSelection.isnumeric() == False):
if menuSelection == 'Q':
exit()
else:
print('You have not selected a valid option. Please try again.')
menuSelection = None
validation = False
#view_all_employees()
#menuSelection = main_menu()
#empSelection = input("Please enter the employee's last name to display their info or enter 'q' to quit: ")
#if empSelection.upper() == 'Q':
# sys.exit
#else:
# if (0 < int(empSelection) < num):
# print(employeeList[empSelection])
employeeList = {}
lstMenuOption = ('1', '2', '3', 'Q')
#i = 0 #loop count variable
validation = False #initialize validation check to "False"
menuSelection = None
numEmployees = None
num = 1
def main_menu():
print('-----------------------------------------------------')
print('(1) Add new employee(s)')
print('(2) View all employees in the database')
print("(3) Check employee's information")
print('(Q) Exit\n')
totalEmployees = len(employeeList) #Display number of employees in the databse
print('There are (%d) in the database' % totalEmployees)
print('-----------------------------------------------------')
option = input('Please select an option from the menu: ')
return option
def valid(option): #Function to validate menu selection
if (option.isnumeric() == True):
if option in lstMenuOption:
return True
elif (option.upper() == 'Q'):
global menuSelection
menuSelection = option.upper()
return True
elif (option.isnumeric() == False):
print('You have not entered a correct option.')
return False
def num_employees():
numEmployees = (input('Please enter the number of employee(s) you are entering (Q to Quit): '))
if (numEmployees.isnumeric() == True) and (int(numEmployees) < 0):
print('You have entered an invalid quantity\n')
elif (numEmployees.isnumeric() == False):
if (numEmployees.upper() == 'Q'):
exit()
else:
print('You have entered an invalid quantity')
return None
else:
numEmployees = int(numEmployees)
return numEmployees
#while (numEmployees > 0):
def add_employee(): #CPT 200: Functionality 1 part 1
employeeFName = input("Please Emter the Employee #%d's First Name:" % num)
employeeLName = input("Please Enter the Employee #%d's Last Name:" % num)
employeeSSN = input("Please Enter %s %s's SSN (123456789):" % (employeeFName, employeeLName))
employeePhone = input("Please Enter %s %s's Phone Number:" % (employeeFName, employeeLName))
employeeEmail = input("Please Enter %s %s's Email Address:" % (employeeFName, employeeLName))
employeeSalary = input("Please Enter %s %s's Salary:" % (employeeFName, employeeLName))
employeeFull = employeeFName + ' ' + employeeLName
print(" ")
employeeInfo = [employeeFName.capitalize(), employeeLName.capitalize(), employeeSSN, employeePhone, employeeEmail, employeeSalary]
#employeeList[employeeLName] = employeeInfo
return employeeFull.upper(), employeeInfo
def view_all_employees(): #Function to display all the keys of employeeList, Functionality 1 part 2
print('-----------------------------------------------------')
print('The following employees are currently in the database')
for key in employeeList.keys():
print(key)
print('-----------------------------------------------------')
def view_employee(): #Funtionality 1 part 2.5
print('-----------------------------------------------------')
empName = input('Please enter the name of the employee you want to view: ').upper()
if empName in employeeList:
record = employeeList[empName]
print('The employee record for %s is below' % empName)
print('First Name: %s' % record[0])
print('Last Name: %s' % record[1])
print('Employee SSN: %s' % record[2])
print('Employee Phone: %s' % record[3])
print('Employee Email: %s' % record[4])
print('Employee Salary: %s' % record[5])
else:
print('-----------------------------------------------------')
print('''That name is not in the database''')
print('-----------------------------------------------------')
main_menu()
while menuSelection == None:
while validation == False: #Menu option validation
menuSelection = main_menu()
validation = valid(menuSelection)
if menuSelection in lstMenuOption: #Menu option selection
while (menuSelection.isnumeric() == True):
if menuSelection == '1':
while numEmployees == None or numEmployees == 0:
numEmployees = num_employees()
for employee in range(0, numEmployees, 1):
employeeFull, employeeInfo = add_employee()
employeeList[employeeFull] = employeeInfo
numEmployees = numEmployees - 1
num = num + 1
if (numEmployees > 0):
print('Prepare to enter employee #%d' % num)
menuSelection = None #Reset check values to default
validation = False
break
if menuSelection == '2':
view_all_employees()
menuSelection = None #Reset check values to default
validation = False
break
if menuSelection == '3':
view_employee()
menuSelection = None
validation = False
break
else: #(menuSelection.isnumeric() == False):
if menuSelection == 'Q':
exit()
else:
print('You have not selected a valid option. Please try again.')
menuSelection = None
validation = False
#view_all_employees()
#menuSelection = main_menu()
#empSelection = input("Please enter the employee's last name to display their info or enter 'q' to quit: ")
#if empSelection.upper() == 'Q':
# sys.exit
#else:
# if (0 < int(empSelection) < num):
# print(employeeList[empSelection])
Comments
Post a Comment