《网站设计与开发》实验报告
实验题目: 企业信息管理系统案例
专 业:
年 级:
学生学号:
学生姓名:
指导老师:
完成日期: 年 月 日
实验报告
一、实验目的及要求
本案例学习的主要目的是综合运用前面章节相关概念与理念,设计和开发一个企业信息管理系统。通过本案例的实践有助于对Java Web技术的了解和认识,提高项目开发实践能力。要求能够通过本案例的开发了解项目开发的基本过程以及熟练运用前几章所学知识设计其他同类系统的页面。
二、实验原理及主要代码
本案例模拟企业日常管理,实现一个企业信息管理系统。系统可以对客户信息、合同信息、售后服务、产品以及员工进行管理。
1.系统登录模块——实现系统的登录功能。
1.1登录页面(login.jsp)在根文件夹下,在页面中该输入用户名和密码后单击“登录”按钮,请求提交到loginCheck.jsp页面。loginCheck.jsp页面处理提交的数据并进行下一步的页面跳转。文件image中存放项目中使用到的图片。
login.jsp
<%@ page contentType="text/html" pageEncoding="UTF-8" %>
<html>
<head>
<title>企业信息管理系统-登录页面</title>
<meta http-equiv="content-Type" content="text/html;charset=UTF-8">
</head>
<body background="image/login1.jpg">
<br><br><br><br><br><br>
<br><br><br><br><br><br>
<center>
<form action="loginCheck.jsp" method="post">
<table border="0">
<tr>
<td>
<table border="1" cellspacing="0" cellpadding="0" bgcolor="#dddddd" width="360" height="200">
<tr height="130">
<td align="center">
输入用户姓名<input type="text" name="userName" size="20">
<br>
输入用户密码<input type="password" name="password" size="22">
<br>
<input type="submit" value="登录" size="12"/>
<input type="reset" value="清除" size="12"/>
</td>
</tr>
<tr height="30">
<td bgcolor="#95BDFF"> </td>
</tr>
</table>
</td>
</tr>
</table>
</form>
</center>
</body>
</html>
logincheck.jsp
<%@ page import="java.sql.*" %>
<%@ page contentType="text/html" pageEncoding="UTF-8" %>
<html>
<head>
<meta http-equiv="content-Type" content="text/html;charset=UTF-8">
<title>数据处理页面</title>
</head>
<body>
<%
String userName = new String(request.getParameter("userName").getBytes("ISO-8859-1"),"UTF-8");
String password = new String(request.getParameter("password").getBytes("ISO-8859-1"),"UTF-8");
Connection con=null;
Statement st=null;
ResultSet rs=null;
if(userName.equals("")){
response.sendRedirect("login.jsp");
}
try{
Class.forName("com.mysql.jdbc.Driver");
String url="jdbc:mysql://localhost:3306/eims?useUnicode=true&characterEncoding=gbk";
con=DriverManager.getConnection(url,"root","");
st=con.createStatement();
String query="select * from user where userName='"+userName+"'";
rs=st.executeQuery(query);
if(rs.next()){
String query2="select * from user where password='"+password+"'";
rs=st.executeQuery(query2);
if(rs.next()){
response.sendRedirect("main/main.jsp");
}else{
response.sendRedirect("login.jsp");
}
}
}catch(Exception e){
e.printStackTrace();
}finally{
rs.close();
st.close();
con.close();
}
%>
</body>
</html>
1.2如果用户名和密码正确将跳转到系统的主页面(main.jsp),主页面是使用框架进行分割的,主页面级子窗口用到的页面在文件夹main中。
main.jsp
<%@ page contentType="text/html" pageEncoding="UTF-8" %>
<html>
<head>
<title>企业信息管理系统-主页面</title>
<meta http-equiv="content-Type" content="text/html;charset=UTF-8">
</head>
<frameset rows="*" cols="120,*">
<frame src="left.jsp" name="left" scrolling="no"/>
<frameset rows="180,*" cols="*">
<frame src="top.jsp" name="top" scrolling="no"/>
<frame src="bottom.jsp" name="main" />
</frameset>
</frameset>
</html>
left.jsp
<%@ page contentType="text/html" pageEncoding="UTF-8" %>
<html>
<head>
<meta http-equiv="content-Type" content="text/html;charset=UTF-8">
<title>JSP Page</title>
</head>
<body bgcolor="CCCFFF" background="../image/left.jpg">
<table>
<tr>
<td><a href="../clientManage/lookClient.jsp" target="main">客户管理</a></td>
</tr>
<tr>
<td><a href="../contactManage/lookContact.jsp" target="main">合同管理</a></td>
</tr>
<tr>
<td><a href="../CSManage/lookCS.jsp" target="main">售后管理</a></td>
</tr>
<tr>
<td><a href="../productManage/lookProduct.jsp" target="main">产品管理</a></td>
</tr>
<tr>
<td><a href="../staffManage/lookStaff.jsp" target="main">员工管理</a></td>
</tr>
<tr>
<td><a href="../login.jsp" target="_parent">退出系统</a></td>
</tr>
</table>
</body>
</html>
bottom.jsp
<%@ page contentType="text/html" pageEncoding="UTF-8" %>
<html>
<head>
<meta http-equiv="content-Type" content="text/html;charset=UTF-8">
<title>JSP Page</title>
</head>
<body bgcolor="#99aaee" background="">
<center>
<br><br><br><br>
<h3>本项目是对前四章知识点的综合训练!一分耕耘一分收获!</h3>
<br><br><br><br>
<br><br><br><br>
<br><br><br><br>
<p><font size="-1">Copyright 2013.清华大学出版社</font></p>
<p></p>
</center>
</body>
</html>
top.jsp
<%@ page contentType="text/html" pageEncoding="UTF-8" %>
<html>
<head>
<meta http-equiv="content-Type" content="text/html;charset=UTF-8">
<title>JSP Page</title>
</head>
<body background="../image/top.jpg">
<h2 align="center"color="red">欢迎使用企业信息管理平台</h2>
</body>
</html>
2.客户管理模块——系统中对客户信息的管理主要包括客户信息查询、客户信息添加、客户信息修改、客户信息删除等。其页面在clientManage文件夹中
查询
lookClient.jsp
<%@page import="java.sql.*" %>
<%@page contentType="text/html" pageEncoding="UTF-8" %>
<html>
<head>
<title>客户查询</title>
<meta http-equiv="content-type" content="text/html;charset=utf-8">
</head>
<body bgcolor="lightblue">
<table align="center" width="500">
<tr>
<td>客户查询</td>
<td>
<a href="addClient.jsp">客户添加</a>
</td>
<td>
<a href="updateClient.jsp">客户修改</a>
</td>
<td>
<a href="deleteClient.jsp">客户删除</a>
</td>
</tr>
</table>
<br/>
<hr/>
<br/>
<table align="center" width="700" border="2">
<tr>
<th colspan="4" align="center" >查看客户信息</th>
</tr>
<tr>
<td>姓名</td>
<td>电话</td>
<td>地址</td>
<td>邮箱</td>
</tr>
<%
Connection con=null;
Statement stmt=null;
ResultSet rs=null;
Class.forName("com.mysql.jdbc.Driver");
String url="jdbc:mysql://localhost:3306/eims?useUnicode=true&characterEncoding=gbk";
con=DriverManager.getConnection(url,"root","");
stmt=con.createStatement();
String sql="select * from client";
rs=stmt.executeQuery(sql);
while(rs.next()){
%>
<tr>
<td><%=rs.getString("clientName") %></td>
<td><%=rs.getString("clientTelephone") %></td>
<td><%=rs.getString("clientAddress") %></td>
<td><%=rs.getString("clientEmail") %></td>
</tr>
<%
}
rs.close();
stmt.close();
con.close();
%>
</table>
</body>
</html>
添加
addClient.jsp
<%@page import="java.sql.*" %>
<%@page contentType="text/html" pageEncoding="UTF-8" %>
<html>
<head>
<title>添加客户信息</title>
<meta http-equiv="content-type" content="text/html;charset=utf-8">
</head>
<body bgcolor="lightblue">
<form action="addClientCheck.jsp" method="post">
<table align="center" width="500">
<tr>
<td>
<a href="lookClient.jsp">客户查询</a>
</td>
<td>客户添加</td>
<td>
<a href="updateClient.jsp">客户修改</a>
</td>
<td>
<a href="deleteClient.jsp">客户删除</a>
</td>
</tr>
</table>
<br/>
<hr/>
<br/>
<table align="center" width="300">
<tr>
<th colspan="4" align="center" >添加客户信息</th>
</tr>
<tr>
<td>姓名</td>
<td><input type="text" name="clientName"/></td>
</tr>
<tr>
<td>电话</td>
<td><input type="text" name="clientTelephone"/></td>
</tr>
<tr>
<td>地址</td>
<td><input type="text" name="clientAddress"/></td>
</tr>
<tr>
<td>邮箱</td>
<td><input type="text" name="clientEmail"/></td>
</tr>
<tr align="center">
<td colspan="2">
<input type="submit" name="sure" value="确认"/>
<input type="reset" name="clear" value="取消"/>
</td>
</tr>
</table>
</form>
</body>
</html>
addClientCheck.jsp
%@page import="java.sql.*" %>
<%@page contentType="text/html" pageEncoding="UTF-8" %>
<html>
<head>
<title>处理客户添加数据</title>
<meta http-equiv="content-type" content="text/html;charset=utf-8">
</head>
<body>
<%
String clientName=new String(request.getParameter("clientName").getBytes("ISO-8859-1"),"UTF-8");
String clientTelephone=new String(request.getParameter("clientTelephone").getBytes("ISO-8859-1"),"UTF-8");
String clientAddress=new String(request.getParameter("clientAddress").getBytes("ISO-8859-1"),"UTF-8");
String clientEmail=new String(request.getParameter("clientEmail").getBytes("ISO-8859-1"),"UTF-8");
Connection con=null;
Statement stmt=null;
try{
Class.forName("com.mysql.jdbc.Driver");
String url="jdbc:mysql://localhost:3306/eims?useUnicode=true&characterEncoding=gbk";
con=DriverManager.getConnection(url,"root","");
stmt=con.createStatement();
String sql="insert into client(clientName,clientTelephone,clientAddress,clientEmail) values ('"+clientName+"','"+clientTelephone+"','"+clientAddress+"','"+clientEmail+"')";
stmt.executeUpdate(sql);
response.sendRedirect("lookClient.jsp");
}
catch(Exception e){
e.printStackTrace();
}
finally{
stmt.close();
con.close();
}
%>
</body>
</html>
修改
updateClient.jsp
<%@page contentType="text/html" pageEncoding="UTF-8" %>
<html>
<head>
<title>修改客户信息</title>
<meta http-equiv="content-type" content="text/html;charset=utf-8">
</head>
<body bgcolor="lightblue">
<form action="updateClientCheck.jsp" method="post">
<table align="center" width="500">
<tr>
<td>
<a href="lookClient.jsp">客户查询</a>
</td>
<td>
<a href="addClient.jsp">客户添加</a>
</td>
<td>客户修改</td>
<td>
<a href="deleteClient.jsp">客户删除</a>
</td>
</tr>
</table>
<br/>
<hr/>
<br/>
<table align="center" width="300">
<tr>
<th colspan="2" align="center" >修改客户信息</th>
</tr>
<tr>
<td>姓名</td>
<td><input type="text" name="clientName"/></td>
</tr>
<tr>
<td>电话</td>
<td><input type="text" name="clientTelephone"/></td>
</tr>
<tr>
<td>地址</td>
<td><input type="text" name="clientAddress"/></td>
</tr>
<tr>
<td>邮箱</td>
<td><input type="text" name="clientEmail"/></td>
</tr>
<tr align="center">
<td colspan="2">
<input type="submit" name="sure" value="确认"/>
<input type="reset" name="clear" value="取消"/>
</td>
</tr>
</table>
</form>
</body>
</html>
updateClientCheck.jsp
<%@page import="java.sql.*" %>
<%@page contentType="text/html" pageEncoding="UTF-8" %>
<html>
<head>
<meta http-equiv="content-type" content="text/html;charset=utf-8">
<title>处理客户修改数据</title>
</head>
<body>
<%
String clientName=new String(request.getParameter("clientName").getBytes("ISO-8859-1"),"UTF-8");
String clientTelephone=new String(request.getParameter("clientTelephone").getBytes("ISO-8859-1"),"UTF-8");
String clientAddress=new String(request.getParameter("clientAddress").getBytes("ISO-8859-1"),"UTF-8");
String clientEmail=new String(request.getParameter("clientEmail").getBytes("ISO-8859-1"),"UTF-8");
Connection con=null;
Statement st=null;
if(clientName.equals("")){
response.sendRedirect("updateClient.jsp");
}
else{
try{
Class.forName("com.mysql.jdbc.Driver");
String url="jdbc:mysql://localhost:3306/eims?useUnicode=true&characterEncoding=gbk";
con=DriverManager.getConnection(url,"root","");
st=con.createStatement();
String sql="update client set clientName='"+clientName+"',clientTelephone='"+clientTelephone+"',clientAddress='"+clientAddress+"',clientEmail='"+clientEmail+"'";
st.executeUpdate(sql);
response.sendRedirect("../clientManage/lookClient.jsp");
}
catch(Exception e){
e.printStackTrace();
}
finally{
st.close();
con.close();
}
}
%>
</body>
</html>
删除
deleteClient.jsp
<%@page contentType="text/html" pageEncoding="UTF-8" %>
<html>
<head>
<title>客户删除</title>
<meta http-equiv="content-type" content="text/html;charset=utf-8">
</head>
<body bgcolor="lightblue">
<form action="deleteClientCheck.jsp" method="post">
<table align="center" width="500">
<tr>
<td>
<a href="lookClient.jsp">客户查询</a>
</td>
<td> <a href="addClient.jsp">客户添加</a>
</td>
<td>
<a href="updateClient.jsp">客户修改</a>
</td>
<td> 客户删除</td>
</tr>
</table>
<br/>
<hr/>
<br/>
<table align="center">
<tr>
<th colspan="2">删除客户信息</th>
</tr>
<tr>
<td>客户姓名</td>
<td>
<input type="text" name="clientName"/>
输入要删除的客户姓名
</td>
</tr>
<tr align="center">
<td colspan="2">
<input type="submit" name="sure" value="确认"/>
<input type="reset" name="clear" value="取消"/>
</td>
</tr>
</table>
</form>
</body>
</html>
deleteClientCheck.jsp
<%@page import="java.sql.*" %>
<%@page contentType="text/html" pageEncoding="UTF-8" %>
<html>
<head>
<title>处理客户删除数据</title>
<meta http-equiv="content-type" content="text/html;charset=utf-8">
</head>
<body>
<%
String clientName=new String(request.getParameter("clientName").getBytes("ISO-8859-1"),"UTF-8");
Connection con=null;
Statement stmt=null;
try{
Class.forName("com.mysql.jdbc.Driver");
String url="jdbc:mysql://localhost:3306/eims?useUnicode=true&characterEncoding=gbk";
con=DriverManager.getConnection(url,"root","");
stmt=con.createStatement();
String sql="delete from client where clientName='"+clientName+"'";
stmt.executeUpdate(sql);
response.sendRedirect("lookClient.jsp");
}
catch(Exception e){
e.printStackTrace();
}
finally{
stmt.close();
con.close();
}
%>
</body>
</html>
3.合同管理模块
系统中对合同信息的管理主要包括合同信息查询、合同信息添加、合同信息修改、合同信息删除等。其页面在contactManage文件夹中。(代码略)
4.售后管理模块
系统中对售后信息的管理主要包括售后信息查询、售后信息添加、售后信息修改、售后信息删除等。其页面在CSManage文件夹中。(代码略)
5.产品管理模块
系统中对产品信息的管理主要包括产品信息查询、产品信息添加、产品信息修改、产品信息删除等。其页面在productManage文件夹中。(代码略)
6.员工管理模块
系统中对员工信息的管理主要包括员工信息查询、员工信息添加、员工信息修改、员工信息删除等。其页面在staffManage文件夹中。(代码略)
7.退出系统主要实现把主页面关闭并返回登录页面。
三、结果及简要说明
登录页面(login.jsp)在根文件夹下,在页面中该输入用户名和密码后单击“登录”按钮,请求提交到loginCheck.jsp页面。loginCheck.jsp页面处理提交的数据并进行下一步的页面跳转。运行效果如图:
当用户输入正确的用户名和密码单击“登录”按钮后,将进入“企业信息管理系统”的主页面(main.jsp),运行效果如图:
上图是使用框架进行分割的,子窗口分别连接left.jsp、top.jsp、bottom.jsp页面。
单击主页面中的“客户管理”,将出现下图所示的页面(lookClient.jsp),运行效果如图:
单击“客户添加”将出现客户添加页面(addClient.jsp)可以进行客户添加操作,运行效果如图:
单击“客户修改”将出现客户修改页面(updateClient.jsp)进行客户信息修改,运行效果如图:
单击“客户删除”按钮将出现客户删除页面(deleteClient.jsp)进行客户信息删除,运行效果如图:
合同管理模块、售后管理模块、产品管理模块、员工管理模块的页面和可进行的操作与客户管理模块的基本一样,因此便不一一列举。
四、实验总结
由于本次实验不是由一个人全部完成,而是分组完成,所以会出现一些问题也是在所难免的,好在经过小组成员以及老师的帮助下,能解决几乎所有的问题,也是值得肯定的。
在案例的售后管理模块设计与实现中,当点击售后添加后,输入要添加的信息后返回结果却是一片空白,如下图:
后来检查才发现原来是‘insert’中的‘r’写掉了才导致出问题,添加后结果正常了。其实也遇到过很多这种情况,比如链接的地址写错、单词写错,后来改过来就行了。
在案例的员工管理模块设计与实现中,员工添加和员工删除页面一直有问题。如下图:
最后发现由于两个页面中的英文单词大小写不一样导致错误,改过来就没问题了。