0% found this document useful (0 votes)
2 views

Fsdmp Copy

The document is a micro project report on developing an Employee Management System (EMS) submitted to CMR Institute of Technology as part of the II-B.Tech II-Semester requirements. It outlines the purpose of the EMS, which is to streamline HR tasks and enhance employee productivity through features like time tracking and recruitment modules. The report includes a detailed procedure for creating the EMS using HTML, CSS, and JavaScript, along with requirements for setting up a server using Node.js and Express.js.

Uploaded by

skjoveriya
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

Fsdmp Copy

The document is a micro project report on developing an Employee Management System (EMS) submitted to CMR Institute of Technology as part of the II-B.Tech II-Semester requirements. It outlines the purpose of the EMS, which is to streamline HR tasks and enhance employee productivity through features like time tracking and recruitment modules. The report includes a detailed procedure for creating the EMS using HTML, CSS, and JavaScript, along with requirements for setting up a server using Node.js and Express.js.

Uploaded by

skjoveriya
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 23

A Micro Project report on

Developing a Employee Management System


Submitted to the CMR Institute of Technology, Hyderabad in partial fulfillment of the
requirement for the award of the Laboratory of

Node JS/Angular/React JS/Django Lab


of
II-B.Tech. II-Semester
in
Computer Science and Engineering(AI&ML)
Submitted by
N.Monick Sai 22R01A6642
S.Tharun 22R01A6651
SK.Joveriya 22R01A6657

Under the Guidance Of


Mr. P.Niranjan Reddy
(Professor ,Dept of CSE(AI&ML))

CMR INSTITUTE OF TECHNOLOGY


(UGC AUTONOMUS)
(Approved by AICTE,Affiliated to JNTU,Kukatpally,Hyderabad)
Kandlakoya,Medchal Road,Hyderabad
2023-2024

CMR INSTITUTE OF TECHNOLOGY


(UGC AUTONOMUS)
(Approved by AICTE, Affiliated to JNTU, Kukatpally, Hyderabad)

1
Kandlakoya, Medchal Road, Hyderabad.

Department of Computer Science and Engineering (AI&ML)

CERTIFICATE
This is to certify that a Micro Project entitled with: “Employee Management System” is being
Submitted By

N.Monick Sai 22R01A6642


S.Tharun 22R01A6651
SK.Joveriya 22R01A6657

In partial fulfillment of the requirement for award of the OOP through Java of II-B.Tech II-
Semester in CSE(AI&ML)towards a record of a bonafide work carried out under our
guidance and supervision.

Signature of Faculty Signature of HOD

2
ACKNOWLEDGEMENT

We are extremely grateful to Dr. M. Janga Reddy, Director, Dr. B. Satyanarayana,


Principal and Dr. A. Nirmal Kumar, Head of Department, Dept of Computer Science and
Engineering, CMR Institute of Technology for their inspiration and valuable guidance during
entire duration.

We are extremely thankful to our faculty in-charge P.Niranjan Reddy, Computer Science and
Engineering department, CMR Institute of Technology for his constant guidance,
encouragement and moral support throughout the project.

We express our thanks to all staff members and friends for all the help and coordination
extended in bringing out this Project successfully in time.

Finally, we are very much thankful to our parents and relatives who guided directly or
indirectly for successful completion of the project.

N.Monick Sai 22R01A6642


S.Tharun 22R01A6651
Joveriya 22R01A66657

3
CONTENTS

Sl. No. Particulars___________________


1. Introduction
2. Algorithm / Procedure
3. Requirements(Hardware and Software)
4. Implementation
5. Results
6. Conclusion
References

4
INTRODUCTION
An employee management system (EMS) acts as a digital hub for all things related to your
workforce. It's essentially software designed to streamline HR tasks and boost employee
productivity. Imagine a filing cabinet on steroids, ditching the paper for secure digital storage
of employee data, from contact details and salaries to performance records. But an EMS goes
way beyond record keeping.

Many systems offer features to automate time-consuming tasks like time tracking and
payroll. This frees up HR professionals and managers to focus on more strategic initiatives.
Employee self-service options are another perk, allowing staff to access paystubs, update
personal information, or request leave directly through the system. This empowers employees
and reduces the HR workload.

An effective EMS can also be a boon for talent management. Recruitment modules can
streamline the hiring process, while performance management features can be used to set
goals, track progress, and provide feedback. Training and development programs can also be
integrated, ensuring employees have the skills they need to succeed.

Ultimately, a good EMS benefits both employers and employees. For businesses, it means
increased efficiency, improved data-driven decision making, and a happier, more productive
workforce. For employees, it translates to a smoother work experience, easier access to
information, and potentially better opportunities for growth and development.

5
PROCEDURE

Creating an Employee Management System (EMS) using HTML, CSS, and JavaScript
involves building a simple web application that can perform basic CRUD operations (Create,
Read, Update, Delete) on employee data. Below is a step-by-step guide to building a basic
EMS.

Step 1: Set Up the Project Structure

Create a new directory for your project and set up the following file structure:

perl
Copy code
employee-management-system/
├── index.html
├── style.css
└── script.js

Step 2: Create the HTML Structure

Create index.html and add the following code:

html
Copy code
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Employee Management System</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<h1>Employee Management System</h1>

<form id="employeeForm">
<input type="hidden" id="employeeId">
<div>
<label for="name">Name:</label>
<input type="text" id="name" required>
</div>
<div>
<label for="position">Position:</label>
<input type="text" id="position" required>
6
</div>
<div>
<label for="salary">Salary:</label>
<input type="number" id="salary" required>
</div>
<button type="submit">Add/Update Employee</button>
</form>

<table id="employeeTable">
<thead>
<tr>
<th>ID</th>
<th>Name</th>
<th>Position</th>
<th>Salary</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
<!-- Employee rows will be added here dynamically -->
</tbody>
</table>

<script src="script.js"></script>
</body>
</html>

Step 3: Style the Application

Create style.css and add the following code to style your EMS:

css
Copy code
body {
font-family: Arial, sans-serif;
margin: 0;
padding: 20px;
background-color: #f4f4f4;
}

h1 {
text-align: center;
}

form {
max-width: 500px;

7
margin: 20px auto;
padding: 10px;
background-color: #fff;
border: 1px solid #ccc;
border-radius: 5px;
}

form div {
margin-bottom: 10px;
}

form label {
display: inline-block;
width: 100px;
}

form input {
padding: 5px;
width: calc(100% - 120px);
}

button {
display: block;
width: 100%;
padding: 10px;
background-color: #28a745;
color: #fff;
border: none;
border-radius: 5px;
cursor: pointer;
}

button:hover {
background-color: #218838;
}

table {
width: 100%;
border-collapse: collapse;
margin-top: 20px;
}

table, th, td {
border: 1px solid #ccc;
}

th, td {
8
padding: 10px;
text-align: left;
}

th {
background-color: #f8f8f8;
}

.actions button {
background-color: #007bff;
border: none;
color: #fff;
padding: 5px 10px;
cursor: pointer;
border-radius: 3px;
margin-right: 5px;
}

.actions button:hover {
background-color: #0056b3;
}

.actions .delete {
background-color: #dc3545;
}

.actions .delete:hover {
background-color: #c82333;
}

Step 4: Add JavaScript Functionality

Create script.js and add the following code to handle the EMS functionality:

javascript
Copy code
document.addEventListener('DOMContentLoaded', () => {
const employeeForm = document.getElementById('employeeForm');
const employeeTable = d
function saveEmployees() {
localStorage.setItem('employees', JSON.stringify(employees));
}

// Add employee to table


function addEmployeeToTable(employee) {
const row = employeeTable.insertRow();

9
row.setAttribute('data-id', employee.id);

const cellId = row.insertCell(0);


const cellName = row.insertCell(1);
const cellPosition = row.insertCell(2);
const cellSalary = row.insertCell(3);
const cellActions = row.insertCell(4);

cellId.textContent = employee.id;
cellName.textContent = employee.name;
cellPosition.textContent = employee.position;
cellSalary.textContent = employee.salary;
cellActions.classList.add('actions');

const editButton = document.createElement('button');


editButton.textContent = 'Edit';
editButton.addEventListener('click', () => editEmployee(employee.id));
cellActions.appendChild(editButton);

const deleteButton = document.createElement('button');


deleteButton.textContent = 'Delete';
deleteButton.classList.add('delete');
deleteButton.addEventListener('click', () => deleteEmployee(employee.id));
cellActions.appendChild(deleteButton);
}

// Clear the form


function clearForm() {
employeeForm.reset();
currentEditId = null;
}

// Handle form submit


employeeForm.addEventListener('submit', event => {
event.preventDefault();

const id = currentEditId || Date.now();


const name = document.getElementById('name').value;
const position = document.getElementById('position').value;
const salary = document.getElementById('salary').value;

const employee = { id, name, position, salary };

if (currentEditId) {
// Update existing employee
const index = employees.findIndex(emp => emp.id === currentEditId);
employees[index] = employee;
10
// Update the table
const row = employeeTable.querySelector(`[data-id="${currentEditId}"]`);
row.cells[1].textContent = name;
row.cells[2].textContent = position;
row.cells[3].textContent = salary;
} else {
// Add new employee
employees.push(employee);
addEmployeeToTable(employee);
}

saveEmployees();
clearForm();
});

// Edit employee
function editEmployee(id) {
const employee = employees.find(emp => emp.id === id);
document.getElementById('employeeId').value = employee.id;
document.getElementById('name').value = employee.name;
document.getElementById('position').value = employee.position;
document.getElementById('salary').value = employee.salary;
currentEditId = id;
}

// Delete employee
function deleteEmployee(id) {
employees = employees.filter(emp => emp.id !== id);
saveEmployees();

// Remove row from table


const row = employeeTable.querySelector(`[data-id="${id}"]`);
employeeTable.deleteRow(row.rowIndex - 1);
}

// Load employees on page load


loadEmployees();
});

Explanation

HTML:
 The form is used to add or update employee details.
 The table is used to display the list of employees.
 Each employee row has actions for editing and deleting the employee.
11
CSS:
 Styles for form, table, and buttons to make the application look clean and user-
friendly.
JavaScript:
 Load Employees: Load employees from local storage when the page loads.
 Save Employees: Save employees to local storage.
 Add Employee to Table: Add a new employee row to the table.
 Clear Form: Clear the form inputs.
 Handle Form Submit: Handle the form submission for adding or updating
employees.
 Edit Employee: Populate the form with the employee details for editing.
 Delete Employee: Remove the employee from the list and update the table
and local storage.

12
REQUIREMENTS
Node.js: The runtime environment to execute JavaScript code on the server.
Express.js: A web application framework for Node.js to handle routing and middleware.
Database: A database to store employee data. You can use MongoDB (NoSQL) or MySQL
(SQL).
ORM/ODM: For easier database interaction. Use Mongoose for MongoDB or Sequelize for
MySQL.
Body-parser: Middleware to parse incoming request bodies.
CORS: Middleware to enable Cross-Origin Resource Sharing.
Postman: (Optional) For testing API endpoints.

Step-by-Step Guide

Step 1: Set Up the Project

Initialize the project:

bash
Copy code
mkdir employee-management-system
cd employee-management-system
npm init -y

Install dependencies:

bash
Copy code
npm install express body-parser mongoose cors
# For MySQL, use these:
# npm install express body-parser mysql2 sequelize cors

Step 2: Create the Server

Create the directory structure:

bash
Copy code
mkdir models routes controllers config
touch server.js

Set up Express server (server.js):

javascript
Copy code
13
const express = require('express');
const bodyParser = require('body-parser');
const cors = require('cors');
const mongoose = require('mongoose');
// For MySQL, use sequelize and mysql2 instead:
// const { Sequelize } = require('sequelize');

const app = express();

// Middleware
app.use(bodyParser.json());
app.use(cors());

// MongoDB connection
mongoose.connect('mongodb://localhost:27017/ems',
{ useNewUrlParser: true, useUnifiedTopology: true })
.then(() => console.log('MongoDB connected'))
.catch(err => console.log(err));

// For MySQL, use Sequelize connection:


// const sequelize = new Sequelize('database', 'username',
'password', {
// host: 'localhost',
// dialect: 'mysql'
// });
// sequelize.authenticate()
// .then(() => console.log('MySQL connected'))
// .catch(err => console.log('Error: ' + err));

// Routes
const employeeRoutes = require('./routes/employee');
app.use('/api/employees', employeeRoutes);

const PORT = process.env.PORT || 5000;


app.listen(PORT, () => console.log(`Server running on port $
{PORT}`));

Step 3: Define the Employee Model

For MongoDB (models/Employee.js):

javascript
Copy code
const mongoose = require('mongoose');

14
const EmployeeSchema = new mongoose.Schema({
name: { type: String, required: true },
position: { type: String, required: true },
salary: { type: Number, required: true },
});

module.exports = mongoose.model('Employee', EmployeeSchema);

For MySQL (models/Employee.js):

javascript
Copy code
const { Sequelize, DataTypes } = require('sequelize');
const sequelize = require('../config/database'); // Create a
sequelize instance in config/database.js

const Employee = sequelize.define('Employee', {


name: { type: DataTypes.STRING, allowNull: false },
position: { type: DataTypes.STRING, allowNull: false },
salary: { type: DataTypes.INTEGER, allowNull: false },
});

module.exports = Employee;

Step 4: Create the Employee Controller

Create controllers/employeeController.js:
javascript
Copy code
const Employee = require('../models/Employee');

// Create Employee
exports.createEmployee = async (req, res) => {

try {
const newEmployee = new Employee(req.body);
await newEmployee.save();
res.status(201).json(newEmployee);
} catch (err) {
res.status(400).json({ error: err.message });
}
};

// Get All Employees

15
exports.getAllEmployees = async (req, res) => {
try {
const employees = await Employee.find();
res.status(200).json(employees);
} catch (err) {
res.status(500).json({ error: err.message });
}
};

// Get Employee by ID
exports.getEmployeeById = async (req, res) => {
try {
const employee = await
Employee.findById(req.params.id);
if (!employee) return res.status(404).json({ error:
'Employee not found' });
res.status(200).json(employee);
} catch (err) {
res.status(500).json({ error: err.message });
}
};

// Update Employee
exports.updateEmployee = async (req, res) => {
try {
const employee = await
Employee.findByIdAndUpdate(req.params.id, req.body, { new:
true });
if (!employee) return res.status(404).json({ error:
'Employee not found' });
res.status(200).json(employee);
} catch (err) {
res.status(400).json({ error: err.message });
}
};

// Delete Employee
exports.deleteEmployee = async (req, res) => {
try {
const employee = await
Employee.findByIdAndDelete(req.params.id);
if (!employee) return res.status(404).json({ error:
'Employee not found' });
res.status(200).json({ message: 'Employee deleted
successfully' });
} catch (err) {

16
res.status(500).json({ error: err.message });
}
};

Step 5: Set Up Routes

Create routes/employee.js:
javascript
Copy code
const express = require('express');
const router = express.Router();
const employeeController =
require('../controllers/employeeController');

router.post('/', employeeController.createEmployee);
router.get('/', employeeController.getAllEmployees);
router.get('/:id', employeeController.getEmployeeById);
router.put('/:id', employeeController.updateEmployee);
router.delete('/:id', employeeController.deleteEmployee);

module.exports = router;

Step 6: Start the Server

Run the server using:

bash
Copy code
node server.js

Implementation
Implementing an Employee Management System (EMS) using Node.js
involves creating a server-side application that handles CRUD operations
(Create, Read, Update, Delete) on employee data. Below is a step-by-step
guide to build a basic EMS with Node.js, Express, and MongoDB.

17
Step 1: Set Up the Project

Initialize the project:

bash
Copy code
mkdir employee-management-system
cd employee-management-system
npm init -y

Install dependencies:

bash
Copy code
npm install express mongoose body-parser cors

Step 2: Create the Server

Create the directory structure:

bash
Copy code
mkdir models routes controllers config
touch server.js

Set up Express server (server.js):

javascript
Copy code
const express = require('express');
const bodyParser = require('body-parser');
const cors = require('cors');
const mongoose = require('mongoose');

const app = express();

// Middleware
app.use(bodyParser.json());
app.use(cors());

// MongoDB connection
mongoose.connect('mongodb://localhost:27017/ems', { useNewUrlParser: true,
useUnifiedTopology: true })
.then(() => console.log('MongoDB connected'))
.catch(err => console.log(err));
18
// Routes
const employeeRoutes = require('./routes/employee');
app.use('/api/employees', employeeRoutes);

const PORT = process.env.PORT || 5000;


app.listen(PORT, () => console.log(`Server running on port ${PORT}`));

Step 3: Define the Employee Model

Create the Employee model (models/Employee.js):


javascript
Copy code
const mongoose = require('mongoose');

const EmployeeSchema = new mongoose.Schema({


name: { type: String, required: true },
position: { type: String, required: true },
salary: { type: Number, required: true },
});

module.exports = mongoose.model('Employee', EmployeeSchema);

Step 4: Create the Employee Controller

Create controllers/employeeController.js:
javascript
Copy code
const Employee = require('../models/Employee');

// Create Employee
exports.createEmployee = async (req, res) => {
try { const newEmployee = new Employee(req.body);
await newEmployee.save();
res.status(201).json(newEmployee);
} catch (err) {
res.status(400).json({ error: err.message });
}
};

// Get All Employees


exports.getAllEmployees = async (req, res) => {
try {
const employees = await Employee.find();
res.status(200).json(employees);

19
} catch (err) {
res.status(500).json({ error: err.message });
}
};

// Get Employee by ID
exports.getEmployeeById = async (req, res) => {
try {
const employee = await Employee.findById(req.params.id);
if (!employee) return res.status(404).json({ error: 'Employee not found' });
res.status(200).json(employee);
} catch (err) {
res.status(500).json({ error: err.message });
}
};

// Update Employee
exports.updateEmployee = async (req, res) => {
try {
const employee = await Employee.findByIdAndUpdate(req.params.id, req.body, { new:
true });
if (!employee) return res.status(404).json({ error: 'Employee not found' });
res.status(200).json(employee);
} catch (err) {
res.status(400).json({ error: err.message });
}
};

// Delete Employee
exports.deleteEmployee = async (req, res) => {
try {
const employee = await Employee.findByIdAndDelete(req.params.id);
if (!employee) return res.status(404).json({ error: 'Employee not found' });
res.status(200).json({ message: 'Employee deleted successfully' });
} catch (err) {
res.status(500).json({ error: err.message });
}
};

Step 5: Set Up Routes

Create routes/employee.js:
javascript
Copy code
const express = require('express');
const router = express.Router();
20
const employeeController = require('../controllers/employeeController');

router.post('/', employeeController.createEmployee);
router.get('/', employeeController.getAllEmployees);
router.get('/:id', employeeController.getEmployeeById);
router.put('/:id', employeeController.updateEmployee);
router.delete('/:id', employeeController.deleteEmployee);

module.exports = router;

Step 6: Start the Server

Run the server using:

bash
Copy code
node server.js

Summary

With this setup, you have a basic Employee Management System using Node.js, Express, and
MongoDB. The system includes routes for creating, reading, updating, and deleting employee
records. You can test the API endpoints using tools like Postman.

Additional Improvements

To make this EMS more robust and user-friendly, consider adding the following features:

Validation: Use a library like joi for request validation.


Authentication: Implement user authentication and authorization.
Front-End Interface: Create a front-end using a framework like React.js or Vue.js.
Error Handling: Implement better error handling and logging.
Testing: Write unit and integration tests for your API.

By following the steps above, you can set up a functional EMS and extend it according to
your needs.

OUTPUT:

21
CONCLUSION
Implementing an Employee Management System (EMS) using Node.js provides a robust
foundation for efficiently managing employee data within an organization. Node.js, coupled
with frameworks like Express and databases like MongoDB or MySQL, offers flexibility,
scalability, and performance, making it ideal for such applications.

One of the primary advantages of using Node.js is its non-blocking, event-driven


architecture, which allows handling multiple concurrent requests efficiently. This ensures that
the EMS can manage a large number of employees and concurrent user interactions without
significant performance degradation.

The EMS built with Node.js follows a structured architecture comprising models, controllers,
routes, and middleware, promoting maintainability and code organization. Models define the
schema and interactions with the database, while controllers handle business logic and

22
request processing. Routes provide endpoints for CRUD operations, ensuring clear separation
of concerns.

Integration with MongoDB or MySQL enables storing employee data securely and allows for
seamless retrieval, modification, and deletion operations. MongoDB, a NoSQL database,
offers flexibility in schema design and scalability, while MySQL provides strong ACID
compliance and relational data management capabilities, catering to different organizational
needs.

Furthermore, employing Express.js simplifies route handling and middleware integration,


enhancing development productivity. Middleware like bodyParser and cors facilitates request
parsing and Cross-Origin Resource Sharing, respectively, ensuring secure and efficient
communication between clients and the server.

In conclusion, building an Employee Management System with Node.js empowers


organizations with a scalable, performant, and flexible solution for managing employee data.
It leverages Node.js's strengths in handling asynchronous operations, integrates well with
various databases, and provides a structured approach to application development. Such
systems not only streamline administrative tasks but also enhance data integrity, accessibility,
and security, thereby contributing to organizational efficiency and employee satisfaction. As
technologies evolve, Node.js continues to be a preferred choice for developing modern,
responsive, and efficient enterprise applications.

23

You might also like