Professional Documents
Culture Documents
EMPLOYEE MANAGEMENT SYSTEM Eding (Repaired) Sorce Code
EMPLOYEE MANAGEMENT SYSTEM Eding (Repaired) Sorce Code
import pickle
import os import
datetime
from prettytable import PrettyTable
Emp={ } # Creating Empty Dictionary
print("*"*68)
print("* *")
print("* Welcome to Employee Management System *")
print("* *")
print("*"*68)
now=datetime.datetime.now()
print("Date:",now.strftime("%d-%m-%y"),end="\t\t\t\t\t")
print("Time:",now.strftime("%H:%M:%S"))
count=0
#Main Menu
def MainMenu(): global
count
if User=="admin" and Pass=="admin@123":
print("1.Employee Registration")
print("2.Display all Employees")
print("3.Search Particular Employee Details")
print("4.Modify Employee Detail")
print("5.Delete Employees Details")
opt=int(input("Enter your choice:"))
if opt==1:
Registration()
elif opt==2:
Display()
elif opt==3:
Search()
elif opt==4:
Modify()
elif opt==5:
Delete()
else:
print("Invalid Option")
exit()
else:
if count<2:
print("Try again!!! Invalid Username/Password") count+=1
MainMenu()
else:
print("Too Many Try, Sorry Access is Blocked!!!")
print("| |")
print("| Welcome to Employee Details Menu |")
print("| |")
print("-"*68)
x=PrettyTable()
try:
while True:
S=pickle.load(f)
x.field_names=list(S.keys())
x.add_row(list(S.values()))
except:
print(x)
f.close()
MainMenu()
# Employee Search Module
def Search():
print("1.Search using Employee Id")
opt=int(input("Enter YourChoice:"))
if opt==1:
def Search_Id():
F=open("emp.dat",'rb')
try:
while True:
S=pickle.load(F)
return(S['Id'])
except:
F.close()
def Search_Choice(p,q):
F=open("emp.dat",'rb')
found=0 x=PrettyTable()
try:
while True:
S=pickle.load(F) if
S[p]==q:
x.field_names=list(S.keys())
x.add_row(list(S.values()))
found=1
except EOFError:
print(x) F.close()
if found==0:
print("Searching Record is not found") MainMenu()
x.field_names=list(S.keys())
x.add_row(list(S.values()))
print("Before Modify")
print(x)
f=1
print("10.MobileNumber","11.AadharNumber","12.E-Mail Address","13.Martiual
Status","14.Country",sep=" ")
h=int(input("Enter which detail of the Emp you want to modify""\t"":")) if h==1:
S['Id']=ID
elif h==2:
NAME=input("Enter the Name of the Employee""\t"":")
S['Name']=NAME
elif h==3:
Dob=input("Enter the new Dob of the Employee""\t"":")
S['Dob']=Dob
elif h==4:
elif h==6:
Des=input("Enter the new Designation of the Employee""\t"":")
S['Des']=Des
elif h==7:
Sal=int(input(”Enter the new Salary of the Employee""\t"":"))
S['Sal']=Sal
elif h==8:
Doj=input("Enter the new DOJ of the Employee""\t"":")
S['Doj']=Doj
elif h==9:
BG=input("Enter the new Blood Group of the Employee""\t"":")
S['BG']=BG
elif h==10:
Mob=int(input("Enter the new Mobile Number ""\t"":"))
S['Mobno']=Mob
elif h==11:
Aadhar=int(input("Enter the new Aadhar Number ""\t"":"))
S['Adh']=Aadhar
elif h==12:
Email=input("Enter the new Email Address of the Employee""\t"":")
S['Mail']=Email
elif h==13:
MS=input("Enter the Present Martial Status of the Employee""\t"":")
S['Ms']=MS
elif h==14:
Country=input("Enter the new Country of the Employee""\t"":")
S['Country']=Country else:
print("Invalid option")
break
pickle.dump(S,F2)
else:
pickle.dump(S,F2)
except:
F1.close()
F2.close()
if f==0:
print("Employee ID not found") else:
print("Record Modified Successfully")
os.remove("emp.dat") os.rename("temp.dat","emp.dat")
Search_Choice('Id',no)
MainMenu()
print("| |")
print("| Welcome to Employee Deletion Menu |")
print("| |")
print("-"*68)
no=int(input("Enter the employee id of which you want to Delete?")) x=PrettyTable()
try:
while True:
S=pickle.load(F1) if
S['Id']==no:
x.field_names=list(S.keys())
x.add_row(list(S.values()))
print(x)
f=1
if opt=='y':
print("The above Employee Details are Deleted Successfully") else:
pickle.dump(S,F2)
else:
pickle.dump(S,F2)
except:
F1.close()
F2.close()
if f==0:
# Main Program
MainMenu()
SCREEN SHOTS
1. Main Menu:
BOOKS:
❖ COMPUTER SCIENCE WITH PYTHON -BY SUMITA ARORA
❖ COMPUTER SCIENCE WITH PYTHON -BY PREETI ARORA
❖ PYTHON COOKBOOK
WEBSITES:
❖ www.geeksforgeeks.org
❖ https://docs.python.org/3/
❖ https://www.w3schools.com/python/
*************************************************************************************