欢迎光临
我们一直在努力

JSP实现树型组织架构(5)–删除部门页面orgDelete.jsp-JSP教程,Jsp/Servlet

建站超值云服务器,限时71元/月

//orgdelete.jsp 删除部门页面,由orgmanage.jsp 而来

<%@ page contenttype="text/html;charset=big5"%>

<%@ include file="orgconninclude.jsp"%>

<%@ page import="javax.sql.*"%>

<%

request.setcharacterencoding("big5");

string depname=request.getparameter("name");

//out.println(depname+"<br>");

string message=null;

boolean autocommit=conn.getautocommit();

string query1=" select total "+

" from ngb_org "+

" where name="+depname+" ";

string query2=" select * "+

" from ngb_org "+

" where total like ? ";

string delete=" delete from ngb_org "+

" where total like ? ";

string delete1=" delete from ngb_org "+

" where name=? ";

string temp1=null;

string temp1a=null;

string temp1aa=null;

string temp1b=null;

try{

conn.setautocommit(false);

preparedstatement ps=conn.preparestatement(query1);

resultset rs1=ps.executequery();

while(rs1.next())

{temp1=rs1.getstring("total");}

//out.println(temp1);

temp1a=temp1.substring(0,1);

temp1aa=temp1.substring(0,3);

temp1b=temp1.substring(3,6);

//out.println(temp1b);

/* 刪除部門級:第二層,所屬第三層,每個第三層所屬第四層一起刪除*/

if(temp1a.equals("b"))

{

ps=conn.preparestatement(delete);

ps.setstring(1, temp1);

int resultb1=ps.executeupdate();

if(resultb1>0){

//out.println("delete b success!!!!");

ps=conn.preparestatement(query2);

ps.setstring(1, temp1b+"%");

resultset resultb2=ps.executequery();

while(resultb2.next()){

temp1=resultb2.getstring("total");

string namec1=resultb2.getstring("name");

temp1a=temp1.substring(0,1);

temp1aa=temp1.substring(0,3);

temp1b=temp1.substring(3,6);

//out.println(namec1);

//刪除子部門

ps=conn.preparestatement(delete);

ps.setstring(1, temp1);

int resultb3=ps.executeupdate();

if(resultb3>0){

//out.println("delete c success!!!!");

ps=conn.preparestatement(query2);

ps.setstring(1, temp1b+"%");

resultset bd3=ps.executequery();

while(bd3.next()){

string totalc1=bd3.getstring("total");

namec1=bd3.getstring("name");

string temp1c=temp1.substring(0,1);

string temp1ca=temp1.substring(0,3);

string temp1cb=temp1.substring(3,6);

ps=conn.preparestatement(delete);

ps.setstring(1, temp1aa+"%");

//out.println(namec1);

ps=conn.preparestatement(delete1);

ps.setstring(1, namec1);

int resultc2=ps.executeupdate();

if(resultc2>0)

{message=depname;}

}}}}}

/* 刪除部門級:第三層和第四層一起刪除*/

if(temp1a.equals("c")){

//刪除本部門

ps=conn.preparestatement(delete);

ps.setstring(1, temp1);

int resultc1=ps.executeupdate();

if(resultc1>0){

//out.println("delete c success!!!!");

//刪除子部門

ps=conn.preparestatement(query2);

ps.setstring(1, temp1b+"%");

resultset rs2=ps.executequery();

while(rs2.next()){

string totalc1=rs2.getstring("total");

string namec1=rs2.getstring("name");

string temp1c=temp1.substring(0,1);

string temp1ca=temp1.substring(0,3);

string temp1cb=temp1.substring(3,6);

ps=conn.preparestatement(delete);

ps.setstring(1, temp1aa+"%");

//out.println(namec1);

ps=conn.preparestatement(delete1);

ps.setstring(1, namec1);

int resultc2=ps.executeupdate();

if(resultc2>0)

{message=depname;}

}}}

//只刪除第4層

if(temp1a.equals("d"))

{

ps=conn.preparestatement(delete);

ps.setstring(1, temp1);

int result3=ps.executeupdate();

if(result3>0)

{message=depname;}

}

%>

<html>

<head>

<meta http-equiv="content-type" content="text/html; charset=big5">

<title>刪除部門</title>

</head>

<body>

<p>&nbsp;</p>

<p>&nbsp;</p>

<p>&nbsp;</p>

<table width="38%" border="1" align="center" cellpadding="0" cellspacing="0">

<tr>

<td height="17" bgcolor="#0099ff" scope="col"><div align="center" class="style1">信息刪除成功</div></td>

</tr>

<tr>

<td height="160" colspan="2" bgcolor="#e6f0ff" scope="row"><div align="center" class="style2">部門: <%=depname%> &nbsp;刪除成功!</div> <br> <div align="center" class="style2"><a href="orgmanage.jsp">繼續刪除</a> &nbsp; &nbsp;&nbsp;<a href="orgview.jsp">返回組織架構</a></div></td>

</tr>

</table>

</body>

<%

conn.commit();

}

catch(sqlexception se1)

{se1.printstacktrace();

conn.rollback();

}

finally{

conn.setautocommit(autocommit);

conn.close();

}

%>

</html>

赞(0)
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com 特别注意:本站所有转载文章言论不代表本站观点! 本站所提供的图片等素材,版权归原作者所有,如需使用,请与原作者联系。未经允许不得转载:IDC资讯中心 » JSP实现树型组织架构(5)–删除部门页面orgDelete.jsp-JSP教程,Jsp/Servlet
分享到: 更多 (0)