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

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

JSP实现树型组织架构(4)--插入页面orgInsert.jsp

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

领测软件测试网 //orgInsert.jsp插入页面


<%@ include file="connectionDB.jsp"%>
<%
request.setCharacterEncoding("big5");
String fDep=request.getParameter("fDep");
String dep=request.getParameter("dep");
//out.println(fDep);
//out.println(dep);
boolean autoCommit=conn.getAutoCommit();
try{
conn.setAutoCommit(false);
String queryF=" select total " +
" from ngb_org "+
" where name=''"+fDep+"'' ORDER BY TOTAL ";
//out.println(queryF+"<br>");
String tempF=null;
PreparedStatement ps=conn.prepareStatement(queryF);
ResultSet rs=ps.executeQuery();
while(rs.next())
{ tempF=rs.getString("total");}
//out.println(tempF+"<br>");
char tempFa=tempF.charAt(0);
char tempFb=tempF.charAt(1);
char tempFc=tempF.charAt(2);
char tempFd=tempF.charAt(3);
char tempFe=tempF.charAt(4);
char tempFf=tempF.charAt(5);
int tempFg=Integer.parseInt(tempF.substring(4,6));
String tempC=null;
String tempCC=null;
if(tempFd==''A'')
{tempC="%B%"; tempCC="B";}
else if(tempFd==''B'')
{tempC="%C%"; tempCC="C";}
else if (tempFd==''C'')
{tempC="%D%"; tempCC="D";}
else if (tempFd==''D'')
{tempC="%E%"; tempCC="E";}


String queryColumn=" select count(*) "+
" from ngb_org "+
" where total like ''"+tempC+"'' ";

String queryDefference=" select total "+
" from ngb_org "+
" where total like ? ";

int totalNumber=0;

//統計同層的部門最大值
ps=conn.prepareStatement(queryColumn);
ResultSet rs1=ps.executeQuery();

while(rs1.next())
{totalNumber+=rs1.getInt(1);}

String tempFDD=Character.toString(tempFd);
String totalNewTemp=tempFDD+tempFg+tempCC+(totalNumber+1);
String totalNew=null;
int sameMax=1;
String totalSame=tempFDD+"%"+tempCC+"%";


//查詢本層是否有相同的total值
ps=conn.prepareStatement(queryDefference);
ps.setString(1, totalSame);
ResultSet rsd=ps.executeQuery();
//boolean same=false;
while(rsd.next())
{

//找出同层最大的值
String same1=rsd.getString("total");
String same1Temp1=same1.substring(4,6);
int sameMaxTemp=Integer.parseInt(same1Temp1);
//out.println(sameMaxTemp+" & ");
if(sameMax<sameMaxTemp)
sameMax=sameMaxTemp;
//out.println(sameMax+"//"+"<br>");

}

//如果值小于10,把它赋值为10
if(sameMax<10)
{sameMax+=8;}

totalNew=tempFDD+tempFg+tempCC+(sameMax+1);
//out.println(totalNew);

String insertDep= " insert into ngb_org(id, p_layer, p_id, c_layer, c_id, total, name, sn, create_by, create_date, update_by,update_date) "+
" values(ngb_org_seq.nextval, ''"+tempFd+"'', "+tempFg+", ''"+tempCC+"'',"+(sameMax+1)+" , ''"+totalNew+"'', ''"+dep+"'', NULL, NULL, NULL, NULL, NULL) ";
ps=conn.prepareStatement(insertDep);
//out.println(insertDep+"<br>");
int result =ps.executeUpdate();
if(result>0)
{


%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=Big5">
<title>新增部門</title>
<style type="text/css">
<!--
.style1 {color: #FFFFFF}
.style2 {color: #000066}
-->
</style>
</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">部門: <%=dep%> 添加成功!</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认证 | 国际软件测试工程师认证 | 领测软件测试网