Académique Documents
Professionnel Documents
Culture Documents
On
Submitted By:
AJMAL RAHMAN (12110004)
AKHIL G (12120093)
SANJAY P R (12120098)
B. TECH DEGREE
In
School of Engineering
Cochin University of Science & Technology
Kochi-682022
CERTIFICATE
AJMAL RAHMAN(12110004)
AKHIL G(12120093)
SANJAY PR (12120098)
I take this occasion to thank God, almighty for blessing us with his
for providing me with the right guidance and advice at the crucial junctures
and for showing me the right way. I extend my sincere thanks to our
us to use the facilities available. I would like to thank the other faculty
members also, at this occasion. Last but not the least, I would like to thank
my friends and family for the support and encouragement they have given
AJMAL RAHMAN
AKHIL G
SANJAY P.R
ABSTRACT
This is an integrated service which provide all information about the metro
rail and its routes for public. The proposed system is a web based
application which provides information regarding timings, routes, fair.
This system manages public feedback about services through its complaint
management system. This system also contains an online ticket recharge
module where users can recharge their smart cards online through the site.
There is also an admin module where admin can add stations, trains, routes
and also update the fairs. The admin is a panel consisting of a group of
authorized persons.
LIST OF FIGURES
PAGE
PAGE
PAGE
ACKNOWLEDGEMENT
ABSTRACT i
LIST OF FIGURE ii
LIST OF TABLES iii
1. INTRODUCTION
1.1 OBJECTIVES 1
1.2 OVER VIEW 1
1.2.1 COMPLAINT MANAGMENT MODULE 2
1.2.2 ONLINE TICKET RECHARGE 3
1.2.3 METRO TIME TABLE 4
1.2.4 FAIR AND ROUTE MAP 4
1.2.5 ADMIN 5
2. SYSTEM ANALYSIS 6
2.1 EXISTING SYSTEM 6
2.2 PROPOSED SYSTEM 7
2.3 SYSTEM REQUIREMENT SPECIFICATION 8
2.3.1 GENERAL DESCRIPTION 8
2.3.2 SYSTEM OBJECTIVES 9
2.3.3 SYSTEM REQUIREMENTS 9
2.3.3.1 NON FUNCTIONAL REQUIREMENT 9
2.3.3.2 FUNCTIONAL REQUIREMENT 10
2.3.4 SOFTWARE AND HARDWAREREQUIREMENTS 12
2.3.4.1 SOFTWARE REQUIREMENTS 12
2.3.4.2 HARDWARE REQUIREMENTS 13
3. SYSTEM DESIGN 14
3.2 DATABASE 15
3.4 TABLES 18
REFERENCES 57
APPENDIX 58
Metro Rail Management Online
CHAPTER 1
INTRODUCTION
This is an integrated service which provide all information about the metro
rail and its routes for public. The proposed system is a web based
application which provides information regarding timings, routes, fair.
There is also an admin module where admin can add stations, trains,
routes and also update the fairs. The admin is a panel consisting of a
group of authorized persons.
1.1 OBJECTIVE
. The objectives of the projectare as follows:
1.2 OVERVIEW
This module contains various facilities like view complaints and reply to
complaints.
This module contains various facilities like request for smart card,
recharge ,view balance ,view journey history.
This module contains various facilities like view time chart between two
stations.
This module contains various facilities like display fair and display route
map.
This module contains facilities like view & reply to complaints, issue smart
card,add stations ,add train ,add routes ,add & update fair details ,add trip
and add admin.
CHAPTER 2
SYSTEM ANALYSIS
Easier Access.
Easy to use
decisions.
unambiguous.
time.
reliable outputs.
realized.
Product Description:
Metro rail management system is an online system which helps the user
to recharge their tickets online, it also have a complaint management
system in which users can register their complaints online.
By visiting the site the users can get metro time table. Other than that by
entering the source station and destination station the users can get all
sorts of information about trains arriving and departing from the stations,
its fair details and even it provides you the route map.
Problem Statement:
The problem occurred before having online system includes:
File lost
When online system is not implemented the complaints are reported in
files. The files are always lost due to some human errors.
Time consuming
When there is no computerized system then for recharge purposes the
users need to travel to the stations and also sometimes even need to
stand in large queues for recharge purposes.
Most updations are unnoticeable
When online systems is not implemented any changes in fair, timings etc
when updated ,the details of these things are only available at the
stations.
EFFICIENCY REQUIREMENT
When a metro rail management system will be implemented then the user
can recharge, complaint and view metro information fastly& easily.
RELIABILITY REQUIREMENT
The system should accurately perform recharge, store complaints, show
the details of metro such as fair, route maps.
USABILITY REQUIREMENT
The system is designed for a user friendly environment so that user and
admin of metro rail can perform various tasks easily and in an effective
way.
IMPLEMENTATION REQUIREMENTS
In implementing whole system it uses html in front end with jsp as server
side scripting language which will be used for database connectivity and
the backend ie the database part is developed using mysql.
DELIVERY REQUIREMENTS
The whole system is expected to be delivered in six months of time with a
weekly evaluation by the project guide.
REGISTER COMPLAINT
Description of Feature
This feature allows users to file complaints through the site. The user does
not require a registration. He can give his name, email-id, phone number,
address and other details along with the complaints. The admin will reply
to the complaints sent by user.
Functional Requirements
METRO CARD
Description of Feature
This feature allows the user to recharge their metro card online, there by
saving their valuable time. Users need to login with their card number&
password and can recharge their tickets online. It also allows them to view
their balance and journey history.
Functional Requirements
Description of feature
This feature allows the users to view the metro time table. Users are
required to enter the source station and destination station, when they
enter the data then the system will show the metro time table.
Functional Requirements
System must allow the users to enter the source station and
destination stations.
System must be able to process information from database.
Description of Feature
This feature allows the users to view the fair and route map. Users are
required to enter the source and destination station, when they enter the
data then the system will display fair details and the route map.
Functional Requirements
System must allow the users to enter the source and destination
stations.
System must be able to retrieve information from the database.
ADMIN
Description of Feature
This feature allows the admin to view and reply to complaints. Admin can
add stations, routes ,train , trip . Admin can also add and update fair
details, and even add a new admin. Actually, the admin is a panel
consisting of a group of authorized persons.
Functional Requirements
CHAPTER 3
SYSTEM DESIGN
Logical design
Physical design
Input design is the link that ties the information system into the world of its
users. The input design involves determining the inputs, validating the
data, minimizing the data entry and provides a multi-user facility.
Inaccurate inputs are the most common cause of errors in data
processing. Errors entered by the data entry operators can be
controlled by input design. The user-originated inputs are converted to a
computer based format in the input design. Input data are collected and
organized into groups of similar data. Once identified, the appropriate
input media are selected for processing. All the input data are validated
and if any data violates any conditions, the user is warned by a
message. If the data satisfies all the conditions, it is transferred to
the appropriate tables in the database. In this project the student details
are to be entered at the time of registration. A page is designed for this
purpose which is user friendly and easy to use. The design is done
such that users get appropriate messages when exceptions occur.
3.2 DATABASE
DATABASE DESIGN:
Databases are the storehouses of data used in the software systems. The
data is stored in tables inside the database. Several tables are
created for the manipulation of the data for the system. Two essential
settings for a database are
The various system tools that have been used in developing both the front
end and the back end of the project are being discussed in this chapter.
3.3.1.FRONT END:
JSP, HTML, CSS, JAVA SCRIPTS are utilized to implement the frontend.
Different pages in the applications are designed using jsp. A Java Server
Pages component is a type of Java servlet that is designed to fulfil the role
of a user interface for a Java web application. Web developers write JSPs
as text files that combine HTML or XHTML code, XML elements, and
embedded JSP actions and commands. Using JSP, one can collect input
from users through web page.
CSS is a style sheet language used for describing the look and
formatting of a document written in a markup language.
Java Script
The back end is implemented using MySQL which is used to design the
databases.
MySQL
3.4 TABLES
Admin
S# Name Type
1 admin_id int(11)
2 a_name varchar(25)
3 a_address varchar(75)
4 phone_num varchar(13)
5 email varchar(30)
6 Age int(11)
7 Gender varchar(6)
8 Permission int(11)
9 designation varchar(25)
10 Password varchar(30)
Complaints
# Name Type
1 c_id int(11)
2 u_name varchar(25)
3 u_address varchar(50)
4 phone_num varchar(13)
5 c_msg varchar(100)
6 email varchar(25)
7 age int(11)
8 status tinyint(1)
9 time timstamp
Fair
# Name Type
1 f_id int(11)
2 fair_unit Float
3 amt_per_unit float
4 min_charge float
5 min_distance float
METRO CARD
# Name Type
1 card_id int(11)
2 card_num varchar(20)
3 u_name varchar(25)
4 u_address varchar(75)
5 age int(11)
6 gender varchar(5)
7 phone_num varchar(11)
8 email varchar(30)
9 password varchar(20)
10 card_status tinyint(1)
11 balance int(11)
RECHARGE _DETAILS
# Name Type
1 r-id int(11)
2 card_num int(11)
3 amount int(11)
4 date timestamp
5 r_status int(11)
6 payment_dtls varchar(30)
Reply
# Name Type
1 r_id int(11)
2 c_id int(11)
3 r_msg text
4 admin_id int(11)
Routes
# Nmae Type
1 route_id int(11)
2 route_name varchar(30)
3 total_stations int(11)
Route_details
# Name Type
1 r_id int(11)
2 s_id int(11)
3 s_order_num int(11)
4 length_from_start Float
Stations
# Name Type
1 stations_id int(11)
2 s_name varchar(25)
3 latitude float
4 longitude float
Trains
# Name Type
1 train_id int(11)
2 t_name varchar(15)
3 capacity int(11)
Trip
# Name Type
1 trip_id int(11)
2 trip_code varrchar(15)
3 train_id int(11)
4 route_id int(11)
Trip details
# Name Type
1 td_id int(11)
2 trip_num int(11)
3 stations_id int(11)
4 arrival_time time
5 departure_time time
A Data Flow Diagram (DFD) is a structured analysis and design tool that
can be used for flowcharting. A DFD is a network that describes the
flow of data and the processes that change or transform the data
throughout a system. This network is constructed by using a set of
symbols that do not imply any physical implementation. It has
the purpose of clarifying system requirements and identifying major
transformations. So it is the starting point of the design phase that
functionally decomposes the requirements specifications down to the
lowest level of detail. DFD can be considered to an abstraction of the
logic of an information-oriented or a process-oriented system flow-
chart. For these reasons DFDs are often referred to as logical data flow
diagrams.
EXTERNAL ENTITY
PROCESS
DATAFLOW
The data flow shows the flow of information from a source to its
destination. Data flow is represented by a line, with arrowheads
showing the direction of flow. Information always flows to or from a
process and may be written, verbal or electronic. Each data flow
may be referenced by the processes or data stores at its head and
tail, or by a description of its contents.
DATA STORE
3.7 SCREENSHOT
HOME
SUBMIT COMPLAINTS
TIMING
BALANCE ENQUIRY
ADMIN LOGIN
ADD STATION
ADD ROUTE
ADD TRAIN
COMPLAINTS GRID
REPLY COMPLAINT
CHAPTER 4
CONCLUSION
The system has been developed with much care and free of errors and at
the same time it is efficient and less time consuming. The purpose of this
project was to develop a web application for metro rail management .
REFERENCES
APPENDIX
1. Index page
pageEncoding="ISO-8859-1"%>
<%
String adminFlag="false";
if(session.getAttribute("adminVar")!= null)
adminFlag=session.getAttribute("adminVar").toString();
System.out.println("session:"+adminFlag);
try
if(!(request.getParameter("currentTab").isEmpty()))
currentTab = request.getParameter("currentTab");
else
currentTab = "home";
catch(Exception e)
System.out.print(e);
%>
<html>
<head>
<title>Metro Rail</title>
functionredirectToTab(tab)
document.getElementById("currentTab").value = tab;
document.forms["homejspform"].submit();
function logout()
//alert("logout");
window.location.href = "logout.jsp";
</script>
</head>
<body>
<div class="container">
</div>
<%}
else{%>
</div>
<%} %>
</div>
<div class="header">
</div>
<div class="navdiv">
<div class="main-nav">
<ul>
<%}%>
</ul>
</div>
</div>
<%
if(currentTab.compareToIgnoreCase("home")==0)
%>
<jsp:include page="home.jsp">
</jsp:include>
</div>
<%}
if(currentTab.compareToIgnoreCase("complaints")==0)
%>
<jsp:include page="complaints.jsp">
</jsp:include>
</div>
<%}
if(currentTab.compareToIgnoreCase("adminLogin")==0)
%>
<jsp:include page="adminLogin.jsp">
</jsp:include>
</div>
<%}
if(currentTab.compareToIgnoreCase("fair")==0)
%>
<jsp:include page="fair.jsp">
</jsp:include>
</div>
<%}
if(currentTab.compareToIgnoreCase("timing")==0)
%>
<jsp:include page="timing.jsp">
</jsp:include>
</div>
<%}
if(currentTab.compareToIgnoreCase("recharge")==0)
%>
<jsp:include page="metroCard.jsp">
</jsp:include>
</div>
<%}
if(currentTab.compareToIgnoreCase("admin")==0)
%>
<jsp:include page="admin/admin.jsp">
</jsp:include>
</div>
<% } %>
</form>
</div>
</body>
</html>
2. Complaint Registration
<%@pagelanguage="java"contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPEhtml>
<html>
<head>
<metahttp-equiv="Content-Type"content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
<linkrel="stylesheet"type="text/css"href="css/complaints.css"/>
<scripttype="text/javascript"src="jquery/jquery-2.0.2.js"></script>
<scriptsrc="jquery/jquery.h5validate.js"></script>
<scripttype="text/javascript">
$(document).ready(function(){
$('#complaintForm').submit(function ()
{
$.ajax({
type: "post",
url: "addComplaintsAjax.jsp",
data: $("#complaintForm").serialize(),
success: function(msg){
alert(msg);
document.getElementById("user").value="";
document.getElementById("age").value="";
document.getElementById("email").value="";
document.getElementById("phone").value="";
document.getElementById("address").value="";
document.getElementById("c_msg").value="";
}
});
});
});
</script>
</head>
<body>
<divclass="complaintTable">
<formid="complaintForm"name="complaintForm"class="complaintForm"method="
post"action="">
<tablewidth="400"border="0">
<tr>
<thheight="35"align="left">
<p><b>Submit a complaint</b></p>
</th>
</tr>
<tr>
<tdheight="35"align="left">
<p>Name</p>
</td>
<tdalign="left"style="padding-left:7px;">
<p><inputtype="text"name="user"id="user"size="30"required/></p>
</td>
</tr>
<tr>
<tdheight="35"align="left">
<p>Age</p>
</td>
<tdalign="left"style="padding-left:7px;">
<inputtype="number"min="10"max="100"step="1"pattern="[1-9][0-
9]"placeholder="00"requiredname="age"id="age"size="30"/>
</td>
</tr>
<tr>
<tdheight="35"align="left">
<p>email</p>
</td>
<tdalign="left"style="padding-left:7px;">
<inputtype="email"placeholder="Enter your
email"id="email"name="email"size="30"required/>
</td>
</tr>
<tr>
<tdheight="35"align="left">
<p>Phone number</p>
</td>
<tdalign="left"style="padding-left:7px;">
<inputtype="tel"name="phone"id="phone"size="30"placeholder="eg:
9496826455"pattern="[789][0-9]{9}"size="30"required/>
</td>
</tr>
<tr>
<tdheight="35"align="left">
<p>Address</p>
</td>
<tdalign="left"style="padding-left:7px;">
<p><textareaname="address"id="address"style="width: 200px;
height: 50px;" required></textarea></p>
</td>
</tr>
<tr>
<tdheight="35"align="left">
<p>Message</p>
</td>
<tdalign="left"style="padding-left:7px;">
</td>
</tr>
<tr>
<tdcolspan=2align="center">
<inputtype="submit"value="Submit"id="submit"/>
</td>
</tr>
</table>
</form>
</div>
</body>
</html>
<%@pagelanguage="java"contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPEhtmlPUBLIC"-//W3C//DTD HTML 4.01
Transitional//EN""http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<metahttp-equiv="Content-Type"content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
<linkrel="stylesheet"type="text/css"href="css/fair.css"/>
<scripttype="text/javascript"src="jquery/jquery-2.0.2.js"></script>
<scriptsrc="http://maps.google.com/maps/api/js?sensor=false"type="text/j
avascript"></script>
<scripttype="text/javascript">
var map;
var count1=0;
$(document).ready(function(){
$('#find').click(function ()
{
document.getElementById("stationsHiddenDiv").innerHTML = "";
document.getElementById("map").innerHTML = "";
$.ajax({
type: "post",
url: "getStationsForMapAjax.jsp", //this is my servlet
data:"s_stationid="+$('#s_station').val()+"&d_stationid="+$('#d_station'
).val(),
success: function(msg){
$("#stationsHiddenDiv").append(msg);
count1=$('#count1').val();
draw();
//document.getElementById("station").value="";
//document.getElementById("latitude").value="";
//document.getElementById("longitude").value="";
}
});
$.ajax({
type: "post",
url: "admin/stationSelectAjax.jsp",
data:"",
success: function(msg){
//alert(msg);
$("#s_station").append(msg);
document.getElementById("s_station").selectedIndex = -1;
$("#d_station").append(msg);
document.getElementById("d_station").selectedIndex = -1;
}
});
});
function draw(){
for(var m=0,j=1;m<count1;m++,j++)
{
locations[m][0]=document.getElementById('stname'+j).value;
locations[m][1]=document.getElementById('latitude'+j).value;
locations[m][2]=document.getElementById('longitude'+j).value;
//alert(locations[m][0]+","+locations[m][1]+","+locations[m][2]);
}
map = newgoogle.maps.Map(document.getElementById('map'), {
zoom: 11,
center: newgoogle.maps.LatLng(10.04754, 76.31846),
mapTypeId: google.maps.MapTypeId.ROADMAP
});
varinfowindow = newgoogle.maps.InfoWindow();
var marker, i;
</script>
</head>
<body>
<divclass="fairTable">
<formid="fairTableForm"method="post"action="">
<tablewidth="500"border="0">
<tr>
<thheight="35"align="center"colspan="2">
<p>Find fair and route between two stations.
</p>
</th>
</tr>
<tr>
<tdheight="35"align="left">
<p>Source </p>
</td>
<tdalign="left">
<p><selectclass="s_station"name="s_station"id="s_station">
<option></option>
</select></p>
</td>
</tr>
<tr>
<tdheight="35"align="left">
<p>Destination</p>
</td>
<tdwidth="50%"align="left">
<p><selectclass="d_station"name="d_station"id="d_station">
<option></option>
</select></p>
</td>
</tr>
<tr>
<tdcolspan=2align="center">
<inputtype="button"value="Find"id="find"/>
</td>
</tr>
</table>
</form>
<divid="stationsHiddenDiv"name="stationsHiddenDiv">
</div>
</div>
</body>
</html>
<%@pagelanguage="java"contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPEhtml>
<html>
<head>
<metahttp-equiv="Content-Type"content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
<linkrel="stylesheet"type="text/css"href="css/recharge.css"/>
<scripttype="text/javascript"src="jquery/jquery-2.0.2.js"></script>
<scripttype="text/javascript">
$(document).ready(function(){
$('#metroCardApplicationForm').submit(function ()
{
$.ajax({
type: "post",
url: "addMetroCardFormAjax.jsp",
data: $("#metroCardApplicationForm").serialize(),
success: function(msg){
alert(msg);
document.getElementById("loadDiv").innerHTML
= "";
jQuery("#loadDiv").load('applicationForCard.jsp');
}
});
});
});
</script>
</head>
<body>
<divclass="rechargeTableDiv">
<formid="metroCardApplicationForm"method="post"action="">
<tablewidth="400"border="0">
<tr>
<thheight="35"align="left"colspan="2">
<p><b>Application for Metro card</b></p>
</th>
</tr>
<tr>
<tdheight="35"align="left">
<p>Name</p>
</td>
<tdalign="left"style="padding-left:7px;">
<p><inputtype="text"requiredname="user"id="user"size="30"/></p>
</td>
</tr>
<tr>
<tdheight="35"align="left">
<p>Password</p>
</td>
<tdalign="left"style="padding-left:7px;">
<p><inputtype="password"requiredname="password"id="password"size=
"30"/></p>
</td>
</tr>
<tr>
<tdheight="35"align="left">
<p>Age</p>
</td>
<tdalign="left"style="padding-left:7px;">
<p><inputtype="text"requiredname="age"id="age"size="30"/></p>
</td>
</tr>
<tr>
<tdheight="35"align="left">
<p>Gender</p>
</td>
<tdalign="left"style="padding-left:7px;">
<p><inputtype="text"requiredname="gender"id="gender"size="30"/></
p>
</td>
</tr>
<tr>
<tdheight="35"align="left">
<p>Phone number</p>
</td>
<tdalign="left"style="padding-left:7px;">
<p><inputtype="text"requiredname="phone"id="phone"size="30"/></p>
</td>
</tr>
<tr>
<tdheight="35"align="left">
<p>email</p>
</td>
<tdalign="left"style="padding-left:7px;">
<p><inputtype="text"requiredname="email"id="email"size="30"/></p>
</td>
</tr>
<tr>
<tdheight="35"align="left">
<p>Address</p>
</td>
<tdalign="left"style="padding-left:7px;">
<p><textareaname="address"requiredid="address"style="width:
200px; height: 50px;"></textarea></p>
</td>
</tr>
<tr>
<tdcolspan=2align="center">
<inputtype="submit"value="Submit"id="add"/>
</td>
</tr>
</table>
</form>
</div>
</body>
</html>
5. Database Connection
packageDataBase;
importjava.sql.*;
public class DB {
staticResultSetrs = null;
try {
Class.forName("com.mysql.jdbc.Driver");
con =
DriverManager.getConnection("jdbc:mysql://localhost:3306/metrorail",
"root", "");
} catch (Exception e) {
System.out.println("Exception" + e);
return con;
boolean f = false;
try {
con = getConnection();
stmt = con.createStatement();
int b = stmt.executeUpdate(query);
if (b > 0) {
f = true;
} else {
f = false;
} catch (Exception e) {
System.out.println("Exception" + e);
return f;
try {
con = getConnection();
stmt = con.createStatement();
rs = stmt.executeQuery(sql);
returnrs;
} catch (Exception e) {
System.out.println("Exception" + e);
return null;
try {
con.close();
stmt.close();
rs.close();
} catch (Exception e) {
System.out.println("Exception" + e);
<%@pagelanguage="java"contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%@pageimport="java.io.File"%>
<%@pageimport="java.sql.ResultSet"%>
<%@pageimport="DataBase.DB"%>
<%
{
%>Aplication submitted successfully
<% }
else{%>
notsunmited<%}
%>
<divclass="tableForm">
<formid="login"method="post"action="loginServlet">
<tablewidth="300"border="0">
<tr>
<tdheight="35"align="left">
<p>User name</p>
</td>
<tdalign="left"style="padding-left:7px;">
<p><inputtype="text"name="user"id="user"size="30"/></p>
</td>
</tr>
<tr>
<tdheight="35"align="left">
<p>Password</p>
</td>
<tdalign="left"style="padding-left:7px;">
<p><inputtype="text"name="password"id="password"size="30"/></p>
</td>
</tr>
<tr>
<tdcolspan=2align="center">
<inputtype="submit"value="login"id="submit"/>
</td>
</tr>
</table>
</form>
</div>
</body>
</html>
<head>
<metahttp-equiv="Content-Type"content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
<linkrel="stylesheet"type="text/css"href="css/admin.css"/>
<scripttype="text/javascript"src="jquery/jquery-2.0.2.js"></script>
<scripttype="text/javascript">
var count=1;
$(document).ready(function(){
$('#save').click(function ()
{
document.getElementById("countnum").value = count-1;
alert(document.getElementById("countnum").value);
$.ajax({
type: "post",
url: "admin/routeSubmitAjax.jsp", //this is my servlet
data: $("#routeForm").serialize(),
success: function(msg){
alert(msg);
}
});
});
$('#add').click(function (){
var tr1=createtablerow(count);
$("#stations").append(tr1);
getOptions();
});
});
functiongetOptions()
{
var count1=count-1;
$.ajax({
type: "post",
url: "admin/stationSelectAjax.jsp", //this is my servlet
data:"",
success: function(msg){
//alert(msg);
$("#"+ count1 ).append(msg);
if(count1==1)
{
document.getElementById("length1").value=0;
}
}
});
}
functionautoLength(sbox)
{
var sid2=parseInt(sbox.id);
var sid1=sid2-1;
//alert("inside lengths id: "+sid2);
if(sid2!==1)
{
getDistance(sid1,sid2);
}
else
{
document.getElementById("length1").value=0;
}
}
functiongetDistance(boxid1,boxid2)
{
$.ajax({
type: "post",
url: "admin/getDistanceAjax.jsp",
data:"boxid1="+$('#'+boxid1).val()+"&boxid2="+$('#'+boxid2).val()
,
success: function(msg){
var distance=parseFloat(msg);
if(distance==1000)
{
}
else{
var
len1=parseFloat(document.getElementById("length"+boxid1).value);
distance=distance+len1;
document.getElementById("length"+boxid2).value=distance;
}
}
});
}
functioncreatetablerow() {
vartr = '<tr>' ;
var label1='Station'+count;
var label2="Length from start";
var id1 ='station'+count;
var id3 =count;
varid2 ='length'+count;
count++;
// create a new selectBox
<tr>
<tdheight="35"align="left">
<p>Route name</p>
</td>
<tdalign="left"style="padding-left:7px;">
<p><inputtype="text"name="rname"id="rname"size="30"/></p>
</td>
<td></td>
<td></td>
</tr>
</table>
<inputtype="button"value="Add station"id="add"/><br>
<inputtype="button"value="submit"id="save"/>
</form>
</div>
</div>
</body>
</html>
<%@pagelanguage="java"contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%@pageimport="java.io.File"%>
<%@pageimport="java.sql.ResultSet"%>
<%@pageimport="DataBase.DB"%>
<%@pageimport="java.io.PrintWriter"%>
<%@pageimport="java.sql.*"%>
<%
int boxid1=Integer.parseInt(request.getParameter("boxid1"));
int boxid2=Integer.parseInt(request.getParameter("boxid2"));
ResultSet rs1 = null;
ResultSet rs2 = null;
intcnt=0;
int cnt2;//first station's position in route
int cnt3;//second station's position in route
boolean flag=false;
float length1=0;
float length2=0;
float distance=0;
try
{
rs1=DB.executeQuery("select r_id from route_details where
s_id="+boxid1);
while(rs1.next())
{
cnt2=0;
cnt3=0;
intr_id=rs1.getInt("r_id");
rs2=DB.executeQuery("select s_id,length_from_start,s_order_num
from route_details where r_id="+r_id+" order by s_order_num ");
while(rs2.next())
{
cnt2++;
ints_id=rs2.getInt("s_id");
if(boxid1==s_id)
{
length1=rs2.getFloat("length_from_start");
break;
}
}
cnt3=cnt2;
while(rs2.next())
{
cnt3++;
ints_id=rs2.getInt("s_id");
if(boxid2==s_id)
{
flag=true;
length2=rs2.getFloat("length_from_start");
break;
}
}
if(flag==true)
{
System.out.println("ids1:"+length1);
System.out.println("ids1:"+length2);
distance=length2-length1;
System.out.println("ds:"+distance);
%><%=distance%>
<%
break;
}//if true
}//try
catch(Exception e)
{
System.out.println(e);
}
%>
<%@pagelanguage="java"contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPEhtmlPUBLIC"-//W3C//DTD HTML 4.01
Transitional//EN""http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<metahttp-equiv="Content-Type"content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
<linkrel="stylesheet"type="text/css"href="css/admin.css"/>
<scripttype="text/javascript"src="jquery/jquery-2.0.2.js"></script>
<scripttype="text/javascript">
var count=1;
$(document).ready(function(){
$("#popup_block").hide();
loadComplaintsDiv();
});
functionsubmitReplyForm()
{
$("#popup_block").show();
$.ajax({
type: "post",
url: "admin/submitReplyAjax.jsp", //this is my servlet
data: $("#complaintForm").serialize(),
success: function(msg){
alert(msg);
$("#popup_block").hide();
hideReplyDiv();
}
});
functionloadComplaintsDiv()
{
$.ajax({
type: "post",
url: "admin/getAllComplaintsAjax.jsp", //this is my servlet
data: "",
success: function(msg){
// alert(msg);
document.getElementById("allComplaintsDiv").innerHTML = "";
$("#allComplaintsDiv").append(msg);
}
});
}
functionloadReplyDiv(selectedId)
{
varcid=selectedId.id;
$.ajax({
type: "post",
url: "admin/getComplaintByIdAjax.jsp", //this is my servlet
data: "cid="+cid,
success: function(msg){
//alert(msg);
$("#allComplaintsDiv").hide();
document.getElementById("replyDiv").innerHTML = "";
$("#replyDiv").append(msg);
$("#replyDiv").show();
}
});
}
function Reply()
{
alert("hai");
}
functionhideReplyDiv()
{
$("#replyDiv").hide();
loadComplaintsDiv();
$("#allComplaintsDiv").show();
}
</script>
</head>
<body>
<divid="allComplaintsDiv">
</div>
<divid="replyDiv"style="padding-left:100px;padding-top:40px; "></div>
<divid="popup_block"class="popup_block"style="hieght:200px;width:100px;f
loat:left;position:fixed;top:50%;left:50%;z-index: 999999;">
<imgalt=""src="img/ajax-loader.gif">
</div>
</body>
</html>