• 软件测试技术
  • 软件测试博客
  • 软件测试视频
  • 开源软件测试技术
  • 软件测试论坛
  • 软件测试沙龙
  • 软件测试资料下载
  • 软件测试杂志
  • 软件测试人才招聘
    暂时没有公告

字号: 小 中 大 | 推荐给好友 上一篇 | 下一篇

JSP实现树型组织架构(5)--删除部门页面orgDelete.jsp

发布: 2007-7-04 13:34 | 作者: admin | 来源:  网友评论 | 查看: 18次 | 进入软件测试论坛讨论

领测软件测试网 //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>



文章来源于领测软件测试网 https://www.ltesting.net/


关于领测软件测试网 | 领测软件测试网合作伙伴 | 广告服务 | 投稿指南 | 联系我们 | 网站地图 | 友情链接
版权所有(C) 2003-2010 TestAge(领测软件测试网)|领测国际科技(北京)有限公司|软件测试工程师培训网 All Rights Reserved
北京市海淀区中关村南大街9号北京理工科技大厦1402室 京ICP备10010545号-5
技术支持和业务联系:[email protected] 电话:010-51297073

软件测试 | 领测国际 | ISTQB | ISTQB官网 | TMMi | TMMi认证 | 国际软件测试工程师认证 | 领测软件测试网