<%response.buffer=true%>
<%dim ThisKey
ThisKey = "t"
%>
<!--#include file="../inc/permission.htm"-->
<!--#include file="../inc/conn.htm"-->

<HTML>
<HEAD>
<link rel=stylesheet href="../css/main.css" type="text/css">
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</HEAD>
<%
dim LoginID
LoginID = trim(Session("LoginID"))

IF LoginID="" then 
	LoginID = 0
	oConn.close
	set oConn = Nothing
	Response.End
end if

set rs=Server.CreateObject("ADODB.Recordset")

if request("cmdUpdate")<>"" and request("ID")<>"" then
	sql="select * from tblDocClass where Name ='" & Replace(request("name"),"'","''") & "'"
	rs.open sql,oConn
	if not rs.eof and not rs.bof then
	rs.close
	response.write "<body bgcolor=""#FFFFFF"">"
	response.write "<b>名称重复，请重新填写。</b>"
	elseif rs.eof then
	if request("Name")<>"" then
		rs.close
		sql="update tblDocClass set Name='" & Replace(request("Name"),"'","''") & "'"
		sql=sql & " where ID=" & request("ID")
		oConn.execute(sql)
		alertinfo="类别修改成功！"
	else
		alertinfo="请输入新类别名称！"
	end if
	end if
end if

if request("cmdAdd")<>""  then
	sql="select * from tblDocClass where Name='" & Replace(request("Name"),"'","''") & "'"
	rs.open sql,oConn
	if not rs.eof and not rs.bof then
	rs.close
	response.write "<body bgcolor=""#FFFFFF"">"
	response.write "<b>名称重复，请重新填写。</b>"
	elseif rs.eof then
	if request("Name")<>"" then
		rs.close
		sql="insert into tblDocClass(Name) values('" &  Replace(request("Name"),"'","''") & "')"
		oConn.execute(sql)
		alertinfo="新类别添加成功！"
	else
		alertinfo="请输入类别名称！"
	end if
	end if
end if
 
if request("cmdDel")<>"" and  request("ID")<>"" then
	sql="delete from tblDocClass where ID=" & request("ID")
	oConn.execute(sql)
end if

%>
<BODY BGCOLOR="#FFFFFF" >
<BR><BR><BR>
<div align="center">
<table border=0 width="95%"><tr><td>
<p><b>公文类别维护</b></p>
<input type="text" name="Name" size="15" maxlength=50 class="input">（添加或修改请输入新名称）</p>
<p>
<input type="submit" value="修改" name="cmdUpdate" class='Font9BoldWhite'>
<input type="submit" value="添加" name="cmdAdd" onclick="return formcheck(0);" class='Font9BoldWhite'>
<input type="submit"  value="删除" name="cmdDel" onclick="return DelAlert()" class='Font9BoldWhite'>
<input type="reset" value="重置" name="B1" class='Font9BoldWhite'></p>
</form>
</td></tr></table>
</div>
</BODY>
</HTML>
<!--#include file="../inc/conn_close.htm"-->

<script language="Javascript">
function formcheck(i)
{
if (document.forms[i].Name.value=="")
	{
	alert("类别名称不能为空！");
	document.forms[i].Name.focus;
	return false;
	}
}

	function DelAlert(){
		return confirm('删除该数据将不能恢复,是否继续?');
	
	}

</script>