<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<%
'****************************************************************
'**   版权所有：烈火工作室  演示网站http://www.strongfire.cn   **
'**   QQ:839225572   邮箱：strongfire2008@163.com              **
'**   非正版用户不得擅自非法修改用于商业用途！查出必究。       **
'****************************************************************
%>
<!--#include file="islogin.asp"-->
<!--#include file="Check_SqlIn.asp"-->
<!--#include file="admin_conn.asp"-->

<html>
<head>
<LINK href="admin_Css.css" type=text/css rel=stylesheet>
<script language="JavaScript" type="text/JavaScript">
function checkBig()
{
  if (document.form1.NewClassName.value=="")
  {
    alert("大类名称不能为空！");
    document.form1.NewClassName.focus();
    return false;
  }
}
</script>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>修改大类名称</title>
<style type="text/css">
<!--
.STYLE1 {
	color: #FF0000;
	font-weight: bold;
}
-->
</style>
</head>
<%
ClassID=trim(Request("ClassID"))
Action=trim(Request("Action"))
NewClassName=trim(Request("NewClassName"))
OldClassName=trim(Request("OldClassName"))

if ClassID="" then
  response.Redirect("ClassManage.asp")
end if
Set rs=Server.CreateObject("Adodb.RecordSet")
rs.Open "Select * from Class where ID=" & CLng(ClassID),conn,1,3
if rs.Bof and rs.EOF then
	response.write"<SCRIPT language=JavaScript>alert('此大类不存在！');"
	response.write"javascript:history.go(-1)</SCRIPT>"
	response.End
else

	if Action="Modify" then
		   if NewClassName="" then
		   		response.write"<SCRIPT language=JavaScript>alert('大类名不能为空！');"
				response.write"javascript:history.go(-1)</SCRIPT>"
			    
			    response.End
			
	        end if
			if NewClassName=OldClassName then
				response.write"<SCRIPT language=JavaScript>alert('您还没有修改大类名！');"
				response.write"javascript:history.go(-1)</SCRIPT>"
			   
			    response.End
			
	        end if
			'修改后的大类名，不能重复
			Set rs1=Server.CreateObject("Adodb.RecordSet")
			rs1.open "Select * From Class Where ClassName='" & NewClassName & "'",conn,1,1
			if not (rs1.bof and rs1.EOF) then
				response.write"<SCRIPT language=JavaScript>alert('大类名称已经存在！');"
				response.write"javascript:history.go(-1)</SCRIPT>"
				
				response.End
			end if
			rs1.close
			set rs1=nothing
			
			rs("ClassName")=NewClassName
			rs.update
			rs.Close
	     	set rs=Nothing
			if NewClassName<>OldClassName then
				
				conn.execute "Update article set ClassName='" & NewClassName & "' where ClassID=" & ClassID
     		end if		
			conn.close
			set conn=nothing
     		Response.Redirect "ClassManage.asp" 
		
	 else

%>
<body>
<div align="center"><br>
    <a href="ClassManage.asp"><strong><font size="2" color="#FF0000"><u>类别管理</u></font></strong></a></p>
      <form name="form1" method="post" action="ClassModify.asp" onSubmit="return checkBig()">
  <table border="0" cellspacing="1" align="center" class="list1">
    <tr>
      <th colspan="2" ><div align="center">修改大类名称</div></th>
    </tr>
    <tr>
      <td ><div align="right">大类ID：</div></td>
      <td ><%=rs("ID")%>
        <input name="ClassID" type="hidden" id="ClassID" value="<%=rs("ID")%>">
        <input name="OldClassName" type="hidden" id="OldClassName" value="<%=rs("ClassName")%>"></td>
    </tr>
    <tr>
      <td ><div align="right">大类名称：</div></td>
      <td ><input name="NewClassName" type="text" id="NewClassName" value="<%=rs("ClassName")%>" size="20" maxlength="30"></td>
    </tr>
    <tr>
      <td >&nbsp;</td>
      <td align="center" ><div align="left" >
          <input name="Action" type="hidden" id="Action" value="Modify">
          <input name="Save" type="submit" id="Save" value=" 修 改 ">
      </div></td>
    </tr>
  </table>
  
  </form>
  <p><br>
    <br>
  </p>
</div>
</body>
<%
	end if
end if
rs.close
set rs=nothing
conn.close
set conn=nothing
%>
</html>
