Canteen Management DOC

Download as doc, pdf, or txt
Download as doc, pdf, or txt
You are on page 1of 83

S. K.

SOMAIYA COLLEGE OF ARTS, SCIENCE AND COMMERCE


VIDYAVIHAR (W), MUMBAI -400077

Canteen Management System

BY
Mr. Mohammed Kesury
T.Y.BSC (COMPUTER SCIENCE)
UNIVERSITY OF MUMBAI
2018-2019

PROJECT GUIDE
Prof. Swati Maurya

1
INDEX

SR. NO. CONTENTS PAGE NO

1. ACKNOWLEDGEMENT

2. PRELIMINARY INVESTIGATION

2.1 Introduction
2.2 Requirement Specification
2.3 Synopsis

3. SYSTEM ANALYSIS

3.1 Objective and Existing System


3.2 Proposed System and its Advantages
3.3 Feasibility Study
3.4 Tools and Technology

4. SYSTEM DESIGN

4.1 Event Table


4.2 E-R Diagram
4.3 Use Case Diagram
4.4 Class Diagram

5 SYSTEM CODING

5.1 Database Design


5.2 Forms
6 Testing
7. System maintenance and Future Enhancements
8. References and Bibliography

2
ACKNOWLEDGEMENT

It gives great pleasure and pride as I present my project on ‘CANTEEN


MANAGEMENT SYSTEM’. This acknowledgement is a small effort to
express our and gratitude to all those who have shown me the path to bring out
the various colours of this project with their vast treasures of experience and
knowledge.I express my deep sense of thanks and indebtedness towards my
internal project guide. I would like to thank my entire department of Computer
Science for their solitude help to complete my project work. I express my
thanks to Last but not least I wish to avail myself of this opportunity, express
a sense of gratitude and love to my friends and my beloved parents for their
manual support, strength and help for everything.

Mr. Mohammed Kesury

3
PRELIMINARY INVESTIGATION
Introduction
 The main objective of project is to manage details of canteen, sales, customer etc.
 The purpose of the project is to build an application program to reduce manual work.
 It tracks all the details about customer, sales, products, etc.
 No additional knowledge is needed for the user to use this software.
 This system id’s designed for particular need of the company to carry out operations in a
smooth and effective manner.

REQUIREMENT SPECIFICATION
 A requirement specification is a complete description of the behavior to be performed.
 The requirement specification enlists all necessary requirements that are required for the
project development.
 The requirement specification is produced at the culmination of the analysis task
 System needs to keep records of all customer
 System needs to delete and update as well
 System also need to keep record of the products,etc

EXISTING SYSTEM
Manual errors:
 Since the records are maintained manually, searching for a particular record and maintaining all
records is very difficult.
 All records and details are maintained in registers.
 There is a large chance of Human error in calculations, maintainence.
 Misplacement of registers causes a valuable data to be lost.

Time Consuming:
 A lot of paper work has to be done, which is very time consuming.
 Searching records, details from registers is very tedious job due to excess paper work.

4
Risky:
 There are no provisions for security.
 Due to this company’s confidential data is at risk.

Tedious Job:
 In the current system, there is a chance of data redundancy therefore maintainence and updating
is difficult.

PROPOSED SYSTEM

Features:
 The customer details and billing process are to be computerized.
 It is fully computerized so no need of maintaining records manually.
 The time factor of the system is reduced drastically.
 Bill generation is automated.
 Proper Validation is provided for the system.
 Report generation is also done, so manual work is reduced to a large extent.

Advantages of Proposed System:


 This system is User-friendly, interactive and easy to use.
 Save excess paper work.
 Time saving.
 No complexities.
 Formatted data.
 Easy to keep record and maintain database.
 Security of data.

FEASIBILITY STUDY

5
 Preliminary Investigation is the first phase in any system developing life cycle. The
Feasibility Study is a major part of this phase.
 Feasibility Study means selecting the best system that meet the performance requirement.
 It is the measure of how beneficial or practical the development of an Information System
would be to the organization.
 Our study of the feasible development of the software is going to be in terms of the
following aspects:

Operational Feasibility:
Proposed system is beneficial only if it can be turned into management system that will meet the
need of the client’s operating requirements. The proposed system is operationally feasible due to the
following reasons:
 The system is easy to use and is very simple.
 The proposed system will cost no harm to the company; instead it
will enhance the result in a better respect.

 The new system will avoid confusion and resistance by catching the user’s attention, as it is
presentable.

Economical Feasibility:
1. Development Cost

 Equipments required for developing the software are easily available.


 Equipment maintenance is also minimum.
 Saving of paper work and manpower reduced.
 Once the required hardware and software requirements get fulfilled
there is no need for the user of our system to spend for any additional
overhead.
 Training cost is reduced.
2. Benefits which cannot be measured:
 Increased customer Loyalty
 Increased customer satisfaction

6
Technical Feasibility:
At first it is necessary to check that the proposed system is technically
feasible or not and to determine the technology and skill necessary to carry out
the project. If they are not available then find out the solution to obtain them.
Hardware is already available in the college.

TOOLS AND TECHNOLOGY


Software:
 Operating System: Window 7,8,10
 Frontend: Java, Jsp, Html,CSS
 Backend: MySql

Hardware:
 Intel® Pentium® Core 2 Duo CPU 2.10GHz
 2 GB DDR2 RAM.
 200 GB Hard Disk
 Logitech Mouse

EVENT TABLE

EVENTS:
An event occurs at a specific time & place, that can be described & is
worth remembered by the system. Events drive or trigger all processing that a

7
system does, so listing them & then analyzing them make sense when you
need to define system requirements.
EXTERNAL EVENT:
An event that occurs outside the system usually initiated by an
external agent or actor.
TABLE

A table that lists events in rows & key pieces of information about
each event in columns.

TRIGGER:
An occurrence that tells the system that an event has occurred, either the
arrival of data needing for processing or point in time.

SOURCE:

An external agent or actor that supplies data to the system.

ACTIVITY:

Behaviour that the system performs when an event occurs

RESPONSE:
An output, produce by the system that goes to the system.

DESTINATION:

An external agent or actor that receives data from the system

Sr.no Event Trigger Source Activity Response Destination


1. Admin/User Login Admin/ Checks for Open Admin/
Login User Valid account User
username

8
And If
password successful
2. Add employee Entering Admin Adding new New Admin
Employee Employee Employee
Details Added
3. Edit employee Entering Admin Editing Employee Admin
Employee employee Details
Details edited
4. Add product Adding User Adding the Product gets User
product product added
5. Add sales Adding sales Admin Adding the Sales Admin
sales added
6. Admin/User Logout Admin/ Logging out Logs out Admin/
Logout User User

USE CASE DIAGRAM

Use Case Diagram is used to identify the “uses” or use cases of the
new system-- in other words, to identify how the system will be used .The
Use Case Diagram is essentially an extension of the Event Table.

USE CASE:
It describes an activity the system carries out in response to an event.

ACTOR:
In UML, the person involved is called an Actor. An Actor is always
outside of the Automation Boundary of the system.

CONNECTING LINE:

9
The arrow is used to show which Actors participate in which Use
cases.

USE CASE DIAGRAM NOTATIONS:

Use Case

Automation Boundary
Connecting Line

Use Case

Actor

DESCRIPTION:
The Object Oriented approach uses the term use case to describe an
activity the system carries out in response to an event. One can think of a
use case as a case or situation where the system is used for some purpose .A
use case diagram is a convenient way to document the functions that the
system must support. Sometimes a single, comprehensive diagram is used
to describe the entire system. At other times, a set of smaller use case
diagrams make up the use case model.

USE CASE DIAGRAM

10
ENTITY-RELATIONSHIP DIAGRAM

The entity – relationship (ER) data model allows us to describe the data
involved in a real world enterprise in terms of object and their relationships
and is widely used to develop an initial database design.
The ER model is important primarily for its role in database design. It
provides useful concepts that allow us to move from an informal description
of what users want from their database to a more detailed and precise
description that can be implemented in a DBMS. The ER model is used in a
phase called “Conceptual Database Design”. It should be noted that many
variations of ER diagrams are in use and no widely accepted standards prevail.

11
ER modeling is something regarded as a complete approach to design a
logical database schema. This is incorrect because the ER diagram is just an
approximate description of data, constructed through a very subjective
evaluation of the information collected during requirements analysis.
Entity:
An entity is an object in the real world that is distinguishable from other
objects. Examples include the following: The C++ language, the address of
the manager of the institution. It is often useful to identify a collection of
similar entities.Such a collection is called as “Entity set”. Note that entity set
need not be disjoint.
Attributes:
An entity is described using a set of attributes. All entities in a given
entity set have the same attributes; this essentially what we mean by similar.
Our choice of attributed reflects the level of detail at which we wish to
represent information in crisis.
For e.g. The Admission entity set would use the name, age, and
qualification of the students as the attributes. In this case we will store the
name, the register no, the course enrolled of the student and not his/her
address or the gender.
Domain:
For each attribute associated with an entity set, we must identify a
domain of possible values. For e.g. the domain associated with the attribute
name of the student might be of the set of 20-character string. Another
example would be the ranking of the students in the institute would be on the
scale of 1-6, the associated domain consists of integers 1 through 6.
Key:
Further, for each entity set we choose a key. A key is a minimal set of
attributed whose values uniquely identify an entity in the set. There could be

12
more than one candidate; if so we designate one of them as primary key. For
now we will assume that each entity set contains at least one set of attributes
that uniquely identify an entity in the entity set; that is the set of attributes
contains a key.

SYMBOLS USED FOR ERD:

ENTITY SET

PROCESS

LINK ATTRIBUTE TO ENTITY SET AND


ENTITY SET TO RELATIONSHIPSET

13
ENTITY-RELATIONSHIP DIAGRAM

Login
Has

User

Manag
e products

given Orders Has


by

Bill Gener
ated
customer by

Pays Admin

14
CLASS DIAGRAM:
The Class diagrams are used to identify and classify the objects
which constitute a system. It also includes the important attributes of the
objects which must be captured.
CLASS:
It is a collection of objects of same type.

RELATIONSHIP:
A naturally occurring association among specific things

CLASS DIAGRAM NOTATIONS:


In Class diagram, rectangles represent Class and the lines
connecting the rectangle show the relationships among Classes.

CLASS NAME

ATTRIBUTES OF CLASS

IMPORTANT CLASS METHODS

DESCRIPTION:
It is a model which is used to show the classes constituting a
system and their interrelationships .It is based on UML (Unified
Modeling Language). Only the important attributes and methods are
shown in Class Diagrams. In the initial period of analysis, the important
attributes of the classes, which must be captured and the functionalities
provided by the class may not be very clear. As the analysis progresses,
the attributes and methods may be added.

15
16
TABLE DESIGN
1. Login:

SERIAL FIELD NAME DATA SIZE CONSTRAINT


NO TYPE
1 User Name varchar 18 Primary key
2 Password varchar 50

2. Employee:

SERIAL FIELD NAME DATA SIZE CONSTRAINT


NO TYPE
1 Emp_id int 11 Primary key
2 Emp_first_name varchar 50 Not null
3 Emp_middle_name varchar 50
4 Emp_last_name varchar 50
5 Emp_gender varchar 10
6 Emp-mobile int 11
7 Emp_address varchar 50

3. Product:

SERIAL FIELD NAME DATA SIZE CONSTRAINT


NO TYPE
1 Prod_id int 11 Primary key
2 Prod_title varchar 50
3 Prod_unit varchar 50
4 Prod_price_per_unit varchar 20
5 Prod_desc varchar 50

4. Company:

SERIAL FIELD NAME DATA SIZE CONSTRAINT


NO TYPE

17
1 Company_id Int 11 Primary key
2 Company_name varchar 50
3 Company_phone int 50
4 Company_address varchar 20
5 Company_desc varchar 100

5. Order:

SERIAL FIELD NAME DATA SIZE CONSTRAINT


NO TYPE
1 Order_id int 11 Primary key
2 Order_cus_name varchar 50 Foreign key
3 Order_cus_mobile int 20
4 Order_total varchar 20

6. Stock:

SERIAL FIELD NAME DATA SIZE CONSTRAINT


NO TYPE
1 Stock_id int 11 Primary key
2 Stock_prod_id int 50 Foreign key
3 Stock_number Int 20
4 Stock_desc varchar 100

7. Sales:

SERIAL FIELD NAME DATA SIZE CONSTRAINT


NO TYPE
1 Sell_id int 11 Primary key
2 Sell_price_per_unit int 50
3 Sell_units int 20
4 Sell_total varchar 50

18
FORM DESIGN

LOG_IN:

19
MAIN FORM:

20
Registration Form:

21
Sales Form:

Product Form:

22
Company Form:

Bill Form:

23
VALIDATIONS

Login:
Txtusername This textbox is used to take input of username from the user
Txtpassword This textbox is used to take input of password from the user
Btnlogin This button is used to login into the system

Employee:
txtemployeeid This text should not be empty.
txtemployeename This text should not be empty or should not contain single

24
character.
txtemployeeaddress This text should not be empty or should not contain single
character.
txtemployeecity This text should not be empty or should not contain single
character.
txtpincode This text should not be empty or should contain 6 digit number.
txtcontactno This text should not be empty or should contain 10 digit number.

Product:
txtprodid This text field should not be empty.
txtprodtitle This text field should not be empty.
txtproddesc This text should not be empty or should not contain single
character.
prodprice This text field should not be empty.

Company:

txtcompanyid This text should not be empty.


txtcompanyname This text should not be empty or should not contain single
character.
txtcompanyaddress This text should not be empty or should not contain single
character.

25
txtcompanydesc This text should not be empty or should not contain single
character.
txtcompanyphone This text should not be empty or should contain 10 digit number.

Order:

txtorderid This text should not be empty.


txtordercusname This text should not be empty.
txtordertotal This text should not be empty.
txtordercusmobile This text should not be empty or should contain 10 digit number.

26
SYSTEM CODING

Login.jsp
<%@ include file="includes/header.jsp" %>
<div class="wrapper row3">
<div class="rounded">
<main class="container clear">
<div id="comments" style="width: 50%; margin: auto">
<div align="center" style="color: #00ff00">
<%
If (request.getParameter ("msg")! =null) out.print
(request.getParameter ("msg"));
%>
</div><br/><font size="50">
<h1 style = "color:red;">Login</font></h1>
<form action="model/login.jsp" method="post"
name="frm_login"><div>
<label for="name">Username<span></span></label>
<input type="text" name="login_user" id="name" value="" size="22">
</div><div>
<label for="email">Password<span></span></label>
<input type="password" name="login_password" id="email" value=" "
size="22">
</div><div>
<input name="submit" type="submit" value="Login">
<input name="reset" type="reset" value="Cancel">
<input type="hidden" name="act" value="chk_login">
</div><div><a href="forgot-password.jsp">Forgot Password</a></div>
</form>
</div>
<div class="clear"></div>

27
</main>
</div>
</div>
<%@ include file="includes/footer.jsp" %>

Model/Login.jsp
<%@ page import= "Model.*" %>
<%@ page import= "java.util.*" %>
<%
Login login_obj = new Login();
Employee employeeDetails= new Employee();
If (( request.getParameter ("act")). equals("chk_login"))
{ if(login_obj.checkLogin(request.getParamete
r("login_user"),request.getParameter("login_password"))
{
HashMap Values= login_obj.getLoginDetails
(request.getParameter("login_user"),request.getParameter("login_pa
ssword"));
HashMap employeeValues =
employeeDetails.getEmployeeDetails(Integer.parseInt(Values.get("lo
gin_emp_id").toString()));
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"));
session.setAttribute("login_name",employeeValues.get("employee_fir
st_name")+" "+employeeValues.get("employee_last_name"));
response.sendRedirect("../login-home.jsp?msg=You are
login
successfully.");
}
else
{

28
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"),r
equest.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
does not 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......");
}
%>

Loginhome.jsp
<%@ include file="includes/header.jsp" %>
<%@ page import= "java.util.*" %>
<div class="wrapper row3">
<div class="rounded">
<main class="container clear">
<div style="width: 70%; float:left; margin-right:30px" id="login-
home">

29
<h2>Welcome to Canteen Management System</h2>
<%
if(session.getAttribute("login_level") != null &&
session.getAttribute("login_level").equals("3"))
{ %>
<ul>
<li><a href="index.jsp">Home</a></li>
<li><a href="about-us.jsp">About Us</a></li>
<li><a href="report-product.jsp">Manage Food Items</a></li>
<li>
<a href="employee.jsp?employee_id=<
%=session.getAttribute("login_emp_id")%>">My Account</a></li>
</ul>
<% } %>
<%
if(session.getAttribute("login_level") != null &&
session.getAttribute("login_level").equals("1")) { %>
<ul>
<li><a href="employee.jsp?employee_id=0">Add User</a></li>
<li><a href="sell.jsp">Add Sell</a></li>
<li><a href="report-product.jsp">Manage Food Items</a></li>
<li><a href="report-sell.jsp?emp_id=0">Manage sell</a></li>
<li><a href="report-employee.jsp">Manage User</a></li>
<li><a href="change-password.jsp">Change Password</a></li>
</ul>
<% } %>
</div>
<div>
<div><img src="images/demo/log.png" align="left"
style="width:250px"></div><br>
</div>
<div class="clear"></div>
</main>
</div>
</div>
<%@ include file="includes/footer.jsp" %>

30
Login.java
package Model;
import java.util.*;
import java.sql.*;
import com.*;
import java.io.*;
public class Login extends Connect
{
public Login()
{
Connect.connect_mysql();
}
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,login_id);
record = pstmt.executeUpdate();
pstmt.close();

31
connection.close();
}
}
catch(Exception e)
{
System.out.println(" Error : "+ e.toString());
}
if(count==0)
return false;
return true;
}
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;
}
public HashMap getLoginDetails(String login_user,String
login_password)
{
HashMap resultsArray = new HashMap();

32
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;
}
public int checkUsernameExits(String login_user, int type)
{
HashMap resultsArray = new HashMap();
int exits=0;

33
try
{
String SQL = " " ;
if(type == 1)
{
SQL = "SELECT * FROM login WHERE
login_user = '"+login_user+"'" ;
}
if(type == 2)
{
SQL = "SELECT * FROM login WHERE
login_email = '"+login_user+"'" ;
}
statement = connection.createStatement();
rs = statement.executeQuery(SQL);
while(rs.next())
{
exits++;
}
}
catch(Exception e)
{
System.out.println("Error is: "+ e);
}
return exits;
}
}

Index.jsp
<%@ include file="includes/header.jsp" %>
<div class="wrapper row3">
<div class="rounded">
<main class="container clear">
<div class=" ">
<div class="one_quarter first">

34
<ul class="nospace">
<li><a href=" ">
<img src="images/demo/slider/pizza.jpg" ></a></li><br>
<li ><a href="#">
<img src="images/demo/slider/canteen.jpg" ></a></li><br>
<li ><a href="#">
<img src="images/demo/slider/3.png" ></a></li><br>
<li><a href="#">
<img src="images/demo/slider/4.jpg"></a></li>
</ul>
</div>
<div class="one_half" style="width:70%">
<h1>CANTEEN MANAGEMENT SYSTEM</h1>
<ul class="nospace listing">
<li class="clear">
<div class="imgl">
<img src="images/demo/food.jpg" align="top" height="70"
width="70">
</div>
<p class="nospace"><a href="#"></a></p>
</li>
<li class="clear">
<div class="img1"><img src="images/demo/cold.jpg" height="70"
width="70"></div>
<p class="nospace"><a href="#"></a></p>
</li>
<li class="clear">
<div class="imgl"></div>
<p class="nospace"> <a href="#"></a></p>
</li>
</ul>
</div>
</div>
<div class="clear"></div>
</main>
</div>
</div>

35
Product.jsp
<%@ include file="includes/header.jsp" %>
<%@ page import= "java.util.*" %>
<%@ page import= "Model.*" %>
<%
Product productDetails = new Product();
String productLabel = "Save";
int product_id = Integer.parseInt(request.getParameter
("product_id"));
if(product_id != 0) {
productLabel = "Update";
}
HashMap Values =
productDetails.getProductDetails(product_id);
%>
<div class="wrapper row3">
<div class="rounded">
<main class="container clear">
<div id="comments" style="width: 70%; float:left; margin-
right:30px">
<h2>Product Entry Form</h2>
<form action="model/product.jsp" method="post">
<div id="empl_id">
<label for="email">Product Type<span></span></label>
<select style="height: 40px; width:300px" name = "product_type_id"
id = "product_type_id" required>
<% out.print(productDetails.getProductTypeOption((Integer)
Values.get("product_type_id"))); %>
</select>
</div>
<div>
<label for="email">Product Company<span></span></label>

36
<select style="height: 40px; width:300px" name =
"product_company_id" id = "product_company_id" required>
<%
out.print(productDetails.getCompanyOption((Integer)Values.get("pro
duct_company_id"))); %>
</select></div>
<div id="product_status_row">
<label for="email">Product Name<span></span></label>
<input type="text" name="product_title" id="product_title"
value="<% out.print(Values.get("product_title")); %>" size="22"
style="width:300px;" required>
</div>
<div>
<label for="email">Product Units<span></span></label>
<input type="text" name="product_unit" id="product_unit" value="<%
out.print(Values.get("product_unit")); %>" size="22"
style="width:300px;" required></div>
<div>
<label for="email">Product Price Per Unit<span></span></label>
<input type="text" name="product_price_per_unit"
id="product_price_per_unit" value="<%
out.print(Values.get("product_price_per_unit")); %>" size="22"
style="width:300px;" required></div>
<div>
<label for="email">Description<span></span></label>
<textarea style="width:300px; height:100px;"
name="product_description" required><%
out.print(Values.get("product_description")); %></textarea></div>
<div class="block clear"></div>
<div>
<input name="submit" type="submit" value="<%
out.print(productLabel); %> Product">
&nbsp;
<input name="reset" type="reset" value="Reset Form"></div>
<input type="hidden" name="act" value="Save" />
<input type="hidden" name="product_id" value="<%
out.print(Values.get("product_id")); %>"/>

37
</form></div>
<div style="float: left">
<div><img src="images/save_1.jpg" style="width: 250px"></div><br>
<div><img src="images/save_2.jpg" style="width: 250px"></div>
</div>
<div class="clear"></div>
</main></div></div>
<%@ include file="includes/footer.jsp" %>

Reportproduct.jsp
<%@ include file="includes/header.jsp" %>
<%@ page import= "java.util.*" %>
<%@ page import= "Model.*" %>
<%
Product productDetails = new Product();
String employeeID = "0";
ArrayList allProduct = productDetails.getAllProduct();
%>
<div class="wrapper row3">
<div class="rounded">
<main class="container clear">
<div class="scrollable">
<h2>Product Report</h2>
<% if(request.getParameter("msg") != null) { %>
<div class="msg"><%=request.getParameter("msg") %></div>
<% } %>
<table>
<thead>
<tr>
<th>Product Name</th>
<th>Type</th>
<th>Company</th>
<th>Units (mg)</th>

38
<th>Price Per Unit</th>
<th>Action</th>
</tr></thead>
<tbody>
<% for(int i=0;i<allProduct.size();i++)
{
HashMap ProductDetails = new HashMap();
ProductDetails = (HashMap)allProduct.get(i);
%>
<tr>
<td style="text-align:center;"><%
out.print(ProductDetails.get("product_title")); %></td>
<td><% out.print(ProductDetails.get("type_title")); %></td>
<td><% out.print(ProductDetails.get("company_name")); %></td>
<td><% out.print(ProductDetails.get("product_unit")); %></td>
<td><% out.print(ProductDetails.get("product_price_per_unit"));
%></td>
<td> <a href="product.jsp?product_id=<%
out.print(ProductDetails.get("product_id")); %>">Edit</a>
</td></tr>
<%
if(allProduct.size() == 0) {%>
<tr>
<td colspan="5">No Records Found !!!</td></tr>
<%
}
%>
</tbody></table>
</div></main>
</div></div>
<%@ include file="includes/footer.jsp" %>

Product.java
package Model;

39
import java.util.*;
import java.sql.*;
import com.*;
import java.io.*;
public class Product extends Connect
{
public Product()
{
Connect.connect_mysql();
}
public String saveProduct(HashMap productData)
{
String SQL = "INSERT INTO `product` (`product_type_id`,
`product_company_id`, `product_title`, `product_unit`,
`product_price_per_unit`, `product_description`) VALUES (?, ?, ?,
?, ?, ?);";
int record=0;
String error = "";
try
{
pstmt = connection.prepareStatement(SQL);
pstmt.setString(1,(String)
productData.get("product_type_id"));
pstmt.setString(2,(String)
productData.get("product_company_id"));
pstmt.setString(3,(String)
productData.get("product_title"));
pstmt.setString(4,(String)
productData.get("product_unit"));
pstmt.setString(5,(String)
productData.get("product_price_per_unit"));
pstmt.setString(6,(String)
productData.get("product_description"));
record = pstmt.executeUpdate();
pstmt.close();
connection.close();
}

40
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 HashMap getProductDetails(int product_id)
{
HashMap results = new HashMap();
int count=0;
try
{
String SQL="SELECT * FROM `product`,`type`,`company` WHERE
product_type_id = type_id AND product_company_id = company_id AND
product_id = "+product_id ;
statement=connection.createStatement();
rs = statement.executeQuery(SQL);
while(rs.next())
{
results.put("product_id",rs.getString("product_id"));

results.put("product_type_id",Integer.parseInt(rs.getString("produ
ct_type_id")));

results.put("product_company_id",Integer.parseInt(rs.getString
("product_company_id")));

results.put("product_title",rs.getString("product_title"));

results.put("product_unit",rs.getString("product_unit"));
results.put("product_price_per_unit",rs.getString

41
("product_price_per_unit"));

results.put("product_description",rs.getString("product_descriptio
n"));

results.put("company_name",rs.getString("company_name"));
results.put("type_title",rs.getString("type_title"));
count++;
}
if(count==0)
{
results.put("product_id","");
results.put("product_company_id",0);
results.put("product_type_id",0);
results.put("product_unit","");
results.put("product_title","");
results.put("product_price_per_unit","");
results.put("product_description","");
results.put("type_title","");
}
}
catch(Exception e)
{
System.out.println("Error is: "+ e);
}
return results;
}
public String updateProduct(HashMap productData)
{
String SQL = "UPDATE `product` SET `product_type_id` = ?,
`product_company_id` = ?, `product_title` = ?, `product_unit` = ?,
`product_price_per_unit` = ?, `product_description` = ? WHERE
`product_id` = ?";
String error = "";
int record=0;
try
{

42
pstmt = connection.prepareStatement(SQL);
pstmt.setString(1,(String)
productData.get("product_type_id"));
pstmt.setString(2,(String)
productData.get("product_company_id"));
pstmt.setString(3,(String)
productData.get("product_title"));
pstmt.setString(4,(String)
productData.get("product_unit"));
pstmt.setString(5,(String)
productData.get("product_price_per_unit"));
pstmt.setString(6,(String)
productData.get("product_description"));
pstmt.setString(7,(String) productData.get("product_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 ArrayList getAllProduct()
{
String SQL="SELECT * FROM `product`,`type`,`company` WHERE
product_type_id = type_id AND product_company_id = company_id";
int count=0;
ArrayList resultArray = new ArrayList();
try

43
{
statement=connection.createStatement();
rs=statement.executeQuery(SQL);
while(rs.next())
{
HashMap results = new HashMap();
results.put("product_id",rs.getString("product_id"));

results.put("product_type_id",Integer.parseInt(rs.getString("produ
ct_type_id")));

results.put("product_company_id",Integer.parseInt(rs.getString
("product_company_id")));

results.put("product_title",rs.getString("product_title"));

results.put("product_unit",rs.getString("product_unit"));
results.put("product_price_per_unit",rs.getString
("product_price_per_unit"));

results.put("product_description",rs.getString("product_descriptio
n"));

results.put("company_name",rs.getString("company_name"));
results.put("type_title",rs.getString("type_title"));
count++;
resultArray.add(results);
}
}
catch(Exception e)
{
System.out.println("Error is: "+ e);
}
return resultArray;
}
public String getProductTypeOption(Integer SelID)
{

44
int selectedID = SelID.intValue();
return
Connect.getOptionList("type","type_id","type_title","type_id,type_
title",selectedID,"1");
}
public String getCompanyOption(Integer SelID)
{
int selectedID = SelID.intValue();
return
Connect.getOptionList("company","company_id","company_name","compa
ny_id,company_name",selectedID,"1");
}
}

Sell.jsp
<%@ include file="includes/header.jsp" %>
<%@ page import= "java.util.*" %>
<%@ page import= "Model.*" %>
<%
Sell sellObj = new Sell();
%>
<style>
table {
margin-bottom:0px;
}
#comments input, #comments textarea {
padding:5px;
}
.my_button {
cursor: pointer;
display: inline-block;
margin: 0;
padding: 4px 5px;
width: auto;

45
background-color: #ac1212;
color: #ffffff;
font-weight: bold;
}
</style>
<script>
$(document).ready(function() {
var max_fields=10;
var wrapper=$(".input_fields_wrap");
var add_button=$(".add_field_button");
var add_more_html;
var x = 1;
$(add_button).click(function(e){
e.preventDefault();
if(x < max_fields){
x++;
add_more_html = $("#add_more_fields").html();
$(wrapper).append(add_more_html); //add input box
}
});
$(wrapper).on("click",".remove_field", function(e){
e.preventDefault(); $(this).closest('table').remove();
x--;
calculateTotal();
})
});
function calculateTotal() {
var total = 0;
$('.product_total').each(function(i, obj) {
if($(this).val())
{
total = total + parseInt($(this).val());
}
});
$('#total_cost').val(total);
}
</script>

46
<div class="wrapper row3">
<div class="rounded">
<main class="container clear">
<div id="comments" style="width: 70%; float:left; margin-
right:30px">
<h2>Sell Product</h2>
<form action="model/sell.jsp" method="post">
<div id="empl_id" class="half_width">
<label for="email">Customer Name<span>*</span></label>
<input type = "text" name = "customer_name" id="customer_name"
style="width:300px;" required>
</div>
<div class="half_width">
<label for="email">Mobile Number<span>*</span></label>
<input type = "text" name = "customer_mobile" id="customer_mobile"
style="width:300px;" required>
</div>
<div class="input_fields_wrap">
<div style="margin-bottom:15px; clear:both; text-align: right;">
<button class="add_field_button my_button">Add More
Product</button>
</div>
<table>
<tr>
<th>Product</th>
<th>Quantity</th>
<th>Unit Price</th>
<th>Total</th>
<th>Action</th>
</tr>
<tr>
<td>
<select name="product_name" id="product_name" required>

<% out.print(sellObj.getProductOption(0)); %>


</select>
</td>

47
<td><input type="text" name="product_quantity"
id="product_quantity" required></td>
<td><input type="text" name="product_price_per_unit"
id="product_price_per_unit" required></td>
<td><input type="text" name="product_total" class="product_total"
required onkeyup="calculateTotal()"></td>
<td style="width:100px;"> &nbsp; </td>
</tr>
</table>
</div>
<div style="float:right"><b>Total Cost: </b><input type="text"
style=" width:300px" id="total_cost" name="total_cost"></div>
<div class="block clear"></div>
<div>
<input name="submit" type="submit" value="Save Sales">
&nbsp;
<input name="reset" type="reset" value="Reset Form">
</div>
<input type="hidden" name="act" value="Save" />
</form>
</div>
<div style="float: left">
<div><img src="images/save_1.jpg" style="width: 250px"></div><br>
<div><img src="images/save_2.jpg" style="width: 250px"></div>
</div>
<div class="clear"></div>
</main>
</div>
</div>
<div id = "add_more_fields" style="display:none">
<table>
<tr style="background-color:#ffffff">
<td>
<select name="product_name" id="medicin_name" required>
<% out.print(sellObj.getProductOption(0)); %>
</select>
</td>

48
<td><input type="text" name="product_quantity" required></td>
<td><input type="text" name="product_price_per_unit"
required></td>
<td><input type="text" name="product_total" class="product_total"
required onkeyup="calculateTotal()"></td>
<td style="width:100px; text-align:center; vertical-align:middle;
font-weight:bold; font-size:11px;"><a href="#"
class="remove_field">Remove</a></td>
</tr>
</table>
</div>
<%@ include file="includes/footer.jsp" %>

Reportsell.jsp
<%@ include file="includes/header.jsp" %>
<%@ page import= "java.util.*" %>
<%@ page import= "Model.*" %>
<%
Sell sellDetails = new Sell();
ArrayList allSell = sellDetails.getAllOrder();
%>
<div class="wrapper row3">
<div class="rounded">
<main class="container clear">
<div class="scrollable">
<h2>Sell Report</h2>
<%
if(request.getParameter("msg") != null) { %>
<div class="msg"><%=request.getParameter("msg") %></div>
<% } %>
<table>

49
<thead>
<tr>
<th>Customer Name</th>
<th>Mobile</th>
<th>Total Order</th>
<th>Action</th>
</tr>
</thead>
<tbody>
<%
for(int i=0;i<allSell.size();i++)
{
HashMap SellDetails = new HashMap();
SellDetails = (HashMap)allSell.get(i);
%>
<tr>
<td style="text-align:center;">
<% out.print(SellDetails.get("order_customer_name")); %></td>
<td><% out.print(SellDetails.get("order_customer_mobile"));
%></td>
<td>&#8377; <% out.print(SellDetails.get("order_total"));
%>.00</td>
<td><a href="print-receipt.jsp?order_id=<%
out.print(SellDetails.get("order_id")); %>">View Details</a></td>
</tr>
<%
}
if(allSell.size() == 0)
{
%>
<tr>
<td colspan="5">No Records Found !!!</td>
</tr>
<%
}
%>
</tbody>

50
</table>
</div>
</main>
</div>
</div>
<%@ include file="includes/footer.jsp" %>

Stock.jsp
<%@ include file="includes/header.jsp" %>
<%@ page import= "java.util.*" %>
<%@ page import= "Model.*" %>
<%
Stock stockDetails = new Stock();
String stockLabel = "Save";
int stock_id = Integer.parseInt(request.getParameter
("stock_id"));
if(stock_id != 0) {
stockLabel = "Update";
}
HashMap Values = stockDetails.getStockDetails(stock_id);
%>
<div class="wrapper row3">
<div class="rounded">
<main class="container clear">
<div id="comments" style="width: 70%; float:left; margin-
right:30px">
<h2>Stock Entry Form</h2>
<form action="model/stock.jsp" method="post">
<div id="empl_id">
<label for="email">Select Product<span>*</span></label>
<select style="height: 40px; width:300px" name =
"stock_product_id" id = "stock_product_id" required>

51
<% out.print(stockDetails.getProductOption((Integer)
Values.get("stock_product_id"))); %>
</select>
</div>
<div>
<label for="email">No. of items in Stock<span>*</span></label>
<input type="text" name="stock_number" id="stock_number" value="<%
out.print(Values.get("stock_number")); %>" size="22"
style="width:300px;" required>
</div>
<div>
<label for="email">Description<span>*</span></label>
<textarea style="width:300px; height:100px;"
name="stock_description" required><%
out.print(Values.get("stock_description")); %></textarea>
</div>
<div class="block clear"></div>
<div>
<input name="submit" type="submit" value="<%
out.print(stockLabel); %> Stock">
&nbsp;
<input name="reset" type="reset" value="Reset Form">
</div>
<input type="hidden" name="act" value="Save" />
<input type="hidden" name="stock_id" value="<%
out.print(Values.get("stock_id")); %>"/>
</form>
</div>
<div style="float: left">
<div>
<img src="images/save_1.jpg" style="width: 250px"></div><br>
<div>
<img src="images/save_2.jpg" style="width: 250px"></div>
</div>
<div class="clear"></div>
</main>
</div>

52
</div>
<%@ include file="includes/footer.jsp" %>

Stock.java
package Model;
import java.util.*;
import java.sql.*;
import com.*;
import java.io.*;
public class Stock extends Connect
{
public Stock()
{
Connect.connect_mysql();
}
public String saveStock(HashMap stockData)
{
String SQL = "INSERT INTO `stock` (`stock_product_id`,
`stock_number`, `stock_description`) VALUES (?, ?, ?);";
int record=0;
String error = " " ;
try
{
pstmt = connection.prepareStatement(SQL);
pstmt.setString(1,(String)
stockData.get("stock_product_id"));
pstmt.setString(2,(String)
stockData.get("stock_number"));
pstmt.setString(3,(String)
stockData.get("stock_description"));
record = pstmt.executeUpdate();
pstmt.close();

53
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 HashMap getStockDetails(int stock_id)
{
HashMap results = new HashMap();
int count=0;
try
{
String SQL = "SELECT * FROM `stock`,`product`
WHERE stock_product_id =
product_id AND stock_id = "+stock_id ;
statement = connection.createStatement();
rs = statement.executeQuery(SQL);
while(rs.next())
{

results.put("stock_id",rs.getString("stock_id"));

results.put("stock_product_id",Integer.parseInt(rs.getString
("stock_product_id")));

results.put("stock_number",rs.getString("stock_number"));

54
results.put("stock_description",rs.getString("stock_description"))
;

results.put("product_title",rs.getString("product_title"));
count++;
}
if(count==0)
{
results.put("stock_id","");
results.put("stock_product_id",0);
results.put("stock_number","");
results.put("stock_description","");
results.put("product_title","");
}
}
catch(Exception e)
{
System.out.println("Error is: "+ e);
}
return results;
}
public String updateStock(HashMap stockData)
{
String SQL = "UPDATE `stock` SET `stock_product_id`
= ?, `stock_number` = ?,
`stock_description` = ? WHERE `stock_id` = ?";
String error = " " ;
int record=0;
try
{
pstmt = connection.prepareStatement(SQL);
pstmt.setString(1,(String)
stockData.get("stock_product_id"));
pstmt.setString(2,(String)
stockData.get("stock_number"));

55
pstmt.setString(3,(String)
stockData.get("stock_description"));
pstmt.setString(4,(String)
stockData.get("stock_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 ArrayList getAllStock()
{
String SQL = "SELECT * FROM `stock`,`product` WHERE
stock_product_id =
product_id";
int count=0;
ArrayList resultArray = new ArrayList();
try
{
statement = connection.createStatement();
rs = statement.executeQuery(SQL);
while(rs.next())
{
HashMap results = new HashMap();

results.put("stock_id",rs.getString("stock_id"));

56
results.put("stock_product_id",Integer.parseInt(rs.getString
("stock_product_id")));

results.put("stock_number",rs.getString("stock_number"));

results.put("product_title",rs.getString("product_title"));
count++;
resultArray.add(results);
}
}
catch(Exception e)
{
System.out.println("Error is: "+ e);
}
return resultArray;
}
public String getProductOption(Integer SelID)
{
int selectedID = SelID.intValue();
return
Connect.getOptionList("product","product_id","product_title","prod
uct_id,product_title",selectedID,"1");
}
}

Employee.jsp
<%@ include file="includes/header.jsp" %>
<%@ page import= "java.util.*" %>
<%@ page import= "Model.*" %>
<%
Employee employeeDetails = new Employee();
int employee_id = Integer.parseInt(request.getParameter
("employee_id"));

57
String male = " " ;
String female = " " ;
HashMap Values = employeeDetails.getEmployeeDetails(employee_id);
if(Values.get("employee_gender").equals("Male"))
{
male = "Selected";
}
else if(Values.get("employee_gender").equals("Female"))
{
female = "Selected";
}
%>
<script>
jQuery(function() {
jQuery( "#employee_dob" ).datepicker({
changeMonth: true,
changeYear: true,
yearRange: "-50:-18",
dateFormat: 'd MM,yy'
});
});
</script>
<div class="wrapper row3">
<div class="">
<main class="container clear">
<div id="comments" style="width: 70%; float:left; margin-
right:30px">
<h2>Registration Form</h2>
<%
if(request.getParameter("msg") != null) { %>
<div class="msg"><%=request.getParameter("msg") %></div>
<% } %>
<form action="model/employee.jsp" method="post">
<div class="one_third first">
<label for="email">Salution<span></span></label>
<select style="height: 40px; width:200px" name="employee_sal"
required>

58
<% out.print(employeeDetails.getSalutionOption((Integer)
Values.get("employee_sal"))); %>
</select>
</div>
<div class="one_third">
<label for="email">Status<span></span></label>
<select style="height: 40px; width:200px" name= "employee_status"
id = "employee_status" >
<% out.print(employeeDetails.getStatusOption((Integer)
Values.get("employee_status"))); %>
</select>
</div>
<div class="one_third">
<label for="email">Department<span></span></label>
<select style="height: 40px; width:200px" name =
"employee_deparment" id = "employee_deparment" >
<% out.print(employeeDetails.getDepartmentOption((Integer)
Values.get("employee_deparment"))); %>
</select>
</div>
<div class="one_third first">
<label for="email">First Name <span></span></label>
<input type="text" name="employee_first_name"
id="employee_first_name" value="<%
out.print(Values.get("employee_first_name")); %>" size="22">
</div>
<div class="one_third">
<label for="email">Middle Name <span></span></label>
<input type="text" name="employee_middle_name"
id="employee_middle_name" value="<%
out.print(Values.get("employee_middle_name")); %>" size="22" >
</div>
<div class="one_third">
<label for="url">Last Name</label>
<input type="text" name="employee_last_name"
id="employee_last_name" value="<%
out.print(Values.get("employee_last_name")); %>" size="22" >

59
</div>
<div class="one_third first">
<label for="url">Gender</label>
<select style="height: 40px; width:200px" name="employee_gender"
required>
<option value="0">Please Select</option>
<option value="Male" <% out.print(male); %>>Male</option>
<option value="Female" <% out.print(female); %>>Female</option>
</select>
</div>
<div class="one_third">
<label for="url">Date of Birth</label>
<input type="text" name="employee_dob" id="employee_dob" value="<%
out.print(Values.get("employee_dob")); %>" size="22" >
</div>
<div class="one_third">
<label for="url">Nationality</label>
<input type="text" name="employee_nationalty"
id="employee_nationalty" value="<%
out.print(Values.get("employee_nationalty")); %>" size="22" >
</div>
<div class="one_third first">
<label for="url">E-mail</label>
<input type="text" name="employee_email" id="employee_email"
value="<% out.print(Values.get("employee_email")); %>" size="22" >
</div>
<div class="one_third">
<label for="url">Landline</label>
<input type="text" name="employee_landline" id="employee_landline"
value="<% out.print(Values.get("employee_landline")); %>"
size="22" >
</div>
<div class="one_third">
<label for="url">Mobile</label>
<input type="text" name="employee_mobile" id="employee_mobile"
value="<% out.print(Values.get("employee_mobile")); %>" size="22"
>

60
</div>
<div style="clear:both"></div>
<h4>Address Details</h4>
<div class="one_third first">
<label for="url">Address</label>
<input type="text" name="employee_address" id="employee_address"
value="<% out.print(Values.get("employee_address")); %>" size="22"
>
</div>
<div class="one_third">
<label for="url">Village/City/Town</label>
<input type="text" name="employee_village" id="employee_village"
value="<% out.print(Values.get("employee_village")); %>" size="22"
>
</div>
<div class="one_third">
<label for="url">State</label>
<select style="height: 40px; width:200px" name="employee_state"
required>
<%
out.print(employeeDetails.getStateOption((Integer)
Values.get("employee_state"))); %>
</select>
</div>
<div class="one_third first">
<label for="url">Country</label>
<select style="height: 40px; width:200px" name="employee_country"
required>
<%
out.print(employeeDetails.getCountryOption((Integer)
Values.get("employee_country"))); %>
</select>
</div>
<%
if(session.getAttribute("login_level") != null &&
session.getAttribute("login_level").equals("1")) { %>
<div class="block clear">

61
</div>
<h4>Role & Manager</h4>
<div class="one_third first">
<label for="email">Role<span></span>
</label>
<select style="height: 40px; width:200px" name= "employee_role" id
= "employee_role" >
<% out.print(employeeDetails.getRoleOption((Integer)
Values.get("employee_role"))); %>
</select>
</div>
<div class="one_third">
<label for="email">Manager Code<span></span>
</label>
<select style="height: 40px; width:200px" name =
"employee_manager_id" id = "employee_manager_id" >
<% out.print(employeeDetails.getEmployeeOption((Integer)
Values.get("employee_manager_id"))); %>
</select>
</div>
<% } %>
<div class="block clear"></div>
<% if(employee_id == 0) { %>
<h4>Login Details</h4>
<div class="one_third first">
<label for="url">Username</label>
<input type="text" name="employee_user" id="employee_user"
value="<% out.print(Values.get("employee_user")); %>" size="22">
</div>
<div class="one_third">
<label for="url">Password</label>
<input type="password" name="employee_password"
id="employee_password" value="" size="22">
</div>
<div class="one_third ">
<label for="url">Confirm Password</label>

62
<input type="password" name="employee_confirm_password"
id="employee_confirm_password" value="" size="22">
</div>
<% } %>
<div class="block clear"></div>
<div>
<input name="submit" type="submit" value="Save Form">
&nbsp;
<input name="reset" type="reset" value="Reset Form">
</div>
<input type="hidden" name="act" value="Save" />
<input type="hidden" name="employee_id" value="<%
out.print(Values.get("employee_id")); %>"/>
</form>
</div>
<div style="float: left">
<div><img src="images/save_2.jpg" style="width: 250px"></div><br>
<div><img src="images/save_3.jpg" style="width: 250px"></div>
</div>
<div class="clear"></div>
</main>
</div>
</div>
<%@ include file="includes/footer.jsp" %>

Employee.java
package Model;
import java.util.*;
import java.sql.*;
import com.*;
import java.io.*;
public class Employee extends Connect
{

63
public Employee()
{
Connect.connect_mysql();
}
public String saveEmployee(HashMap employeeData)
{

String SQL = "INSERT INTO employee (employee_sal,


employee_first_name, employee_middle_name, employee_last_name,
employee_gender, employee_address, employee_village,
employee_state, employee_country, employee_landline,
employee_mobile, employee_email, employee_status,
employee_deparment, employee_dob, employee_nationalty,
employee_manager_id, employee_role) VALUES
( ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);";
int record=0,last_inserted_id=0;
String error = " ";
try
{
pstmt = connection.prepareStatement(SQL,
Statement.RETURN_GENERATED_KEYS);
pstmt.setString(1,(String)
employeeData.get("employee_sal"));
pstmt.setString(2,(String)
employeeData.get("employee_first_name"));
pstmt.setString(3,(String)
employeeData.get("employee_middle_name"));
pstmt.setString(4,(String)
employeeData.get("employee_last_name"));
pstmt.setString(5,(String)
employeeData.get("employee_gender"));
pstmt.setString(6,(String)
employeeData.get("employee_address"));
pstmt.setString(7,(String)
employeeData.get("employee_village"));
pstmt.setString(8,(String)
employeeData.get("employee_state"));

64
pstmt.setString(9,(String)
employeeData.get("employee_country"));
pstmt.setString(10,(String)
employeeData.get("employee_landline"));
pstmt.setString(11,(String)
employeeData.get("employee_mobile"));
pstmt.setString(12,(String)
employeeData.get("employee_email"));
pstmt.setString(13,(String)
employeeData.get("employee_status"));
pstmt.setString(14,(String)
employeeData.get("employee_deparment"));
pstmt.setString(15,(String)
employeeData.get("employee_dob"));
pstmt.setString(16,(String)
employeeData.get("employee_nationalty"));
pstmt.setString(17,(String)
employeeData.get("employee_manager_id"));
pstmt.setString(18,(String)
employeeData.get("employee_role"));
record = pstmt.executeUpdate();
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;

65
System.out.println(" Error : "+ e.toString());
}
SQL = "INSERT INTO login (login_emp_id, login_user,
login_password,
login_email, login_level) VALUES (?, ?, ?, ?, ?);";
try
{
pstmt = connection.prepareStatement(SQL);
pstmt.setInt(1,last_inserted_id);
pstmt.setString(2,(String)
employeeData.get("employee_user"));
pstmt.setString(3,(String)
employeeData.get("employee_password"));
pstmt.setString(4,(String)
employeeData.get("employee_email"));
pstmt.setString(5,(String)
employeeData.get("employee_role"));
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 HashMap getEmployeeDetails(int employee_id)
{
HashMap resultsArray = new HashMap();

66
int count=0;
try
{
String SQL = "SELECT * FROM employee WHERE
employee_id =
"+employee_id
statement = connection.createStatement();
rs = statement.executeQuery(SQL);
while(rs.next())
{

resultsArray.put("employee_id",rs.getString("employee_id"));

resultsArray.put("employee_manager_id",Integer.parseInt(rs.getStri
ng
("employee_manager_id")));

resultsArray.put("employee_role",Integer.parseInt(rs.getString
("employee_role")));

resultsArray.put("employee_sal",Integer.parseInt(rs.getString
("employee_sal")));

resultsArray.put("employee_first_name",rs.getString("employee_firs
t_name"));

resultsArray.put("employee_middle_name",rs.getString
("employee_middle_name"));

resultsArray.put("employee_last_name",rs.getString("employee_last_
name"));

resultsArray.put("employee_gender",rs.getString("employee_gender")
);

resultsArray.put("employee_address",rs.getString("employee_address
"));

67
resultsArray.put("employee_village",rs.getString("employee_village
"));

resultsArray.put("employee_state",Integer.parseInt(rs.getString
("employee_state")));

resultsArray.put("employee_country",Integer.parseInt
(rs.getString("employee_country")));

resultsArray.put("employee_landline",rs.getString("employee_landli
ne")

resultsArray.put("employee_mobile",rs.getString("employee_mobile")
);

resultsArray.put("employee_email",rs.getString("employee_email"));

resultsArray.put("employee_status",Integer.parseInt
(rs.getString("employee_status")));

resultsArray.put("employee_deparment",Integer.parseInt
(rs.getString("employee_deparment")));

resultsArray.put("employee_dob",rs.getString("employee_dob"));

resultsArray.put("employee_nationalty",rs.getString("employee_nati
onalty"));
count++;
}
if(count==0)
{

resultsArray.put("employee_id","");
resultsArray.put("employee_manager_id",0);
resultsArray.put("employee_role",0);
resultsArray.put("employee_user","");

68
resultsArray.put("employee_sal",0);
resultsArray.put("employee_first_name","");

resultsArray.put("employee_middle_name","");

resultsArray.put("employee_last_name","");
resultsArray.put("employee_gender","");

resultsArray.put("employee_address","");

resultsArray.put("employee_village","");
resultsArray.put("employee_state",0);
resultsArray.put("employee_country",0);

resultsArray.put("employee_landline","");
resultsArray.put("employee_mobile","");
resultsArray.put("employee_email","");

resultsArray.put("employee_status",0);
resultsArray.put("employee_deparment",0);
resultsArray.put("employee_dob","");
resultsArray.put("employee_nationalty","");
}
}
catch(Exception e)
{
System.out.println("Error is: "+ e);
}
return resultsArray
}
public String updateEmployee(HashMap employeeData)
{
String SQL = "UPDATE employee SET employee_sal = ?,
employee_first_name = ?, employee_middle_name = ?,
employee_last_name = ?, employee_gender = ?, employee_address = ?,
employee_village = ?, employee_state = ?, employee_country = ?,
employee_landline = ?, employee_mobile = ?, employee_email = ?,

69
employee_status = ?, employee_deparment = ?, employee_dob = ?,
employee_nationalty = ?, employee_manager_id = ?, employee_role
= ? WHERE employee_id = ?";
String error = " " ;
int record=0;
try
{
pstmt = connection.prepareStatement(SQL);
pstmt.setString(1,(String)
employeeData.get("employee_sal"));
pstmt.setString(2,(String)
employeeData.get("employee_first_name"));
pstmt.setString(3,(String)
employeeData.get("employee_middle_name"));
pstmt.setString(4,(String)
employeeData.get("employee_last_name"));
pstmt.setString(5,(String)
employeeData.get("employee_gender"));
pstmt.setString(6,(String)
employeeData.get("employee_address"));
pstmt.setString(7,(String)
employeeData.get("employee_village"));
pstmt.setString(8,(String)
employeeData.get("employee_state"));
pstmt.setString(9,(String)
employeeData.get("employee_country"));
pstmt.setString(10,(String)
employeeData.get("employee_landline"));
pstmt.setString(11,(String)
employeeData.get("employee_mobile"));
pstmt.setString(12,(String)
employeeData.get("employee_email"));
pstmt.setString(13,(String)
employeeData.get("employee_status"));
pstmt.setString(14,(String)
employeeData.get("employee_deparment"));

70
pstmt.setString(15,(String)
employeeData.get("employee_dob"));
pstmt.setString(16,(String)
employeeData.get("employee_nationalty"));
pstmt.setString(17,(String)
employeeData.get("employee_manager_id"));
pstmt.setString(18,(String)
employeeData.get("employee_role"));
pstmt.setString(19,(String)
employeeData.get("employee_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 deleteEmployee(int employee_id)
{
return true;
}
public String getStateOption(Integer SelID)
{
int selectedID = SelID.intValue();
return
Connect.getOptionList("state","state_id","state_name","state_id,st
ate_name",selectedID,"1");

71
}
public String getEmployeeOption(Integer SelID)
{
int selectedID = SelID.intValue();
return
Connect.getOptionList("employee","employee_id","employee_id","empl
oyee_id,employee_id",selectedID,"1");
}
public String getRoleOption(Integer SelID)
{
int selectedID = SelID.intValue();
return
Connect.getOptionList("roles","role_id","role_title","role_id,role
_title",selectedID,"1");
}
public String getCountryOption(Integer SelID)
{
int selectedID = SelID.intValue();
return
Connect.getOptionList("country","country_id","country_name","count
ry_id,country_name",selectedID,"1");
}
public String getSalutionOption(Integer SelID)
{
int selectedID = SelID.intValue();
return
Connect.getOptionList("salutions","sl_id","sl_name","sl_id,sl_name
",selectedID,"1");
}
public String getStatusOption(Integer SelID)
{
int selectedID = SelID.intValue();
return
Connect.getOptionList("status","status_id","status_name","status_i
d,status_name",selectedID,"1");
}
public String getDepartmentOption(Integer SelID)

72
{
int selectedID = SelID.intValue();
return
Connect.getOptionList("department","dept_id","dept_name","dept_id,
dept_name",selectedID,"1");
}
public ArrayList getAllEmployee(String managerID)
{
int count=0;
String error = " " ;
String SQL = "SELECT * FROM employee";
ArrayList resultArray = new ArrayList();
try
{
if(!managerID.equals("0"))
{
SQL = "SELECT * FROM employee WHERE
employee_manager_id =
"+managerID;
}
statement = connection.createStatement();
rs = statement.executeQuery(SQL);
while(rs.next())
{
HashMap results = new HashMap();

results.put("employee_id",rs.getString("employee_id"));

results.put("employee_role",rs.getString("employee_role"));

results.put("employee_sal",rs.getString("employee_sal"));

results.put("employee_first_name",rs.getString("employee_first_nam
e"));

results.put("employee_middle_name",rs.getString("employee_middle_n
ame"));

73
results.put("employee_last_name",rs.getString("employee_last_name"
));

results.put("employee_gender",rs.getString("employee_gender"));

results.put("employee_address",rs.getString("employee_address"));

results.put("employee_village",rs.getString("employee_village"));

results.put("employee_state",rs.getString("employee_state"));

results.put("employee_country",rs.getString("employee_country"));

results.put("employee_landline",rs.getString("employee_landline"))
;

results.put("employee_mobile",rs.getString("employee_mobile"));

results.put("employee_email",rs.getString("employee_email"));

results.put("employee_status",Integer.parseInt(rs.getString
("employee_status")))

results.put("employee_deparment",Integer.parseInt(rs.getString
("employee_deparment")));

results.put("employee_dob",rs.getString("employee_dob"));

results.put("employee_nationalty",rs.getString("employee_nationalt
y"));

results.put("employee_manager_id",Integer.parseInt
(rs.getString("employee_manager_id")));
count++;
resultArray.add(results);
}

74
}
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 resultArray;
}
public String getDepartment(int dept_id)
{
HashMap results = new HashMap();
String SQL = " " ;
String value = " " ;
int count=0;
try
{
SQL = "SELECT dept_name FROM department WHERE
dept_id = "+dept_id ;
statement = connection.createStatement();
rs = statement.executeQuery(SQL);
while(rs.next())
{
value = rs.getString("dept_name");
}
}
catch(Exception e)
{
System.out.println("Error is: "+ e);
}
return value;
}
public String getStatus(int status_id)

75
{
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;
}
}

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;

76
public static PreparedStatement pstmt;
public static void connect_mysql()
{
try
{

Class.forName("com.mysql.jdbc.Driver").newInstance();
connection = DriverManager.getConnection

("jdbc:mysql://localhost/canteen_management_system?" +
"user=root");
statement=connection.createStatement();
}
catch(Exception e)
{
System.out.println(" Error : "+ e.toString());
}
}
public static String getOptionList(String tableName,String
idColumn,String
valueColumn,String Columns,int selID,String conn)
{
String SQL = "SELECT "+Columns+" FROM "+tableName+"
where "+conn;
String Option="<option value=''>Please Select</option>";
try
{
rs = statement.executeQuery(SQL);
while(rs.next())
{
int selectedID = rs.getInt(idColumn);
if(selectedID==selID)
Option+="<option value=\""+selectedID+"\"

Selected>"+rs.getString(valueColumn)+"</option>";
else
Option+="<option

77
value=\""+selectedID+"\">"+rs.getString(valueColumn)+"</option>";
}
}
catch(Exception e)
{
System.out.println("Error : "+e);
}
return Option;
}
}

Testing

Software testing is an investigation conducted to provide stakeholders with


information about the quality of the product or service under test. Software testing can also
provide an objective, independent view of the software to allow the business to appreciate
and understand the risks of software implementation. Test techniques include, but are not
limited to the process of executing a program or application with the intent of finding
software bugs (errors or other defects). Software testing can be stated as the process of
validating and verifying that a computer program/application/product:

 meets the requirements that guided its design and development,


 works as expected,
 can be implemented with the same characteristics,
 Satisfies the needs of stakeholders.

Debugging: is a methodical process of finding and reducing the number of bugs, or


defects, in a computer program or a piece of electronic hardware, thus making it behave as
expected. Debugging tends to be harder when various subsystems are tightly coupled, as
changes in one may cause bugs to emerge in another. Many books have been written about
debugging (see below: Further reading), as it involves numerous aspects, including
interactive debugging, control flow, integration testing, log files, monitoring (application,
system), memory dumps, profiling, Statistical Process Control, and special design tactics to
improve detection while simplifying changes.

Module Testing: - Module testing is the testing of complete code objects as produced by
the compiler when built from source. Each test case is independent from the others.

78
Substitutes such as method stubs, mock objects, fakes, and test harnesses can be used to
assist testing a module in isolation. Unit tests are typically written and run by software
developers to ensure that code meets its design and behaves as intended. Benefits of
Module Testing:-

 Find Error Early: Unit tests find problems early in the development cycle.
 Facilitates change: Unit testing allows the programmer to refactor code at a later
date, and make sure the module still works correctly (e.g., in regression testing).
The procedure is to write test cases for all functions and methods so that whenever a
change causes a fault, it can be quickly identified.
 Simplifies integration: - Unit testing may reduce uncertainty in the units
themselves and can be used in a bottom-up testing style approach. By testing the
parts of a program first and then testing the sum of its parts, integration testing
becomes much easier.
 Documentation: - Unit testing provides a sort of living documentation of the
system. Developers looking to learn what functionality is provided by a unit and
how to use it can look at the unit tests to gain a basic understanding of the unit's
interface (API).

System Testing:Testing of software or hardware is testing conducted on a complete,


integrated system to evaluate the system's compliance with its specified requirements.
System testing falls within the scope of black box testing, and as such, should require no
knowledge of the inner design of the code or logic. As a rule, system testing takes, as its
input, all of the "integrated" software components that have passed integration testing and
also the software system itself integrated with any applicable hardware system(s). The
purpose of integration testing is to detect any inconsistencies between the software units
that are integrated together (called assemblages) or between any of the assemblages and the
hardware. System testing is a more limited type of testing; it seeks to detect defects both
within the "inter-assemblages" and also within the system as a whole.

System testing is performed on the entire system in the context of a Functional


Requirement Specification(s) (FRS) and/or a System Requirement Specification (SRS).
System testing tests not only the design, but also the behaviour and even the believed
expectations of the customer. It is also intended to test up to and beyond the bounds defined
in the software/hardware requirements specification. The following examples are different
types of testing that should be considered during System testing:

 Graphical user interface testing: This is the process of testing a product's


graphical user interface to ensure it meets its written specifications. This is normally
done through the use of a variety of test cases.
 Usability testing: This is a technique used in user-centered interaction design to
evaluate a product by testing it on users. This can be seen as an irreplaceable
usability practice, since it gives direct input on how real users use the system.
 Performance testing: This is a testing performed to determine how a system
performs, in terms of responsiveness and stability, under a particular workload. It
can also serve to investigate measure, validate or verify other quality attributes of
the system, such as scalability, reliability and resource usage.

79
 Compatibility testing: Part of software non-functional tests, is testing conducted
on the application to evaluate the application's compatibility with the computing
environment.
 Scalability Testing: Part of the battery of non-functional tests, is the testing of a
software application for measuring its capability to scale up or scale out in terms of
any of its non-functional capability.
 Regression testing: is a type of software testing that seeks to uncover new software
bugs, or regressions, in existing functional and non-functional areas of a system
after changes such as enhancements, patches or configuration changes, have been
made to them.’

Test Cases
Test cases
Test Test case Input Actual value Expected value Test result
case name
no
1 Login Username is Enter Username Enter Username No error
blank
2 Login Employee Enter password Enter password No error
password is
blank
3 Login Enter incorrect Cannot login, Invalid Cannot login, Invalid No error
Employee no and username/password. username/password.
password
combination
4 Login Enter correct Logged in Logged in No error
Employee no and successfully successfully
password
combination
5 Adding All the details of Fill all required detail Fill all required detail No error
Employee employee of employee of employee
registration is

80
blank.
6 Adding Enter number in Employee name Employee name No error
Employee Name field cannot be numeric cannot be numeric
7 Adding Enter new New changes saved New changes saved No error
Employee employee details successfully successfully
and submit
8 Adding All field are kept Enter customer Enter customer No error
Sales blank and name,mobile no name,mobile no
submitted
9 Adding Enter alphabets Enter numeric value Enter numeric value No error
Sales in name field only only
10 Adding All fields are Sales saved Sales saved No error
Sales entered correctly successfully successfully
11 Change All fields are left Enter Old password Enter Old password No error
password blank and and new password and new password
submitted
12 Change Enter different New and confirm New and confirm No error
password values in new password do not password do not
password and match match
confirm
password fields
13 Change Enter correct Password changed Password changed No error
password values in all successfully successfully
fields
14 Logout Click on logout User session should User redirected to No error
be ended and login screen
redirected to login
screen

Test Reports
Test Reports
Functions Purpose of Set of test Cases per Area Number of test
Cases Successful
Login The Verification of username and password 100%

Employee The employee have to fill up details. 100%


Registration

Add Sales User is able to view all information about sales 100%

Change password Registered users should be able to change their password 100%

81
Logout Registered users should be able to logout from the 100%
session

FUTURE ENHANCEMENTS

This project has big scope towards the future developments. Due to the time
factor we could not add some of the interesting features which may make the
software more user friendly an independent of user interaction. Some of the
features we could add to the system are as follows:
a) Trying to modify the program to get more faster software possible.
b) Trying to get more reliable and also will add more security.
c) By making this software as web-enabling, the owner can fill the
required forms from anywhere.
Eliminating the problems that are faced in the current system is the “Future
Enhancement”.

Bibliography

Websites Referred:

 www.oracle.com

82
 www.stackoverflow.com

 www.google.com

 www.youtube.com

 www.tutorialspoint.com

83

You might also like