Operate_Column.jsp
资源名称:zyp.rar [点击查看]
上传用户:zdly666
上传日期:2022-08-09
资源大小:6511k
文件大小:3k
源码类别:
WEB源码(ASP,PHP,...)
开发平台:
JavaScript
- <%@ page contentType="text/html; charset=gb2312" language="java" import="java.sql.*" errorPage="" %>
- <%@ include file="conn.jsp"%>
- <%@page import="java.util.Date"%>
- <%@page import="java.util.*"%>
- <%@page import="java.text.*"%>
- <%@ page import ="java.io.* "%>
- <%@page import="com.oreilly.servlet.MultipartRequest"%>
- <html>
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
- <link rel="stylesheet" type="text/css" href="Admin_Style.css">
- <title>博客文章管理</title>
- </head>
- <body>
- <jsp:useBean id="pathtest" class="yu.beans.path_test" scope="page"/>
- <%
- String EditType=new String(request.getParameter("EditType").getBytes("ISO-8859-1"));//操作类别
- if(EditType==null||EditType.equals("null")){
- out.println("抱歉,参数出错!");
- out.close();
- }else{
- %>
- <%
- String sqlStr1="";
- String sqlStr2="";
- //删除栏目操作
- if(EditType.equals("columnDel"))
- {
- //对应的栏目id
- String EditID=new String(request.getParameter("columnid").getBytes("ISO-8859-1"));
- if(EditID==null||EditID.equals("null")){
- out.println("抱歉,参数出错!");
- }else{
- //删除栏目
- sqlStr1="delete from S_fileColumn where column_id ='"+EditID+"'";
- //删除栏目对应的文件
- pathtest.initialize(pageContext);//初始化
- String savaPath=pathtest.getPhysicalPath("/Media/file/",0);
- String DelfileSQL="select * from S_fileInfor where column_id='"+EditID+"'";
- rs=stmt.executeQuery(DelfileSQL);
- rs.last();
- int size=rs.getRow();
- String FileName[]=new String[size];
- rs.first();
- try
- {
- for(int j=0;j<FileName.length;j++)
- {
- String file_name=rs.getString("file_name");
- FileName[j]=file_name;
- File DelFile= new File(savaPath,FileName[j] );
- boolean lzquan=DelFile.delete();
- rs.next();
- //out.print(FileName[j]+" has deleted ");
- }
- }catch(Exception e)
- {
- out.print(e.getMessage());
- }
- //删除栏目表中对应的记录
- sqlStr2="delete from S_fileInfor where column_id ='"+EditID+"'";
- stmt.executeUpdate(sqlStr1);
- stmt.executeUpdate(sqlStr2);
- stmt.close();
- conn.close();
- response.sendRedirect("Manage_Column.jsp");
- }
- }
- //添加栏目操作
- if(EditType.equals("columnAdd"))
- {
- String column_name=new String(request.getParameter("column_name").getBytes("ISO-8859-1"));//栏目名称
- if(column_name==null||column_name.equals("null")){
- out.println("抱歉,参数出错!"); }else{
- sqlStr1="insert into S_fileColumn(column_name) values('"+column_name+"')";
- stmt.executeUpdate(sqlStr1);
- stmt.close();
- conn.close();
- response.sendRedirect("Manage_Column.jsp");
- }
- }
- //修改栏目
- if(EditType.equals("columnEdit"))
- {
- String ColumnName=new String(request.getParameter("columnName").getBytes("ISO-8859-1"));
- String EditID=new String(request.getParameter("columnid").getBytes("ISO-8859-1"));
- if(ColumnName==null||ColumnName.equals("null"))
- {
- out.println("抱歉,参数出错!");
- }
- else
- {
- sqlStr1 = "update S_fileColumn set column_name='"+ColumnName+"'where column_id='"+EditID+"'";
- out.print(sqlStr1);
- stmt.executeUpdate(sqlStr1);
- stmt.close();
- conn.close();
- out.print("<script>");
- out.print("opener.location.reload();");
- out.print("window.close();");
- out.print("</script>");
- }
- }
- }%>
- </body>
- </html>