📄 manager_meeting.jsp
字号:
<%@ page errorPage="ErrPage.jsp"
import="java.util.Date, java.sql.*"
contentType="text/html;charset=gb2312"%>
<jsp:useBean id="pool" scope="application" class="com.PoolBean"/>
<%
String strLoginUser = (String)session.getAttribute("LoginUser");
if (strLoginUser == null || strLoginUser.length() == 0)
response.sendRedirect("../Login.jsp");
%>
<HTML>
<HEAD>
<LINK REL="stylesheet" HREF="../littleproject.css" TYPE="text/css">
<TITLE>会务管理</TITLE>
</HEAD>
<BODY bgcolor=LightBlue>
<%
try{
//得到注册用户的用户名
if (pool.getConnectionSize() == 0)
{
pool.initializePool();
}
Connection con = null;
Statement stmt = null;
ResultSet rs=null;
int PageSize = 10; //设置每张网页显示十条记录
int ShowPage = 1; //设置欲显示的页数
int RowCount = 0; //ResultSet的记录笔数
int PageCount = 0; //ResultSet分页后的总页数
int p,m,n;
double box_1=0;
double box_2=0;
con = pool.getConnection();
stmt = con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,
ResultSet.CONCUR_READ_ONLY);
//建立Statement对象, 并设置记录指标类型为可前后移动
String sql=null;
String search_txt="";
String ToPage = request.getParameter("ToPage");
String box_title="";
String box_place="";
if (request.getParameter("box_title") != null && !request.getParameter("box_title").equals(""))
{
box_title= new String(request.getParameter("box_title").trim().getBytes("8859_1"));
if (box_title != null && !box_title.equals(""))
{
box_1=Double.parseDouble(box_title);
}
}
if (request.getParameter("box_place") != null && !request.getParameter("box_place").equals(""))
{
box_place= new String(request.getParameter("box_place").trim().getBytes("8859_1"));
if (box_place != null && !box_place.equals(""))
{
box_2=Double.parseDouble(box_place);
}
}
if (request.getParameter("search_txt") != null && !request.getParameter("search_txt").equals(""))
{
search_txt = new String(request.getParameter("search_txt").trim().getBytes("8859_1"));
}
if (search_txt != null && !search_txt.equals("")) //
{
if(box_1==0 && box_2==0 )
{
sql="select * from meeting where num like '%" + search_txt + "%'";
sql=sql + " or title like '%" + search_txt + "%'";
sql=sql + " or begin_time like '%" + search_txt + "%' or end_time like '%" + search_txt + "%'";
sql=sql + " or place like '%" + search_txt + "%'";
sql=sql + "order by num";
}
else
{
sql="select * from meeting where";
if(box_1==1)
{
sql=sql + " title like '%" + search_txt + "%'";
}
if(box_2==1)
{
if(box_1==0)
{
sql=sql + " place like '%" + search_txt + "%'";
}
else
{
sql=sql + " or place like '%" + search_txt + "%'";
}
}
sql=sql + " order by num";
}
}
else
{
sql="SELECT id,num,title,place FROM meeting order by num";
}
rs = stmt.executeQuery(sql);
rs.last(); //将指标移至最后一笔记录
RowCount = rs.getRow(); //取得ResultSet中记录的笔数
PageCount = ((RowCount % PageSize) == 0 ?
(RowCount/PageSize) : (RowCount/PageSize)+1);
//计算显示的页数
//判断是否可正确取得ToPage参数,
//可取得则表示JSP网页应显示特定分页记录的语句
if(ToPage != null)
{
//取得指定显示的分页页数
ShowPage = Integer.parseInt(ToPage);
//下面的if语句将判断用户输入的页数是否正确
if(ShowPage > PageCount)
{
//判断指定页数是否大于总页数, 是则设置显示最后一页
ShowPage = PageCount;
}
else if(ShowPage <= 0)
{ //若指定页数小于0, 则设置显示第一页的记录
ShowPage = 1;
}
}
rs.absolute((ShowPage - 1) * PageSize + 1);
//计算欲显示页的第一笔记录位置
%>
<center>
<table border="0" width="800">
<tr>
<td colspan="2">
<font size="6" face="隶书">会议管理首页</font>
</td>
</tr>
<tr>
<td width="600" height="10">
<%
if (search_txt != null && !search_txt.equals(""))
{
%>
下是包含关键字<font color="#ff0000"><%=search_txt%></font>的所有信息
<%
}
else
{
%>
以下是所有的信息<% } %>
共:<font color="blue"><%=RowCount%></font>条 共<font color="blue"><%=PageCount%></font>页 当前页为第<font color="red"><%=ShowPage%></font>页
<%
if (PageCount>1)
{
if (ShowPage-3>0)
{
m=ShowPage-3;
}
else
{
m=1;
}
if (ShowPage+3<PageCount)
{
n=ShowPage+3;
}
else
{
n=PageCount;
}
%>
转到页码:[
<%
for( p=m;p<=n;p++)
{
if( ShowPage==p )
{
%>
<font color="red"><b><%=p%></b></font>
<%
}
else
{
%>
<a <%
if (ShowPage==p)
{
%>
style="color:red"
<%
}
%>
href="manager_meeting.jsp?ToPage=<%=p%>&search_txt=<%=search_txt%>
&box_title=<%=box_title %>&box_place=<%=box_place %>">
<%=p%>
</a>
<%
}
}
%>
]
<%
}
%>
</td>
<td width="200" align="right">
<a href="manager_meeting_add.jsp">新建会议</a>
<img border="0" src="images/image.gif" width="30" height="30"><a href="default.jsp"> 退出管理</a> </td>
</tr>
</table>
<TABLE border=1 bordercolor=RoyalBlue bgcolor=LightBlue width=800>
<tr>
<TD bgcolor=LightYellow width=50 align=center>序号</TD>
<TD bgcolor=LightYellow width=350 align=center>会议主题</TD>
<TD bgcolor=LightYellow width=250 align=center>会议地址</TD>
<TD bgcolor=LightYellow width=75 align=center>修改</TD>
<TD bgcolor=LightYellow width=75 align=center>删除</TD>
</tr>
<%
//利用For循环配合PageSize属性输出一页中的记录
for(int i = 1; i <= PageSize; i++)
{
int select_id = rs.getInt("id");
int select_num = rs.getInt("num");
String select_title= rs.getString("title");
String select_place= rs.getString("place");
out.println("<TR>");
out.println("<TD align=center width=50>" + select_num +"</TD>");
out.println("<TD align=center width=350>" + select_title +"</TD>");
out.println("<TD align=center width=250>" + select_place +"</TD>");
out.println("<TD align=center width=75><a href=manager_meeting_edit.jsp?num="+select_num+">修改</a></TD>");
out.println("<TD align=center width=75><a href=manager_meeting_delete.jsp?num="+select_num+">删除</a></TD>");
out.println("</TR>");
if(!rs.next()) //判断是否到达最后一笔记录
break; //跳出for循环
}
%>
</TABLE>
<TABLE border="0" width="700">
<TR valign=baseline align=center>
<td width=500> </td>
<%
if(ShowPage != 1)
{
%>
<TD Width=50>
<A Href=manager_meeting.jsp?ToPage=<%= 1 %>
&search_txt=<%=search_txt%>&box_title=<%=box_title %>
&box_place=<%=box_place %>>第一页</A>
</TD>
<TD Width=50>
<A Href=manager_meeting.jsp?ToPage=<%= ShowPage - 1 %>
&search_txt=<%=search_txt%>&box_title=<%=box_title %>
&box_place=<%=box_place %>>上一页</A>
</TD>
<%
}
if(ShowPage != PageCount)
{
%>
<TD Width=50>
<A Href=manager_meeting.jsp?ToPage=<%= ShowPage + 1%>
&search_txt=<%=search_txt%>&box_title=<%=box_title %>
&box_place=<%=box_place %>>下一页</A>
</TD>
<TD Width=50>
<A Href=manager_meeting.jsp?ToPage=<%= PageCount %>
&search_txt=<%=search_txt%>&box_title=<%=box_title %>
&box_place=<%=box_place %>>最后页</A>
</TD>
<%
}
%>
</TR>
</TABLE>
<FORM action=manager_meeting.jsp method=POST>
<table border="0" width="800" align="center" cellspacing="0">
<tr>
<td align="center">
<input type="checkbox" name="box_title" value="1">会议主题
<input type="checkbox" name="box_place" value="1">会议地址
</td>
</tr>
<tr>
<td width="700" align="center">
<img border="0" src="images/new1[1].gif" width="30" height="25">
信息关键字搜索:
<input type="text" name="search_txt" size="17"
value="<%=search_txt%>">
<input type="submit" value="搜索" name="B1">
</td>
</tr>
<tr>
<td width="700" align="center">
<font color="red">(如果关键字内容为空则列出所有信息)</font>
</td>
</tr>
</table>
</form>
</CENTER>
<%
if (rs != null) rs.close();
pool.releaseConnection(con);
}
catch(Exception e)
{
System.out.println("Exception: " + e.getMessage());
}
%>
</BODY>
</HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -