SlideShare a Scribd company logo
EMPLOYEE MANAGEMENT SYSTEM
Mini-Project Report submitted in partial fulfilment of the requirements of the degree of Second
Year of Engineering by
Sanchit Raut - 46
Rohit Pujari – 44
Vaibhav Patel - 34
Department of Computer Engineering
St. John College of Engineering and Management
University of Mumbai
2017-2018
Abstract
Employee management is handy for organization for business tools for convinent information
storing which is easily accessible. By this system burden of managing and viewing employee
information is reduced.
This system is flexible and can be run on almost all major Operating systems like windows, linux
and mac.
Introduction
The organization are suffering from pity bad condition. Carrying heavy diaries to maintain
records and managing their salaries is a very tough job. To overcome these problems, we are
proposing “EMPLOYEE MANAGEMENT SYSTEM”. This app is very simple and easy to use.
Management team can add details of the Employees. It can store all details like name,
address, telephone number, their role, date of joining, salaries etc. of Employees.
All the data is stored in the database so there is no worry of Data Loss. The Data can be
accessed using Database manager (phpMyAdmin).
Implementation
Modules used :
 use DBI :
- It is a database access module for the Perl programming language. (Database
Independent Interface)
- Program is connected to database using this DBI module.
- During connection it will do a authentication check.
my $dsn = "DBI:mysql:Employee";
my $username = "root";
my $password = "mysql";
my $dbh = DBI->connect($dsn, $username, $password) or die "Connection failed.Please Check
Username and Password $!";
print("Connected To Database Successfully.n");
Here $dsn is the host, where Employee is the name of the database.
If the authentication failed due to some reason such as invalid Username or Password it will
execute the die() function notifying the error message.
Database (MySQL):
My Sql database is used for collecting the employees information and storing it to the
database.
Queries:
 Inserting :
my $sql = "INSERT INTO Data(ID, NAME, ADDRESS, PHONE_NO,
DATE_OF_JOINING, ROLE_ASSIGN, SALARY)VALUES(?,?,?,?,?,?,?)"
Here, ‘Insert into Data’ is used to insert information into table where ‘Data’ is the name of
the table.‘?’ binds the Index parameters coloumnwise.
 Viewing all employees :
my $sql = "SELECT * FROM Data";
This query displays all the data available in the database table.
 Viewing single employee(Single row):
my $var = $dbh->quote($ID);
For this at first User input is taken from user.The value of ID is then stored in the variable
“$var”. quote() function is used to fetch the user value which is stored in $ID.
my @row;
while (@row = $sth->fetchrow_array)
{
print join(", ", @row), "n";
}
fetchrow_arrow get the whole row from the table where ID is <STDIN>.
 Removing all rows:
my $sql = "TRUNCATE TABLE Data";
Truncate Table Data is the query to flush all the rows from the table.
 Removing a single employee :
my $sql = "DELETE FROM Data WHERE ID = ?"
Delete query will delete a single row from the table where ID is <STDIN>(User value).
 Update Employe data :
my $sql = "UPDATE Data SET NAME = ?, ADDRESS=?, PHONE_NO=?,
DATE_OF_JOINING=?, ROLE_ASSIGN=?, SALARY=? WHERE ID = ?";
It will Update the data and replace(SET) the new value to it as user give the input.
bind_param() :
bind parameters binds the scalar value fetched from user which is then updated in database
table.
$dbh :
Databasehandler is used to specify the DBI dsn (“connect in DBI”) as a hash reference
instead of a string.
Code
To create database table
#!usrbinperl
use warnings;
use strict;
use DBI;
my ($dbh, $sth);
$dbh=DBI->connect('dbi:mysql:Employee','root','mysql') ||
die "Error opening database: $DBI::errsn";
$sth=$dbh->prepare("CREATE TABLE Data (
ID INTEGER , NOT NULL
NAME VARCHAR(32) NOT NULL,
ADDRESS VARCHAR(32) NOT NULL,
PHONE_NO VARCHAR(32),
DATE_OF_JOINING VARCHAR(32) NOT NULL,
ROLE_ASSIGN VARCHAR(32) NOT NULL,
SALARY INTEGER)");
$sth->execute();
$sth->finish();
print "n Table created in database Employeen";
$dbh->disconnect || die "Failed to disconnectn";
Main code
#!/usr/bin/perl
use warnings;
use strict;
use DBI;
#Connecting to Database.
my $dsn = "DBI:mysql:Employee";
my $username = "root";
my $password = "mysql";
my $dbh = DBI->connect($dsn, $username, $password);
print("Connected To Database Successfully.n");
#Insert into Database.
sub insert
{
my $sql = "INSERT INTO Data(ID, NAME, ADDRESS, PHONE_NO,
DATE_OF_JOINING, ROLE_ASSIGN, SALARY)
VALUES(?,?,?,?,?,?,?)";
my $stmt = $dbh->prepare($sql);
my @employee = get_details();
foreach my $employee(@employee)
{
if($stmt->execute($employee->{ID}, $employee->{NAME}, $employee-
>{ADDRESS}, $employee->{PHONE_NO}, $employee->{DATE_OF_JOINING}, $employee-
>{ROLE_ASSIGN}, $employee->{SALARY}))
{
print("n Employee Inserted Successfully n");
}
}
$stmt->finish();
}
#Entering Details of an Employee
sub get_details
{
#my $trnl = '';
my @employee;
my($ID, $NAME, $ADDRESS, $PHONE_NO, $DATE_OF_JOINING,
$ROLE_ASSIGN, $SALARY);
print("ID : ");
chomp($ID = <STDIN>);
print("NAME : ");
chomp($NAME = <STDIN>);
print("ADDRESS : ");
chomp($ADDRESS = <STDIN>);
print("PHONE_NO : ");
chomp($PHONE_NO = <STDIN>);
print("DATE_OF_JOINING : ");
chomp($DATE_OF_JOINING = <STDIN>);
print("ROLE_ASSIGN : ");
chomp($ROLE_ASSIGN = <STDIN>);
print("SALARY : ");
chomp($SALARY = <STDIN>);
my %employee = (ID=> $ID, NAME=> $NAME, ADDRESS=> $ADDRESS,
PHONE_NO=> $PHONE_NO, DATE_OF_JOINING=> $DATE_OF_JOINING,
ROLE_ASSIGN=> $ROLE_ASSIGN, SALARY=> $SALARY);
push(@employee,%employee);
return @employee;
}
#Give Details of One Employee
sub view_one
{
print("ID : ");
chomp(my $ID = <STDIN>);
my $var = $dbh->quote($ID);
my $sql = "SELECT * FROM Data WHERE ID = $var";
my $sth = $dbh->prepare($sql) or die $DBI::errs;
$sth->execute() or die $DBI::errs;
my @row;
while (@row = $sth->fetchrow_array)
{
print join(", ", @row), "n";
}
#$sth->finish();
}
#Get Details of all Employee
sub view_all
{
my ($dbh) = @_;
my $sql = "SELECT * FROM Data";
my $sth = $dbh->prepare($sql) or die $DBI::errs;
$sth->execute() or die $DBI::errs;
$sth->dump_results();
$sth->finish();
}
#Update an Employee
sub update
{
my $sql = "UPDATE Data SET NAME = ?, ADDRESS=?, PHONE_NO=?,
DATE_OF_JOINING=?, ROLE_ASSIGN=?, SALARY=? WHERE ID = ?";
my $sth = $dbh->prepare($sql);
print("Enter ID to update : ");
chomp(my $ID = <STDIN>);
print("n");
print("NAME : ");
chomp(my $NAME = <STDIN>);
print("ADDRESS : ");
chomp(my $ADDRESS = <STDIN>);
print("PHONE_NO : ");
chomp(my $PHONE_NO = <STDIN>);
print("DATE_OF_JOINING : ");
chomp(my $DATE_OF_JOINING = <STDIN>);
print("ROLE_ASSIGN : ");
chomp(my $ROLE_ASSIGN = <STDIN>);
print("SALARY : ");
chomp(my $SALARY = <STDIN>);
$sth->bind_param(1,$NAME);
$sth->bind_param(2,$ADDRESS);
$sth->bind_param(3,$PHONE_NO);
$sth->bind_param(4,$DATE_OF_JOINING);
$sth->bind_param(5,$ROLE_ASSIGN);
$sth->bind_param(6,$SALARY);
$sth->bind_param(7,$ID);
$sth->execute();
print("n The record has been updated successfully! n");
$dbh->{mysql_auto_reconnect} = 1;
$sth->finish();
$dbh->disconnect();
}
#Delete single Employee
sub delete_one_row
{
my $sql = "DELETE FROM Data WHERE ID = ?";
my $sth = $dbh->prepare($sql);
print "Enter ID to remove : ";
chomp(my $ID = <STDIN>);
$sth->execute($ID);
print "ID no.$ID has been deleted successfully";
$dbh->{mysql_auto_reconnect} = 1;
$dbh->disconnect();
}
#Deletes all Employee
sub delete_all_rows
{
my($dbh) = @_;
my $sql = "TRUNCATE TABLE Data";
my $sth = $dbh->prepare($sql);
return $sth->execute();
}
#multi-line print() Function
sub menu
{
print <<EOT;
Please make a choice :
1. Add an Employee.
2. View an Employee.
3. View all Employee.
4. Update an Employee.
5. Remove an Employee.
6. Remove all Employee.
7. Exit.
Your Choice :
EOT
}
#Select Options
while(1)
{
menu();
chomp(my $answer = <STDIN>);
SWITCH: {
$answer == 1 and insert(), last SWITCH;
$answer == 2 and view_one(), last SWITCH;
$answer == 3 and view_all($dbh), last SWITCH;
$answer == 4 and update(), last SWITCH;
$answer == 5 and delete_one_row(), last SWITCH;
$answer == 6 and delete_all_rows($dbh), last SWITCH;
$answer == 7 and exit(0);
}
Output
Fig 1: Main Menu
Fig 2: Inserting Data
`
Fig 3: Updating Data
Conclusion
The project aims at bringing simplicity of the system such as by using this program to show details
in a well organized manner and with ease. In future this system can be extended to integrate more
modules and features. Provisions can be made in future so that much better GUI can be provided
to all the user of the system.
References
1. http://www.mysqltutorial.org
2. https://www.tutorialspoint.com/perl/index.htm
3. Programming the Perl DBI – O’REILLY

More Related Content

What's hot (20)

PPTX
Bubble sort, Selection sort SORTING .pptx
Kalpana Mohan
 
PPT
OOP V3.1
Sunil OS
 
DOC
SQL practice questions - set 3
Mohd Tousif
 
PPT
JUnit 4
Sunil OS
 
PDF
엘라스틱서치 실무 가이드_202204.pdf
한 경만
 
TXT
Programs for Operating System
LPU
 
PPTX
Interfaces in java
Abishek Purushothaman
 
PPTX
MySql Triggers Tutorial - The Webs Academy
thewebsacademy
 
PDF
Introduction to oracle functions
Nitesh Singh
 
DOCX
Data Structures Using C Practical File
Rahul Chugh
 
PPTX
Class or Object
Rahul Bathri
 
PDF
Extensible Data Modeling
Karwin Software Solutions LLC
 
PPT
Sql oracle
Md.Abu Noman Shuvo
 
ODP
Oracle SQL Advanced
Dhananjay Goel
 
PPT
Java Basics
Sunil OS
 
PPT
Resource Bundle
Sunil OS
 
PPTX
Python
Sangita Panchal
 
PPTX
Class, object and inheritance in python
Santosh Verma
 
PPTX
Structure & union
lalithambiga kamaraj
 
PPTX
SUBQUERIES.pptx
RenugadeviR5
 
Bubble sort, Selection sort SORTING .pptx
Kalpana Mohan
 
OOP V3.1
Sunil OS
 
SQL practice questions - set 3
Mohd Tousif
 
JUnit 4
Sunil OS
 
엘라스틱서치 실무 가이드_202204.pdf
한 경만
 
Programs for Operating System
LPU
 
Interfaces in java
Abishek Purushothaman
 
MySql Triggers Tutorial - The Webs Academy
thewebsacademy
 
Introduction to oracle functions
Nitesh Singh
 
Data Structures Using C Practical File
Rahul Chugh
 
Class or Object
Rahul Bathri
 
Extensible Data Modeling
Karwin Software Solutions LLC
 
Sql oracle
Md.Abu Noman Shuvo
 
Oracle SQL Advanced
Dhananjay Goel
 
Java Basics
Sunil OS
 
Resource Bundle
Sunil OS
 
Class, object and inheritance in python
Santosh Verma
 
Structure & union
lalithambiga kamaraj
 
SUBQUERIES.pptx
RenugadeviR5
 

Similar to Miniproject on Employee Management using Perl/Database. (20)

ODP
DBI
abrummett
 
PDF
Sqlite perl
Ashoka Vanjare
 
PDF
Using Perl Stored Procedures for MariaDB
Antony T Curtis
 
PPT
Mysql DBI
Joe Christensen
 
PPTX
Class 8 - Database Programming
Ahmed Swilam
 
ODP
perl usage at database applications
Joe Jiang
 
ODP
DBI
Lambert Lum
 
PPT
Working with databases in Perl
Laurent Dami
 
PPT
php databse handling
kunj desai
 
PPT
SQL -PHP Tutorial
Information Technology
 
PPT
Php Mysql
Mudasir Syed
 
PDF
MySQL for beginners
Saeid Zebardast
 
PDF
PHP Data Objects
Wez Furlong
 
PDF
Os Furlong
oscon2007
 
PDF
Php summary
Michelle Darling
 
PDF
Employee Management (CS Project for 12th CBSE)
PiyushKashyap54
 
PPTX
Learn PHP Lacture2
ADARSH BHATT
 
PPTX
MySQL
Hideo Amezawa
 
Sqlite perl
Ashoka Vanjare
 
Using Perl Stored Procedures for MariaDB
Antony T Curtis
 
Mysql DBI
Joe Christensen
 
Class 8 - Database Programming
Ahmed Swilam
 
perl usage at database applications
Joe Jiang
 
Working with databases in Perl
Laurent Dami
 
php databse handling
kunj desai
 
SQL -PHP Tutorial
Information Technology
 
Php Mysql
Mudasir Syed
 
MySQL for beginners
Saeid Zebardast
 
PHP Data Objects
Wez Furlong
 
Os Furlong
oscon2007
 
Php summary
Michelle Darling
 
Employee Management (CS Project for 12th CBSE)
PiyushKashyap54
 
Learn PHP Lacture2
ADARSH BHATT
 
Ad

Recently uploaded (20)

PPTX
Agentic Automation Journey Series Day 2 – Prompt Engineering for UiPath Agents
klpathrudu
 
PPTX
Transforming Mining & Engineering Operations with Odoo ERP | Streamline Proje...
SatishKumar2651
 
PDF
Online Queue Management System for Public Service Offices in Nepal [Focused i...
Rishab Acharya
 
PPTX
Agentic Automation: Build & Deploy Your First UiPath Agent
klpathrudu
 
PDF
AI + DevOps = Smart Automation with devseccops.ai.pdf
Devseccops.ai
 
PPTX
Hardware(Central Processing Unit ) CU and ALU
RizwanaKalsoom2
 
PDF
SAP Firmaya İade ABAB Kodları - ABAB ile yazılmıl hazır kod örneği
Salih Küçük
 
PDF
Wondershare PDFelement Pro Crack for MacOS New Version Latest 2025
bashirkhan333g
 
PDF
MiniTool Partition Wizard 12.8 Crack License Key LATEST
hashhshs786
 
PPTX
Change Common Properties in IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
PDF
Generic or Specific? Making sensible software design decisions
Bert Jan Schrijver
 
PDF
vMix Pro 28.0.0.42 Download vMix Registration key Bundle
kulindacore
 
PPTX
In From the Cold: Open Source as Part of Mainstream Software Asset Management
Shane Coughlan
 
PDF
유니티에서 Burst Compiler+ThreadedJobs+SIMD 적용사례
Seongdae Kim
 
PPTX
Help for Correlations in IBM SPSS Statistics.pptx
Version 1 Analytics
 
PDF
HiHelloHR – Simplify HR Operations for Modern Workplaces
HiHelloHR
 
PPTX
Tally software_Introduction_Presentation
AditiBansal54083
 
PDF
iTop VPN With Crack Lifetime Activation Key-CODE
utfefguu
 
PDF
Alexander Marshalov - How to use AI Assistants with your Monitoring system Q2...
VictoriaMetrics
 
PPTX
Human Resources Information System (HRIS)
Amity University, Patna
 
Agentic Automation Journey Series Day 2 – Prompt Engineering for UiPath Agents
klpathrudu
 
Transforming Mining & Engineering Operations with Odoo ERP | Streamline Proje...
SatishKumar2651
 
Online Queue Management System for Public Service Offices in Nepal [Focused i...
Rishab Acharya
 
Agentic Automation: Build & Deploy Your First UiPath Agent
klpathrudu
 
AI + DevOps = Smart Automation with devseccops.ai.pdf
Devseccops.ai
 
Hardware(Central Processing Unit ) CU and ALU
RizwanaKalsoom2
 
SAP Firmaya İade ABAB Kodları - ABAB ile yazılmıl hazır kod örneği
Salih Küçük
 
Wondershare PDFelement Pro Crack for MacOS New Version Latest 2025
bashirkhan333g
 
MiniTool Partition Wizard 12.8 Crack License Key LATEST
hashhshs786
 
Change Common Properties in IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
Generic or Specific? Making sensible software design decisions
Bert Jan Schrijver
 
vMix Pro 28.0.0.42 Download vMix Registration key Bundle
kulindacore
 
In From the Cold: Open Source as Part of Mainstream Software Asset Management
Shane Coughlan
 
유니티에서 Burst Compiler+ThreadedJobs+SIMD 적용사례
Seongdae Kim
 
Help for Correlations in IBM SPSS Statistics.pptx
Version 1 Analytics
 
HiHelloHR – Simplify HR Operations for Modern Workplaces
HiHelloHR
 
Tally software_Introduction_Presentation
AditiBansal54083
 
iTop VPN With Crack Lifetime Activation Key-CODE
utfefguu
 
Alexander Marshalov - How to use AI Assistants with your Monitoring system Q2...
VictoriaMetrics
 
Human Resources Information System (HRIS)
Amity University, Patna
 
Ad

Miniproject on Employee Management using Perl/Database.

  • 1. EMPLOYEE MANAGEMENT SYSTEM Mini-Project Report submitted in partial fulfilment of the requirements of the degree of Second Year of Engineering by Sanchit Raut - 46 Rohit Pujari – 44 Vaibhav Patel - 34 Department of Computer Engineering St. John College of Engineering and Management University of Mumbai 2017-2018
  • 2. Abstract Employee management is handy for organization for business tools for convinent information storing which is easily accessible. By this system burden of managing and viewing employee information is reduced. This system is flexible and can be run on almost all major Operating systems like windows, linux and mac.
  • 3. Introduction The organization are suffering from pity bad condition. Carrying heavy diaries to maintain records and managing their salaries is a very tough job. To overcome these problems, we are proposing “EMPLOYEE MANAGEMENT SYSTEM”. This app is very simple and easy to use. Management team can add details of the Employees. It can store all details like name, address, telephone number, their role, date of joining, salaries etc. of Employees. All the data is stored in the database so there is no worry of Data Loss. The Data can be accessed using Database manager (phpMyAdmin).
  • 4. Implementation Modules used :  use DBI : - It is a database access module for the Perl programming language. (Database Independent Interface) - Program is connected to database using this DBI module. - During connection it will do a authentication check. my $dsn = "DBI:mysql:Employee"; my $username = "root"; my $password = "mysql"; my $dbh = DBI->connect($dsn, $username, $password) or die "Connection failed.Please Check Username and Password $!"; print("Connected To Database Successfully.n"); Here $dsn is the host, where Employee is the name of the database. If the authentication failed due to some reason such as invalid Username or Password it will execute the die() function notifying the error message.
  • 5. Database (MySQL): My Sql database is used for collecting the employees information and storing it to the database. Queries:  Inserting : my $sql = "INSERT INTO Data(ID, NAME, ADDRESS, PHONE_NO, DATE_OF_JOINING, ROLE_ASSIGN, SALARY)VALUES(?,?,?,?,?,?,?)" Here, ‘Insert into Data’ is used to insert information into table where ‘Data’ is the name of the table.‘?’ binds the Index parameters coloumnwise.  Viewing all employees : my $sql = "SELECT * FROM Data"; This query displays all the data available in the database table.  Viewing single employee(Single row): my $var = $dbh->quote($ID); For this at first User input is taken from user.The value of ID is then stored in the variable “$var”. quote() function is used to fetch the user value which is stored in $ID. my @row; while (@row = $sth->fetchrow_array) { print join(", ", @row), "n"; } fetchrow_arrow get the whole row from the table where ID is <STDIN>.  Removing all rows: my $sql = "TRUNCATE TABLE Data"; Truncate Table Data is the query to flush all the rows from the table.  Removing a single employee : my $sql = "DELETE FROM Data WHERE ID = ?" Delete query will delete a single row from the table where ID is <STDIN>(User value).  Update Employe data : my $sql = "UPDATE Data SET NAME = ?, ADDRESS=?, PHONE_NO=?, DATE_OF_JOINING=?, ROLE_ASSIGN=?, SALARY=? WHERE ID = ?";
  • 6. It will Update the data and replace(SET) the new value to it as user give the input. bind_param() : bind parameters binds the scalar value fetched from user which is then updated in database table. $dbh : Databasehandler is used to specify the DBI dsn (“connect in DBI”) as a hash reference instead of a string.
  • 7. Code To create database table #!usrbinperl use warnings; use strict; use DBI; my ($dbh, $sth); $dbh=DBI->connect('dbi:mysql:Employee','root','mysql') || die "Error opening database: $DBI::errsn"; $sth=$dbh->prepare("CREATE TABLE Data ( ID INTEGER , NOT NULL NAME VARCHAR(32) NOT NULL, ADDRESS VARCHAR(32) NOT NULL, PHONE_NO VARCHAR(32), DATE_OF_JOINING VARCHAR(32) NOT NULL, ROLE_ASSIGN VARCHAR(32) NOT NULL, SALARY INTEGER)"); $sth->execute(); $sth->finish(); print "n Table created in database Employeen"; $dbh->disconnect || die "Failed to disconnectn";
  • 8. Main code #!/usr/bin/perl use warnings; use strict; use DBI; #Connecting to Database. my $dsn = "DBI:mysql:Employee"; my $username = "root"; my $password = "mysql"; my $dbh = DBI->connect($dsn, $username, $password); print("Connected To Database Successfully.n"); #Insert into Database. sub insert { my $sql = "INSERT INTO Data(ID, NAME, ADDRESS, PHONE_NO, DATE_OF_JOINING, ROLE_ASSIGN, SALARY) VALUES(?,?,?,?,?,?,?)"; my $stmt = $dbh->prepare($sql); my @employee = get_details(); foreach my $employee(@employee)
  • 9. { if($stmt->execute($employee->{ID}, $employee->{NAME}, $employee- >{ADDRESS}, $employee->{PHONE_NO}, $employee->{DATE_OF_JOINING}, $employee- >{ROLE_ASSIGN}, $employee->{SALARY})) { print("n Employee Inserted Successfully n"); } } $stmt->finish(); } #Entering Details of an Employee sub get_details { #my $trnl = ''; my @employee; my($ID, $NAME, $ADDRESS, $PHONE_NO, $DATE_OF_JOINING, $ROLE_ASSIGN, $SALARY); print("ID : "); chomp($ID = <STDIN>); print("NAME : "); chomp($NAME = <STDIN>); print("ADDRESS : ");
  • 10. chomp($ADDRESS = <STDIN>); print("PHONE_NO : "); chomp($PHONE_NO = <STDIN>); print("DATE_OF_JOINING : "); chomp($DATE_OF_JOINING = <STDIN>); print("ROLE_ASSIGN : "); chomp($ROLE_ASSIGN = <STDIN>); print("SALARY : "); chomp($SALARY = <STDIN>); my %employee = (ID=> $ID, NAME=> $NAME, ADDRESS=> $ADDRESS, PHONE_NO=> $PHONE_NO, DATE_OF_JOINING=> $DATE_OF_JOINING, ROLE_ASSIGN=> $ROLE_ASSIGN, SALARY=> $SALARY); push(@employee,%employee); return @employee; } #Give Details of One Employee sub view_one { print("ID : "); chomp(my $ID = <STDIN>);
  • 11. my $var = $dbh->quote($ID); my $sql = "SELECT * FROM Data WHERE ID = $var"; my $sth = $dbh->prepare($sql) or die $DBI::errs; $sth->execute() or die $DBI::errs; my @row; while (@row = $sth->fetchrow_array) { print join(", ", @row), "n"; } #$sth->finish(); } #Get Details of all Employee sub view_all { my ($dbh) = @_; my $sql = "SELECT * FROM Data"; my $sth = $dbh->prepare($sql) or die $DBI::errs; $sth->execute() or die $DBI::errs; $sth->dump_results(); $sth->finish();
  • 12. } #Update an Employee sub update { my $sql = "UPDATE Data SET NAME = ?, ADDRESS=?, PHONE_NO=?, DATE_OF_JOINING=?, ROLE_ASSIGN=?, SALARY=? WHERE ID = ?"; my $sth = $dbh->prepare($sql); print("Enter ID to update : "); chomp(my $ID = <STDIN>); print("n"); print("NAME : "); chomp(my $NAME = <STDIN>); print("ADDRESS : "); chomp(my $ADDRESS = <STDIN>); print("PHONE_NO : "); chomp(my $PHONE_NO = <STDIN>); print("DATE_OF_JOINING : "); chomp(my $DATE_OF_JOINING = <STDIN>);
  • 13. print("ROLE_ASSIGN : "); chomp(my $ROLE_ASSIGN = <STDIN>); print("SALARY : "); chomp(my $SALARY = <STDIN>); $sth->bind_param(1,$NAME); $sth->bind_param(2,$ADDRESS); $sth->bind_param(3,$PHONE_NO); $sth->bind_param(4,$DATE_OF_JOINING); $sth->bind_param(5,$ROLE_ASSIGN); $sth->bind_param(6,$SALARY); $sth->bind_param(7,$ID); $sth->execute(); print("n The record has been updated successfully! n"); $dbh->{mysql_auto_reconnect} = 1; $sth->finish(); $dbh->disconnect(); } #Delete single Employee sub delete_one_row {
  • 14. my $sql = "DELETE FROM Data WHERE ID = ?"; my $sth = $dbh->prepare($sql); print "Enter ID to remove : "; chomp(my $ID = <STDIN>); $sth->execute($ID); print "ID no.$ID has been deleted successfully"; $dbh->{mysql_auto_reconnect} = 1; $dbh->disconnect(); } #Deletes all Employee sub delete_all_rows { my($dbh) = @_; my $sql = "TRUNCATE TABLE Data"; my $sth = $dbh->prepare($sql); return $sth->execute(); } #multi-line print() Function sub menu { print <<EOT;
  • 15. Please make a choice : 1. Add an Employee. 2. View an Employee. 3. View all Employee. 4. Update an Employee. 5. Remove an Employee. 6. Remove all Employee. 7. Exit. Your Choice : EOT } #Select Options while(1) { menu(); chomp(my $answer = <STDIN>); SWITCH: { $answer == 1 and insert(), last SWITCH; $answer == 2 and view_one(), last SWITCH; $answer == 3 and view_all($dbh), last SWITCH; $answer == 4 and update(), last SWITCH; $answer == 5 and delete_one_row(), last SWITCH; $answer == 6 and delete_all_rows($dbh), last SWITCH; $answer == 7 and exit(0); }
  • 16. Output Fig 1: Main Menu Fig 2: Inserting Data ` Fig 3: Updating Data
  • 17. Conclusion The project aims at bringing simplicity of the system such as by using this program to show details in a well organized manner and with ease. In future this system can be extended to integrate more modules and features. Provisions can be made in future so that much better GUI can be provided to all the user of the system. References 1. http://www.mysqltutorial.org 2. https://www.tutorialspoint.com/perl/index.htm 3. Programming the Perl DBI – O’REILLY