<!--#include file="../../conn/conn_other.asp"-->
<!--#include file="../check.asp"-->
<!--#include file="../../film/Incs/syscode.asp"-->
<!--#include file="../../inc/sql.asp"-->
<%
	end if
	useflag=1
%>
<!--#include file="../flag.asp"-->
<link href="css/Admin_Style.Css" rel="stylesheet">
<link href='../Include/Admin_Style.CSS' rel='stylesheet' type='text/css'>
<script language="javascript" src="js/Admin_Js.js"></script>
<%
	Dim Action,ClassID
	Action=CheckStr(Request("Action"))
	ClassID=CheckNum(Request("ClassID"))
	Select Case Action
		Case "ClassSave"
			Call ClassSave()
		Case "ClassDel"
			Call ClassDel()
		Case Else
			Call ClassList()
	End Select
	
	Function ClassList()
%>
<table width="100%" border="0" cellspacing="0" cellpadding="0" class="sortbutton">
<tr>    
<td height="23" align="center" valign="middle">视频分类列表</td>
</tr>
</table>
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="1" class="table">
  <tr>
    <td colspan="5" class="title">视频分类列表</td>
  </tr>
  <tr>
    <td class="tabletd tc" width="5%">ID</td>
    <td class="tabletd tc" width="25%">分类名称</td>
    <td class="tabletd tc" width="25%">分类文件夹</td>
    <td class="tabletd tc" width="25%">排序</td>
    <td class="tabletd tc">管理操作</td>
  </tr>
<%
	Dim Rs,Sql
	Sql="Select * From Dm_Class"
	Set Rs=Conn.Execute(Sql)
	If Rs.Bof And Rs.Eof Then
		Rw(" </tr>")
		Rw(" <td colspan=""5"" class=""tabletd tc"">暂无分类！</td>")
		Rw(" <tr>")
	Else 
		Do While Not Rs.Eof
%>
<form name="order" method="post" action="?Action=ClassSave">
  <tr onmouseover="this.className='tabletr';" onmouseout="this.className='tabletr2';">
    <td class="tabletd tc"><%=Rs("ClassID")%></td>
    <td class="tabletd tc"><input name="ClassName" type="text" class="text" value="<%=Rs("ClassName")%>" size="15"></td>
    <td class="tabletd tc"><input name="ClassEName" type="text" class="text" value="<%=Rs("ClassEName")%>" size="15"></td>
    <td class="tabletd tc">
    <input name="OrderID" type="text" class="text" value="<%=Rs("OrderID")%>" size="4">
    <input name="ClassID" type="hidden" value="<%=Rs("ClassID")%>">
    <input name="submit" type="submit" class="button" value="更新">
    </td>
    <td class="tabletd tc">&nbsp;<a href="?Action=ClassDel&ClassID=<%=Rs("ClassID")%>" onclick="{if(confirm('确定删除吗?该分类的下属视频也会删除！')){return true;}return false;}"><img src="Images/del.gif" align="absmiddle" border="0" /> 删除</a></td>
  </tr>
</form>
  <%
		Rs.MoveNext
		Loop
	End If
	Rs.Close
	Set Rs=Nothing
%>
</table>
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="1" class="table">
<form id="form1" name="form1" method="post" action="?Action=ClassSave">
  <tr>
    <td colspan="6" class="title">添加视频分类</td>
  </tr>
  <tr>
    <td class="tbove">分类名称</td>
    <td class="tbove"><input name="ClassName" type="text" class="text" id="ClassName" size="15" />
      <input name="ClassID" type="hidden" id="ClassID" value="0" /></td>
    <td class="tbove">分类文件夹：</td>
    <td class="tbove"><input name="ClassEName" type="password" class="text" id="ClassEName" size="15"  style="display:none;"/></td>
    <td class="tbove"><input name="uspell" type="checkbox" id="uspell" onclick="userspell();" value="1" checked="checked"/>使用分类名称拼音</td>
    <td class="tbove"><input name="button" type="submit" class="button" id="button" value="添加" /></td>
  </tr>
</form>
</table>
<%
	End Function
	
	Function ClassSave()
		Dim ClassName,ClassEName,OrderID
		ClassName=CheckStr(Request("ClassName"))
		ClassEName=CheckStr(Request("ClassEName"))
		If ClassName ="" Then Call ShowErr("请输入分类名称!")
		If ClassEName="" Then
			ClassEName=GetSpell(ClassName,50)
		End If
		Dim Rs,Sql
		If ClassID=0 Then
			OrderID=DBGetNum("Dm_Class","ClassID",0)
			Set Rs=Server.Createobject("Adodb.Recordset")
			Sql="Select * From Dm_Class Where ClassName='"&ClassName&"'"
			Rs.Open Sql,Conn,1,3
			If Rs.Bof And Rs.Eof Then
				Rs.AddNew
				Rs("ClassName")=ClassName
				Rs("ClassEName")=ClassEName
				Rs("OrderID")=OrderID+1
				Rs.Update
			Else
				Call ShowErr("该分类已存在！")
			End If
			Rs.Close
			Set Rs=Nothing
		Else
			OrderID=DBGetNum("Dm_Class","OrderID",2)
			Set Rs=Server.Createobject("Adodb.Recordset")
			Sql="Select * From Dm_Class Where ClassID="&ClassID&""
			Rs.Open Sql,Conn,1,3
			Rs("ClassName")=ClassName
			Rs("ClassEName")=ClassEName
			Rs("OrderID")=CheckNum(Request("OrderID"))
			Rs.Update
			Rs.Close
			Set Rs=Nothing
		End If
		Dim Fso
		Set Fso=New DmFso
			Call Fso.CreateFolder("../"&ClassEName&"/")
		Set Fso=Nothing
		Call ShowSuccMsg("<li>分类保存成功！</li>","Admin_Class.asp")
	End Function
	
	Function ClassDel()
		Dim ClassEName
		ClassEName=DBGetValue("Dm_Class","ClassEName","ClassID="&ClassID&"")
		Call DBDel("Dm_Class","ClassID="&ClassID&"")
		Call DBDel("Dm_Video","ClassID="&ClassID&"")
		Set Fso=New DmFso
			Call Fso.DelFolder("../"&ClassEName&"/")
		Set Fso=Nothing
		Call ShowSuccMsg("<li>视频分类删除成功！</li>","")
	End Function
	
	Call CloseDB()
%>