cs file
cs file
4. Performance Monitoring
o Provides tools to set goals, track key performance indicators (KPIs),
and evaluate employee contributions.
o Offers detailed performance reports and feedback mechanisms to
enhance growth and development.
Project Overview:
First, we need to set up the database. You can use Python to create the database
and table for storing employee records.
python
Copy
import sqlite3
def create_connection():
# Create or connect to an SQLite database
conn = sqlite3.connect('employees.db')
return conn
def create_table():
conn = create_connection()
c = conn.cursor()
# Create the employees table
c.execute('''CREATE TABLE IF NOT EXISTS employees (
id INTEGER PRIMARY KEY,
first_name TEXT,
last_name TEXT,
email TEXT,
phone TEXT,
position TEXT
)''')
conn.commit()
conn.close()
create_table()
python
Copy
def add_employee(first_name, last_name, email, phone,
position):
conn = create_connection()
c = conn.cursor()
# Insert the employee record into the table
c.execute('''INSERT INTO employees (first_name,
last_name, email, phone, position)
VALUES (?, ?, ?, ?, ?)''',
(first_name, last_name, email, phone, position))
conn.commit()
conn.close()
print(f'Employee {first_name} {last_name} added
successfully.')
# Example usage
add_employee("John", "Doe", "[email protected]",
"123-456-7890", "Software Engineer")
python
Copy
def view_employees():
conn = create_connection()
c = conn.cursor()
c.execute("SELECT * FROM employees")
employees = c.fetchall()
conn.close()
# Example usage
view_employees()
python
Copy
def update_employee(emp_id, first_name=None,
last_name=None, email=None, phone=None, position=None):
conn = create_connection()
c = conn.cursor()
# Build the query dynamically
query = "UPDATE employees SET"
params = []
if first_name:
query += " first_name = ?,"
params.append(first_name)
if last_name:
query += " last_name = ?,"
params.append(last_name)
if email:
query += " email = ?,"
params.append(email)
if phone:
query += " phone = ?,"
params.append(phone)
if position:
query += " position = ?,"
params.append(position)
c.execute(query, tuple(params))
conn.commit()
conn.close()
print(f"Employee with ID {emp_id} updated.")
# Example usage
update_employee(1, email="[email protected]",
position="Senior Software Engineer")
python
Copy
def delete_employee(emp_id):
conn = create_connection()
c = conn.cursor()
c.execute("DELETE FROM employees WHERE id = ?",
(emp_id,))
conn.commit()
conn.close()
print(f"Employee with ID {emp_id} deleted.")
# Example usage
delete_employee(1)
python
Copy
def search_employee(name_or_position):
conn = create_connection()
c = conn.cursor()
c.execute("SELECT * FROM employees WHERE first_name
LIKE ? OR last_name LIKE ? OR position LIKE ?",
('%' + name_or_position + '%', '%' +
name_or_position + '%', '%' + name_or_position + '%'))
employees = c.fetchall()
conn.close()
if employees:
for employee in employees:
print(f"ID: {employee[0]}, Name:
{employee[1]} {employee[2]}, Email: {employee[3]},
Phone: {employee[4]}, Position: {employee[5]}")
else:
print("No matching employees found.")
# Example usage
search_employee("Engineer")
python
Copy
def main():
while True:
print("\nEmployee Management System")
print("1. Add Employee")
print("2. View Employees")
print("3. Update Employee")
print("4. Delete Employee")
print("5. Search Employee")
print("6. Exit")
if choice == '1':
first_name = input("First Name: ")
last_name = input("Last Name: ")
email = input("Email: ")
phone = input("Phone: ")
position = input("Position: ")
add_employee(first_name, last_name, email,
phone, position)
elif choice == '2':
view_employees()
elif choice == '3':
emp_id = int(input("Enter Employee ID to
update: "))
first_name = input("First Name (leave blank
to skip): ")
last_name = input("Last Name (leave blank
to skip): ")
email = input("Email (leave blank to skip):
")
phone = input("Phone (leave blank to skip):
")
position = input("Position (leave blank to
skip): ")
update_employee(emp_id, first_name,
last_name, email, phone, position)
elif choice == '4':
emp_id = int(input("Enter Employee ID to
delete: "))
delete_employee(emp_id)
elif choice == '5':
search_term = input("Enter name or position
to search: ")
search_employee(search_term)
elif choice == '6':
print("Exiting...")
break
else:
print("Invalid choice. Please try again.")
if __name__ == "__main__":
main()
bash
Copy
pip install sqlite3
2. Run the Program: Save all the code in a .py file (e.g.,
employee_management.py) and run it using:
bash
Copy
python employee_management.py
When you run the code to create the database and table, no output is directly
shown. The system just creates the database file employees.db and the
employees table. You can check if it's created by looking at the directory where
the script is run.
2. Adding an Employee
text
Copy
Employee John Doe added successfully.
3. Viewing Employees
If you call view_employees() after adding some employees, you will see
something like this:
text
Copy
ID: 1, Name: John Doe, Email: [email protected],
Phone: 123-456-7890, Position: Software Engineer
If you add more employees and view them again, you will get an output similar to
this:
text
Copy
ID: 1, Name: John Doe, Email: [email protected],
Phone: 123-456-7890, Position: Software Engineer
ID: 2, Name: Jane Smith, Email: [email protected],
Phone: 987-654-3210, Position: Data Scientist
4. Updating an Employee
If you view employees after the update (view_employees()), the output will
show the updated details:
text
Copy
ID: 1, Name: John Doe, Email: [email protected],
Phone: 123-456-7890, Position: Senior Software Engineer
ID: 2, Name: Jane Smith, Email: [email protected],
Phone: 987-654-3210, Position: Data Scientist
5. Deleting an Employee
text
Copy
Employee with ID 1 deleted.
text
Copy
ID: 2, Name: Jane Smith, Email: [email protected],
Phone: 987-654-3210, Position: Data Scientist
text
Copy
ID: 1, Name: John Doe, Email: [email protected],
Phone: 123-456-7890, Position: Software Engineer
If no employee is found, the output will be:
text
Copy
No matching employees found.
7. Menu System
When you run the main() function, it will prompt the user with a menu like this:
text
Copy
Employee Management System
1. Add Employee
2. View Employees
3. Update Employee
4. Delete Employee
5. Search Employee
6. Exit
Enter your choice:
For example, if the user chooses Add Employee, they will be prompted to input
details like this:
text
Copy
First Name: John
Last Name: Doe
Email: [email protected]
Phone: 123-456-7890
Position: Software Engineer
text
Copy
Employee John Doe added successfully.
꧁༺ Acknowledgment ༻
I am deeply grateful to everyone who supported me throughout
the development of this project, Employee Management
System. Their guidance, encouragement, and expertise made
this project a fulfilling learning experience.
First and foremost, I would like to express my sincere gratitude
to my CS teacher Mr Rajesh mittal, for their invaluable
guidance, constructive feedback, and unwavering support
throughout the project. Their expertise and advice played a
crucial role in shaping the direction and outcome of this work.
I also extend my heartfelt thanks to my school Shivalik
CambridgeCollege for providing me with the resources and
opportunities to undertake this project.
Special thanks go to my friends and classmates, who offered
their insights and encouragement, making the learning journey
even more enjoyable and rewarding.
Finally, I am profoundly grateful to my family for their constant
support, patience, and motivation throughout the development of
this project.
This project is a testament to the collaborative efforts and the
knowledge gained during my academic journey, and I am
sincerely thankful to everyone who contributed to its successful
completion.
CERTIFICATE
This is to certify that Yash Raj Nidar has successfully
completed the project entitled
“Employee Management System”
as part of the requirements for the fulfillment of the
Computer Science Boards Project file
during the academic year 2024-2025.
This project has been carried out under the guidance of
Mr Rajesh mittal .of
Shivalik Cambridge College
We hereby declare that this project is the original work of
the student and has not been copied or reproduced from
any source without proper acknowledgment.
Date:
……………………… ………………………
COMPUTER SCIENCE (083)
PROJECT FILE
AISSCE 2024-2025
CLASS- XII