#                             EMPLOYEE MANAGEMENT SYSTEM

# 1. View all the details of employees
# 2. Inserting a new Employee
# 3. Deleting details of an Employee
# 4. Updating
# 5. Searching 
# 6. Exit
print("\n----------------------------------------------------------------")
print('''Press: 
                1 - View All Details of Employee
                2 - Insert New Employee
                3 - Delete an Employee
                4 - Update Employee's info
                5 - Search Details of an Employee
                6 - Exit
                ''') 
print("----------------------------------------------------------------")
emp_exit= True
Employee = []


while(emp_exit):
 print("\n----------------------------------------------------------------")
 choice = int(input("Enter Your Choice: "))

 #--------------------------------- View all details of Employee
 if choice==1:
  if len(Employee)==0:
   print("No Employees' details exists in the System")
  else:
   for employees in Employee:
    print(employees)

 #-------------------------------- Inserting New Employee
 if choice==2:
  print("You need to give Details Of Employee ")
  emp_id = int(input("\tID: "))
  
  # Checking Duplicate ID
  dup_id = 'NO'
  if len(Employee)!= 0:
   inc = 0
   for allemps in Employee:
    if Employee[inc][0]==emp_id:
     print("Oops! Employee with this ID already exists...")
     dup_id='YES'
     break
    else:
     inc += 1
  if dup_id=='NO':
   emp_name = input("\tName: ")
   emp_dept_no = int(input("Department No.: "))
   emp_salary = int(input("Salary: "))
   employees = []
   employees.append(emp_id)
   employees.append(emp_name)
   employees.append(emp_dept_no)
   employees.append(emp_salary)
   Employee.append(employees)

 #--------------------------------- Deleting Employee
 if choice==3:
  if len(Employee)==0:
   print("System contains 0 records...")
  else:
   inc = 0
   print("Do you want to Delete an Employee from the system?")
   ans = input("Yes/No ").upper()
   if ans=="YES":
    del_id = int(input("Enter ID of Employee which you want to Delete "))
    for allemps in Employee:
     if Employee[inc][0]==del_id:
      del(Employee[inc])
      inc += 1
     else:
      print("This Employee doesn't exist in the System")
      break
   else:
    pass

  # --------------------- Update Details of Emps
 if choice==4:
   if len(Employee)==0:
    print("System contains 0 records...")
   else:
    print("Please give ID of the Employee whose info you want to Update... ")
    updat_id = int(input("ID: "))
    print('''Press
              'N' for updating Name
              'S' for updating Salary
              'D' for updating Dept ID
              ''')
    ans = input().upper()
    inc = 0
    id_match_found = False
    for allemps in Employee:
     if Employee[inc][0]==updat_id:
      id_match_found = True
      if ans=='N':
       allemps[1] = input("Enter New Name of Employee ")
      if ans=='S':
       allemps[3]= int(input("Enter New Salary "))
      if ans=='D':
       allemps[2]= int(input("Enter New Dept. ID "))
     else:
      inc += 1
    
    # if ID is wrongly entered, then a message is sent to the user
    if not id_match_found:
     print("Oops! No Employee with this ID exists...")
 
 # ---------------------------- Searching an Employee 
 if choice== 5:
  if len(Employee)==0:
   print("System contains 0 records...")
  else:
   inc = 0
   print("Enter ID to search an Employee ")
   search_id = int(input())
   for allemps in Employee:
    if Employee[inc][0]==search_id:
     print(allemps)
  
 #------------------------------- Exit option
 if choice==6:
  emp_exit = False





Leave a comment