Employee Management Project
Employee Management Project
Employee Management Project
connector
con = mysql.connector.connect(
host="localhost", user="root", password="", database="emp")
def Add_Employee():
Id = input("Enter Employee Id : ")
if(check_employee(Id) == True):
print("Employee aready exists\nTry Again\n")
menu()
else:
Name = input("Enter Employee Name : ")
Post = input("Enter Employee Post : ")
Salary = input("Enter Employee Salary : ")
data = (Id, Name, Post, Salary)
sql = 'insert into empd values(%s,%s,%s,%s)'
c = con.cursor()
c.execute(sql, data)
con.commit()
print("Employee Added Successfully ")
menu()
def Promote_Employee():
Id = int(input("Enter Employ's Id"))
if(check_employee(Id) == False):
print("Employee does not exists\nTry Again\n")
menu()
else:
Post = input("Enter change in post")
c.execute(sql, data)
r = c.fetchone()
t = Post
c.execute(sql, d)
con.commit()
print("Employee Promoted")
menu()
def Bonus_Employee():
Id = int(input("Enter Employ's Id"))
if(check_employee(Id) == False):
print("Employee does not exists\nTry Again\n")
menu()
else:
bn = int(input("Enter Bonus:"))
c.execute(sql, data)
r = c.fetchone()
t = r[0]+bn
c.execute(sql, d)
con.commit()
print("Bonus Added")
menu()
def leave_Employee():
Id=input("Enter employee Id")
day=int(input("Enter the number of leave days"))
if (day<=3):
print("LEAVE GRANTED")
print("EMPLOYEE ID:",Id,",",day,"DAYS LEAVE GRANTED")
else:
print("PLEASE SEEK PERMISSION FROM THE HR MANAGER")
menu()
def Remove_Employee():
Id = input("Enter Employee Id : ")
if(check_employee(Id) == False):
print("Employee does not exists\nTry Again\n")
menu()
else:
c.execute(sql, data)
con.commit()
print("Employee Removed")
menu()
def check_employee(employee_id):
c = con.cursor(buffered=True)
data = (employee_id,)
c.execute(sql, data)
r = c.rowcount
if r == 1:
return True
else:
return False
def Display_Employees():
c.execute(sql)
r = c.fetchall()
for i in r:
print("Employee Id : ", i[0])
print("Employee Name : ", i[1])
print("Employee Post : ", i[2])
print("Employee Salary : ", i[3])
print("---------------------\
-----------------------------\
------------------------------\
---------------------")
menu()
def menu():
print(" Employee Management System")
print("Press: ")
print("1 to Add Employee")
print("2 to Remove Employee ")
print("3 to Display Employee")
print("4 to Bonus Employees")
print("5 to promote Employee")
print("6 to Grant leave")
print("7 tO Exit")
menu()