<!--#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>
<script language="javascript">
function checkbanner(o){
	if(!check_in(o,"BannerName","广告说明！")){return false;};
	if(!check_in(o,"oResult","广告代码！")){return false;};
}
</script>
</script>
<%
	Dim Action,BannerID
	Action=CheckStr(Request("Action"))
	BannerID=CheckNum(Request("BannerID"))
	Select Case Action
		Case "BannerEdit"
			Call BannerEdit()
		Case "BannerSave"
			Call BannerSave()
		Case "BannerDel"
			Call BannerDel()
		Case Else
			Call BannerList()
	End Select
	
	Function BannerList()
%>
<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="4" class="title">视频系统广告列表</td>
  </tr>
  <tr>
    <td class="tabletd tc" width="5%">AdID</td>
    <td class="tabletd tc" width="45%">广告说明</td>
    <td class="tabletd tc" width="25%">Js地址</td>
    <td class="tabletd tc">管理操作</td>
  </tr>
<%
	Dim Tag,Table,TagStr,Order,PageSize,PageUrl
	Tag="BannerID"										
	Table="[Dm_Banner]"								
	TagStr="*"	
	Order="BannerID"									
	PageSize=10									
	PageUrl="Admin_Banner.asp"								
	LinkNum=10										
	Dim TotalCount,PageCount,Page
	Dim Rs,Sql,WhereStr
	TotalCount=GetTotalCount(Tag,Table,WhereStr)
	PageCount=GetPageCount(TotalCount,PageSize)
	Page=GetPageNow(PageCount)
	Sql=GetPageSql(Tag,Table,TagStr,Order,PageSize,WhereStr,Page)
	Set Rs=Server.CreateObject("Adodb.RecordSet")
	Rs.Open Sql,Conn,1,1
	If Rs.Bof And Rs.Eof Then
		Rw("<tr>")
    	Rw("<td colspan='4' class=""tabletd tc"">暂无数据！</td>")
  		Rw("</tr>")
	Else
		Do While Not Rs.Eof
%>
  <tr onmouseover="this.className='tabletr';" onmouseout="this.className='tabletr2';">
    <td class="tabletd tc"><%=Rs("BannerID")%></td>
    <td class="tabletd tc"><%=Rs("BannerName")%></td>
    <td class="tabletd tc">/Banner/banner_<%=Rs("BannerID")%>.js</td>
    <td class="tabletd tc"><a href="?Action=BannerEdit&BannerID=<%=Rs("BannerID")%>"><img src="Images/edit.gif" align="absmiddle" border="0" /> 修改</a>&nbsp;<a href="?Action=BannerDel&BannerID=<%=Rs("BannerID")%>"><img src="Images/del.gif" align="absmiddle" border="0" /> 删除</a></td>
  </tr>
<%
		Rs.MoveNext
		Loop
%>
  <tr>
    <td colspan="4" class="tabletd"><%Call PageShow(TotalCount,PageSize,Page,PageCount,PageUrl,LinkNum)%></td>
  </tr>
</table>
<%
	End If
	Rs.Close
	Set Rs=Nothing
%>
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="1" class="table">
<form id="form1" name="form1" method="post" action="?Action=BannerSave" onsubmit="return checkbanner(this);">
  <tr>
    <td colspan="2" class="title">添加网站广告</td>
  </tr>
  <tr>
    <td width="14%" class="tabletd tl">广告说明：</td>
    <td class="tabletd tl"><input name="BannerName" type="text" class="text" id="BannerName" size="50" /> 
      如(网站头部广告)
      <input name="BannerID" type="hidden" id="BannerID" value="0" /></td>
    </tr>
  <tr>
    <td class="tabletd tl">广告代码：</td>
    <td class="tabletd tl"><textarea name="oSource" id="oSource" onpropertychange="change()" cols="45" rows="5" class="textrea"></textarea></td>
  </tr>
  <tr>
    <td class="tabletd tl">转换的JS代码：</td>
    <td class="tabletd tl"><textarea name="oResult" cols="45" rows="5" class="textrea" id="oResult"></textarea></td>
  </tr>
  <tr>
    <td colspan="2" class="tbove">
      <input name="button" type="submit" class="button" id="button" value="添加广告" />
      <input name="button2" type="reset" class="button" id="button2" value="重新填写" />
      </td>
  </tr>
</form>
</table>
<%
	End Function

	Function BannerSave()
		Dim BannerName,BannerCode
		BannerName=Request("BannerName")
		BannerCode=Request("oResult")
		If BannerName="" Then Call ShowErr("请输入广告说明！")
		If BannerCode="" Then Call ShowErr("请输入广告代码！")
		Dim Rs,Sql
		If BannerID=0 Then
			Set Rs=Server.Createobject("Adodb.Recordset")
			Sql="Select * From Dm_Banner"
			Rs.Open Sql,Conn,1,3
			Rs.AddNew
			Rs("BannerName")=BannerName
			Rs("BannerCode")=BannerCode
			Rs.Update
			ID=Rs("BannerID")
			Rs.Close
			Set Rs=Nothing
		Else
			Set Rs=Server.Createobject("Adodb.Recordset")
			Sql="Select * From Dm_Banner Where BannerID="&BannerID&""
			Rs.Open Sql,Conn,1,3
			Rs("BannerName")=BannerName
			Rs("BannerCode")=BannerCode
			Rs.Update
			ID=Rs("BannerID")
			Rs.Close
			Set Rs=Nothing
		End If
		Dim Fso
		Set Fso=New DmFso
			Call Fso.CreateFile("../Banner/banner_"&ID&".js",BannerCode,True)
		Set Fso=Nothing
		Call ShowSuccMsg("<li>网站广告保存成功！</li>","Admin_Banner.asp")
	End Function
	
	Function BannerEdit()
		If Action="BannerEdit" And BannerID<>0 Then
			Dim Rs,Sql
			Set Rs=Server.Createobject("Adodb.Recordset")
			Sql="Select * From Dm_Banner Where BannerID="&BannerID&""
			Rs.Open Sql,Conn,1,3
			If Rs.Bof And Rs.Eof Then
				Call ShowErr("该广告不存在！")
			Else
				BannerName=Rs("BannerName")
				BannerCode=Rs("BannerCode")
			End If
			Rs.Close
			Set Rs=Nothing
		End If
%>
<table width="98%" border="0" align="center" cellpadding="0" cellspacing="1" class="table">
<form id="form1" name="form1" method="post" action="?Action=BannerSave" onsubmit="return checkbanner(this);">
  <tr>
    <td colspan="2" class="title">修改网站广告</td>
  </tr>
  <tr>
    <td width="14%" class="tabletd tl">广告说明：</td>
    <td class="tabletd tl"><input name="BannerName" type="text" class="text" id="BannerName" value="<%=BannerName%>" size="50" /> 
      如(网站头部广告)
      <input name="BannerID" type="hidden" id="BannerID" value="<%=BannerID%>" /></td>
    </tr>
  <tr>
    <td class="tabletd tl">广告代码：</td>
    <td class="tabletd tl"><textarea name="oSource" id="oSource" onpropertychange="change()" cols="45" rows="5" class="textrea"></textarea></td>
  </tr>
  <tr>
    <td class="tabletd tl">转换的JS代码：</td>
    <td class="tabletd tl"><textarea name="oResult" cols="45" rows="5" class="textrea" id="oResult"><%=BannerCode%></textarea></td>
  </tr>
  <tr>
    <td colspan="2" class="tbove">
      <input name="button" type="submit" class="button" id="button" value="保存广告" />
      <input name="button2" type="reset" class="button" id="button2" value="重新填写" />
      </td>
  </tr>
</form>
</table>
<%
	End Function

	Function BannerDel()
		Call DBDel("Dm_Banner","BannerID="&BannerID&"")
		Set Fso=New DmFso
			If Fso.CheckFile("../Banner/banner_"&BannerID&".js") Then
				Call Fso.DelFile("../Banner/banner_"&BannerID&".js")
			End If
		Set Fso=Nothing
		Call ShowSuccMsg("<li>网站广告删除成功！</li>","Admin_Banner.asp")
	End Function
%>