delhw.jsp
上传用户:helenhuo66
上传日期:2007-06-01
资源大小:865k
文件大小:6k
源码类别:

百货/超市行业

开发平台:

Java

  1. <%@ page contentType="text/html;charset=GBK" language="java" import="java.sql.*,java.util.Date" errorPage="" %>
  2. <%@ include file="conn.jsp"%>
  3. <%
  4. if(session.getAttribute("admin_name")!=null){
  5. //--------------------------------------logged------------------------------------------------------------------
  6. %>
  7. <html><head>
  8. <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
  9. <link href=../css.css rel=STYLESHEET type=text/css>
  10. </head>
  11. <%
  12. String action=request.getParameter("action");
  13. if(action!=null)
  14. {   action=action.trim();
  15.    if(action.equals("del"))
  16.    {int n=0;
  17.     sql="delete * from hw where hw_id="+Cint(request.getParameter("hw_id"));
  18.     mdb.executeDelete(sql);
  19.     out.print("货物删除成功");
  20.     out.print("<br>");
  21.     out.print ("<a href=delhw.jsp>返回</a>");
  22. }
  23. }else
  24. {
  25. %>
  26. <div align="center">
  27.   <center>
  28. <table width="550" border="0" cellspacing="0" cellpadding="0" bgcolor="#808080" style="border-collapse: collapse" bordercolor="#111111" >
  29.   <tr>
  30.     <td>
  31.       <table width="100%" border="0" cellspacing="1" cellpadding="0" height="73" align="center">
  32.             <!--DWLayoutTable-->
  33.             <tr> 
  34.               <td width="123" height="20" valign="top" bgcolor="#808080"> 
  35.                 <div align="center"><font color="#FFFFFF">商品名称</font></div></td>
  36.               <td width="80" valign="top" bgcolor="#808080"> <div align="center"><font color="#FFFFFF">作者 
  37.                   </font> </div></td>
  38.               <td width="78" valign="top" bgcolor="#808080"> 
  39.                 <div align="center"><font color="#FFFFFF">会员价</font></div></td>
  40.               <td width="75" valign="top" bgcolor="#808080">
  41. <div align="center"><font color="#FFFFFF">ISBN号码</font></div></td>
  42.               <td width="103" valign="top" bgcolor="#808080"> <div align="center"><font color="#FFFFFF">加入日期</font></div></td>
  43.               <td colspan="3" valign="top" bgcolor="#808080"> <div align="center"><font color="#FFFFFF">操作</font></div></td>
  44.             </tr>
  45.             <%
  46. int PageSize =20; //设置每张网页显示两条记录
  47. int ShowPage = 1; //设置欲显示的页数
  48. int RowCount = 0; //ResultSet的记录数目
  49. int PageCount = 0; //ResultSet分页后的总页数
  50. int duoyu=0;
  51. sql="select * from hw order by hw_id DESC";
  52. rs=mdb.executeQuery(sql);
  53. if(rs.next())
  54. {  
  55.   //建立ResultSet(结果集)对象,并执行SQL语句
  56.     rs.last(); //将指标移至最后一笔记录
  57.     RowCount=rs.getRow();
  58.     duoyu=RowCount % PageSize;
  59.     if(duoyu==0)
  60.      {
  61.           PageCount=RowCount/PageSize;
  62.       }
  63.      else{
  64.       PageCount=(RowCount-duoyu)/PageSize;
  65.        PageCount++;
  66.       }
  67.  // PageCount=((RowCount % PageSize) == 0?(RowCount/PageSize) : (RowCount/PageSize)+1);
  68.   //计算显示的页数
  69.     String ToPage = request.getParameter("ToPage");
  70.     if(ToPage==""){ToPage="1";}
  71. //判断是否可正确取得ToPage参数, 
  72. //可取得则表示JSP网页应显示特定分页记录的语句
  73.    if(ToPage!=""){
  74.       ShowPage =Cint(ToPage); //取得指定显示的分页页数
  75.    //下面的if语句将判断用户输入的页数是否正确
  76.        if(ShowPage > PageCount)
  77.        { //判断指定页数是否大于总页数, 是则设置显示最后一页
  78.            ShowPage = PageCount;
  79.        } else if(ShowPage <= 0)
  80.        { //若指定页数小于0, 则设置显示第一页的记录
  81.               ShowPage = 1;
  82.         }
  83.     }
  84. rs.absolute((ShowPage - 1) * PageSize+1); 
  85. //计算欲显示页的第一笔记录位置
  86. %>
  87.             <!----------------------one showing unit------------------------------->
  88.             <%
  89.  //利用For循环配合PageSize属性输出一页中的记录
  90.    int i=1,linshi=1;
  91.   linshi=ShowPage;
  92.   rs.previous();
  93.    String hw_sn,isbn;
  94.    int hw_id;
  95.   while(rs.next()&i<= PageSize)
  96.  {
  97.      i++;
  98.      hw_id=rs.getInt("hw_id"); 
  99. %>
  100.             <tr bgcolor="#FFFFFF"> 
  101.               <td height="18" valign="middle"><%=rs.getString("hw_name")%> </td>
  102.               <td valign="middle"> 
  103.                 <div align="center"><%=rs.getString("hw_sn")%></div></td>
  104.               <td valign="middle"> 
  105.                 <div align="center"><%=rs.getInt("hw_cash")%></div></td>
  106.               <td valign="middle"> 
  107.                 <div align="center"><%=rs.getString("isbn")%></div></td>
  108.               <td valign="middle"> 
  109.                 <div align="center"><%=rs.getDate("hw_date")%></div></td>
  110.               <td width="42" valign="middle"> 
  111.                 <div align="center"> <a href="delhw.jsp?hw_id=<%=hw_id%>&action=del">删除</a></div></td>
  112.               <td colspan="2" valign="middle"> 
  113.                 <div align="center"><a href="changehw.jsp?hw_id=<%=hw_id%>&sort_id=<%=rs.getInt("sort_id")%>&Nsort_id=<%=rs.getInt("Nsort_id")%>">修改</a> 
  114.                 </div></td>
  115.             </tr>
  116.             <%
  117. //下面的if判断语句用于防止输出最后一页记录时, 
  118. //将记录指标移至最后一笔记录之后
  119.  //跳出for循环
  120.    }
  121.  %>
  122.             <!-----------------------shonwing unit end----------------------------------------------->
  123.             <tr> 
  124.               <td height="20" colspan="7" valign="middle"> 
  125.                 <div align="center">第<%=ShowPage%>页/共<%=PageCount%>页&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
  126.                   <%
  127.                  linshi=ShowPage-1;
  128.  if(linshi>0)
  129.  {%>
  130.                   <a href="delhw.jsp?ToPage=<%=linshi%>">上一页</a> 
  131.                   <%
  132.  }else
  133. {%>
  134.                   上一页 
  135.                   <%}   linshi=ShowPage+1;
  136. if(linshi<=PageCount)
  137. {%>
  138.                   <a href="delhw.jsp?ToPage=<%=linshi%>">下一页</a> 
  139.                   <%
  140. }else
  141.   {%>
  142.                   下一页 
  143.                   <%}%></font>
  144.                   </div></td>
  145.               <td width="11">&nbsp;</td>
  146.             </tr>
  147.             <tr> 
  148.               <td height="2"></td>
  149.               <td></td>
  150.               <td></td>
  151.               <td></td>
  152.               <td></td>
  153.               <td></td>
  154.               <td width="29"></td>
  155.               <td></td>
  156.             </tr>
  157.             <%
  158. rs.close();
  159. }
  160. else
  161. {//数据库中无新闻
  162.      out.print("对不起,没有产品!");
  163. }
  164. %>
  165.           </table>
  166.     </td>
  167.   </tr>
  168. </table>
  169.   </center>
  170. </div>
  171. <%
  172. }
  173. mdb.Close();
  174. %>
  175. <%}
  176. else{
  177. //--------------------------------------not logged------------------------------------------------------------------
  178. response.sendRedirect("index.jsp");
  179. }%>