<!--#include file="conn.asp"-->
<!--#include file="check.asp"-->

<% 
 '===========================================================================================
	'软件名称：126 cms 视频影视管理系统
	'程序版权：126电影               '咨询QQ：479025
	'开发作者：magicblack(479025)    '官方网站：http://www.126oo.com/
	'Copyright (C) 2009 - ... 126oo.com  All Rights Reserved.
	'郑重声明:
	'    1、免费版本请在程序首页保留版权信息，并做上本站LOGO友情连接,商业版本无此要求;
	'    2、任何个人或组织不得以盈利为目的发布,修改,本软件及其他副本上一切关于版权的信息；
	'    3、126电影保留此软件的法律追究权利；
'==========================================================================================
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3c.org/TR/1999/REC-html401-19991224/loose.dtd">
<HTML xmlns="http://www.w3.org/1999/xhtml">
<HEAD>
<TITLE>专题管理 - 后台管理中心 - 126电影程序CMS</TITLE>
<META http-equiv=Content-Type content="text/html; charset=gb2312">
<LINK href="images/css_body.css" type=text/css rel=stylesheet>
<script language="javascript" src="images/admin.js"></script>
</HEAD>
<BODY>
<DIV class=bodytitle>
<DIV class=bodytitleleft></DIV>
<DIV class=bodytitletxt>专题管理</DIV>
<DIV class=bodytitletxt2><a href="admin_topic.asp?action=add">添加专题</a></DIV>
</DIV>

<%
response.Charset="GBK"
dim action
action = SafeData("RQ","action",0)

Select case action
	case "add" : add
	case "addsave" : addsave
	case "edit" : edit
	case "editsave" : editsave
	case "editall" : editall
	case "del" : del
	case "delall" : delAll
	case else : main
End Select

sub addsave
Dim T_Name : T_Name = SafeData("RF","T_Name",0)
Dim T_EnName : T_EnName = SafeData("RF","T_EnName",0)
Dim T_Template : T_Template = SafeData("RF","T_Template",0)
Dim T_Sort : T_Sort = SafeData("RF","T_Sort",0)

if isN(T_Sort) then  T_Sort= Database.GetRecordBySQL("select max(T_Sort) from Tbl_Topic")(0)+1

if not isNum(T_Sort) then ErrMsg "专题","信息填写不完整，请检查!"

Dim result : result = DataBase.AddRecord("Tbl_Topic",Array("T_Name:"&T_Name, "T_EnName:"&T_EnName,"T_Template:"&T_Template,"T_Sort:"&T_Sort))   

If result<>0 Then  
    ShowMsg "添加专题成功！"  ,"admin_topic.asp" 
End If  

end sub

sub editsave
Dim T_ID : T_ID = SafeData("RF","T_ID",0)
Dim T_Name : T_Name = SafeData("RF","T_Name",0)
Dim T_EnName : T_EnName = SafeData("RF","T_EnName",0)
Dim T_Template : T_Template = SafeData("RF","T_Template",0)
Dim T_Sort : T_Sort = SafeData("RF","T_Sort",0)

if isN(T_Sort) then  T_Sort= Database.GetRecordBySQL("select max(T_Sort) from Tbl_Topic")(0)+1
if not isNum(T_Sort) then ErrMsg "专题","信息填写不完整，请检查!"
		
Dim result : result = DataBase.UpdateRecord("Tbl_Topic","T_ID = "& T_ID ,Array("T_Name:"&T_Name, "T_EnName:"&T_EnName,"T_Template:"&T_Template,"T_Sort:"&T_Sort))   
If result<>0 Then  
    ShowMsg "修改专题成功！" ,"admin_topic.asp" 
End If  

end sub

sub editall
	dim ids,id,T_Name,T_Sort,T_EnName,T_Template
	ids = split(replace(SafeData("RF","T_ID",0)," ",""),",")
	For Each id In ids
		T_Name = SafeData("RF","T_Name" &id,0)
		T_Sort = SafeData("RF","T_Sort" &id,0) 
		T_EnName = SafeData("RF","T_EnName" &id,0)
		T_Template = SafeData("RF","T_Template" &id,0)
		
		if isN(T_Name)  then   ErrMsg "专题","信息填写不完整，请检查!"
		if isN(T_EnName)  then   ErrMsg "专题","信息填写不完整，请检查!"
		if isN(T_Sort) then  T_Sort= Database.GetRecordBySQL("select max(T_Sort) from Tbl_Topic")(0)+1
		if not isNum(T_Sort) then ErrMsg "专题","信息填写不完整，请检查!"
		
			DataBase.UpdateRecord "Tbl_Topic","T_ID = "& id ,Array("T_Name:"&T_Name, "T_EnName:"&T_EnName,"T_Template:"&T_Template,"T_Sort:"&T_Sort)
		
	Next
	
	ShowMsg "批量修改完毕!","admin_topic.asp" 
end sub


sub del
	Dim T_ID : T_ID = SafeData("RQ","T_ID",0)
	Dim result : result = Database.DeleteRecord("Tbl_Topic", "T_ID:" & T_ID)   
	If result<>0 Then  
    ShowMsg "删除记录成功!" ,"admin_topic.asp"  
	End If  
end sub

sub delall
	Dim T_ID : T_ID = SafeData("RF","T_ID",0)
	if isN(T_ID) then ShowMsg "没有选择任何数据!" ,"admin_topic.asp"  
	Dim result : result = Database.DeleteRecord("Tbl_Topic", "T_ID in (" & T_ID & ")")   
	If result<>0 Then  
    ShowMsg "批量删除记录成功!" ,"admin_topic.asp"  
	End If 

end sub

sub main
Dim rs : Set rs = DataBase.GetPageRecord(0,Array("Tbl_Topic:T_ID,T_Name,T_Sort,T_EnName,T_Template","","T_Sort,T_ID Asc","T_ID")) 

Dim Page
 Page = DataBase.GetPager ("")

%>

<TABLE width="96%" border=0 align=center cellpadding="5" cellSpacing=1 class=tbtitle style="BACKGROUND: #cad9ea;">
<form action="" method="post" name="form1"> 
  <TBODY>
    <TR bgColor="#f5fafe">
	  <TD width="4%" align="center" >&nbsp;</TD>
      <TD align="center">名称</TD>
	  <TD width="15%" align="center">别称</TD>
	  <TD width="15%" align="center">模板</TD>
	  <TD width="15%" align="center">排序</TD>
	  <TD width="25%" align="center">操作</TD>
    </TR>
	<%if not rs.eof then
		While Not rs.eof
	 %>
    <TR bgcolor="#FFFFFF">
	  <TD align="center"><input name="T_ID" type="checkbox" id="T_ID" value="<%=rs("T_ID")%>" /></TD>
      <TD><input type="text" name="T_Name<%=rs("T_ID")%>" value="<%=rs("T_Name")%>" size="20"/></TD>
	  <TD><input type="text" name="T_EnName<%=rs("T_ID")%>" value="<%=rs("T_EnName")%>" size="20"/></TD>
	  <TD><input type="text" name="T_Template<%=rs("T_ID")%>" value="<%=rs("T_Template")%>" size="20"/></TD>
	  <TD><input name="T_Sort<%=rs("T_ID")%>" type="text" value="<%=rs("T_Sort")%>"  size="10"/></TD>
      <TD align="center">
	  <A href="admin_topic.asp?action=edit&T_ID=<%=rs("T_ID")%>">修改</a> | 
	  <A href="admin_topic.asp?action=del&T_ID=<%=rs("T_ID")%>" onClick="return confirm('确定要删除吗?');">删除</a></TD>
    </TR>
	<%rs.MoveNext
	Wend 
	end if%>
	<TR bgColor="#f5fafe">
	<td  colspan="6"><label>全选<input type="checkbox" name="chkall" id="chkall" class="checkbox" onClick="checkAll(this.checked,'input','T_ID')" /></label><label>反选<input type="checkbox" name="chkothers" id="chkothers" class="checkbox" onClick="checkOthers('input','T_ID')" /></label><input type="submit" value="批量删除" onClick="if(confirm('确定要删除吗')){form1.action='?action=delall';}else{return false}" class="btn"  />
	&nbsp;&nbsp;<input type="submit" value="批量修改选中" name="Submit"  class="btn"  onclick="form1.action='?action=editall';"/>
	</td></tr>
	
    <TR align="center" bgcolor="#f8fbfb">
      <TD colspan="6"><%=Page%></TD>
    </TR>
  </TBODY>
  </form>
</TABLE>

<%
Database.C(rs)
end sub

sub add
%>

<TABLE width="96%" border=0 align=center cellpadding="4" cellSpacing=1 class=tbtitle style="BACKGROUND: #cad9ea;">
<form action="?action=addsave" method="post" name="addform">
  <TBODY>
    <TR>
      <TD vAlign=center width="20%" bgColor=#f5fafe>专题名称：</TD>
      <TD bgColor=#ffffff><INPUT id="T_Name" size=50 value="" name="T_Name" dataType="Require" msg="请填写专题名称">
	  </TD>
    </TR>
	<TR>
     <TD vAlign=center width="20%" bgColor=#f5fafe>专题别名：</TD>
      <TD bgColor=#ffffff><INPUT id="T_EnName" size=50 value="" name="T_EnName" dataType="Require">
	  </TD>
    </TR>
	<TR>
     <TD vAlign=center width="20%" bgColor=#f5fafe>模版文件：</TD>
      <TD bgColor=#ffffff><INPUT id="T_template" size=50 value="" name="T_template" dataType="Require">
	  </TD>
    </TR>
	<TR>
     <TD vAlign=center width="20%" bgColor=#f5fafe>排序：</TD>
      <TD bgColor=#ffffff><INPUT id="T_Sort" size=5 value="" name="T_Sort" dataType="Require">
	  </TD>
    </TR>
	
    <TR align="center" bgcolor="#f8fbfb">
      <TD colspan="2"><INPUT class=inputbut type=submit value=添加 name=Submit>
      &nbsp;</TD>
    </TR>
  </TBODY>
  </form>
</TABLE>

<%
end sub

sub edit
Dim T_ID : T_ID = SafeData("RQ","T_ID",0)
Dim rs : Set rs = Database.GetRecordDetail("Tbl_Topic","T_ID=" & T_ID)  

if rs.eof then ShowMsg "找不到此ID的专题!","admin_topic.asp"

%>
<TABLE width="96%" border=0 align=center cellpadding="4" cellSpacing=1 class=tbtitle style="BACKGROUND: #cad9ea;">
<form action="?action=editsave" method="post" name="editform">
<input name="T_ID" type="hidden" value="<%=rs("T_ID")%>">
  <TBODY>
    <TR>
      <TD vAlign=center width="20%" bgColor=#f5fafe>专题名称：</TD>
      <TD bgColor=#ffffff><INPUT id="T_Name" size=50 value="<%=rs("T_Name")%>" name="T_Name" dataType="Require" msg="请填写专题标题">
	  </TD>
    </TR>	
	
	<TR>
     <TD vAlign=center width="20%" bgColor=#f5fafe>专题别名：</TD>
      <TD bgColor=#ffffff><INPUT id="T_EnName" size=50 value="<%=rs("T_EnName")%>" name="T_EnName" dataType="Require">
	  </TD>
    </TR>
	<TR>
     <TD vAlign=center width="20%" bgColor=#f5fafe>模版文件：</TD>
      <TD bgColor=#ffffff><INPUT id="T_template" size=50 value="<%=rs("T_template")%>" name="T_template" dataType="Require">
	  </TD>
    </TR>
	<TR>
     <TD vAlign=center width="20%" bgColor=#f5fafe>排序：</TD>
      <TD bgColor=#ffffff><INPUT id="T_Sort" size=5 value="<%=rs("T_Sort")%>" name="T_Sort" dataType="Require">
	  </TD>
    </TR>
	
    <TR align="center" bgcolor="#f8fbfb">
      <TD colspan="2"><INPUT class=inputbut type=submit value=添加 name=Submit>
      &nbsp;</TD>
    </TR>
  </TBODY>
  </form>
</TABLE>
<%
Database.c(rs)
end sub
%>
</BODY>
</HTML>