<%@language=vbscript codepage=936 %>
<!--#include file="Conn.asp"-->
<!--#include file="Manage_Sub.asp"-->
<script language="JavaScript" type="text/JavaScript">
function checkBig()
{
  if (document.form1.ClassName.value=="")
  {
    alert("大类名称不能为空！");
    document.form1.ClassName.focus();
    return false;
  }
}
</script>
<html>
<head>
<titel></titel>
<LINK href="admin/admin.css" type=text/css rel=stylesheet>
</head>
<body>
<%
If Request.QueryString("action")="add" Then
Call AddManageClass
  If Request.Form("Add")=" 添 加 " Then
  ClassName=Trim(Request("ClassName"))
   If ClassName="" Then
   FoundErr=True
        Response.write "<script language='javascript'>" & chr(13)
		Response.write "alert('介绍类别名不能为空!');" & Chr(13)
		Response.write "window.document.location.href='Manage_ClassMan.asp';"&Chr(13)
		Response.write "</script>" & Chr(13)
        Response.End 
   End if
     If FoundErr<>True then
     Set rs=Server.CreateObject("Adodb.RecordSet")
     rs.Open "Select * From [ClassManage] Where Type='" & ClassName & "'",Conn,1,3
        If not (rs.bof and rs.EOF) then
	FoundErr=True
	Response.Write  "<br><li>介绍类别“" & BigClassName & "”已经存在！</li>"
        Else
    	rs.addnew
     	rs("Type")=ClassName
    	rs.Update
     	rs.Close
	set rs=Nothing
        JaSys("管理员" & session("ManagerUser") & "<font color=red>添加介绍类别["&ClassName&"]</font>成功")
    	Response.Redirect "Manage_ClassMan.asp"  
	End if
     End if
  End if
End if

If Request.QueryString("action")="update" Then
Call EditManageClass
   If Request.Form("Update")=" 修 改 " Then
   ClassName=Trim(Request("ClassName"))
   If ClassName="" Then
   FoundErrS=True
        Response.write "<script language='javascript'>" & chr(13)
		Response.write "alert('介绍类别名不能为空!');" & Chr(13)
		Response.write "window.document.location.href='Manage_ClassMan.asp';"&Chr(13)
		Response.write "</script>" & Chr(13)
        Response.End 
   End if
     If FoundErrS<>True then
     Set rss=Server.CreateObject("Adodb.RecordSet")
     rss.Open "Select * From [ClassManage] Where Type='" & ClassName & "'",Conn,1,3
        If not (rss.bof and rss.EOF) then
	FoundErrS=True
	Response.Write  "<center><br><li>介绍类别“" & ClassName & "”已经存在！</li></center>"
        Else
        Set rst=Conn.Execute("Select * From [ClassManage] Where ID="&Clng(Request("id")))
        tt = rst("Type")
        Sql1 = "Update [About_Manage] Set [ManageType]='"&ClassName&"' Where [ManageType]='"&tt&"' "
        Conn.Execute (Sql1)
        Sql = "Update [ClassManage] Set [Type]='"&ClassName&"' Where ID="&Clng(Request("id"))
        Conn.Execute (Sql)
        JaSys("管理员" & session("ManagerUser") & "<font color=red>修改介绍类别ID"&Request("id")&"的为["&ClassName&"]</font>成功")
    	Response.Redirect "Manage_ClassMan.asp"  
	End if
        rss.Close
	set rss=Nothing
     End if
  End if   
End if

If Request.QueryString("action")="del" Then
Set sss = Conn.Execute("Select * From [ClassManage] Where Type="&Clng(Request("id")))
bbb = sss("Type")
Set bs = Conn.Execute("Delete * From [About_Manage] Where [ManageType]='"&bbb&"'")
Set bg = Conn.Execute("Delete * From [ClassManage] Where ID="&Clng(Request("id")))
JaSys("管理员" & session("ManagerUser") & "<font color=red>删除介绍类别ID为"&Request("id")&"</font>成功")
Response.Redirect "Manage_ClassMan.asp"
End if
%>
</body>
</html>