<%@ page contentType="text/html; charset=utf-8" language="java" import="java.sql.*" import="java.sql.Connection"
import="java.util.Date" errorPage="" %>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>查看所有</title>
<LINK href=style.css type=text/css rel=stylesheet>
<link rel="stylesheet" type="text/css" href="../css/table.css" />
<script type="text/javascript" src="../script/DelCar.js"></script>
</head>
<body bgcolor=#DCDCDC>
<div style ="width:100px; height:50px;position:absolute; top:20px; left:50px"><button οnclick="javascript:history.go(-1)">返回到上一页</button></div>
<div align="center"><a style="font-size:200%">申请列表</a></div>
<div style="position:relative; top:0px;left:680px;">
<a style="font-size:70%">关键值:</a>
<input type="text" size=9 name="databy" >
<select Style="font-size:60%" name="selectcheck">
<option value="cardtype">卡类</option>
<option value="carnum">车牌号</option>
<option value="applyname">用户姓名</option>
<option value="ghxh">账号/工号</option>
</select>
<button type="button" οnclick=window.navigate("./abytest.jsp?name="+selectcheck.value+"&dataname="+databy.value+"") target="carFrame">查看</button>
</div>
<hr>
<div style="height:10px"></div>
<table class="tabletop" align="center" bordercolor="#DCDCDC" cellpadding="0" cellspacing="0">
<tr bgcolor="999999">
<Th id="tdl">申请流水号</th>
<th id="tdl" width="133">申请人</th>
<th id="tdl" width="133">申请类别</th>
<th id="tdl" width="133">申请人工号</th>
<th id="tdl" width="133">车辆所有人</th>
<th width="133">操作</th>
</tr>
<%
//载入驱动程序类别
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection conn=DriverManager.getConnection("jdbc:odbc:Driver={SQL Server};Server=XXX-PC;uid=sa;pwd=admin419;Database=car;");
//建立数据库链接,jspdata为ODBC数据源名称
//建立Statement对象
Statement stmt = conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY);
String sql="select * from tab_car";
//建立ResultSet(结果集)对象,并执行SQL语句
ResultSet rs = stmt.executeQuery(sql);
boolean a = rs.next();
if(a==false){
System.out.println("wrong");
rs.close();
stmt.close();
conn.close();
return;
}else{
System.out.println("true");
}
//一页显示的记录数
int intPageSize;
//记录总数
int intRowCount;
//总页数
int intPageCount;
//待显示页码
int intPage;
String strPage;
int i;
//设置一页显示的记录数
intPageSize =10;
//取得待显示页码
strPage = request.getParameter("page");
//表明在QueryString中没有page这一个参数,此时显示第一页数据
if(strPage==null){
intPage = 1;
} else{
//将字符串转换成整型
intPage = java.lang.Integer.parseInt(strPage);
}
if(intPage< 1){
intPage = 1;
}
//获取记录总数
rs.last();
intRowCount = rs.getRow();
//记算总页数
intPageCount = (intRowCount+intPageSize-1) / intPageSize;
//调整待显示的页码
if(intPage >intPageCount) intPage = intPageCount;
if(intPageCount >0){
//将记录指针定位到待显示页的第一条记录上
rs.absolute((intPage-1) * intPageSize+1);
//显示数据
}
i = 0;
while(i< intPageSize && !rs.isAfterLast()){%>
<tr bgcolor="#f8f8f8" class=time>
<%String idl = rs.getString("id");
String carownerl=rs.getString("carowner");
String applyghl=rs.getString("applygh");
String applynamel=rs.getString("applyname");
String cardtypel=rs.getString("cardtype");
String applyidl=rs.getString("applyid");
%>
<td id="td1100"><%=applyidl%></td>
<td id="td1100"><%=applynamel%></td>
<td id="td1100"><%=cardtypel%></td>
<td id="td1100"><%=applyghl%></td>
<td id="td1100"><%=carownerl%></td>
<td id="td1000">
<input type='button' value="详情" οnclick="window.open('QueryCarapp.jsp?applyid=<%=applyidl%>')">
<input type='button' value="删除" οnclick="del(<%=applyidl%>)" >
</td>
</tr>
<%rs.next();
i++;
} rs.close();
stmt.close();
conn.close();%>
</table><p align="center">
共<%=intRowCount%>个记录,分<%=intPageCount%>页显示,当前页是:第<%=intPageCount%>页
<%for(int j=1;j<=intPageCount;j++)
{out.print(" <a href='atest.jsp?page="+j+"'>"+j+"</a>");
}%>
</body>
</html>
效果图: