📄 modi.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="../../css/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 deptId=new String(request.getParameter("deptId").getBytes("8859_1"));
String deptName="",fzr="",dpinfo="",dpdemo="",p_dept="";
strSQL="select * from deptlist where deptId='"+deptId+"'";
sqlRst = sqlStmt.executeQuery(strSQL);
if(sqlRst.next()){
p_dept=sqlRst.getString("p_dept");
deptName=sqlRst.getString("deptName");
fzr=sqlRst.getString("fzr");
dpinfo=sqlRst.getString("dpinfo");
dpdemo=sqlRst.getString("dpdemo");
}
sqlRst.close();
%>
<center>
<h5>部门管理-->修改部门</h5>
<form method="POST" action="modisave.jsp" name=form1>
<input type='hidden' name='op_dept' value='<%=p_dept%>'>
<input type='hidden' name='odeptId' value='<%=deptId%>'>
<table border="0" width="60%" cellspacing="1" cellpadding="5" class="main">
<tr>
<td align="right" class="top">父 部 门:</td>
<td><select name="p_dept" size="1" style="font-size: 9pt; border: 0px solid; border-color: black black #000000; color: #0000FF ;cursor:hand;" disabled><option value="02">--------------------------------------</option>
<%
strSQL="select * from tree where left(id,2)='02' and len(id)>2 order by id";
sqlRst = sqlStmt.executeQuery(strSQL);
while(sqlRst.next()){
String id=sqlRst.getString("id");
String name=sqlRst.getString("name");
String tmpI="";
for(int i=0;i<id.length();i++){
tmpI=tmpI+" ";
}
if(p_dept.equals(id)){
out.println("<option value="+id+" selected>"+tmpI+"|--"+name+"</option>");
}
else{
out.println("<option value="+id+">"+tmpI+"|--"+name+"</option>");
}
}
sqlRst.close();
%></select><font color='red'>*</font>
</td>
</tr>
<tr>
<td align="right" class="top">部门编号:</td>
<td><input type="text" name="deptId1" size=8 value='<%=deptId.substring(0,deptId.length()-2)%>' disabled style="font-size: 9pt; border: 0px solid; border-color: black black #000000; color: #0000FF ;cursor:hand;"><input type="text" name="deptId" size=31 maxlength=2 disabled value='<%=deptId.substring(deptId.length()-2,deptId.length())%>' style="font-size: 9pt; border: 0px solid; border-color: black black #000000; color: #0000FF ;cursor:hand;"onBlur="javascript:checkws_ybNumber()"><font color='red'>*</font>(注:01--99)</td>
</tr>
<tr>
<td align="right" class="top">部门名称:</td>
<td><input type="text" name="deptName" value=<%=deptName%> size=41 maxlength=12 style="font-size: 9pt; border: 0px solid; border-color: black black #000000; color: #0000FF ;cursor:hand;"><font color='red'>*</font>(注:12字内)</td>
</tr>
<tr>
<td align="right" class="top">负 责 人:</td>
<td><select name="fzr" size="1" style="font-size: 9pt; border: 0px solid; border-color: black black #000000; color: #0000FF ;cursor:hand;"><option value="">--------------------------------------</option>
<%
strSQL="select * from userlist";
sqlRst = sqlStmt.executeQuery(strSQL);
while(sqlRst.next()){
String username=sqlRst.getString("username");
if(fzr.equals(username)){
out.println("<option value="+sqlRst.getString("userid")+" selected>"+username+"</option>");
}
else{
out.println("<option value="+sqlRst.getString("userid")+">"+username+"</option>");
}
}
sqlRst.close();
%></select><font color='red'>*</font>
</td>
</tr>
<tr>
<td align="right" class="top">部门描述:</td>
<td><TEXTAREA NAME="dpinfo" ROWS="4" COLS="40" style="font-size: 9pt; border: 0px solid; border-color: black black #000000; color: #0000FF ;cursor:hand;"><%=dpinfo%></TEXTAREA></td>
</tr>
<tr>
<td align="right" class="top">部门备注:</td>
<td><TEXTAREA NAME="dpdemo" ROWS="4" COLS="40" style="font-size: 9pt; border: 0px solid; border-color: black black #000000; color: #0000FF ;cursor:hand;"><%=dpdemo%></TEXTAREA></td>
</tr>
</table>
<%
//关闭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>");
}
%>
<br>
【<a href="javascript:check()">保存</a>】【<a href="default.jsp">返回</a>】
</form>
</center>
</body>
</html>
<script language=javascript>
function changep(){
document.form1.deptId1.value=document.form1.p_dept.value;
document.form1.deptId.focus();
}
//验证邮政编码:或者为空或者为六位数字
function checkws_ybNumber(){
var reg =/^[0-9]{1,18}$/;
var obj =document.form1.deptId;
if(obj.value!=''){
if(reg.exec(obj.value)==null||obj.value.length<2) {
alert("请正确输入部门编号!");
obj.focus();
obj.select;
return;
}
}
}
function check(){
if(form1.p_dept.value.length>=form1.odeptId.value.length){
if(form1.p_dept.value.substring(0,form1.odeptId.value.length)==form1.odeptId.value){
alert("父部门选择无效!");
form1.p_dept.focus();
return;
}
}
if(form1.deptId.value==""){
alert("请输入部门编号!");
form1.deptId.focus();
return;
}
if(form1.deptName.value==""){
alert("请输入部门名称!");
form1.deptName.focus();
return;
}
if(form1.fzr.value==""){
alert("请选择负责人!");
form1.fzr.focus();
return;
}
form1.submit();
}
</script>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -