[go: up one dir, main page]

0% found this document useful (0 votes)
12 views19 pages

Wa0058.

The document presents a Computer Science project titled 'Employee Management' completed by students Mrigank Abhishek and Gaurav Bisht at Kendriya Vidyalaya No.-1 A.F.S. The project involves the development of a fully functioning Employee Management System using Python, which allows users to add, display, and remove employee information through a Tkinter-based interface. The project includes source code, output screenshots, and acknowledges the guidance received from their project guide and the Computer Science Department.

Uploaded by

rahul.20243228
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)
12 views19 pages

Wa0058.

The document presents a Computer Science project titled 'Employee Management' completed by students Mrigank Abhishek and Gaurav Bisht at Kendriya Vidyalaya No.-1 A.F.S. The project involves the development of a fully functioning Employee Management System using Python, which allows users to add, display, and remove employee information through a Tkinter-based interface. The project includes source code, output screenshots, and acknowledges the guidance received from their project guide and the Computer Science Department.

Uploaded by

rahul.20243228
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/ 19

COMPUTER SCIENCE

PROJECT

TOPIC: EMPLOYEE
MANAGMENT
MADE BY:
MRIGANK ABHISHEK AND GAURAV BISHT
CLASS: XII-B
SCHOOL: KENDRIYA VIDYALAYA NO.-1 A.F.S
HINDAN G.Z.B
CERTIFICATE
This is to certify that Mrigank Abhishek and Gaurav Bisht of
class XII-B has satisfactorily completed their Computer
Science Project on the topic Employee Management during
the academic year 2021-22.

Sign. of Examiner Sign. Of Subject Sign. of Candidate


Teacher
DECLARATION
I hereby declare that the project work entitled “Employee
Management” submitted to the Department of Computer
Science, Kendriya Vidyalaya No.1 Air Force Station
Hindan, Ghaziabad is prepared by us. All the coding for the
program is the result of our efforts.

.
ACKNOWLEDGEMENT
We would like to express our thanks and gratitude to our
project guide Ms. Renu Singh Mam for guiding us
immensely through the course of the project. She always
took a keen interest in our work and motivated us to do
better. We also thank the Computer Science Department
of our school for providing us with all the facilities and
support required. Our sincere gratitude to all those who
directly and indirectly helped us in the successful
completion of this project.
CONTENTS
 CERTIFICATE
 DECLARATION
 ACKNOWLEDGEMENT
 OVERVIEW
 PROJECT SORCE CODE
 OUTPUT
 TKINTER OPENING SCREEN
 ACCEPT INPUT FOR NEW EMPLOYEE
 DISPLAY ALL EMPLOYEES INFORMATION
 REMOVE EMPLOYEE DETAILS
 EXIT THE PROGRAM
 CONCLUSION
 BIBLOGRAPHY
OVERVIEW
In this project we have created fully functioning
“Employee Management System”. This program is capable
of performing multiple tasks like: - Adding, Deleting,
Displaying, and Removing information about the employee.

The types of information about the employee that are


accessible from this program are:- Name, Address and
Employee Id, Salary, Age and Post for a particular employee.
In this program we have used Tkinter Module, Pickle Module,
Binary File, Mysql.connector, Dump and Load Function,
Class, Nested If-Else Statements, For and While Loops,
Nested Lists, Index and Len Function’s. The source code and
the output screenshots are given in this project.
PROJECT SOURCE CODE
import pickle
import sys
import os
import mysql.connector
from tkinter import *
from tkinter.ttk import *

class Employee(object):
def __init__(self, emp_id, emp_name, emp_address, emp_post, emp_age):
self.__employee_id = emp_id
self.__employee_name = emp_name
self.__employee_address = emp_address
self.__employee_post = emp_post
self.__employee_age = emp_age

def get_name(self):
return self.__employee_name

def __str__(self):
emp = f"Employee Id: {self.__employee_id}"
emp += f"\nEmployee Name: {self.__employee_name}"
emp += f"\nEmployee Address: {self.__employee_address}"
emp += f"\nEmployee Post: {self.__employee_post}"
emp += f"\nEmployee Age: {self.__employee_age}"
return emp

class FullTimeEmployee(Employee):
def __init__(self, emp_id, emp_name, emp_address, post, emp_age, salary):
super().__init__(emp_id, emp_name, emp_address, post, emp_age)
self.__emp_salary = salary

def __str__(self):
childData = super().__str__()
childData = f"\n\n***Employee Details***\n{childData}"
childData += f"\n\n***Full Time Employee***"
childData += f"\nSalary: {self.__emp_salary}"
return childData

class HourlyEmployee(Employee):
def __init__(self,emp_id, emp_name, emp_address, post, emp_age, hoursWorked,
hourlyRate):
super().__init__(emp_id, emp_name, emp_address, post, emp_age)
self.__emp_hoursWorked = hoursWorked
self.__emp_hourlyRate = hourlyRate

def __str__(self):
childData = super().__str__()
childData = f"\n\n***Employee Details***\n{childData}"
childData += f"\n\n***Hourly Rate Employee***"
childData += f"\nHours Worked: {self.__emp_hoursWorked}"
childData += f"\nHourly Rate: {self.__emp_hourlyRate}"
return childData

class Consultant(Employee):

def __init__(self, emp_id, emp_name, emp_address, post, emp_age, hoursWorked):


super().__init__(emp_id, emp_name, emp_address, post, emp_age)
self.__emp_hoursWorked = hoursWorked

def __str__(self):
childData = super().__str__()
childData = f"\n\n***Employee Details***\n{childData}"
childData += f"\n\n***Consultant***"
childData += f"\nHours Worked: {self.__emp_hoursWorked}"
return childData

def main():

mydb = mysql.connector.connect(host="localhost", user="root", password="",


database="employee")
mycursor=mydb.cursor()
table_creation = "create table if not exists employee(id int, name varchar(30), address
varchar(100), post varchar(20), age int(2))"
mycursor.execute(table_creation)
root = Tk()
root.title("Employee Management System")
root.geometry("300x200")
style=Style()

emp_data_list = read_file_data()
sel = 1

style.configure('W.TButton', font =('calibri',10,'bold','underline'),foreground='black')


btn1=Button(root,text="1. Accept Input For New Employees",command=lambda:
write_to_file(mydb, emp_data_list))
btn1.pack(side='top')

style.configure('W.TButton', font =('calibri',10,'bold','underline'),foreground='black')


btn1=Button(root,text="2. Display All Employees Information",command=lambda:
run_option2())
btn1.pack(side='top')

style.configure('W.TButton', font =('calibri',10,'bold','underline'),foreground='black')


btn1=Button(root,text="3. Remove Employee",command=lambda: run_option3())
btn1.pack(side='top')

style.configure('W.TButton', font =('calibri',10,'bold','underline'),foreground='black')


btn1=Button(root,text="4. Exit The System.",command= lambda:
run_option4(emp_data_list))
btn1.pack(side='top')

def write_to_file(mydb, my_lst):


my_lst.append(run_option1(mydb))
fb = open('empdata.dat', 'wb')
for obj in my_lst:
pickle.dump(obj, fb)
fb.close()

def read_file_data():
my_lst = []
try:
fb = open('empdata.dat', 'rb')
except FileNotFoundError:
return my_lst

else:
try:
while (True):
my_lst.append(pickle.load(fb))
except EOFError:
fb.close()
return my_lst

def run_option1(mydb):
sel = 0

while(sel < 1 or sel > 3):


try:
sel = int(input("Type of Employee?(1-Full Time Employee; 2-Hourly Employee; 3-
Consultant) : "))
except ValueError:
print('Wrong selection of type of employee!')
continue

emp_id, emp_name, emp_address, emp_post, emp_age = get_emp_input(mydb)

if sel == 1:
sal = get_fulltimeemployee_input()
result = FullTimeEmployee(emp_id, emp_name, emp_address, emp_post,emp_age, sal)
elif sel == 2:
hoursWorked, hourlyRate = get_hourlyemployee_input()
result = HourlyEmployee(emp_id, emp_name, emp_address, emp_post, emp_age,
hoursWorked, hourlyRate)
elif sel == 3:
hoursWorked = get_consultant_input()
result = Consultant(emp_id, emp_name, emp_address, emp_post, emp_age,
hoursWorked)
return result
'''
Display employee information (including vehicle information) for all the employees that are
there in the system.
'''
def run_option2():
print("-----------------------------")
my_lst = read_file_data()
for ele in my_lst:
print(ele)
print("-----------------------------")

'''
List the name of the Employees along with the compensation received by each.
'''
def run_option3():
fb = read_file_data()
emp_name = input('Enter the Employee Name to be removed: ')
flag = False
if(len(fb) != 0):
print("-----------------------------")
for _ in fb:
if _.get_name()==emp_name:
fb.remove(_)
flag = True
break
if (flag):
print("Employee Removed")
else:
print("Employee Not Found")
file = open('empdata.dat', 'wb')
for obj in fb:
pickle.dump(obj, file)
file.close()

else:
print("File empty!")

def run_option4(my_lst):
print("You chose to exit the program")
yes_no = input("Are you sure (Y/N)? ")

if yes_no.lower() == 'y':
fb = open('empdata.dat', 'wb')
for obj in my_lst:
pickle.dump(obj, fb)
fb.close()
print('Execution stopped!')
sys.exit()
else:
print('Execution not stopped.')

def get_emp_input(mydb):
emp_id = input('Enter the Employee Id: ')
emp_name = input('Enter the Employee Name: ')
emp_address = input('Enter the Address: ')
emp_post = input('Enter the Employee Post: ')
emp_age = input('Enter the Employee Age: ')
query ="insert into employee (id,name,address,post,age) values (%s,%s,%s,%s,%s)"
emp_details = (emp_id, emp_name, emp_address, emp_post, emp_age)
mycursor = mydb.cursor()
mycursor.execute(query, emp_details)
mydb.commit();
return (emp_id, emp_name, emp_address, emp_post, emp_age)

def get_fulltimeemployee_input():
err_flg = True
while err_flg:
try:
sal = float(input('Enter the salary: '))
except ValueError:
print('\nEnter a numerical value for salary!')
else:
err_flg = False
return (sal)

def get_hourlyemployee_input():
err_flg = True
while err_flg:
try:
hoursWorked = int(input('Enter the hours worked: '))
except ValueError:
print('Enter a integer value for hours worked!')
try:
hourlyRate = float(input('Enter the hourly rate: '))
except ValueError:
print('Enter a numeric value for salary!')
else:
err_flg = False
err_flg = True

return (hoursWorked, hourlyRate)

def get_consultant_input():
err_flg1 = True
while err_flg1:

try:
hoursWorked = int(input('Enter the hours worked: '))
except ValueError:
print('Enter a integer value for hours worked!')
else:
err_flg1 = False
err_flg1 = True
return (hoursWorked)

main()
OUTPUT

TKINTER OPENING
SCREEN

ACCEPT INPUT FOR NEW EMPLOYEE


DISPLAY ALL EMPLOYEES INFORMATION
REMOVE EMPLOYEE DETAILS
EXIT THE PROGRAM
CONCLUSION
A proper functioning “Employee Management System” has been
successfully created by us. With this program one can Add, Display
and Remove information about the employees and thus can be
utilized by various companies of varying size to manage their
employees. The application also supports an interactive User
Interface which makes it easier for its users to use it.

Though it has some limitations like:

 Individual employee name and information cannot be


searched, it only displays complete information of all
employees.
 It cannot update the details of employees.
 Being a desktop application, it is not accessible from any
machine

For future considerations, we aim to improve the program by


adding new features which will remove the above limitations.
BIBLOGRAPHY
 Computer Science with Python-Sumita Arora XI

 Computer Science with Python-Sumita Arora XII

 https://docs.python.org/3/library/tkinter.html

 https://docs.python.org/3/library/pickle.html

You might also like