国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > JSP > 正文

Jsp分頁

2024-09-05 00:20:32
字體:
來源:轉載
供稿:網友

<%@ page contenttype="text/html;charset=gb2312"%>
<%
//變量聲明
java.sql.connection sqlcon; //數據庫連接對象
java.sql.statement sqlstmt; //sql語句對象
java.sql.resultset sqlrst; //結果集對象
java.lang.string strcon; //數據庫連接字符串
java.lang.string strsql; //sql語句
int intpagesize; //一頁顯示的記錄數
int introwcount; //記錄總數
int intpagecount; //總頁數
int intpage; //待顯示頁碼
int rowi;
java.lang.string strpage;
int i,j,k; 
rowi=0;
string pagesize = (string) session.getvalue("pagesize");

 

//if(pagesize!=null){
intpagesize=integer.parseint(pagesize);
strpage = request.getparameter("page");  //取得待顯示頁碼
if(strpage==null){
//表明在querystring中沒有page這一個參數,此時顯示第一頁數據
intpage = 1;
} else{
//將字符串轉換成整型
intpage = java.lang.integer.parseint(strpage);
if(intpage<1) intpage = 1; }
//裝載jdbc驅動程序
class.forname("com.microsoft.jdbc.sqlserver.sqlserverdriver");
//設置數據庫連接字符串
strcon ="jdbc:microsoft:sqlserver://localhost:1433;databasename=sunmoon" ;
//連接數據庫
sqlcon = java.sql.drivermanager.getconnection(strcon,"sa","sa");
//創建sql語句對象
sqlstmt = sqlcon.createstatement();
//獲取記錄總數 
 

 string companyname = (string) session.getvalue("companyname");
 
if ("全部客戶".equals(companyname))
{
    strsql = "select count(*) from customer";
 
}

else 
{
 strsql = "select count(*) from customer where 客戶名稱='"+companyname+"'";
 
}


//strsql = "select count(*) from loadweight where 收貨方='"+company+"' ";
sqlrst = sqlstmt.executequery(strsql);
//執行sql語句并取得結果集
sqlrst.next(); //記錄集剛打開的時候,指針位于第一條記錄之前
introwcount = sqlrst.getint(1);
sqlrst.close(); //關閉結果集
//記算總頁數
intpagecount = (introwcount+intpagesize-1) / intpagesize;
//調整待顯示的頁碼
if(intpage>intpagecount) intpage = intpagecount;
//設置獲取數據sql語句
//strsql = "select * from loadweight where 收貨方='廣州世經'";
{
 if ("全部客戶".equals(companyname))
 
    {
  strsql = "select * from customer order by 客戶序號";

  }
 else
 {
  strsql = "select * from customer where 客戶名稱='"+companyname+"' order by 客戶序號";
 }

 //strsql = strsql+" and 時間 between '2003-3-1' and '2003-4-1' ";
 //out.println(strsql);
 
}
//執行sql語句并取得結果集
sqlrst = sqlstmt.executequery(strsql);
//將記錄指針定位到待顯示頁的第一條記錄上
i = (intpage-1) * intpagesize;
for(j=0;j<i;j++) sqlrst.next(); %>
<html>

<link href="../../css/style.css" rel="stylesheet" type="text/css">

<head>
<title>數據庫查詢系統</title>
</head>
<script language=javascript>
  function selectrow(ocurrent)
           {
        ocurrent.style.backgroundcolor="ccccff";

        for(var i = 0; i < document.all('t1').rows.length;i++)
         {

       if(t1.rows[i] != ocurrent) t1.rows[i].style.backgroundcolor="ffffff";
         }
          }
 
 
 function moveto(page)
 {
  form1.action = "/sunmoon/jsp/inside/customer/customdbqueary.jsp?page=" + page;
  form1.method = "post";
  form1.submit();
 }
   function printpage() { print(document); }
</script>
<body>
<table width="90%" border="0" align="center">
  <tr>
    <td nowrap>
<div align="center"><strong><font color="#660099" size="4" face="宋體">系統查詢結果</font></strong></div></td>
  </tr>
</table>
<p align=center><strong></strong></p>

<table width=90% border=0 align=center cellpadding=0 cellspacing=0 id=t1>
  <tr>
    <td width="104" height="16" align=center  nowrap bgcolor="#ffffcc"> <div align="left"><font color="#0000ff">編號</font></div></td>
    <td width=60 align=center  nowrap bgcolor="#ffffcc"> <div align="left"><font color="#0000ff">客戶名稱</font></div></td>
    <td width="103" align=center nowrap bgcolor="#ffffcc"> <div align="left"><font color="#0000ff">賬號</font></div></td>
    <td width="117" align=center nowrap bgcolor="#ffffcc"> <div align="left"><font color="#0000ff">稅號</font></div></td>
    <td width="117" align=center nowrap bgcolor="#ffffcc"> <div align="left"><font color="#0000ff">開戶行</font></div></td>
    <td width="86" align=center nowrap bgcolor="#ffffcc"> <div align="left"><font color="#0000ff">電話號碼</font></div></td>
    <td width="100" align=center nowrap bgcolor="#ffffcc"> <div align="left"><font color="#0000ff">詳單</font></div></td>
  </tr>
  <%
//顯示數據

i = 0;
while(i<intpagesize && sqlrst.next()){rowi=rowi+1; %>
    <% if(rowi%2==0)
 {
    out.print("<tr bgcolor=#ccccff onmouseover=selectrow(this)>");
 }
 else
 {
 //out.print("<tr onmouseover="selectrow(this)"">;
 }
 %>
    <td height="18" valign="top" nowrap><%=sqlrst.getstring("客戶序號")%></td>
    <td valign="top" nowrap><%=sqlrst.getstring("客戶名稱")%></td>
    <td nowrap><%=sqlrst.getstring("賬號")%></td>
    <td nowrap><%=sqlrst.getstring("稅號")%></td>
    <td nowrap><%=sqlrst.getstring("開戶行")%></td>
    <td nowrap><%=sqlrst.getstring("電話號碼")%></td>
    <%   string customname=sqlrst.getstring("客戶序號");  
    out.print("<td width=9% nowrap><a href=customsingle.jsp?customer="+customname+">詳單</a></td>");
 %>
  </tr>
  <% i++; } %>
  <tr bgcolor="#ffccff">
    <td height="18" colspan=7 align=right> <div align="right"><font color="#0000ff">第<%=intpage%>頁 共<%=intpagecount%>頁 <a href="customdbqueary.jsp?page=1">首頁</a>
        <%if(intpage>1){%>
        <a href="customdbqueary.jsp?page=<%=intpage-1%>">上一頁</a>
        <%
}
%>
        <%if(intpage<intpagecount){%>
        <a href="customdbqueary.jsp?page=<%=intpage+1%>">下一頁</a>
        <%
}
%>
        <a href="customdbqueary.jsp?page=<%=intpagecount%>">尾頁&nbsp;</a>
        </font> </div></td>
    <td>&nbsp;</td>
  </tr>
  <tr align="right">
    <td height="22" colspan="8"  align="right"  valign="top" nowrap bgcolor="#ffffff">
      <form name="form1" method="post" action="" >
        <font color="#0000ff">轉到第
        <input type=text name=page size=2 maxlength=3 value='' style='height:16;vertical-align:8%'>
        頁
        <input class=buttonface type=submit value='go'>
        </font> </form></td>
  </tr>
  <tr align="right">
    <td height="22" colspan="8" align="right" valign="top"> <input  class=buttonface value="打印" type="button" onclick="printpage()"></td>
  </tr>
</table>


</body>

</html>
<%
//關閉結果集
sqlrst.close();
//關閉sql語句對象
sqlstmt.close();
//關閉數據庫
sqlcon.close();
%>

 

 

國內最大的酷站演示中心!
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 乐清市| 咸宁市| 额尔古纳市| 阜康市| 灵寿县| 留坝县| 呼伦贝尔市| 潼南县| 永泰县| 淮安市| 商水县| 株洲市| 体育| 房山区| 沙湾县| 巫溪县| 修水县| 临泉县| 博湖县| 老河口市| 新化县| 喀喇沁旗| 郧西县| 长宁县| 托里县| 乡宁县| 六枝特区| 邢台市| 清丰县| 梅州市| 新丰县| 永和县| 大英县| 明溪县| 井陉县| 公安县| 临漳县| 南华县| 靖边县| 丹凤县| 浦县|