<!--#include file="conn.asp"-->
<html>
<head>
<title>天气预报</title>
<link href="images/style.css" rel="stylesheet" type="text/css"></head>
<body topmargin=0 leftmargin=0>
<%
Private Function judge(url)

  if instr(1,url,"http://www.weathercn.com/forecast/citydetail.jsp",1)<>0 then 
  judge=0 
  else
  judge=1
  end if
end Function
%>
<%call main()%>
<%sub main()%>

<%
if Request("action") = "add" then
	call add()
elseif request("action") = "del" then
	call del()
elseif request("action") = "edit" then
	call edit()
elseif request("action") = "saveedit" then
	call saveedit()
elseif request("action") = "saveeditdemo" then
	call saveeditdemo()	
else
	call list()
end if
%>
<%end sub%>
<%sub add()%>
【<a href=help.htm  target="_blank"><font color=#cc0000>使用帮忙</font></a>】

<table width="550" cellspacing="1" cellpadding="3" bgcolor="#999999" align="center">
<form action="login.asp?action=saveedit" method=POST name=add>
<tr bgcolor="#CCCCCC" align=center><td colspan="2"><b>增加天气预报地址</b></td></tr>
<tr bgcolor="#eeeeee"><td align=right>地址名称：</td><td><input type=text name=addresname size=68 value=信阳></td></tr>
<tr bgcolor="#eeeeee"><td align=right>天气地址：</td><td><input type=text name=url size=68 value=http://www.weathercn.com/forecast/citydetail.jsp?sta_id=57297></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 edit()%>
<%
     set rs=server.createobject("adodb.recordset")
   sql="select * from [weather] where id="&request("id")
   rs.open sql,conn,1,1
%>
【<a href=help.htm  target="_blank"><font color=#cc0000>使用帮忙</font></a>】
<table width="500" cellspacing="1" cellpadding="3" bgcolor="#999999" align="center">
<form action="login.asp?action=saveeditdemo&id=<%=rs("id")%>" 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=addresname size=60 value=<%=rs("addresname")%>></td></tr>
<tr bgcolor="#eeeeee"><td align=right>天气地址：</td><td><input type=text name=url size=60 value=<%=rs("url")%>></td></tr>
<tr bgcolor=#eeeeee><td></td><td><input type="submit" name="Submit" value="确定"></td></tr>
</form></table>
<%
rs.Close 
set rs=nothing
end sub%>


<%sub saveedit()%>
<%if request("addresname")="" then%>
<script language=javascript>  
alert( "错误：请输入地址名称！"  );
location.href = "javascript:history.back()"  
</script>
<%elseif request("url")="" then%>
<script language=javascript>  
alert( "错误：请输入天气地址！"  );
location.href = "javascript:history.back()"  
</script>
<%elseif judge(request("url")) then%>
<script language=javascript>  
alert( "错误：请输入天气地址有误！\n请重新输入！"  );
location.href = "javascript:history.back()"  
</script>

<%else%>
<%
set rs = server.CreateObject ("adodb.recordset")
sql = "select * from weather"
	rs.Open sql,conn,1,3
	rs.AddNew
	rs("addresname") = Request("addresname")
	rs("url") = Request("url")
	rs("Addtime") = now()
	rs.Update 
	rs.Close 
set rs=nothing
%>
<script language=javascript>  
alert( "模版天气预报成功"  );
location.href = "login.asp"  
</script>
<%end if%>
<%end sub%>
<%sub del()
sql="delete from weather where id="&cstr(request("id"))
conn.execute(sql)
%>
<script language=javascript>  
alert( "天气预报删除成功"  );
location.href = "login.asp"  
</script>
<%end sub%>

<%sub list()%>
<table width="500" 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 weather order by addtime 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>【<a href=login.asp?action=add><font color=#cc0000>增加天气地址</font></a>】【<a href=help.htm  target="_blank"><font color=#cc0000>使用帮忙</font></a>】</td>
  </tr></table>
<%else%>
【<a href=login.asp?action=add><font color=#cc0000>增加天气地址</font></a>】【<a href=help.htm  target="_blank"><font color=#cc0000>使用帮忙</font></a>】
<tr bgcolor="#ffffff" height=20>
  <td colspan="5" >&nbsp;</td>
</tr>
<tr bgcolor="#dddddd" align=center><td><b>ID</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("id")%></b></td><td><center><font color=#0033cc><a href= show.asp?id=<%=rs("id")%> target="_blank"><%=rs("addresname")%></font></td><td>&nbsp;&nbsp;&nbsp;&nbsp;<font color=#666666><%=rs("addtime")%></font></td>
<td><center>【<a href=login.asp?action=edit&id=<%=rs("id")%>><font color=#cc0000>修改</font></a>】【<a href=login.asp?action=del&id=<%=rs("id")%>><font color=#cc0000>删除</font></a>】</td></tr>

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

<%if request("addresname")="" then%>
<script language=javascript>  
alert( "错误：请输入地址名称！"  );
location.href = "javascript:history.back()"  
</script>
<%elseif request("url")="" then%>
<script language=javascript>  
alert( "错误：请输入天气地址！"  );
location.href = "javascript:history.back()"  
</script>
<%elseif judge(request("url")) then%>
<script language=javascript>  
alert( "错误：请输入天气地址有误！\n请重新输入！"  );
location.href = "javascript:history.back()"  
</script>

<%else%>
<%
set rs = server.CreateObject ("adodb.recordset")
sql = "select * from weather where id="&cstr(request("id"))
	rs.Open sql,conn,1,3
if not rs.eof then
	rs("addresname").value = Request("addresname")
	rs("url").value = Request("url")
	rs("addtime").value =now()
	rs.Update 
end if
rs.Close 
set rs=nothing
%>
<script language=javascript>  
alert( "修改天气预报成功"  );
location.href = "login.asp"  
</script>
<%end if%>
<%end sub%>
</body>
</html>
