<!doctype html public "-//w3c//dtd html 4.0 transitional//en" "http://www.w3.org/TR/REC-html40/strict.dtd">
<%@page contentType="text/html;charset=shift_JIS" language="java" import="java.sql.*,java.io.*,java.text.*,java.util.*,javax.servlet.jsp.*" %>
<%!String trans(String chi)
<% 
request.setCharacterEncoding("shift_JIS");
java.sql.Connection sqlCon;
java.sql.Statement sqlStmt;
java.sql.ResultSet sqlRst;
java.lang.String strCon;
java.lang.String strSQL;
java.lang.String strPage;
int intPageSize;
int intRowCount;
int intPageCount;
int intPage;
int i;
        //从上一页文本框内获取要检索的信息
String id = request.getParameter("id");
String nm = request.getParameter("nm");
String age = request.getParameter("age");
String sectioncd = request.getParameter("sectioncd");
String tel = request.getParameter("tel");
String email = request.getParameter("email");
String reday1 = request.getParameter("reday1");
String reday2 = request.getParameter("reday2");
String upday1 = request.getParameter("upday1");
String upday2 = request.getParameter("upday2");

intPageSize=20;
strPage=request.getParameter("page");
if(strPage==null)
{
intPage=1;
}
else
{
intPage=java.lang.Integer.parseInt(strPage);
if(intPage<1)
intPage=1;
}
Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
strCon="jdbc:microsoft:sqlserver://127.0.0.1:1433;DatabaseName=TEST";
sqlCon=java.sql.DriverManager.getConnection(strCon,"test","test01");
sqlStmt=sqlCon.createStatement(java.sql.ResultSet.TYPE_SCROLL_INSENSITIVE,java.sql.ResultSet.CONCUR_READ_ONLY);
strSQL="select * from M_USER,M_SECTION where (M_USER.SECTIONCD=M_SECTION.SECTIONCD) and ( (M_USER.USERCD like '%"+id+"' or M_USER.USERCD like '%"+id+"%') and (M_USER.NM like '%"+nm+"%') and (M_USER.AGE like '%"+age+"%' or AGE = '"+age+"') and (M_USER.SECTIONCD like '%"+sectioncd+"%') and (M_USER.TEL like '"+tel+"%' or M_USER.TEL like '%"+tel+"%') and (M_USER.EMAIL like '%"+email+"%') and ((M_USER.REG_DT between '"+reday1+"' and '"+reday2+"' or (M_USER.REG_DT >= '"+reday1+"' and M_USER.REG_DT like '%"+reday2+"%')) or (M_USER.REG_DT like '%"+reday1+"%' and M_USER.REG_DT like '%"+reday2+"%')) and ((M_USER.UP_DT between '"+upday1+"' and '"+upday2+"' or (M_USER.UP_DT >= '"+upday1+"' and M_USER.REG_DT like '%"+upday2+"%')) or (M_USER.UP_DT like '%"+upday1+"%' and M_USER.UP_DT like '%"+upday2+"%'))) order by M_USER.USERCD;";
sqlRst=sqlStmt.executeQuery(strSQL);
sqlRst.last();
intRowCount=sqlRst.getRow();
intPageCount=(intRowCount+intPageSize-1)/intPageSize;
if(intPage>intPageCount)
intPage=intPageCount;

 %>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=shift_JIS">
<title>ページの処理</title>
</head>
<LINK href="hellking.css" type=text/css tel=stylesheet>
<body topmargin="50px" leftmargin="30px">
<form method="POST" action="searchbottom.jsp">
<%=(intPage-1)*intPageSize+1%>/<%=intRowCount%>
  <% if(intPage>1){ %>
  <a href="searchbottom.jsp?page=1">先  頭</a>
  <% } %>
  
  <% if(intPage>1){ %>
  <a href="searchbottom.jsp?page=<%=intPage-1%>">前一頁</a>
  <% } %>
  
  <% if(intPage<intPageCount){ %>
  <a href="searchbottom.jsp?page=<%=intPage+1%>">次一頁</a>
  <% } %>
  
  <% if(intPage<intPageCount){ %>
  <a href="searchbottom.jsp?page=<%=intPageCount%>">最  後</a>
  <% } %>
移動第:<input type="text" name="page" size="8">頁
<span><input class="buttonface" type="submit" value="GO" name="cndok"></span>&nbsp;&nbsp;第<%=intPage%>頁/共<%=intPageCount%>頁
<hr>
</form>
<table border=1 cellspacing="0" cellPadding="0">
<tr>
<th>ユーザーコード</th>
<th>パスワード</th>
<th>名称</th>
<th>カナ</th>
<th>年齢</th>
<th>部署</th>
<th>電話番号</th>
<th>Email</th>
<th>作成日</th>
<th>更新日</th>
<th width="8%">更新</th>
<th width="8%">詳細</th>
</tr>
<% 
if(intPageCount>0)
{
sqlRst.absolute((intPage-1)*intPageSize+1);
i=0;
while(i<intPageSize && !sqlRst.isAfterLast())
{
out.println("<tr>");
out.println("<td>"+trans(sqlRst.getString("USERCD"))+"</td>");
out.println("<td>"+trans(sqlRst.getString("PASSWD"))+"</td>");
out.println("<td>"+trans(sqlRst.getString("NM"))+"</td>");
out.println("<td>"+trans(sqlRst.getString("KANA"))+"</td>");
out.println("<td>"+sqlRst.getInt("AGE")+"</td>");
out.println("<td>"+trans(sqlRst.getString("SECTIONNM"))+"</td>");
out.println("<td>"+trans(sqlRst.getString("TEL"))+"</td>");
out.println("<td>"+trans(sqlRst.getString("EMAIL"))+"</td>");
out.println("<td>"+sqlRst.getDate("REG_DT")+"</td>");
out.println("<td>"+sqlRst.getDate("UP_DT")+"</td>");
 %>
<td width="8%" align="center">
<a href="searchupdate.jsp?nu=<%=sqlRst.getString("USERCD")%>" target="topFrame">更新</a></td>
<td width="8%" align="center">
<a href="searchinfo.jsp?nu=<%=sqlRst.getString("USERCD")%>" target="topFrame">詳細</a></td>
</tr>
<%
sqlRst.next();
i++;
}
}
%>
</table>
<div align="center">
<hr>
now time is:
<%=new java.util.Date()%></div>
</body>
</html><% 
sqlRst.close();
sqlStmt.close();
sqlCon.close();
 %>