<%@ page contentType="text/html; charset=GBK" %>
<%@ page language="java" import="java.sql.*"%>
<jsp:useBean id="visitDbBean" scope="page" class="jspcontrol.VisitDbBean" />
<jsp:useBean id="timerBean" scope="page" class="jspcontrol.TimerBean" />
<jsp:useBean id="pageControlBean" scope="page" class="jspcontrol.PageControlBean" />
<jsp:useBean id="ygIdBean" scope="application" class="jspcontrol.YgIdBean" />
<%!
    ResultSet rs;
    String strUserId;//复核员Id
    int intMaxRow=0;
%>
<%
strUserId="";
if(session.getAttribute("userId")!=null)
    {
     strUserId =(String)session.getAttribute("userId");
    }
    else
    {
     %>
        <script>
                self.location="/logging.jsp";
         </script>
        <%
    }
%>
<%//建立连接!!!!!!!!!!!!!!!!!!!!!!!
if(visitDbBean.conDb()=="false")
{
%>
          <script>
          alert("数据库连接出错!,请刷新页面");
          </script>
        <%
}
%>
<%//定出一页的长度
 rs=visitDbBean.getRs("select count(*) as rowLong from employees"+
     " where employees.ygId In (SELECT empChange.ygId FROM empChange "+
               "WHERE empChange.shbz = '1' and empChange.czyId<>"+strUserId+")");
     while(rs.next())
     {
       intMaxRow=rs.getInt("rowLong");
     }
     rs.close();
%>
<head>
<META HTTP-EQUIV="Pragma" CONTENT="no-cache"> 
<META HTTP-EQUIV="Cache-Control" CONTENT="no-cache"> 
<META HTTP-EQUIV="Expires" CONTENT="0"> 
<meta http-equiv="Content-Language" content="zh-cn">
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<title>查询</title>
<link rel="stylesheet" type = "text/css" href="css/main.css">
<script language = "javascript">
function sendId(strYgId,strXm)//给出员工Id给gjxxxg.jsp页面
{
top.infoUpdate.location="gjxxsh.jsp?pYgId="+strYgId+"&pXm="+strXm; 
top.infoCon.location="gjxxshnr.jsp?pYgId="+strYgId;
}
</script>
</head>
<body>
<form method="Get|Post" name="selectInfo" action ="gjxxshcx.jsp" >
    <table class = "dgdTable" cellSpacing="1" cellPadding="0" align="center" border="0" width="250" >
    <tr height="25">
        <td class = "dgdHead">姓名</td>
        <td class = "dgdHead">单位</td>
        <td class = "dgdHead">部门</td>
    </tr>

解决方案 »

  1.   

    <%
         String btn_down =request.getParameter("btn");
         int pageNumber= pageControlBean.getPageNumber(intMaxRow);
         int currentPageNo=0;
         int i;
         if ( btn_down==null)
         {
           rs= visitDbBean.getRs("select employees.ygId,employees.xm,pUnits.dwmc,"+
               "pDepartment.bmmc from employees,pUnits,pDepartment where employees.dwId = pUnits.dwId and employees.bmId = pDepartment.bmId"+
                " and employees.ygId In (SELECT empChange.ygId FROM empChange "+
                   "WHERE empChange.shbz = '1' and empChange.czyId<>"+strUserId+") order by pUnits.dwmc,pDepartment.bmmc");
           pageControlBean.gotoPage(1,rs);
           currentPageNo=1;
           request.setAttribute("int_pageNo",new Integer(currentPageNo));
         }
         else
         {
           if(request.getParameter("oldPageNo")!=null)
           {
            currentPageNo=Integer.parseInt((String) request.getParameter("oldPageNo"));
           }
           else
           {
            currentPageNo=1;
           }
           rs= visitDbBean.getRs("select employees.ygId,employees.xm,pUnits.dwmc,"+
               "pDepartment.bmmc from employees,pUnits,pDepartment where employees.dwId = pUnits.dwId and employees.bmId = pDepartment.bmId"+
                " and employees.ygId In (SELECT empChange.ygId FROM empChange "+
                   "WHERE empChange.shbz = '1' and empChange.czyId<>"+strUserId+") order by pUnits.dwmc,pDepartment.bmmc");
           if(btn_down.equals("9"))
           {
               pageControlBean.gotoPage(1,rs);
               currentPageNo=1;
               request.setAttribute("int_pageNo",new Integer(currentPageNo));
           }
           else if (btn_down.equals("3"))
           {
               currentPageNo -=1;
               if(currentPageNo==0)
               {
                   currentPageNo =1;
               }
               pageControlBean.gotoPage(currentPageNo,rs);
               request.setAttribute("int_pageNo",new Integer(currentPageNo));
           }
           else if (btn_down.equals("4"))
           {
               currentPageNo +=1;
               if(pageNumber<currentPageNo)
               {
                   currentPageNo -=1;
               }
               pageControlBean.gotoPage(currentPageNo,rs);
               request.setAttribute("int_pageNo",new Integer(currentPageNo));
           }
           else if (btn_down.equals(":"))
           {
               int lastPage = pageControlBean.getPageNumber(intMaxRow);
               currentPageNo=pageNumber;
               request.setAttribute("int_pageNo",new Integer(currentPageNo));
               pageControlBean.gotoPage(lastPage,rs);
           }
           else
           {
               pageControlBean.gotoPage(currentPageNo,rs);
           }
         }
      

  2.   

    i=0;
           try
           {
               String strYgId=new String();
               String strXm=new String();
               String strDw=new String();
               String strBm=new String();
               while(rs.next())
               {
                   strYgId=rs.getString("ygId");
                   strXm=rs.getString("xm");
                   strDw=rs.getString("dwmc");
                   strBm=rs.getString("bmmc");
                   i=i+1;
                   if(i>3)
                   {
                       break;
                   }
                   out.println("<tr>");
                   out.println("<td class=\"dgdItem\"><a href=\"Javascript:sendId('"+strYgId+"','"+strXm+"')\">"+strXm+"</a></td>");
       %>
           <td class="dgdItem"><%= strDw%></td>
           <td class="dgdItem"><%= strBm%></td>
        </tr>
        <%
         }
         rs.close();
        }catch(Exception e1)
        {
            out.println("<script> alert('数据库读取出错!') </script>");
        }
         %>
      </table>
      <%
         if (btn_down==null)
         {%>
            <table width="250" align="center">
              <tr>
                   <td width="50%">
                    <input class="button1" type="submit" name="btn" value="9" >
                    <input class="button1" type="submit" name="btn" value="3" >
                    <input class="button1" type="submit" name="btn" value="4" >
                    <input class="button1" type="submit" name="btn" value=":" >
                    </td>
                    <td width="30%" align="left">
                    </td>
                    <td width="20%" align="right">第<%= currentPageNo%>页
                        共<%= pageNumber%>页</td>
               </tr>
               </table>
          <%
          }
          else
          {%>
           <table width="250" align="center">
              <tr>
                    <td width="50%">
                    <input class="button1" type="submit" name="btn" value="9" >
                    <input class="button1" type="submit" name="btn" value="3" >
                    <input class="button1" type="submit" name="btn" value="4" >
                    <input class="button1" type="submit" name="btn" value=":" >
                    </td>
                    <td width="25%" align="left">
                    </td>
                    <td width="25%" align="middle">第<%= currentPageNo%>页
                        共<%= pageNumber%>页</td>
               </tr>
            </table>
          <%
           }
           %>
           <input class="textBox" value = "<%=currentPageNo %>" name="oldPageNo" style="visibility:hidden" >
           <%
            //关闭数据库连接!!!!!!!!!!!!!!!!!
          visitDbBean.closeCon();
           %>
    </form>
    </body>
    </html>