PDF 15dec23 0758 Merged

Download as pdf or txt
Download as pdf or txt
You are on page 1of 20

DECLARATION

I HEREBY DECLARE THAT THE PROJRCT WORK


ENTITLED: EMPLOYEE MANAGEMENT DATABASE
IS PREPARED BY ME, RAVI YADAV UNDER THE
SUPERVISION OF MY SUBJECT TEACHER
MR. ABHISHEK KUMAR GUPTA FOR THE
PARTIAL FULFILLMENT OF
CENTRAL BOARD OF SECONDARY EDUCATION (CBSE).
Introduction

This project is all about software for Employee management


software system. It helps to have a full fledged control over
his/her employees.
It keeps the user record of user name, address, e-mail, phone
no., post. It adds new employee details, update an existing
salary, show all details of any employee.
NAME : RAVI YADAV
CLASS : XII
ROLL NO. : 15
SUBJECT : COMPUTER SCIENCE (083)

UNDER THE GUIDENCE OF

Mr. Abhishek Kumar Gupta

Teacher Sign. Student Sign.


INDEX
1. ACKNOWLEDGEMENT
2. CERTIFICATE
3. DECLARATION
4. INTRODUCTION
5. OBJECTIVE OF THE PROJECT
6. SOURCE CODE
7. OUTPUTS SCREENSHOTS
8. SYSTEM REQUIREMENTS
9. BIBLIOGRAPHY
SOURCE CODE
# Employee Management System Using Python
from os import system
import re
# importing mysql connector
import mysql.connector

# making Connection
con = mysql.connector.connect(host="localhost", user="root", password="abhishek",
database="employee")
if con.is_connected():
print("connection estabalished....");

# preparing a cursor object


cursorObject = con.cursor()

# creating database
#cursorObject.execute("CREATE DATABASE employee")

# make a regular expression


# for validating an Email
regex = r'\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Z|a-z]{2,}\b'

# for validating an Phone Number


Pattern = re.compile("(0|91)?[7-9][0-9]{9}")

#create table
'''query='create table empdata(Id int primary key, Name varchar(200),Email_Id
varchar(40),Phone_no varchar(40),Address varchar(40),Post varchar(40),Salary int(8))'
cursorObject.execute(query)
print("created")'''

#drop- deleting complete data or table


'''s="drop table empdata"
cursorObject.execute(s)
con.commit()'''
# Function to Add_Employ
def Add_Employ():
print("{:>60}".format("-->>Add Employee Record<<--"))
Id = input("Enter Employee Id: ")
# checking If Employee Id is Exit Or Not
if (check_employee(Id) == True):
print("Employee ID Already Exists\nTry Again..")
press = input("Press Any Key To Continue..")
Add_Employ()
Name = input("Enter Employee Name: ")

# checking If Employee Name is Exit Or Not


if (check_employee_name(Name) == True):
print("Employee Name Already Exists\nTry Again..")
press = input("Press Any Key To Continue..")
Add_Employ
Email_Id = input("Enter Employee Email ID: ")
if(re.fullmatch(regex, Email_Id)):
print("Valid Email")
else:
print("Invalid Email")
press = input("Press Any Key To Continue..")
Add_Employ()
Phone_no = input("Enter Employee Phone No.: ")
if(Pattern.match(Phone_no)):
print("Valid Phone Number")
else:
print("Invalid Phone Number")
press = input("Press Any Key To Continue..")
Add_Employ()
Address = input("Enter Employee Address: ")
Post = input("Enter Employee Post: ")
Salary = input("Enter Employee Salary: ")
data = (Id, Name, Email_Id, Phone_no, Address, Post, Salary)
# Instering Employee Details in
# the Employee (empdata) Table
sql = 'insert into empdata values(%s,%s,%s,%s,%s,%s,%s)'
c = con.cursor()

# Executing the sql Query


c.execute(sql, data)

# Commit() method to make changes in the table


con.commit()
print("Successfully Added Employee Record")
press = input("Press Any Key To Continue..")
menu()

# Function To Check if Employee With


# given Name Exist or not
def check_employee_name(employee_name):
# query to select all Rows from
# employee(empdata) table
sql = 'select * from empdata where Name=%s'

# making cursor buffered to make


# rowcount method work properly
c = con.cursor(buffered=True)
data = (employee_name,)

# Execute the sql query


c.execute(sql, data)

# rowcount method to find number


# of rowa with given values
r = c.rowcount
if r == 1:
return True
else:
return False
# Function To Check if Employee With
# given Id Exist or not
def check_employee(employee_id):
# query to select all Rows from
# employee(empdata) table
sql = 'select * from empdata where Id=%s'

# making cursor buffered to make


# rowcount method work properly
c = con.cursor(buffered=True)
data = (employee_id,)

# Execute the sql query


c.execute(sql, data)

# rowcount method to find number


# of row with given values
r = c.rowcount
if r == 1:
return True
else:
return False

# Function to Display_Employ
def Display_Employ():
print("{:>60}".format("-->> Display Employee Record <<--"))
# query to select all rows from Employee (empdata) Table
sql = 'select * from empdata'
c = con.cursor()

# Executing the sql query


c.execute(sql)

# Fetching all details of all the Employees


r = c.fetchall()

for i in r:
print("Employee Id: ", i[0])
print("Employee Name: ", i[1])
print("Employee Email Id: ", i[2])
print("Employee Phone No.: ", i[3])
print("Employee Address: ", i[4])
print("Employee Post: ", i[5])
print("Employee Salary: ", i[6])
print("\n")
press = input("Press Any key To Continue..")
menu()

# Function to Update_Employ
def Update_Employ():
print("{:>60}".format("-->> Update Employee Record <<--\n"))
Id = input("Enter Employee Id: ")
# checking If Employee Id is Exit Or Not
if(check_employee(Id) == False):
print("Employee Record Not exists\nTry Again")
press = input("Press Any Key To Continue..")
menu()
else:
Email_Id = input("Enter Employee Email ID: ")
if(re.fullmatch(regex, Email_Id)):
print("Valid Email")
else:
print("Invalid Email")
press = input("Press Any Key To Continue..")
Update_Employ()
Phone_no = input("Enter Employee Phone No.: ")
if(Pattern.match(Phone_no)):
print("Valid Phone Number")
else:
print("Invalid Phone Number")
press = input("Press Any Key To Continue..")
Update_Employ()
Address = input("Enter Employee Address: ")
# Updating Employee details in empdata Table
sql = 'UPDATE empdata set Email_Id = %s, Phone_no = %s, Address = %s where Id = %s'
data = (Email_Id, Phone_no, Address, Id)
c = con.cursor()

# Executing the sql query


c.execute(sql, data)

# commit() method to make changes in the table


con.commit()
print("Updated Employee Record")
press = input("Press Any Key To Continue..")
menu()

# Function to Promote_Employ
def Promote_Employ():
print("{:>60}".format("-->> Promote Employee Record <<--\n"))
Id = input("Enter Employee Id: ")
# checking If Employee Id is Exit Or Not
if(check_employee(Id) == False):
print("Employee Record Not exists\nTry Again")
press = input("Press Any Key To Continue..")
menu()
else:
Amount = int(input("Enter Increase Salary: "))
#query to fetch salary of Employee with given data
sql = 'select Salary from empdata where Id=%s'
data = (Id,)
c = con.cursor()

#executing the sql query


c.execute(sql, data)

#fetching salary of Employee with given Id


r = c.fetchone()
t = r[0]+Amount
#query to update salary of Employee with given id
sql = 'update empdata set Salary = %s where Id = %s'
d = (t, Id)

#executing the sql query


c.execute(sql, d)

#commit() method to make changes in the table


con.commit()
print("Employee Promoted")
press = input("Press Any key To Continue..")
menu()

# Function to Remove_Employ
def Remove_Employ():
print("{:>60}".format("-->> Remove Employee Record <<--\n"))
Id = input("Enter Employee Id: ")
# checking If Employee Id is Exit Or Not
if(check_employee(Id) == False):
print("Employee Record Not exists\nTry Again")
press = input("Press Any Key To Continue..")
menu()
else:
#query to delete Employee from empdata table
sql = 'delete from empdata where Id = %s'
data = (Id,)
c = con.cursor()

#executing the sql query


c.execute(sql, data)

#commit() method to make changes in the empdata table


con.commit()
print("Employee Removed")
press = input("Press Any key To Continue..")
menu()
# Function to Search_Employ
def Search_Employ():
print("{:>60}".format("-->> Search Employee Record <<--\n"))
Id = input("Enter Employee Id: ")
# checking If Employee Id is Exit Or Not
if(check_employee(Id) == False):
print("Employee Record Not exists\nTry Again")
press = input("Press Any Key To Continue..")
menu()
else:
#query to search Employee from empdata table
sql = 'select * from empdata where Id = %s'
data = (Id,)
c = con.cursor()

#executing the sql query


c.execute(sql, data)

#fetching all details of all the employee


r = c.fetchall()
for i in r:
print("Employee Id: ", i[0])
print("Employee Name: ", i[1])
print("Employee Email Id: ", i[2])
print("Employee Phone No.: ", i[3])
print("Employee Address: ", i[4])
print("Employee Post: ", i[5])
print("Employee Salary: ", i[6])
print("\n")
press = input("Press Any key To Continue..")
menu()

# Menu function to display menu


def menu():
system("cls")
print("{:>60}".format("************************************"))
print("{:>60}".format("-->> Employee Management System <<--"))
print("{:>60}".format("************************************"))
print("1. Add Employee")
print("2. Display Employee Record")
print("3. Update Employee Record")
print("4. Promote Employee Record")
print("5. Remove Employee Record")
print("6. Search Employee Record")
print("7. Exit\n")
print("{:>60}".format("-->> Choice Options: [1/2/3/4/5/6/7] <<--"))

ch = int(input("Enter your Choice: "))


if ch == 1:
system("cls")
Add_Employ()
elif ch == 2:
system("cls")
Display_Employ()
elif ch == 3:
system("cls")
Update_Employ()
elif ch == 4:
system("cls")
Promote_Employ()
elif ch == 5:
system("cls")
Remove_Employ()
elif ch == 6:
system("cls")
Search_Employ()
elif ch == 7:
system("cls")
print("{:>60}7".format("Have A NIce Day :)"))
exit(0)
else:
print("Invalid Choice!")
press = input("Press Any key To Continue..")
menu()
# Calling menu function
menu()
Output Screenshots-
OBJECTIVES OF THE PROJECT

The objective of this project is to let the students apply the


programming knowledge into a real- world situation/problem
and exposed the students how programming skills helps in
developing a good software.
1. Write programs utilizing modern software tools.
2. Apply object oriented programming principle effectively
when developing small to medium sized projects.
3. Write effective procedural code to solve small to medium
sized problems.
4. Students will demonstrate a breadth of knowledge in
computer science, as exemplified in the areas of systems ,
theory and software development.
SYSTEM REQUIREMENTS

HARDWARE REQUIREMENTS:-
1.Operating System : Windows 7 And Above
2.Processor : Pentium® Dual- Core 3.20 GHz
3.RAM : 2 GB+
4.Hard Disk : Sata 40 Gb Or Above
5.Monitor : 14.1 or 15-17 inch
6.Keyboard and Mouse

SOFTWARE REQUIREMENTS:-
1.Windows OS
2.Python
3.MySQL
BIBLIOGRAPHY

1. Computer Science With Python – Class XII By : SUMITA ARORA


2. website: https://www.google.co.in
3. website : https://www.youtube.com
4. website : https://www.python.org
5. website : https://www.mysql.com
ACKNOWLEDGEMENT
I WOULD LIKE TO EXPRESS MY GARTITUDE TO MY
COMPUTER TEACHER Mr. ABHISHEK KUMAR GUPTA FOR HIS
ABLE GUIDANCE AND SUPPORT IN COMPLETING MY PROJECT.

I WOULD ALSO LIKE TO EXTEND MY GARTITUDE TO MY


THE VICE PRINCIPAL Mrs. ANSHULA MANGESHKAR FOR
PROVIDING ME WITH ALL THE FACILITY THAT WAS REQUIRED.

NAME OF THE STUDENT - RAVI YADAV


CERTIFICATE
THIS IS TO CERTIFY THAT RAVI YADAV CBSE ROLL NO.
_________ STUDENT OF
CLASS XII HAS SUCCESSFULLY COMPLETED HIS COMPUTER
SCIENCE (083) PROJECT WORK ON
EMPLOYEE MANAGEMENT DATABASE LAID DOWN IN THE
REGULATIONS OF CBSE FOR THE PURPOSE OF PRACTICAL
EXAMINATION TO BE HELD IN CFI MODEL SCHOOL ON
________
UNDER
THE GUIDENCE OF Mr. ABHISHEK KUMAR GUPTA.

You might also like