⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 addsave.jsp

📁 公文办理系统
💻 JSP
字号:
<%@page contentType="text/html;charset=GBK"%>
<%@include file="..\..\const\global.jsp"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link rel="stylesheet" href="../../../../const/style.css" type="text/css">
</head>
<body background="../../image/backg2.gif">
<%
String StrMsg="";
try{
	Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
	sqlCon = java.sql.DriverManager.getConnection(ConnStr,ConnUser,ConnPassword);
	sqlStmt = sqlCon.createStatement();

	String p_dept=new String(request.getParameter("p_dept").getBytes("8859_1")); 
	String deptId1=new String(request.getParameter("deptId1").getBytes("8859_1"));
	String deptId=new String(request.getParameter("deptId").getBytes("8859_1")); 
	String deptName=new String(request.getParameter("deptName").getBytes("8859_1")); 
	String fzr=new String(request.getParameter("fzr").getBytes("8859_1")); 
	String dpinfo=new String(request.getParameter("dpinfo").getBytes("8859_1")); 
	String dpdemo=new String(request.getParameter("dpdemo").getBytes("8859_1")); 
	deptId=deptId1+deptId;

	String isYes="0";
	strSQL="select * from deptlist where deptid='"+deptId+"'";
	sqlRst = sqlStmt.executeQuery(strSQL);
	if(sqlRst.next()){
		isYes="1";
	}
	sqlRst.close();

	if(isYes.equals("0")){
		strSQL="insert into deptlist(p_dept,deptId,deptName,fzr,dpinfo,dpdemo) values('"+p_dept+"','"+deptId+"','"+deptName+"','"+fzr+"','"+dpinfo+"','"+dpdemo+"')";
		sqlStmt.executeUpdate(strSQL);

		strSQL="delete tree where id='"+deptId+"'";
		sqlStmt.executeUpdate(strSQL);

		strSQL="delete tree_user where id='"+deptId+"'";
		sqlStmt.executeUpdate(strSQL);
		//tree	--insert
		strSQL="insert into tree values('"+deptId+"','"+deptName+"','0','1','bal1.gif','fileadm\\default.jsp')";
		sqlStmt.executeUpdate(strSQL);
		//tree_user	--insert
		strSQL="insert into tree_user select a.userid,b.id,b.name,b.isopen,b.isend,b.icon,b.href,'0' from (select distinct userid  from tree_user)a,tree b where b.id='"+deptId+"'";
		sqlStmt.executeUpdate(strSQL);
		//tree	--update 父亲
		strSQL="update tree set isend='0',icon='plus1.gif',href=null where id='"+p_dept+"'";
		sqlStmt.executeUpdate(strSQL);
		//tree_user	--update 父亲
		strSQL="update tree_user set isend='0',icon='plus1.gif',href=null where id='"+p_dept+"'";
		sqlStmt.executeUpdate(strSQL);

		response.setHeader("Refresh","0;URL=default.jsp");
	}
	else{
		out.println("<font color=red>添加部门:该部门编号已经存在!!! 5秒后自动跳转</font>");
		response.setHeader("Refresh","5;URL=default.jsp");
	}

    //关闭SQL语句对象 
    sqlStmt.close();
    //关闭数据库
    sqlCon.close();
    }catch(SQLException s) { 
        StrMsg="SQL错误信息:"+s.toString()+" "+s.getErrorCode()+" "+s.getSQLState();
    }catch(Exception e) { 
        StrMsg="错误信息:"+e.toString()+e.getMessage();
    }

	if(!StrMsg.equals("")){
		out.println("<font color=red>"+StrMsg+"</font>");
	}
%>
</body>
</html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -