<!--#include file="../siteconfig/conn.asp"-->
<%
if session("adminlogin")<>sessionvar then
Response.Write("<script language=javascript>alert('你尚未登录，或者超时了！请重新登录');this.location.href='login.asp';</script>")
Response.End
End if
%>
<!--#include file="Admin_ClassFunction.asp"-->
<HTML>
<HEAD>
<TITLE>分类管理</TITLE>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312"> 
<LINK REL="stylesheet" HREF="css.css" TYPE="text/css">
</HEAD>
<script language="JavaScript" type="text/javascript" src="js.js"></script>
<BODY>
<%dim Menu,ClassAd_Id,ClassAd_Title,ClassAd_StartTime,ClassAd_EndTime,ClassAd_ClassId,ClassAd_Html,ClassAd_Type
ClassAd_Id=Request("ClassAd_Id")
ClassAd_Title=Request("ClassAd_Title")
ClassAd_StartTime=Request("ClassAd_StartTime")
ClassAd_EndTime=Request("ClassAd_EndTime")
ClassAd_ClassId=Request("ClassAd_ClassId")
ClassAd_Html=Request("ClassAd_Html")
ClassAd_Type=Request("ClassAd_Type")
Menu=Request("Menu")
redim ClassArray(0,6)
if Menu="UpClassAd" then
   rs.open"select * from ClassAd where ClassAd_ClassId="&ClassAd_ClassId&" and ClassAd_Type="&ClassAd_Type,conn,1,3
   if not rs.eof and not rs.bof then
      if rs("ClassAd_Id")<>int(ClassAd_Id) then
          Response.Write("<script language=javascript>alert('广告已存在');javascript:history.go(-1)</script>")
	      Response.End()
	  end if
   end if
   rs.close
   rs.open"select * from ClassAd where ClassAd_Id="&ClassAd_Id,conn,1,3
   if not rs.eof then
      rs("ClassAd_Title")=ClassAd_Title
	  rs("ClassAd_StartTime")=ClassAd_StartTime
	  rs("ClassAd_EndTime")=ClassAd_EndTime
	  rs("ClassAd_ClassId")=ClassAd_ClassId
	  rs("ClassAd_Html")=ClassAd_Html
	  rs("ClassAd_Type")=ClassAd_Type
   rs.update
   rs.close
   Response.Write("<script language=javascript>alert('广告修改成功');parent.window.location.reload();DivOpenClose('',2,0,0);</script>")
   Response.End()
   else
       Response.Write("<script language=javascript>alert('没有找在记录');DivOpenClose('',2,0,0);</script>")
   end if
end if
rs.open"select * from ClassAd where ClassAd_Id="&ClassAd_Id,conn,1,3
   ClassArray(j,0)=rs("ClassAd_ClassId")
   ClassArray(j,1)=rs("ClassAd_Title")
   ClassArray(j,2)=rs("ClassAd_StartTime")
   ClassArray(j,3)=rs("ClassAd_EndTime")
   ClassArray(j,4)=rs("ClassAd_Id")
   ClassArray(j,5)=rs("ClassAd_Html")
   ClassArray(j,6)=rs("ClassAd_Type")
rs.close%>
<table width="100%" border="0" align="center" cellpadding="5" cellspacing="1" bgcolor="#EEEEEE">
  <tr>
    <td width="45%">修改分类广告</td>
    <td width="55%" align="right"><a href="#" onClick="javascript:DivOpenClose('',2,0,0);return false">关闭</a></td>
  </tr>
</table>
<form name="ClassAdFrom" method="post" action="?Menu=UpClassAd" id="ClassAdFrom" onSubmit="return ClassAdCheck();">
<table width="100%" border="0" align="center" cellpadding="5" cellspacing="1" bgcolor="#EEEEEE">
  <tr bgcolor="#FFFFFF">
    <td>广告ID</td>
    <td><%=ClassArray(i,4)%><input name="ClassAd_Id" type="hidden" value="<%=ClassArray(i,4)%>"></td>
  </tr>
  <tr bgcolor="#FFFFFF">
    <td>广告名称</td>
    <td><input name="ClassAd_Title" type="text" class="inputcss" id="ClassAd_Title" value="<%=ClassArray(i,1)%>" size="15"></td>
  </tr>
  <tr bgcolor="#FFFFFF">
    <td>开始时间</td>
    <td><input name="ClassAd_StartTime" type="text" class="inputcss" id="ClassAd_StartTime" value="<%=ClassArray(i,2)%>" size="15">
      时间格式 如:2008-11-11 </td>
  </tr>
  <tr bgcolor="#FFFFFF">
    <td>结束时间</td>
    <td><input name="ClassAd_EndTime" type="text" class="inputcss" id="ClassAd_EndTime" value="<%=ClassArray(i,3)%>" size="15"> 
    时间格式 如:2008-11-11 不设就是长久广告 </td>
  </tr>
  <tr bgcolor="#FFFFFF">
    <td>上级分类</td>
    <td><select name="ClassAd_ClassId" class="inputcss" id="ClassAd_ClassId">
      <option value="0" selected>-默认广告-</option>
<%
set RsClass(0)=server.createobject("adodb.recordset")
RsClass(0).open "select Class_Id,Class_Name from Class where Class_TopClassId=0",conn,1,3
while not RsClass(0).eof
    if RsClass(0)("Class_Id")=ClassArray(j,0) then
	    response.write "<option value='"&RsClass(0)("Class_Id")&"' selected>"&RsClass(0)("Class_Name")&"</option>"&vbCrLf
	else
		response.write "<option value='"&RsClass(0)("Class_Id")&"'>"&RsClass(0)("Class_Name")&"</option>"&vbCrLf
	end if
	call listunder(1)
	RsClass(0).movenext
wend
%>
    </select></td>
  </tr>
  
  <tr bgcolor="#FFFFFF">
    <td>广告HTML</td>
    <td><textarea name="ClassAd_Html" cols="30" rows="5" class="inputcss" id="ClassAd_Html"><%=ClassArray(i,5)%></textarea> 支持HTML和JS</td>
  </tr>
  <tr bgcolor="#FFFFFF">
    <td>广告类型</td>
    <td><select name="ClassAd_Type" class="inputcss" id="ClassAd_Type">
	<%if lassArray(i,6)=0 then%>
	 <option value="0" selected>顶部广告</option>
	 <option value="1">底部广告</option>
	 <%else%>
	 <option value="0">顶部广告</option>
	 <option value="1"selected>底部广告</option>
	 <%end if%>
	 </select></td>
  </tr>
  <tr bgcolor="#FFFFFF">
    <td>&nbsp;</td>
    <td><input name="Submit" type="submit" class="SubmitCss" value="修改广告"></td>
  </tr>
</table>
</form>
</BODY>
</HTML>

