<!--#include file="Conn.asp"-->
<!--#include file ="Check_Manager.asp"-->
<!--#include file="News_Sub.asp"-->
<!--#include file="../Inc/Ubbcode.asp"-->
<!--#include file="JsInc/Function.asp"-->
<script language="JavaScript" type="text/JavaScript">
function checkBig()
{
  if (document.form1.BigClassName.value=="")
  {
    alert("大类名称不能为空！");
    document.form1.BigClassName.focus();
    return false;
  }
}
</script>
<script language="JavaScript" type="text/JavaScript">
function checkSmall()
{
  if (document.form1.SmallClassName.value=="")
  {
    alert("小类名称不能为空！");
    document.form1.SmallClassName.focus();
    return false;
  }
}
</script>
<html>
<head>
<titel></titel>
<LINK href="admin/admin.css" type=text/css rel=stylesheet>
</head>
<body>
<%
If Request.QueryString("action")="upbig" Then
Call EditBigClass
  If Request.Form("UpdateB")=" 修 改 " Then
  BigClassName=Trim(Request("BigClassName"))
   If BigClassName="" Then
   FoundErr=True
   Response.Write "<br><li>文章大类名不能为空！</li>"
   End if
     If FoundErr<>True then
     Set rs=Server.CreateObject("Adodb.RecordSet")
     rs.Open "Select * From [BigClassNews] Where [News_BigClassName]='" & BigClassName & "'",Conn,1,1
        If not (rs.bof and rs.EOF) then
	FoundErr=True
	Response.Write  "<br><li>文章大类“" & BigClassName & "”已经存在！</li>"
        Else
        Set bb = Conn.Execute("Select * From [BigClassNews] Where News_BigID= " &Cint(Request("bigid")))
        big = bb("News_BigClassName")
        Sql = "Update [SmallClassNews] Set News_BigClassName='"&BigClassName&"' Where News_BigClassName='"&big&"'"
        Conn.Execute (Sql)
        Sql1 = "Update [News] Set News_BigClassName='"&BigClassName&"' Where News_BigClassName='"&big&"'"
        Conn.Execute (Sql1)
        Sql2 = "Update [BigClassNews] Set News_BigClassName='"&BigClassName&"' Where News_BigID= " &Cint(Request("bigid"))
        Conn.Execute (Sql2)
        JaSys("管理员" & session("ManagerUser") & "<font color=red>修改新闻大类["&BigClassName&"]</font>成功")
    	Response.Redirect "News_ClassManage.asp"  
	End if
     End if
  End if
End if
If Request.QueryString("action")="upsmall" Then
Call EditSmallClass
  If Request.Form("Update")=" 修 改 " Then
  SmallClassName=Trim(Request("SmallClassName"))
   If SmallClassName="" Then
   FoundErr=True
   Response.Write "<br><li>文章小类名不能为空！</li>"
   End if
     If FoundErr<>True then
     Set rs=Server.CreateObject("Adodb.RecordSet")
     rs.Open "Select * From [SmallClassNews] Where News_SmallClassName='" & SmallClassName & "'",Conn,1,1
        If not (rs.bof and rs.EOF) then
	FoundErr=True
	Response.Write  "<br><li>文章小类“" & SmallClassName & "”已经存在！</li>"
        Else
        Set ss = Conn.Execute("Select * From [SmallClassNews] Where News_SmallID=" &Cint(Request("smallid")))
        small = ss("News_SmallClassName")
        Sql = "Update [News] Set News_SmallClassName='"&SmallClassName&"' Where News_SmallClassName='"&small&"'"
        Conn.Execute (Sql)
        Sql1 = "Update [SmallClassNews] Set News_SmallClassName='"&SmallClassName&"' Where News_SmallID=" &Cint(Request("smallid"))
        Conn.Execute (Sql1)
        JaSys("管理员" & session("ManagerUser") & "<font color=red>修改新闻小类["&SmallClassName&"]</font>成功")
    	Response.Redirect "News_ClassManage.asp"  
	End if
     End if
  End if
End if
If Request.QueryString("action")="delbig" Then
Set sss = Conn.Execute("Select * From [BigClassNews] Where News_BigID="&Cint(Request("bigid")))
bbb = sss("News_BigClassName")
Set bs = Conn.Execute("Delete * From [SmallClassNews] Where News_BigClassName='"&bbb&"'")
Set nn = Conn.Execute("Delete * From [News] Where News_BigClassName='"&bbb&"'")
Set bg = Conn.Execute("Delete * From [BigClassNews] Where News_BigID="&Cint(Request("bigid")))
JaSys("管理员" & session("ManagerUser") & "<font color=red>删除新闻大类["&bbb&"]</font>成功")
Response.Redirect "News_ClassManage.asp"  
End if
If Request.QueryString("action")="delsmall" Then
Set sss = Conn.Execute("Select * From [SmallClassNews] Where News_SmallID="&Cint(Request("smallid")))
bbb = sss("News_SmallClassName")
Set nn = Conn.Execute("Delete * From [News] Where News_SmallClassName='"&bbb&"'")
Set bs = Conn.Execute("Delete * From [SmallClassNews] Where News_SmallClassName='"&bbb&"'")
JaSys("管理员" & session("ManagerUser") & "<font color=red>删除新闻小类["&bbb&"]</font>成功")
Response.Redirect "News_ClassManage.asp"  
End if

If Request.QueryString("action")="upnews" Then
Set news = Conn.Execute("Select * From [News] Where News_ID="&Request("id"))
If news.Bof and news.Eof Then
Response.write "<script language='javascript'>" & chr(13)
		Response.write "alert('没有该新闻!');" & Chr(13)
		Response.write "window.document.location.href='News_Manage.asp';"&Chr(13)
		Response.write "</script>" & Chr(13)
Response.End
Else
If Request.Form("Save")="修改" Then
title = dvhtmlencode(Trim(Request.Form("Title")))
content = ubbcode(Trim(Request.Form("Content")))
content = Replace(content,"'","''")
BigClassName = Trim(Request.Form("BigClassName"))
SmallClassName = Trim(Request.Form("SmallClassName"))
elite = Request.Form("Elite")
UpdateTime = Request.Form("UpdateTime")
If SmallClassName="0" Then 
Response.write "<script language='javascript'>" & chr(13)
		Response.write "alert('请选择新闻小类!');" & Chr(13)
		response.write "javascript:history.go(-1);"&Chr(13)
		Response.write "</script>" & Chr(13)
Response.End
End if
Sql1 = "Update [News] Set [Titel]='"&title&"',[Content]='"&content&"',[News_BigClassName]='"&BigClassName&"',[News_SmallClassName]='"&SmallClassName&"' Where News_ID="&Request("id")
Conn.Execute (Sql1)
        If UpdateTime<>"" and IsDate(UpdateTime)=true then
		UpdateTime=CDate(UpdateTime)
	Else
		UpdateTime=date()
	End if
SqlStr2 = "Update [News] Set [InfoTime]='"&UpdateTime&"',[ShowIndex]= " 
If elite="yes" Then
SqlStr2 = SqlStr2 & "true Where News_ID="&Request("id")
Else
SqlStr2 = SqlStr2 & "false Where News_ID="&Request("id")
End if
Conn.Execute (SqlStr2)
JaSys("管理员" & session("ManagerUser") & "<font color=red>修改新闻ID"&Request("id")&"</font>成功")
Response.write "<script language='javascript'>" & chr(13)
		Response.write "alert('更新成功!');" & Chr(13)
		Response.write "window.document.location.href='News_Manage.asp';"&Chr(13)
		Response.write "</script>" & Chr(13)
Response.End
End if
End if
End if

If Request.QueryString("action")="delnews" Then
Dim ArticleID,Action,sqlDel,rsDel,FoundErr,ObjInstalled
AllID=Trim(Request.Form("AllID"))
ArticleID=Trim(Request("ArticleID"))
Action=Trim(Request("action"))
id=Request("id")
FoundErr=False
ObjInstalled=IsObjInstalled("Scripting.FileSystemObject")

If Request.QueryString("del")="one" then
Set del=Conn.Execute("Delete * From [News] Where News_ID=" & CLng(id))
JaSys("管理员" & session("ManagerUser") & "<font color=red>单个删除新闻ID"&id&"</font>成功")
	Response.write "<script language='javascript'>" & chr(13)
		Response.write "alert('删除成功!');" & Chr(13)
		Response.write "window.document.location.href='News_Manage.asp';"&Chr(13)
		Response.write "</script>" & Chr(13)
        Response.End
End if

If ArticleID="" or Action<>"delnews" then
	FoundErr=True
	Response.write "<script language='javascript'>" & chr(13)
		Response.write "alert('参数不足!');" & Chr(13)
		Response.write "window.document.location.href='News_Manage.asp';"&Chr(13)
		Response.write "</script>" & Chr(13)
        Response.End
End if

If FoundErr=False then
	If instr(ArticleID,",")>0 Then
		dim idarr,i
		idArr=split(ArticleID,",")
		for i = 0 to ubound(idArr)
		If Request.Form(idArr(i))=turn Then
		Set de=Conn.Execute("Delete * From News Where News_ID=" & CLng(idArr(i))) 
                End if	
		next
                JaSys("管理员" & session("ManagerUser") & "<font color=red>多个删除新闻ID"&ArticleID&"</font>成功")
	Else
		Set de=Conn.Execute("Delete * From [News] Where News_ID=" & CLng(id)) 
                JaSys("管理员" & session("ManagerUser") & "<font color=red>单个删除新闻ID"&ID&"</font>成功")
	End if
End if

If FoundErr=False then
	call CloseConn()
	response.Redirect "News_Manage.asp"
Else
	call CloseConn()
End if
End if
%>
</body>
</html>