<!--#include file="conn.asp"-->
<%
dim sql
call main()
%>



<%sub main()

%>

<table width="100%" border="0" cellspacing="3" cellpadding="3"><tr><td height="20">当前位置：<a href=admin_demo.asp>模版管理</a></td>
</tr></table>
<%
if Request("action") = "adddemo" then
	call adddemo()
elseif request("action") = "savedemo" then
	call savedemo()
elseif request("action") = "deldemo" then
	call deldemo()
elseif request("action") = "editdemo" then
	call editdemo()
elseif request("action") = "saveeditdemo" then
	call saveeditdemo()
elseif request("action") = "demono" then
	call demono()
elseif request("action") = "demoyes" then
	call demoyes()
else
	call demolist()
end if
%>
<%end sub%>


<%sub demolist()%>
<table width="95%" cellspacing="1" cellpadding="3" bgcolor="#999999" align="center">
<tr bgcolor="#CCCCCC" align=center><td colspan="5"><b>静态页面模版管理</b></td></tr>
<%

set rs = server.CreateObject ("Adodb.recordset")
sql = "select * from demo order by demoid desc"
rs.open sql,conn,1,1
if rs.eof and rs.bof then
%>
<tr bgcolor="#ffffff" height=20><td colspan="5" ><font color=#cc0000>目前还没有模版！</a></td></tr></table>
<%else%>
<tr bgcolor="#ffffff" height=20><td colspan="5" >【<a href=admin_demo.asp?action=adddemo><font color=#cc0000>增加模版</font></a>】</td></tr>
<tr bgcolor="#dddddd" align=center><td><b>ID</b></td><td><b>模版名称</b></td><td><b>模版说明</b></td><td><b>创建时间</b></td><td><b>管理操作</b></td></tr>
<%do while not rs.EOF%>
<tr bgcolor="#eeeeee"><td><center><b><%=rs("demoid")%></b></td><td><center><font color=#0033cc><%=rs("demoname")%></font></td><td>&nbsp;&nbsp;&nbsp;&nbsp;<font color=#666666><%=rs("demoinfo")%></font></td><td><center><%=rs("addtime")%></td>
<td><center>【<a href=admin_demo.asp?action=editdemo&demoid=<%=rs("demoid")%>><font color=#cc0000>修改</font></a>】【<a href=admin_demo.asp?action=deldemo&demoid=<%=rs("demoid")%>><font color=#cc0000>删除</font></a>】【<%if rs("ifuse")=1 then%><a href=admin_demo.asp?action=demono&demoid=<%=rs("demoid")%>><font color=#0000ff>已启用</font></a><%else%><a href=admin_demo.asp?action=demoyes&demoid=<%=rs("demoid")%>>已停用</a><%end if%>】</td></tr>

<%
rs.MoveNext 
loop
end if
rs.Close 
set rs=nothing
%>
</table>
<%end sub%>

<%sub adddemo()%>
<table width="95%" cellspacing="1" cellpadding="3" bgcolor="#999999" align="center">
<form action="admin_demo.asp?action=savedemo" method=POST name=adddemo>
<tr bgcolor="#CCCCCC" align=center><td colspan="2"><b>增加静态页面模版</b></td></tr>
<tr bgcolor="#eeeeee"><td align=right>模版名称：</td><td><input type=text name=demoname size=20></td></tr>
<tr bgcolor="#eeeeee"><td align=right>模版内容：</td><td><textarea name="demohtml" cols="80" rows="15"></textarea></td></tr>
<tr bgcolor="#eeeeee"><td align=right>模版说明：</td><td><textarea name="demoinfo" cols="40" rows="3"></textarea></td></tr>
<tr bgcolor=#eeeeee><td></td><td><input type="submit" name="Submit" value="确定"> &nbsp;&nbsp;<input type="Reset" name="Reset" value="重填"></td></tr>
</form></table>
<%end sub%>


<%sub savedemo()%>
<%if request("demoname")="" then%>
<script language=javascript>  
alert( "错误：请输入模版名称！"  );
location.href = "javascript:history.back()"  
</script>
<%elseif request("demohtml")="" then%>
<script language=javascript>  
alert( "错误：请输入模版内容！"  );
location.href = "javascript:history.back()"  
</script>
<%elseif request("demoinfo")="" then%>
<script language=javascript>  
alert( "错误：请输入模版介绍！"  );
location.href = "javascript:history.back()"  
</script>

<%else%>
<%
set rs = server.CreateObject ("adodb.recordset")
sql = "select * from demo"
	rs.Open sql,conn,1,3
	rs.AddNew
	rs("demoname") = Request("demoname")
	rs("demohtml") = Request("demohtml")
	rs("demoinfo") = Request("demoinfo")
	rs("Addtime") = now()
	rs("ifuse") = 0
	rs.Update 
	rs.Close 
set rs=nothing
%>
<script language=javascript>  
alert( "模版添加成功"  );
location.href = "admin_demo.asp"  
</script>
<%end if%>
<%end sub%>


<%sub deldemo()
sql="delete from demo where demoid="&cstr(request("demoid"))
conn.execute(sql)
%>
<script language=javascript>  
alert( "模版删除成功"  );
location.href = "admin_demo.asp"  
</script>
<%end sub%>


<%sub demono()
sql="update demo set ifuse=0  where demoid="&cstr(request("demoid"))
conn.execute(sql)
response.redirect "admin_demo.asp"
end sub%>

<%sub demoyes()
sql="update demo set ifuse=1  where demoid="&cstr(request("demoid"))
conn.execute(sql)
response.redirect "admin_demo.asp"
end sub%>


<%sub editdemo()%>
<%
     set rs=server.createobject("adodb.recordset")
   sql="select * from [demo] where demoid="&request("demoid")
   rs.open sql,conn,1,1
%>
<table width="95%" cellspacing="1" cellpadding="3" bgcolor="#999999" align="center">
<form action="admin_demo.asp?action=saveeditdemo&demoid=<%=rs("demoid")%>" method=POST name=editdemo>
<tr bgcolor="#CCCCCC" align=center><td colspan="2"><b>修改静态页面模版</b></td></tr>
<tr bgcolor="#eeeeee"><td align=right>模版名称：</td><td><input type=text name=demoname size=20 value=<%=rs("demoname")%>></td></tr>
<tr bgcolor="#eeeeee"><td align=right>模版内容：</td><td><textarea name="demohtml" cols="80" rows="15"><%=rs("demohtml")%></textarea></td></tr>
<tr bgcolor="#eeeeee"><td align=right>模版说明：</td><td><textarea name="demoinfo" cols="40" rows="3"><%=rs("demoinfo")%></textarea></td></tr>
<tr bgcolor=#eeeeee><td></td><td><input type="submit" name="Submit" value="确定"></td></tr>
</form></table>
<%end sub%>


<%sub saveeditdemo()%>
<%if request("demoname")="" then%>
<script language=javascript>  
alert( "错误：请输入模版名称！"  );
location.href = "javascript:history.back()"  
</script>
<%elseif request("demohtml")="" then%>
<script language=javascript>  
alert( "错误：请输入模版内容！"  );
location.href = "javascript:history.back()"  
</script>
<%elseif request("demoinfo")="" then%>
<script language=javascript>  
alert( "错误：请输入模版介绍！"  );
location.href = "javascript:history.back()"  
</script>
<%else%>
<%
set rs = server.CreateObject ("adodb.recordset")
sql = "select * from demo where demoid="&cstr(request("demoid"))
	rs.Open sql,conn,1,3
if not rs.eof then
	rs("demoname").value = Request("demoname")
	rs("demohtml").value = Request("demohtml")
	rs("demoinfo").value = Request("demoinfo")
	rs.Update 
end if
rs.Close 
set rs=nothing
%>
<script language=javascript>  
alert( "模版修改成功！"  );
location.href = "admin_demo.asp"  
</script>
<%end if%><%end sub%>