this
world
of
growing
technologies
everything
has
been
This project will allow admin to add new Contractors after proper
authentication. Admin can also add new departments and posts. It can
allocate Contractors to different departments at different posts. Database
should store all personal details of Contractors such as date of birth full
name etc. and his educational background, work experience, skill sets,
current and past projects in different tables with proper relations.
This system enables Contractors to perform their own profile. It enables the
automation of work flow notifications and leave request. Work flow
notification from administrator are stored in the backend and notified to
Contractor, once Contractor log in to the system. Leave request made by the
Contractor is placed for administrator approval, the administrator module
checks up with the leave availability and approves or rejects the request.
to
overcome.
every
organization
has
different
Contractor
System Design
In this phase, a logical system is built which fulfils the given requirements.
Design
phase
of
software
development
deals
with
transforming
the
TESTING
Testing is the process in which the system is run on manually created
input so that the system is correctly working as desired or not.
During systems testing, the system is used experimentally to ensure
that the software does not fail. In other words, we can say that it will run
according to its specifications and in the way users expect. Special test data
are input for processing, and the results examined.
A limited number of users may be allowed to use the system so that
analyst can see whether they tr
y to use it in unforeseen ways. It is desirable to discover any surprises
before the organization implements the system and depends on it.
Testing of a system is generally done in two phases One is Unit Testing
which is done for each module independently on its completion and the other
one is System Testing which is done at the end of a project.
VALIDATION CRITERIA
The validation criteria in this project are as follows...
In System also, the user inputs are validated before storing them, and
then further for displaying etc. The main validations that are donel System
are as follows
All the screens have a similar look and feel. They all have the almost same
color combinations in its background. This provides a better user interface to
the users.
1) The primary key values cannot be duplicated.
2) All the entries in any combo box have been sorted in alphabetical
order. This helps a user while selecting a value from the combo box.
IMPORTANCE OF TESTING
During systems testing, the system is used experimentally to ensure that
the software does not fail. In other words, we can say that it will run
according to its specifications and in the way users expect. Special test data
are input for processing, and the results examined.
The importance of system testing is that the system is expected to run
according to members requirement before delivering it to the customer.
Implementation
Detailed Design of Implementation - This phase of the systems
development
life
cycle
refines
hardware
and
software
specifications,
system
design,
adding
detailed
technical
specifications
and
documentation.
Test Specifications and Planning - This activity prepares detailed test
specifications
for
individual
modules
and
programs,
job
streams,
and
Testing
This
activity
encompasses
actual
testing procedures.
Acceptance Test - A final procedural review to demonstrate a system and
secure user approval before a system becomes operational.
Installation Phase - In this phase the new Computerized system is
installed, the conversion to new procedures is fully implemented, and the
potential of the new system is explored.
System Installation: The process of starting the actual use of a system
and training user personnel in its operation.
Review Phase - This phase evaluates the successes and failures during a
systems development project, and to measure the results of a new
Computerized Transystem in terms of benefits and savings projected at the
start of the project.
Development Recap - A review of a project immediately after completion
to find successes and potential problems in future work.
Post-Implementation Review - A review, conducted after a new system
has been in operation for some time, to evaluate actual system performance
against original expectations and projections for cost-benefit improvements.
Also identifies maintenance projects to enhance or improve the system.
THE STEPS IN THE SOFTWARE TESTING
Preparation of the possible test data with all the validation checks.
1) Effort Estimation - This refers to the total man-hours required for the
development of the project. It even includes the time required for doing
documentation and user manual.
2) Hardware Required Estimation - This includes the cost of the PCs and
the hardware cost required for development of this project.
SYSTEM ANALYSIS
The analysis model is a concise, precise abstraction of what the desired
system must do, and not how it will be done after the study of the
existing system is completed. This basically includes system study and
the requirement analysis. Interacting with the clients regarding their
requirements and expectations from the system does requirement
analysis.
The steps, which are essential for system analysis, are:
1. Research and define essential components.
2. Analyze current processes and identify gaps.
3. Interview
users,
Trainee,
Trainers
and
other
concerned
personnel
FEASIBILITY STUDY
At this stage, the analyst estimates the urgency of the project and estimates
the development cost.
In feasibility analysis, we have to study the following:
1) Technical Feasibility:
Technical feasibility is concerned with the availability of hardware and
software required for the development
3) Economic Feasibility:
It is the measure of cost effectiveness of the project. The economic
feasibility is nothing but judging whether the possible benefit of solving
the problems is worthwhile of not. At the feasibility study level, it is
impossible to estimate the cost because members requirements and
alternative solutions have not been identified at this stage. However,
when the specific requirements and solutions have been identified, the
analyst weighs the cost and benefits of all solutions, this is called cost
benefit analysis.
PROJECT SCHEDULING
An elementary Gantt chart or Timeline chart for the development plan is
given below. The plan explains the tasks versus the time (in weeks) they will
take to complete.
January
February
March
Requirement
Gathering
Analysis
Design
Coding
Testing
Implement
W
W4
relational
database
management
system
(RDBMS)
is
database
Implementation Methodology:
Model View Controller or MVC as it is popularly called, is a software design
pattern for developing web applications. A Model View Controller pattern is
made up of the following three parts:
maintaining data.
View - This is responsible for displaying all or a portion of the data to
the user.
Controller - Software Code that controls the interactions between the
Model and View.
MVC is popular as it isolates the application logic from the user interface
layer and supports separation of concerns. Here the Controller receives all
requests for the application and then works with the Model to prepare any
data needed by the View. The View then uses the data prepared by the
Controller to generate a final presentable response. The MVC abstraction can
be graphically represented as follows.
MVC (Model View Controller Flow) Diagram
Design Diagrams
of the Project
Coding of the
Project
Code of Connect.java
package com;
import java.sql.*;
import java.util.*;
public class Connect
{
public static Statement statement = null;
public static Connection connection;
public static ResultSet rs;
public static PreparedStatement pstmt;
/////Function for connect to the MySQL Server Database////////////
public static void connect_mysql()
{
try
{
Class.forName("com.mysql.jdbc.Driver").newInstance();
connection =
DriverManager.getConnection("jdbc:mysql://localhost/Contractor_managem
ent_system?" + "user=root&password=root");
statement=connection.createStatement();
}
catch(Exception e)
{
System.out.println(" Error : "+ e.toString());
}
}
////////Function for geting the Option/////////////////////
Code of Contractor.java
package Model;
import java.util.*;
import java.sql.*;
import com.*;
import java.io.*;
public class Contractor extends Connect
{
/////Function for connect to the MySQL Server Database////////////
public Contractor()
{
Connect.connect_mysql();
}
//////////Save User Details /////
public String saveContractor(HashMap ContractorData)
{
String SQL = "INSERT INTO Contractor (Contractor_user,
Contractor_password, Contractor_level, Contractor_sal,
Contractor_first_name, Contractor_middle_name, Contractor_last_name,
Contractor_gender, Contractor_address, Contractor_village,
Contractor_state, Contractor_country, Contractor_landline,
Contractor_mobile, Contractor_email, Contractor_status,
Contractor_deparment, Contractor_dob, Contractor_nationalty) VALUES
(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);";
int record=0,last_inserted_id=0;
String error = "";
try
{
pstmt = connection.prepareStatement(SQL);
pstmt.setString(1,(String)
ContractorData.get("Contractor_user"));
pstmt.setString(2,(String)
ContractorData.get("Contractor_password"));
pstmt.setString(3,(String)
ContractorData.get("Contractor_level"));
pstmt.setString(4,(String)
ContractorData.get("Contractor_sal"));
pstmt.setString(5,(String)
ContractorData.get("Contractor_first_name"));
pstmt.setString(6,(String)
ContractorData.get("Contractor_middle_name"));
pstmt.setString(7,(String)
ContractorData.get("Contractor_last_name"));
pstmt.setString(8,(String)
ContractorData.get("Contractor_gender"));
pstmt.setString(9,(String)
ContractorData.get("Contractor_address"));
pstmt.setString(10,(String)
ContractorData.get("Contractor_village"));
pstmt.setString(11,(String)
ContractorData.get("Contractor_state"));
pstmt.setString(12,(String)
ContractorData.get("Contractor_country"));
pstmt.setString(13,(String)
ContractorData.get("Contractor_landline"));
pstmt.setString(14,(String)
ContractorData.get("Contractor_mobile"));
pstmt.setString(15,(String)
ContractorData.get("Contractor_email"));
pstmt.setString(16,(String)
ContractorData.get("Contractor_status"));
pstmt.setString(17,(String)
ContractorData.get("Contractor_deparment"));
pstmt.setString(18,(String)
ContractorData.get("Contractor_dob"));
pstmt.setString(19,(String)
ContractorData.get("Contractor_nationalty"));
record = pstmt.executeUpdate();
/// Get the Last Insert ID ///
rs = pstmt.getGeneratedKeys();
if(rs.next())
{
last_inserted_id = rs.getInt(1);
}
pstmt.close();
}
catch(Exception e)
{
StringWriter writer = new StringWriter();
PrintWriter printWriter = new PrintWriter( writer );
e.printStackTrace( printWriter );
printWriter.flush();
String stackTrace = writer.toString();
error+="Error : "+stackTrace;
System.out.println(" Error : "+ e.toString());
}
/// Save Credentials to Login ////
SQL = "INSERT INTO login (login_emp_id, login_user, login_password,
login_email) VALUES (?, ?, ?, ? );";
try
{
pstmt = connection.prepareStatement(SQL);
pstmt.setInt(1,last_inserted_id);
pstmt.setString(2,(String)
ContractorData.get("Contractor_user"));
pstmt.setString(3,(String)
ContractorData.get("Contractor_password"));
pstmt.setString(4,(String)
ContractorData.get("Contractor_email"));
record = pstmt.executeUpdate();
pstmt.close();
connection.close();
}
catch(Exception e)
{
StringWriter writer = new StringWriter();
PrintWriter printWriter = new PrintWriter( writer );
e.printStackTrace( printWriter );
printWriter.flush();
String stackTrace = writer.toString();
error+="Error : "+stackTrace;
System.out.println(" Error : "+ e.toString());
}
return error;
}
//////////////////Function for getting Users Details//////////
public HashMap getContractorDetails(int Contractor_id)
{
HashMap resultsArray = new HashMap();
int count=0;
try
{
String SQL = "SELECT * FROM Contractor WHERE Contractor_id =
"+Contractor_id ;
statement = connection.createStatement();
rs = statement.executeQuery(SQL);
while(rs.next())
{
resultsArray.put("Contractor_id",rs.getString("Contractor_id"));
resultsArray.put("Contractor_user",rs.getString("Contractor_user"));
resultsArray.put("Contractor_level",rs.getString("Contractor_level"));
resultsArray.put("Contractor_sal",Integer.parseInt(rs.getString("Contractor_s
al")));
resultsArray.put("Contractor_first_name",rs.getString("Contractor_first_nam
e"));
resultsArray.put("Contractor_middle_name",rs.getString("Contractor_middle
_name"));
resultsArray.put("Contractor_last_name",rs.getString("Contractor_last_name
"));
resultsArray.put("Contractor_gender",rs.getString("Contractor_gender"));
resultsArray.put("Contractor_address",rs.getString("Contractor_address"));
resultsArray.put("Contractor_village",rs.getString("Contractor_village"));
resultsArray.put("Contractor_state",Integer.parseInt(rs.getString("Contractor
_state")));
resultsArray.put("Contractor_country",Integer.parseInt(rs.getString("Contrac
tor_country")));
resultsArray.put("Contractor_landline",rs.getString("Contractor_landline"));
resultsArray.put("Contractor_mobile",rs.getString("Contractor_mobile"));
resultsArray.put("Contractor_email",rs.getString("Contractor_email"));
resultsArray.put("Contractor_status",Integer.parseInt(rs.getString("Contract
or_status")));
resultsArray.put("Contractor_deparment",Integer.parseInt(rs.getString("Cont
ractor_deparment")));
resultsArray.put("Contractor_dob",rs.getString("Contractor_dob"));
resultsArray.put("Contractor_nationalty",rs.getString("Contractor_nationalty"
));
count++;
}
if(count==0)
{
resultsArray.put("Contractor_id","");
resultsArray.put("Contractor_user","");
resultsArray.put("Contractor_level","");
resultsArray.put("Contractor_sal",0);
resultsArray.put("Contractor_first_name","");
resultsArray.put("Contractor_middle_name","");
resultsArray.put("Contractor_last_name","");
resultsArray.put("Contractor_gender","");
resultsArray.put("Contractor_address","");
resultsArray.put("Contractor_village","");
resultsArray.put("Contractor_state",0);
resultsArray.put("Contractor_country",0);
resultsArray.put("Contractor_landline","");
resultsArray.put("Contractor_mobile","");
resultsArray.put("Contractor_email","");
resultsArray.put("Contractor_status",0);
resultsArray.put("Contractor_deparment",0);
resultsArray.put("Contractor_dob","");
resultsArray.put("Contractor_nationalty","");
}
}
catch(Exception e)
{
System.out.println("Error is: "+ e);
}
return resultsArray;
}
public String updateContractor(HashMap ContractorData)
{
String SQL = "UPDATE Contractor SET Contractor_sal = ?,
Contractor_first_name = ?, Contractor_middle_name = ?,
Contractor_last_name = ?, Contractor_gender = ?, Contractor_address = ?,
Contractor_village = ?, Contractor_state = ?, Contractor_country = ?,
Contractor_landline = ?, Contractor_mobile = ?, Contractor_email = ?,
Contractor_status = ?, Contractor_deparment = ?, Contractor_dob = ?,
Contractor_nationalty = ? WHERE Contractor_id = ?";
String error = "";
int record=0;
try
{
pstmt = connection.prepareStatement(SQL);
pstmt.setString(1,(String)
ContractorData.get("Contractor_sal"));
pstmt.setString(2,(String)
ContractorData.get("Contractor_first_name"));
pstmt.setString(3,(String)
ContractorData.get("Contractor_middle_name"));
pstmt.setString(4,(String)
ContractorData.get("Contractor_last_name"));
pstmt.setString(5,(String)
ContractorData.get("Contractor_gender"));
pstmt.setString(6,(String)
ContractorData.get("Contractor_address"));
pstmt.setString(7,(String)
ContractorData.get("Contractor_village"));
pstmt.setString(8,(String)
ContractorData.get("Contractor_state"));
pstmt.setString(9,(String)
ContractorData.get("Contractor_country"));
pstmt.setString(10,(String)
ContractorData.get("Contractor_landline"));
pstmt.setString(11,(String)
ContractorData.get("Contractor_mobile"));
pstmt.setString(12,(String)
ContractorData.get("Contractor_email"));
pstmt.setString(13,(String)
ContractorData.get("Contractor_status"));
pstmt.setString(14,(String)
ContractorData.get("Contractor_deparment"));
pstmt.setString(15,(String)
ContractorData.get("Contractor_dob"));
pstmt.setString(16,(String)
ContractorData.get("Contractor_nationalty"));
pstmt.setString(17,(String)
ContractorData.get("Contractor_id"));
record = pstmt.executeUpdate();
pstmt.close();
connection.close();
}
catch(Exception e)
{
StringWriter writer = new StringWriter();
PrintWriter printWriter = new PrintWriter( writer );
e.printStackTrace( printWriter );
printWriter.flush();
String stackTrace = writer.toString();
error+="Error : "+stackTrace;
System.out.println(" Error : "+ e.toString());
}
return error;
}
public boolean deleteContractor(int Contractor_id)
{
return true;
}
results.put("Contractor_first_name",rs.getString("Contractor_first_name"));
results.put("Contractor_middle_name",rs.getString("Contractor_middle_nam
e"));
results.put("Contractor_last_name",rs.getString("Contractor_last_name"));
results.put("Contractor_gender",rs.getString("Contractor_gender"));
results.put("Contractor_address",rs.getString("Contractor_address"));
results.put("Contractor_village",rs.getString("Contractor_village"));
results.put("Contractor_state",rs.getString("Contractor_state"));
results.put("Contractor_country",rs.getString("Contractor_country"));
results.put("Contractor_landline",rs.getString("Contractor_landline"));
results.put("Contractor_mobile",rs.getString("Contractor_mobile"));
results.put("Contractor_email",rs.getString("Contractor_email"));
results.put("Contractor_status",Integer.parseInt(rs.getString("Contractor_sta
tus")));
results.put("Contractor_deparment",Integer.parseInt(rs.getString("Contracto
r_deparment")));
results.put("Contractor_dob",rs.getString("Contractor_dob"));
results.put("Contractor_nationalty",rs.getString("Contractor_nationalty"));
count++;
resultArray.add(results);
}
}
catch(Exception e)
{
StringWriter writer = new StringWriter();
}
return value;
}
public String getStatus(int status_id)
{
HashMap results = new HashMap();
String SQL = "";
String value = "";
int count=0;
try
{
SQL = "SELECT status_name FROM status WHERE status_id =
"+status_id ;
statement = connection.createStatement();
rs = statement.executeQuery(SQL);
while(rs.next())
{
value = rs.getString("status_name");
}
}
catch(Exception e)
{
System.out.println("Error is: "+ e);
}
return value;
}
}
Code of Leave.java
package Model;
import java.util.*;
import java.sql.*;
import com.*;
import java.io.*;
public class Leave extends Connect
{
/////Function for connect to the MySQL Server Database////////////
public Leave()
{
Connect.connect_mysql();
}
//////////Save User Details /////
public String saveLeave(HashMap leaveData)
{
String SQL = "INSERT INTO `leave` (leave_Contractor_id,
leave_reason, leave_description, leave_from_date, leave_to_date) VALUES
(?, ?, ?, ?, ?);";
int record=0;
String error = "";
try
{
pstmt = connection.prepareStatement(SQL);
pstmt.setString(1,(String)
leaveData.get("leave_Contractor_id"));
pstmt.setString(2,(String) leaveData.get("leave_reason"));
pstmt.setString(3,(String)
leaveData.get("leave_description"));
pstmt.setString(4,(String)
leaveData.get("leave_from_date"));
pstmt.setString(5,(String)
leaveData.get("leave_to_date"));
record = pstmt.executeUpdate();
pstmt.close();
connection.close();
}
catch(Exception e)
{
StringWriter writer = new StringWriter();
PrintWriter printWriter = new PrintWriter( writer );
e.printStackTrace( printWriter );
printWriter.flush();
String stackTrace = writer.toString();
error+="Error : "+stackTrace;
System.out.println(" Error : "+ e.toString());
}
return error;
}
//////////////////Function for getting Users Details//////////
public HashMap getLeaveDetails(int leave_id)
{
HashMap results = new HashMap();
int count=0;
try
{
String SQL = "SELECT * FROM `leave` WHERE leave_id =
"+leave_id ;
statement = connection.createStatement();
rs = statement.executeQuery(SQL);
while(rs.next())
{
results.put("leave_id",rs.getString("leave_id"));
results.put("leave_Contractor_id",Integer.parseInt(rs.getString("leave_Contr
actor_id")));
results.put("leave_reason",rs.getString("leave_reason"));
results.put("leave_description",rs.getString("leave_description"));
results.put("leave_from_date",rs.getString("leave_from_date"));
results.put("leave_to_date",rs.getString("leave_to_date"));
results.put("leave_status",rs.getString("leave_status"));
count++;
}
if(count==0)
{
results.put("leave_id","");
results.put("leave_Contractor_id",0);
results.put("leave_reason","");
results.put("leave_description","");
results.put("leave_from_date","");
results.put("leave_to_date","");
results.put("leave_status",0);
}
}
catch(Exception e)
{
System.out.println("Error is: "+ e);
}
return results;
}
/// Update the Leave ////
public String updateLeave(HashMap leaveData)
{
String SQL = "UPDATE `leave` SET leave_status = ? WHERE
leave_id = ?";
String error = "";
int record=0;
try
{
pstmt = connection.prepareStatement(SQL);
pstmt.setString(1,(String) leaveData.get("leave_status"));
pstmt.setString(2,(String) leaveData.get("leave_id"));
record = pstmt.executeUpdate();
pstmt.close();
connection.close();
}
catch(Exception e)
{
StringWriter writer = new StringWriter();
PrintWriter printWriter = new PrintWriter( writer );
e.printStackTrace( printWriter );
printWriter.flush();
String stackTrace = writer.toString();
error+="Error : "+stackTrace;
System.out.println(" Error : "+ e.toString());
}
return error;
}
////////////////Function for getting all the Airport
Details////////////////////
public ArrayList getAllLeave(String emp_id)
{
String SQL = "SELECT * FROM `leave`,`Contractor` WHERE
leave_Contractor_id = Contractor_id";
int count=0;
ArrayList resultArray = new ArrayList();
try
{
if(!emp_id.equals("0"))
{
SQL = "SELECT * FROM `leave`,`Contractor`
WHERE leave_Contractor_id = Contractor_id AND Contractor_id =
"+emp_id;
}
statement = connection.createStatement();
rs = statement.executeQuery(SQL);
while(rs.next())
{
HashMap results = new HashMap();
results.put("leave_id",rs.getString("leave_id"));
results.put("leave_Contractor_id",Integer.parseInt(rs.getString("leave_Contr
actor_id")));
results.put("leave_reason",rs.getString("leave_reason"));
results.put("leave_description",rs.getString("leave_description"));
results.put("leave_from_date",rs.getString("leave_from_date"));
results.put("leave_to_date",rs.getString("leave_to_date"));
results.put("leave_status",rs.getString("leave_status"));
results.put("Contractor_name",rs.getString("Contractor_first_name")
+" "+rs.getString("Contractor_last_name"));
count++;
resultArray.add(results);
}
}
catch(Exception e)
{
System.out.println("Error is: "+ e);
}
return resultArray;
}
/////Function for Getting the List////////////
public String getContractorOption(Integer SelID)
{
int selectedID = SelID.intValue();
return
Connect.getOptionList("Contractor","Contractor_id","Contractor_id","Contrac
tor_id,Contractor_id",selectedID,"1");
}
}
Code of Login.java
package Model;
import java.util.*;
import java.sql.*;
import com.*;
import java.io.*;
public class Login extends Connect
{
/////Function for connect to the MySQL Server Database////////////
public Login()
{
Connect.connect_mysql();
}
//////////////////Function for Update the airport////////////////////////
public boolean changePassword(String old_password,String
new_password, int login_id)
{
String SQL;
int count = 0;
try
{
SQL = "SELECT * FROM login WHERE login_password =
'"+old_password+"' AND login_id = "+login_id ;
statement = connection.createStatement();
rs = statement.executeQuery(SQL);
while(rs.next())
count++;
if(count==1)
{
SQL = "UPDATE login SET login_password=? WHERE
login_id=?";
int record=0;
pstmt = connection.prepareStatement(SQL);
pstmt.setString(1,new_password);
pstmt.setInt(2,1);
record = pstmt.executeUpdate();
pstmt.close();
connection.close();
}
}
catch(Exception e)
{
System.out.println(" Error : "+ e.toString());
}
if(count==0)
return false;
return true;
}
//////////////////Function for geting the Single Airport Details//////////
public boolean checkLogin(String login_user,String login_password)
{
int count=0;
try
{
String SQL = "SELECT * FROM login WHERE login_user =
'"+login_user+"' AND login_password = '"+login_password+"'" ;
statement = connection.createStatement();
rs = statement.executeQuery(SQL);
while(rs.next())
count++;
}
catch(Exception e)
{
System.out.println("Error is: "+ e);
}
if(count==0)
return false;
return true;
}
//////////////////Function for getting Login Details//////////
public HashMap getLoginDetails(String login_user,String login_password)
{
HashMap resultsArray = new HashMap();
int count=0;
try
{
String SQL = "SELECT * FROM login WHERE login_user =
'"+login_user+"' AND login_password = '"+login_password+"'" ;
statement = connection.createStatement();
rs = statement.executeQuery(SQL);
while(rs.next())
{
resultsArray.put("login_id",rs.getString("login_id"));
resultsArray.put("login_emp_id",rs.getString("login_emp_id"));
resultsArray.put("login_user",rs.getString("login_user"));
resultsArray.put("login_level",rs.getString("login_level"));
count++;
}
if(count==0)
{
resultsArray.put("login_id","");
resultsArray.put("login_emp_id","");
resultsArray.put("login_user","");
resultsArray.put("login_level","");
}
}
catch(Exception e)
{
System.out.println("Error is: "+ e);
}
return resultsArray;
}
}
Code of Salary.java
package Model;
import java.util.*;
import java.sql.*;
import com.*;
import java.io.*;
public class Salary extends Connect
{
/////Function for connect to the MySQL Server Database////////////
public Salary()
{
Connect.connect_mysql();
}
//////////Save User Details /////
public String saveSalary(HashMap salaryData)
{
String SQL = "INSERT INTO salary (sal_employe_id, sal_month,
sal_year, sal_amount) VALUES (?, ?, ?, ?);";
int record=0;
String error = "";
try
{
pstmt = connection.prepareStatement(SQL);
pstmt.setString(1,(String)
salaryData.get("sal_employe_id"));
pstmt.setString(2,(String) salaryData.get("sal_month"));
pstmt.setString(3,(String) salaryData.get("sal_year"));
pstmt.setString(4,(String) salaryData.get("sal_amount"));
record = pstmt.executeUpdate();
pstmt.close();
connection.close();
}
catch(Exception e)
{
StringWriter writer = new StringWriter();
PrintWriter printWriter = new PrintWriter( writer );
e.printStackTrace( printWriter );
printWriter.flush();
String stackTrace = writer.toString();
error+="Error : "+stackTrace;
System.out.println(" Error : "+ e.toString());
}
return error;
}
//////////////////Function for getting Users Details//////////
public HashMap getSalaryDetails(int sal_id)
{
HashMap results = new HashMap();
int count=0;
try
{
String SQL = "SELECT * FROM salary WHERE sal_id = "+sal_id ;
statement = connection.createStatement();
rs = statement.executeQuery(SQL);
while(rs.next())
{
results.put("sal_id",rs.getString("sal_id"));
results.put("sal_employe_id",Integer.parseInt(rs.getString("sal_employe_id"
)));
results.put("sal_year",rs.getString("sal_year"));
results.put("sal_month",Integer.parseInt(rs.getString("sal_month")));
results.put("sal_amount",rs.getString("sal_amount"));
count++;
}
if(count==0)
{
results.put("sal_id","");
results.put("sal_employe_id",0);
results.put("sal_year","");
results.put("sal_month",0);
results.put("sal_amount","");
}
}
catch(Exception e)
{
System.out.println("Error is: "+ e);
}
return results;
}
//////////////////Function for getting Users Details//////////
int record=0;
try
{
pstmt = connection.prepareStatement(SQL);
pstmt.setString(1,(String)
salaryData.get("sal_employe_id"));
pstmt.setString(2,(String) salaryData.get("sal_year"));
pstmt.setString(3,(String) salaryData.get("sal_month"));
pstmt.setString(4,(String) salaryData.get("sal_amount"));
pstmt.setString(5,(String) salaryData.get("sal_id"));
record = pstmt.executeUpdate();
pstmt.close();
connection.close();
}
catch(Exception e)
{
StringWriter writer = new StringWriter();
PrintWriter printWriter = new PrintWriter( writer );
e.printStackTrace( printWriter );
printWriter.flush();
String stackTrace = writer.toString();
error+="Error : "+stackTrace;
System.out.println(" Error : "+ e.toString());
}
return error;
}
public boolean delete_login(int airline_id)
{
return true;
}
////////////////Function for getting all the Airport
Details////////////////////
public ArrayList getAllSalary(String emp_id)
{
String SQL = "SELECT * FROM salary";
int count=0;
ArrayList resultArray = new ArrayList();
try
{
if(!emp_id.equals("0"))
{
SQL = "SELECT * FROM salary WHERE
sal_employe_id = "+emp_id;
}
statement = connection.createStatement();
rs = statement.executeQuery(SQL);
while(rs.next())
{
HashMap results = new HashMap();
results.put("sal_id",rs.getString("sal_id"));
results.put("sal_employe_id",Integer.parseInt(rs.getString("sal_employe_id"
)));
results.put("sal_year",rs.getString("sal_year"));
results.put("sal_month",Integer.parseInt(rs.getString("sal_month")));
results.put("sal_amount",rs.getString("sal_amount"));
count++;
resultArray.add(results);
}
}
catch(Exception e)
{
System.out.println("Error is: "+ e);
}
return resultArray;
}
/////Function for Getting the List////////////
public String getMonthOption(Integer SelID)
{
int selectedID = SelID.intValue();
return
Connect.getOptionList("month","month_id","month_name","month_id,month
_name",selectedID,"1");
}
/////Function for Getting the List////////////
public String getContractorOption(Integer SelID)
{
int selectedID = SelID.intValue();
return
Connect.getOptionList("Contractor","Contractor_id","Contractor_id","Contrac
tor_id,Contractor_id",selectedID,"1");
}
}
Code of Timesheet.java
package Model;
import java.util.*;
import java.sql.*;
import com.*;
import java.io.*;
public class Timesheet extends Connect
{
/////Function for connect to the MySQL Server Database////////////
public Timesheet()
{
Connect.connect_mysql();
}
//////////Save User Details /////
public String saveTimesheet(HashMap timesheetData)
{
String SQL = "INSERT INTO timesheet (timesheet_Contractor_id,
timesheet_project_id, timesheet_work_title, timesheet_description,
timesheet_hours, timesheet_date) VALUES (?, ?, ?, ?, ?, ?);";
int record=0;
String error = "";
try
{
pstmt = connection.prepareStatement(SQL);
pstmt.setString(1,(String)
timesheetData.get("timesheet_Contractor_id"));
pstmt.setString(2,(String)
timesheetData.get("timesheet_project_id"));
pstmt.setString(3,(String)
timesheetData.get("timesheet_work_title"));
pstmt.setString(4,(String)
timesheetData.get("timesheet_description"));
pstmt.setString(5,(String)
timesheetData.get("timesheet_hours"));
pstmt.setString(6,(String)
timesheetData.get("timesheet_date"));
record = pstmt.executeUpdate();
pstmt.close();
connection.close();
}
catch(Exception e)
{
StringWriter writer = new StringWriter();
PrintWriter printWriter = new PrintWriter( writer );
e.printStackTrace( printWriter );
printWriter.flush();
String stackTrace = writer.toString();
error+="Error : "+stackTrace;
System.out.println(" Error : "+ e.toString());
}
return error;
}
//////////////////Function for getting Users Details//////////
public HashMap getTimesheetDetails(int timesheet_id)
{
results.put("timesheet_Contractor_id",Integer.parseInt(rs.getString("timeshe
et_Contractor_id")));
results.put("timesheet_project_id",Integer.parseInt(rs.getString("timesheet_
project_id")));
results.put("timesheet_work_title",rs.getString("timesheet_work_title"));
results.put("timesheet_description",rs.getString("timesheet_description"));
results.put("timesheet_hours",rs.getString("timesheet_hours"));
results.put("timesheet_date",rs.getString("timesheet_date"));
count++;
}
if(count==0)
{
results.put("timesheet_id","");
results.put("timesheet_Contractor_id",0);
results.put("timesheet_project_id",0);
results.put("timesheet_work_title","");
results.put("timesheet_description","");
results.put("timesheet_hours","");
results.put("timesheet_date","");
}
}
catch(Exception e)
{
System.out.println("Error is: "+ e);
}
return results;
}
/// Update the Timesheet ////
public String updateTimesheet(HashMap timesheetData)
{
String SQL = "UPDATE timesheet SET timesheet_Contractor_id =
?, timesheet_project_id = ?, timesheet_work_title = ?,
timesheet_description = ?, timesheet_hours = ?, timesheet_date = ?
WHERE timesheet_id = ?;";
String error = "";
int record=0;
try
{
pstmt = connection.prepareStatement(SQL);
pstmt.setString(1,(String)
timesheetData.get("timesheet_Contractor_id"));
pstmt.setString(2,(String)
timesheetData.get("timesheet_project_id"));
pstmt.setString(3,(String)
timesheetData.get("timesheet_work_title"));
pstmt.setString(4,(String)
timesheetData.get("timesheet_description"));
pstmt.setString(5,(String)
timesheetData.get("timesheet_hours"));
pstmt.setString(6,(String)
timesheetData.get("timesheet_date"));
pstmt.setString(7,(String)
timesheetData.get("timesheet_id"));
record = pstmt.executeUpdate();
pstmt.close();
connection.close();
}
catch(Exception e)
{
StringWriter writer = new StringWriter();
PrintWriter printWriter = new PrintWriter( writer );
e.printStackTrace( printWriter );
printWriter.flush();
String stackTrace = writer.toString();
error+="Error : "+stackTrace;
System.out.println(" Error : "+ e.toString());
}
return error;
}
////////////////Function for getting all the Airport
Details////////////////////
public ArrayList getAllTimesheet(String emp_id)
{
String SQL = "SELECT * FROM `timesheet`,`Contractor`
WHERE timesheet_Contractor_id = Contractor_id";
int count=0;
ArrayList resultArray = new ArrayList();
try
{
if(!emp_id.equals("0"))
{
SQL = "SELECT * FROM `timesheet`,`Contractor`
WHERE timesheet_Contractor_id = Contractor_id AND Contractor_id =
"+emp_id;
}
statement = connection.createStatement();
rs = statement.executeQuery(SQL);
while(rs.next())
{
HashMap results = new HashMap();
results.put("timesheet_id",rs.getString("timesheet_id"));
results.put("timesheet_Contractor_id",Integer.parseInt(rs.getString("timeshe
et_Contractor_id")));
results.put("timesheet_project_id",Integer.parseInt(rs.getString("timesheet_
project_id")));
results.put("timesheet_work_title",rs.getString("timesheet_work_title"));
results.put("timesheet_description",rs.getString("timesheet_description"));
results.put("timesheet_hours",rs.getString("timesheet_hours"));
results.put("timesheet_date",rs.getString("timesheet_date"));
results.put("Contractor_name",rs.getString("Contractor_first_name")
+" "+rs.getString("Contractor_last_name"));
count++;
resultArray.add(results);
}
}
catch(Exception e)
{
System.out.println("Error is: "+ e);
}
return resultArray;
}
/////Function for Getting the List////////////
Contractor_data.put("Contractor_id",request.getParameter("Contractor_id"))
;
Contractor_data.put("Contractor_user",request.getParameter("Contractor_us
er"));
Contractor_data.put("Contractor_password",request.getParameter("Contract
or_password"));
Contractor_data.put("Contractor_level","1");
Contractor_data.put("Contractor_sal",request.getParameter("Contractor_sal"
));
Contractor_data.put("Contractor_first_name",request.getParameter("Contrac
tor_first_name"));
Contractor_data.put("Contractor_middle_name",request.getParameter("Cont
ractor_middle_name"));
Contractor_data.put("Contractor_last_name",request.getParameter("Contrac
tor_last_name"));
Contractor_data.put("Contractor_gender",request.getParameter("Contractor
_gender"));
Contractor_data.put("Contractor_address",request.getParameter("Contractor
_address"));
Contractor_data.put("Contractor_village",request.getParameter("Contractor_
village"));
Contractor_data.put("Contractor_state",request.getParameter("Contractor_s
tate"));
Contractor_data.put("Contractor_country",request.getParameter("Contractor
_country"));
Contractor_data.put("Contractor_landline",request.getParameter("Contractor
_landline"));
Contractor_data.put("Contractor_mobile",request.getParameter("Contractor_
mobile"));
Contractor_data.put("Contractor_email",request.getParameter("Contractor_e
mail"));
Contractor_data.put("Contractor_status",request.getParameter("Contractor_
status"));
Contractor_data.put("Contractor_deparment",request.getParameter("Contrac
tor_deparment"));
Contractor_data.put("Contractor_dob",request.getParameter("Contractor_do
b"));
Contractor_data.put("Contractor_nationalty",request.getParameter("Contract
or_nationalty"));
if((request.getParameter("Contractor_id")).equals(""))
{
Contractor_obj.saveContractor(Contractor_data);
response.sendRedirect("../report-Contractor.jsp?
msg=Contractor Saved Successfully");
}
else
Contractor_data.put("Contractor_id",request.getParameter("Contractor_id"))
;
out.print(Contractor_obj.updateContractor(Contractor_data));
if(request.getParameter("Contractor_id").equals(session.getAttribute("login_
emp_id")))
{
response.sendRedirect("../Contractor.jsp?
Contractor_id="+session.getAttribute("login_emp_id")+"&msg=Account
Updated Successfully");
}
else
{
response.sendRedirect("../report-Contractor.jsp?
msg=Contractor Updated Successfully");
}
}
}
if((request.getParameter("act")).equals("delete"))
{
int Contractor_id =
Integer.parseInt(request.getParameter("Contractor_id"));
if(Contractor_obj.deleteContractor(Contractor_id))
response.sendRedirect("../register.jsp?msg=Record
Deleted Successfully");
else
response.sendRedirect("../register.jsp?msg=Problem in
Deletion.");
}
%>
results.put("leave_Contractor_id",request.getParameter("leave_Contractor_i
d"));
results.put("leave_reason",request.getParameter("leave_reason"));
results.put("leave_description",request.getParameter("leave_description"));
results.put("leave_from_date",request.getParameter("leave_from_date"));
results.put("leave_to_date",request.getParameter("leave_to_date"));
results.put("leave_status",request.getParameter("leave_status"));
if((request.getParameter("leave_id")).equals(""))
{
out.println(leaveObj.saveLeave(results));
response.sendRedirect("../report-leave.jsp?
emp_id="+emp_id+"&msg=Leave Saved Successfully");
}
else
{
results.put("leave_id",request.getParameter("leave_id"));
out.println(leaveObj.updateLeave(results));
response.sendRedirect("../report-leave.jsp?
emp_id=0&msg=Leave Updated Successfully");
}
}
%>
if(login_obj.checkLogin(request.getParameter("login_user"),request.getPara
meter("login_password")))
{
HashMap Values =
login_obj.getLoginDetails(request.getParameter("login_user"),request.getPar
ameter("login_password"));
session.setAttribute("login_id",Values.get("login_id"));
session.setAttribute("login_emp_id",Values.get("login_emp_id"));
session.setAttribute("login_user",Values.get("login_user"));
session.setAttribute("login_level",Values.get("login_level"));
response.sendRedirect("../login-home.jsp?msg=You are
login successfully.");
}
else
{
response.sendRedirect("../login.jsp?msg=Invalid
User/Password. Please try again.........");
}
}
if((request.getParameter("act")).equals("change_password"))
{
if(login_obj.changePassword(request.getParameter("old_password"),request.
getParameter("new_password"),Integer.parseInt((String)
session.getAttribute("login_id"))))
{
response.sendRedirect("../change-password.jsp?msg=Your
Password has been changed successfully.");
}
else
{
response.sendRedirect("../change-password.jsp?msg=Old
Password doesnot match. Please try again......");
}
}
if((request.getParameter("act")).equals("logout"))
{
session.setAttribute("login_id",null);
session.setAttribute("login_level",null);
response.sendRedirect("../login.jsp?msg=You are logout
successfully......");
}
%>
login_data.put("login_password",request.getParameter("login_password"));
login_data.put("login_email",request.getParameter("login_email"));
login_data.put("login_sal",request.getParameter("login_sal"));
login_data.put("login_first_name",request.getParameter("login_first_name")
);
login_data.put("login_middle_name",request.getParameter("login_middle_na
me"));
login_data.put("login_last_name",request.getParameter("login_last_name"))
;
login_data.put("login_gender",request.getParameter("login_gender"));
login_data.put("login_address",request.getParameter("login_address"));
login_data.put("login_village",request.getParameter("login_village"));
login_data.put("login_state",request.getParameter("login_state"));
login_data.put("login_country",request.getParameter("login_country"));
login_data.put("login_landline",request.getParameter("login_landline"));
login_data.put("login_mobile",request.getParameter("login_mobile"));
if((request.getParameter("login_id")).equals(""))
{
login_obj.save_login(login_data);
if(request.getParameter("login_id").equals(""))
{
response.sendRedirect("../login.jsp?msg=You have
registered successfully.<br>Login to access your account.");
}
else
{
response.sendRedirect("../report-customer.jsp?
msg=Customer Saved Successfully");
}
}
else
{
login_data.put("login_id",request.getParameter("login_id"));
login_obj.update_login(login_data);
if(request.getParameter("login_id").equals(session.getAttribute("login_id")))
{
response.sendRedirect("../register.jsp?
login_id=1&msg=Account Updated Successfully");
}
else
{
response.sendRedirect("../report-customer.jsp?
msg=Customer Updated Successfully");
}
}
}
if((request.getParameter("act")).equals("delete"))
{
int login_id =
Integer.parseInt(request.getParameter("login_id"));
if(login_obj.delete_login(login_id))
response.sendRedirect("../register.jsp?msg=Record
Deleted Successfully");
else
response.sendRedirect("../register.jsp?msg=Problem in
Deletion.");
}
%>
results.put("sal_employe_id",request.getParameter("sal_employe_id"));
results.put("sal_year",request.getParameter("sal_year"));
results.put("sal_month",request.getParameter("sal_month"));
results.put("sal_amount",request.getParameter("sal_amount"));
if((request.getParameter("sal_id")).equals(""))
{
out.println(salaryObj.saveSalary(results));
response.sendRedirect("../report-salary.jsp?msg=Salary
Saved Successfully");
}
else
{
results.put("sal_id",request.getParameter("sal_id"));
out.println(salaryObj.updateSalary(results));
response.sendRedirect("../report-salary.jsp?msg=Salary
Updated Successfully");
}
}
if((request.getParameter("act")).equals("delete"))
{
int pay_id = Integer.parseInt(request.getParameter("sal_id"));
if(salaryObj.delete_login(pay_id))
response.sendRedirect("../register.jsp?msg=Record
Deleted Successfully");
else
response.sendRedirect("../register.jsp?msg=Problem in
Deletion.");
}
%>
results.put("timesheet_id",request.getParameter("timesheet_id"));
results.put("timesheet_Contractor_id",request.getParameter("timesheet_Con
tractor_id"));
results.put("timesheet_project_id",request.getParameter("timesheet_project
_id"));
results.put("timesheet_work_title",request.getParameter("timesheet_work_ti
tle"));
results.put("timesheet_description",request.getParameter("timesheet_descri
ption"));
results.put("timesheet_hours",request.getParameter("timesheet_hours"));
results.put("timesheet_date",request.getParameter("timesheet_date"));
results.put("Contractor_name",request.getParameter("Contractor_first_nam
e")+" "+request.getParameter("Contractor_last_name"));
if((request.getParameter("timesheet_id")).equals(""))
{
out.println(timesheetObj.saveTimesheet(results));
response.sendRedirect("../report-timesheet.jsp?
emp_id="+emp_id+"&msg=Timesheet Saved Successfully");
}
else
{
results.put("timesheet_id",request.getParameter("timesheet_id"));
out.println(timesheetObj.updateTimesheet(results));
response.sendRedirect("../report-timesheet.jsp?
emp_id=0&msg=Timesheet Updated Successfully");
}
}
%>