Operate_Column.jsp
上传用户:zdly666
上传日期:2022-08-09
资源大小:6511k
文件大小:3k
源码类别:

WEB源码(ASP,PHP,...)

开发平台:

JavaScript

  1. <%@ page contentType="text/html; charset=gb2312" language="java" import="java.sql.*" errorPage="" %>
  2. <%@ include file="conn.jsp"%>
  3. <%@page import="java.util.Date"%>
  4. <%@page import="java.util.*"%>
  5. <%@page import="java.text.*"%>
  6. <%@ page import ="java.io.* "%>
  7. <%@page import="com.oreilly.servlet.MultipartRequest"%>
  8. <html>
  9. <head>
  10. <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
  11. <link rel="stylesheet" type="text/css" href="Admin_Style.css">
  12. <title>博客文章管理</title>
  13. </head>
  14. <body>
  15. <jsp:useBean id="pathtest" class="yu.beans.path_test" scope="page"/>
  16. <%
  17. String EditType=new String(request.getParameter("EditType").getBytes("ISO-8859-1"));//操作类别
  18. if(EditType==null||EditType.equals("null")){
  19. out.println("抱歉,参数出错!");
  20. out.close();
  21. }else{
  22. %>
  23. <%
  24.   String sqlStr1="";
  25. String sqlStr2="";
  26. //删除栏目操作
  27. if(EditType.equals("columnDel"))
  28. {
  29. //对应的栏目id
  30. String EditID=new String(request.getParameter("columnid").getBytes("ISO-8859-1"));
  31. if(EditID==null||EditID.equals("null")){
  32. out.println("抱歉,参数出错!");
  33. }else{
  34. //删除栏目
  35. sqlStr1="delete from S_fileColumn where column_id ='"+EditID+"'";
  36. //删除栏目对应的文件
  37. pathtest.initialize(pageContext);//初始化
  38. String savaPath=pathtest.getPhysicalPath("/Media/file/",0);
  39. String DelfileSQL="select * from S_fileInfor where column_id='"+EditID+"'";
  40.  rs=stmt.executeQuery(DelfileSQL);
  41. rs.last();
  42. int size=rs.getRow();
  43. String FileName[]=new String[size];
  44. rs.first();
  45. try
  46. {
  47. for(int j=0;j<FileName.length;j++)
  48. {
  49. String file_name=rs.getString("file_name");
  50. FileName[j]=file_name;
  51. File DelFile= new File(savaPath,FileName[j] );
  52. boolean lzquan=DelFile.delete();
  53. rs.next();
  54. //out.print(FileName[j]+" has deleted            ");
  55. }
  56. }catch(Exception e)
  57. {
  58. out.print(e.getMessage());
  59. }
  60. //删除栏目表中对应的记录
  61. sqlStr2="delete from S_fileInfor where column_id ='"+EditID+"'";
  62. stmt.executeUpdate(sqlStr1);
  63. stmt.executeUpdate(sqlStr2);
  64. stmt.close(); 
  65. conn.close();
  66. response.sendRedirect("Manage_Column.jsp");
  67. }
  68. }
  69. //添加栏目操作
  70. if(EditType.equals("columnAdd"))
  71. {
  72. String column_name=new String(request.getParameter("column_name").getBytes("ISO-8859-1"));//栏目名称
  73. if(column_name==null||column_name.equals("null")){
  74. out.println("抱歉,参数出错!"); }else{
  75. sqlStr1="insert into S_fileColumn(column_name) values('"+column_name+"')";
  76. stmt.executeUpdate(sqlStr1);
  77. stmt.close(); 
  78. conn.close();
  79. response.sendRedirect("Manage_Column.jsp");
  80. }
  81. }
  82. //修改栏目
  83. if(EditType.equals("columnEdit"))
  84. {
  85. String ColumnName=new String(request.getParameter("columnName").getBytes("ISO-8859-1"));
  86. String EditID=new String(request.getParameter("columnid").getBytes("ISO-8859-1"));
  87. if(ColumnName==null||ColumnName.equals("null"))
  88. {
  89. out.println("抱歉,参数出错!");
  90. }
  91. else
  92. {
  93. sqlStr1 = "update  S_fileColumn set column_name='"+ColumnName+"'where column_id='"+EditID+"'";
  94. out.print(sqlStr1);
  95. stmt.executeUpdate(sqlStr1);
  96. stmt.close(); 
  97. conn.close();
  98. out.print("<script>");
  99. out.print("opener.location.reload();");
  100. out.print("window.close();");
  101. out.print("</script>");
  102. }
  103. }
  104. }%>
  105. </body>
  106. </html>