本文主要是介绍简单的金苑宾馆客房系统前端与后端的开发(html+css+jsp+数据库)---河北金融19计科一班结课设计(二,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
最近两天可算把管理员这边的肝完了头发要掉光了,成果如图:
贴几段个人认为比较难搞的代码:
testmodify.jsp
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ page import="java.sql.*" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><meta charset="UTF-8"><base href="<%=basePath%>"><title>信息修改</title><meta http-equiv="pragma" content="no-cache"><meta http-equiv="cache-control" content="no-cache"><meta http-equiv="expires" content="0"><meta http-equiv="keywords" content="keyword1,keyword2,keyword3"><meta http-equiv="description" content="This is my page"><!--<link rel="stylesheet" type="text/css" href="styles.css">--><link rel="stylesheet" href="https://at.alicdn.com/t/font_1757504_k6qar61imrp.css"><link rel="stylesheet" href="index.css"><body><div id="Layer1" style="position:absolute; width:100%; height:100%; z-index:-1">
<img src="images/timg.jpg" height="100%" width="100%"/>
</div> <% request.setCharacterEncoding("UTF-8");String ID = request.getParameter("ID");String Name = request.getParameter("Name");String Sex = request.getParameter("Sex");String IDnum = request.getParameter("IDnum");String Phone = request.getParameter("Phone");String TCnum = request.getParameter("TCnum");String State = request.getParameter("State");String Hno = request.getParameter("Hno");Connection conn = null;PreparedStatement pstmt = null;try{Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");conn=DriverManager.getConnection("jdbc:sqlserver://127.0.0.1:1433;DatabaseName=binguan","sa","123456");if(!"".equals(Name)){String sql="update xinxi set Name=? where ID=?";pstmt=conn.prepareStatement(sql);pstmt.setString(1,Name);pstmt.setString(2,ID);pstmt.executeUpdate(); }if(!"".equals(Sex)){out.println("111");String sql="update xinxi set Sex=? where ID=?";pstmt=conn.prepareStatement(sql);pstmt.setString(1,Sex);pstmt.setString(2,ID);pstmt.executeUpdate(); }if(!"".equals(IDnum)){String sql="update xinxi set IDNum=? where ID=?";pstmt=conn.prepareStatement(sql);pstmt.setString(1,IDnum);pstmt.setString(2,ID);pstmt.executeUpdate(); }if(!"".equals(Phone)){String sql="update xinxi set Phone=? where ID=?";pstmt=conn.prepareStatement(sql);pstmt.setString(1,Phone);pstmt.setString(2,ID);pstmt.executeUpdate(); }if(!"".equals(State)){String sql="update xinxi set State=? where ID=?";pstmt=conn.prepareStatement(sql);pstmt.setString(1,State);pstmt.setString(2,ID);pstmt.executeUpdate(); }if(!"".equals(TCnum)){String sql="update xinxi set TCnum=? where ID=?";pstmt=conn.prepareStatement(sql);pstmt.setString(1,TCnum);pstmt.setString(2,ID);pstmt.executeUpdate(); }if(!"".equals(Hno)){String sql="update xinxi set Hno=? where ID=?";pstmt=conn.prepareStatement(sql);pstmt.setString(1,Hno);pstmt.setString(2,ID);pstmt.executeUpdate();sql="update Hxinxi set State='已入住' where Hno=?";pstmt=conn.prepareStatement(sql);pstmt.setString(1,Hno);pstmt.executeUpdate();}response.sendRedirect("http://localhost:8080/qianduan/modifysuccess.html");pstmt.close();conn.close();}catch(ClassNotFoundException e){e.printStackTrace();}catch(SQLException e){e.printStackTrace();}%></body>
</html>
testsearch.jsp
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ page import="java.sql.*" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><meta charset="UTF-8"><base href="<%=basePath%>"><title>信息搜索</title><meta http-equiv="pragma" content="no-cache"><meta http-equiv="cache-control" content="no-cache"><meta http-equiv="expires" content="0"><meta http-equiv="keywords" content="keyword1,keyword2,keyword3"><meta http-equiv="description" content="This is my page"><!--<link rel="stylesheet" type="text/css" href="styles.css">--><link rel="stylesheet" href="https://at.alicdn.com/t/font_1757504_k6qar61imrp.css"><link rel="stylesheet" href="index.css"><body><div id="Layer1" style="position:absolute; width:100%; height:100%; z-index:-1">
<img src="images/timg.jpg" height="100%" width="100%"/>
</div> <!-- CSS goes in the document HEAD or added to your external stylesheet -->
<!-- Javascript goes in the document HEAD -->
<script type="text/javascript">
function altRows(id){if(document.getElementsByTagName){ var table = document.getElementById(id); var rows = table.getElementsByTagName("tr"); for(i = 0; i < rows.length; i++){ if(i % 2 == 0){rows[i].className = "evenrowcolor";}else{rows[i].className = "oddrowcolor";} }}
}
window.onload=function(){altRows('alternatecolor');
}
</script><!-- CSS goes in the document HEAD or added to your external stylesheet -->
<style type="text/css">
table.altrowstable {font-family: verdana,arial,sans-serif;font-size:11px;color:#333333;border-width: 1px;border-color: #a9c6c9;border-collapse: collapse;
}
table.altrowstable th {border-width: 3px;padding: 24px;border-style: solid;border-color: #a9c6c9;
}
table.altrowstable td {border-width: 3px;padding: 24px;border-style: solid;border-color: #a9c6c9;
}
.oddrowcolor{background-color:#d4e3e5;
}
.evenrowcolor{background-color:#c3dde0;
}
</style><!-- Table goes in the document BODY -->
<table class="altrowstable" id="alternatecolor">
<tr><th>ID</th><th>姓名</th><th>性别</th><th>身份证号</th><th>手机号</th><th>套餐号</th><th>入驻状态</th><th>房间号</th>
</tr><% request.setCharacterEncoding("UTF-8");String Name="";Name = request.getParameter("Name");String Hno = request.getParameter("Hno");Connection conn = null;PreparedStatement pstmt = null;ResultSet rs = null;try{Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");conn=DriverManager.getConnection("jdbc:sqlserver://127.0.0.1:1433;DatabaseName=binguan","sa","123456");String sql="select * from xinxi where Name=?";pstmt=conn.prepareStatement(sql);pstmt.setString(1,Name);rs = pstmt.executeQuery();if(!"".equals(Name)){while(rs.next()){%>
<tr>
<td><%=rs.getString("ID") %></td><td><%=rs.getString("Name") %></td><td><%=rs.getString("Sex") %></td><td><%=rs.getString("IDnum") %></td><td><%=rs.getString("Phone") %></td><td><%=rs.getString("TCnum") %></td><td><%=rs.getString("State") %></td><td><%=rs.getString("Hno") %></td>
</tr>
<% }}else{String sql1 ="select * from xinxi where Hno=?";pstmt=conn.prepareStatement(sql1);pstmt.setString(1,Hno);rs = pstmt.executeQuery();while(rs.next()){%>
<tr>
<td><%=rs.getString("ID") %></td><td><%=rs.getString("Name") %></td><td><%=rs.getString("Sex") %></td><td><%=rs.getString("IDnum") %></td><td><%=rs.getString("Phone") %></td><td><%=rs.getString("TCnum") %></td><td><%=rs.getString("State") %></td><td><%=rs.getString("Hno") %></td>
</tr>
<% }}rs.close();pstmt.close();conn.close();}catch(ClassNotFoundException e){e.printStackTrace();}catch(SQLException e){e.printStackTrace();}%></body>
</html>
基本上到这里就差不多了,还差个留言板算作是扩充,下一目把留言板做完在做一个实验报告,做一下ppt基本上结束了。
这篇关于简单的金苑宾馆客房系统前端与后端的开发(html+css+jsp+数据库)---河北金融19计科一班结课设计(二的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!