0% found this document useful (0 votes)
19 views8 pages

Emp 2

The document outlines an Employee Management System that allows users to add, update, delete, and display employee records. It includes functions for inserting, updating, and deleting employee details, as well as a main menu for user interaction. The system prompts for employee information and handles database operations with error management.

Uploaded by

vikas827227
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
19 views8 pages

Emp 2

The document outlines an Employee Management System that allows users to add, update, delete, and display employee records. It includes functions for inserting, updating, and deleting employee details, as well as a main menu for user interaction. The system prompts for employee information and handles database operations with error management.

Uploaded by

vikas827227
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 8

# Emplovee Management

def employee management ():


print ("\nWELCOME TO EMPLOYEE MANAGEMENT SYSTEM\n)
print ('a. NEW EMPLOYEE')
print ('b. UPDATE STAFF DEIAILS')
print ('c. DELETE EMPLOYEE')
print ('d. DISPLAY EMPLOYEES')

choice = input ("Enter your choice (a-d): ").strip ().lower ()


i f choice = 'a':
insert employee ()
display_ employees()
elif choice 'b':
update employee ()
display employees ()
elif choice c':
delete employee()
display employees ()
elif choice = 'd':

display_employees ()
else :
print (" Invalid choice! Please select a valid option. ")
WELCOME TO SCHOOL MANAGEMENI SYSTEM

1 STUDENT MANAGEMENT
2 EMPLOYEE MANAGEMENI
3 FEE MANAGEMENT
4 EXAM MANAGEMENI

Enter your choice (1-4) : 2


WELCOME TO EMPLOYEE MANAGEMENI SYsTEM
a. NEW EMPLOYEE
b. UPDATE STAFF DETAILS
c. DELETE EMPLOYEH
Enter your choice : a
Enter Employee Name : Raman
Enter Employee No : 105
Enter Designation: Software Enginner
Enter date of joining: 2014-01-19

Modified details are..

(empno=101, ename=naman, job=Manager, hiredate-2015-06-12)


(empno=102, ename=manveer, job=Senior Manager, hiredate=2017-10-15)
(empno=105, ename=Raman, job=Software Enginner, hiredate=2014-01-19)
>>>
def insert employee ()
try:
db = onnect db ()
cursor = db. cursor ()
ename = input ("Enter Employee Name: ")
empno = int (input ("Enter Employee Number: "))
job = input ("Enter Job/Designatian: ")
hiredate = input ("Enter Hire Date (YYYY-M-DD) : ")

sql - "INSERT INTO emp (ename, empnc, jcb, hiredate) VALUES (%3, 9, s , a)"
values = (ename, empno, job, hiredate)
cursor.execute (3ql, values)
db.commit ()
print ("Employee record added successfully! ")
except Exception as e:
print (f"Error: (e)")
finally:
db. close ()
WELCOME TO SCHOOL MANAGEMENT SYSTEM

1. STUDENT MANAGEMENT
2. EMPLOYEE MANAGEMENT
3. FEE MANAGEMENT
4. EXAM MANAGEMENT

Enter your choice (1-4) : 2


WELCOME TO EMPLOYEE MANAGEMENT sYSTEM
a. NEN EMPLOYEE
b. UPDATE STAFF DETAILS
C. DELETE EMPLOYEE
Enter your choice : b
Enter Employee No 101
Enter new designation : Senior manager

Modified details are..

(empno101, ename=naman, job-Senior manager,


* hiredate-2015-06-12)
nveer, E Manager, e2017-10-15)
redare=2014-01-19)
(empn0=105, ename=Raman, job=Software Enginner, hiredate=
>>> |

Ln: 27 Col: 4
def update employee ()
try:
db connect db ()
cursor = db. cursor 0
empno = int (input ("Enter Employee No to Update: "))
new job = input ("Enter New Job/Designation: ")

sql = "UPDATE emp SET job ts WHERE empno = ts"


values (new_job, empno)
cursor. execute (sql, values)
db.coit ()
print ("Employee record updated successfully ! ")
except Exception as e:
print ("Error: (el ")
finally:
db.close ()
WELCOME TO SCHOOL MANAGEMENT SYSTEM

1. STUDENT MANAGEMENT
2. EMPLOYEE MANAGEMENT
3. FEE MANAGEMENI
4. EXAM MANAGEMENT

Enter your choice (1-4) : 2


WELCOME TO EMPLOYEE MANAGEMENI SYSTEM
a. NEW EMPLOYEE
b. UPDATE STAFF DETAILS
C. DELETE EMPLOYEE
Enter your choice : c

Enter employee number to be deleted : 102


Are you sure you want to delete the record (y/n) : y

Modified details are..

(empno=101, ename-naman, job=Senior manager, hiredate=2015-06-12)


(empno=105, ename=Raman, job=Software Enginner, hiredate=2014-01-19)
>>>

Ln: 27 Col: 4
def delete employee ():
try:
db = connect db ()
cursor = db.cursor ()
empno = int (input ("Enter Employee No to Delete: ") )

sql = "DELETE FROM emp WHERE empno = s "


cursor.execute (sql, (empno, ) )
db. cotrnit ()
print ("Employee record deleted successfully ! ")
except Exception as e:
print (f"ErrOr: (e)")
finally:
db.close ()

# Run the main menu


selection ()
def diaplay emnployees ()
try:
db = connect db ()
cursor = db. cursor ()
cursor.execute ("SELECI FROM emp")
results = cursor.fetchall ()
print ("\nEmplyee Details : ")
for row in results:
print (E"Name: {row[0] }, Enployee No: {row [1] , Job: irow [2] }, Hire Date: (row [3] ) ")
except Exception as e:
print (f"Error : e}")
finally:
db.close ()

You might also like