📄 admin_news_lm_move.asp
字号:
<!-- 顺序移动 -->
<td width="90" align="center">
<!-- 顺序上移 -->
<% if class3_hao>1 then %>
<a href="?id=<%=temp_rs3("id")%>&action=hao_up&class=3&lm=<%=temp_rs3("lm3")%>&lmid=<%=temp_rs3("lmid")%>&id_desc=<%=class3_hao-1%>"><font color="green">↑上移</font></a>
<% else %>
<font color="#CCCCCC">↑上移</font>
<% end if %>
<!-- 顺序下移 -->
<% if class3_hao<temp_rs3.recordcount then %>
<a href="?id=<%=temp_rs3("id")%>&action=hao_down&class=3&lm=<%=temp_rs3("lm3")%>&lmid=<%=temp_rs3("lmid")%>&id_desc=<%=class3_hao+1%>"><font color="green">下移↓</font></a>
<% else %>
<font color="#CCCCCC">下移↓</font>
<% end if %>
<%temp_rs3("id_desc")=class3_hao%>
</td>
<!-- 栏目移动 -->
<td width="90" align="center" >
<!-- 三级栏目上移 -->
<% if up2_id<>0 then %>
<a href="?action=lm_up&class=3&id=<%=temp_rs3("id")%>&lmid=<%=temp_rs3("lmid")%>&m_id=<%=up2_id%>&m_lmid=<%=up2_lmid%>"><font color="red">↑上移</font></a>
<% else %>
<font color="#CCCCCC">↑上移</font>
<% end if %>
<!-- 三级栏目下移 -->
<% if dw2_id<>0 then %>
<a href="?action=lm_down&class=3&id=<%=temp_rs3("id")%>&lmid=<%=temp_rs3("lmid")%>&m_id=<%=dw2_id%>&m_lmid=<%=dw2_lmid%>"><font color="red">下移↓</font></a>
<% else %>
<font color="#CCCCCC">下移↓</font>
<% end if %>
</td>
<!-- 旧第三级子栏目视图 -->
<td>
<font color="<%=temp_rs3("fontcolor")%>"> ├<%=temp_rs3("lm3")%></font>
<% if temp_rs3("id")=move_after_id then response.write move_icon %>
</td>
</tr>
<!-- 判断第二级栏目 -->
<%
temp_rs3.update
temp_rs3.movenext
loop '三级temp_rs3循环
temp_rs3.close
set temp_rs3=nothing
'取出本级的栏目ID号,提供给下一次环来调用
'取上移的ID
up2_id=temp_rs2("id")
up2_lmid=temp_rs2("lmid")
temp_rs2.update '保存id_desc字段
temp_rs2.movenext '移动记录
loop '二级temp_rs2循环
temp_rs2.close
set temp_rs2=nothing
'二级栏目结束 -->
'取出本级的栏目ID号,提供给下一次环来调用
up1_id=temp_rs("id")
up1_lmid=temp_rs("lmid")
temp_rs.update '保存id_desc值
temp_rs.movenext
loop '一级temp_rs栏目循环
else '无一级栏目时。
%>
<tr><td colspan="4">暂无栏目记录</td></tr>
<%
end if '新栏目视图结束
temp_rs.close
set temp_rs=nothing
%>
</table> <!-- 新栏目视图表格结束。 -->
<!--table1的第二列结束 -->
</td>
</tr>
<!-- 结束栏目记录输出 -->
</table><!-- table1的结束 -->
<table width="100%"><tr><td class="forumRaw">
<FONT COLOR="#FF0066">文章栏目顺序和子栏目移动说明:<BR> 一、顺序移动:对数据库的栏目表[lm]自动增加了一个数值型(int)的字段(id_desc),顺序调整实际上是调整id_desc的数字大小顺序。<br>要达到有正确栏目顺序,必须对引用栏目的SQL语句中的排序order by id 改为:order by id_desc,id 。 栏目顺序调整仅在同级栏目内进行。<br> 二、支持两种子栏目移动:(一)、第二级子栏目移动变为另一个第二级子栏目。(二)、第三级子栏目移动作为另一个第三级子栏目。</FONT>
</td></tr>
<tr><td class="forumRaw" align="center">
<input type="submit" name="B1" value=" 确 定 " onclick='{if(confirm("严重警告:确实要移动文章的栏目吗?\n\n建议在移动栏目之前先做好数据库备份!")
){return true;}return false;}'>
<input type="button" name="B2" value=" 返 回 " onClick="location='admin_news_lm.asp'">
</td></tr>
</form>
</table>
<%
'显示栏目的视图
end sub '结束,显示栏目的视图show_lm_window()
'第一次进行栏目操作
sub create_temp_table()
'判断是否有增加了一个顺序号的字段:id_desc
sql="select * from lm "
Set rs = Server.CreateObject("ADODB.RecordSet")
rs.Open sql,conn,1,1
for i=0 to rs.fields.count-1
if rs.fields(i).name="id_desc" then
if_field=true '判断一个数据表lm中是否存在一个名称为:id_desc的字段
exit for
else
if_field=false
end if
next
rs.close
set rs=nothing
'没有在数据表[lm]中没有id_desc这个字段,则增加一个。并写入一个初始值
if not if_field then
conn.execute "ALTER TABLE [lm] add id_desc int"
conn.Execute "update [lm] set [id_desc]=50"
end if
'结束判断字段id_desc是否存在。
'判断数据库中一个数据表是否存在.
tablename="_temp_lm" '定义:数据库中的数据表名称
if_table=false '定义:是否存一个标志
set rsSchema=Conn.openSchema(20) 'openschema这个属性,请google一下可知.
rsSchema.movefirst
Do Until rsSchema.EOF
if rsSchema("TABLE_TYPE")="TABLE" then
if rsSchema("TABLE_NAME")=tablename then
if_table=true
exit do
end if
end if
rsSchema.movenext
Loop
rsSchema.close
set rsSchema=nothing
'如果存在lm的临时表,则先删除这个临时数据表
if if_table then conn.execute "drop table _temp_lm"
'创建一个临时表,做为新移动后的栏目表.
Conn.execute "create table _temp_lm (id int,lm text(50),mb text(50),lm2 text(50),lm3 text(50),lmid text(50) ,fontcolor text(50), pic int, id_desc int)"
'把LM中的内容填写入临时表中.以做为备份栏目数据表用
Conn.execute "insert into _temp_lm(id,lm,mb,lm2,lm3,lmid,fontcolor,pic,id_desc) SELECT id,lm,mb,lm2,lm3,lmid,fontcolor,pic,id_desc FROM lm"
'转到显示栏目视图
show_lm_window()
end sub '结束生成临时表
'顺序号上移函数:
sub done_hao_up()
class_n=request("class")
id=request("id")
lm=trim(request("lm"))
lmid=trim(request("lmid"))
id_desc=clng(request("id_desc"))
if class_n="1" then where_sql=" lm<>'' "
if class_n="2" then where_sql=" lm2<>'' and lmid='"&lmid&"' "
if class_n="3" then where_sql=" lm3<>'' and lmid='"&lmid&"' "
if id_desc>0 then
sql = "select id,id_desc from _temp_lm where "&where_sql&" order by id_desc,id"
Set rs = Server.CreateObject("ADODB.RecordSet")
rs.Open sql,conn,1,3
do while not rs.eof
if rs("id")=clng(id) then
rs("id_desc")=id_desc
rs.MovePrevious '移到前一条记录
rs("id_desc")=id_desc+1
rs.update
exit do
end if
rs.movenext
loop
rs.close
set rs=nothing
else
response.redirect "javascript:history.back()"
end if
response.redirect "admin_news_lm_move.asp?action=show&move_after_id="&id
end sub '结束:顺序号上移函数:
'顺序号下移函数:
sub done_hao_down()
class_n=request("class")
id=request("id")
lm=trim(request("lm"))
lmid=trim(request("lmid"))
id_desc=clng(request("id_desc"))
if class_n="1" then where_sql=" lm<>'' "
if class_n="2" then where_sql=" lm2<>'' and lmid='"&lmid&"' "
if class_n="3" then where_sql=" lm3<>'' and lmid='"&lmid&"' "
sql = "select id,id_desc from _temp_lm where "&where_sql&" order by id_desc,id"
Set rs = Server.CreateObject("ADODB.RecordSet")
rs.Open sql,conn,1,3
max_record=rs.recordcount
if id_desc<=max_record then
do while not rs.eof
if rs("id")=clng(id) then
rs("id_desc")=id_desc
rs.movenext '移到前一条记录
rs("id_desc")=id_desc-1
rs.update
exit do
end if
rs.movenext
loop
rs.close
set rs=nothing
else
rs.close
set rs=nothing
response.redirect "javascript:history.back()"
end if
response.redirect "admin_news_lm_move.asp?action=show&move_after_id="&id
end sub '结束:顺序号上移函数:
'栏目上移函数:
sub done_lm_up()
class_n=request("class")
'本记录
id=request("id")
lmid=trim(request("lmid"))
'移动后的记录
m_id=request("m_id")
m_lmid=trim(request("m_lmid"))
sql = "select id,lmid from _temp_lm where id="&id
Set rs = Server.CreateObject("ADODB.RecordSet")
rs.Open sql,conn,1,3
rs("lmid")=m_id
rs.update
rs.close
set rs=nothing
response.redirect "admin_news_lm_move.asp?action=show&move_after_id="&id
end sub '结束:顺序号上移函数:
'栏目下移函数:
sub done_lm_down()
class_n=request("class")
'本记录
id=request("id")
lmid=trim(request("lmid"))
'移动后的记录
m_id=request("m_id")
m_lmid=trim(request("m_lmid"))
sql = "select id,lmid from _temp_lm where id="&id
Set rs = Server.CreateObject("ADODB.RecordSet")
rs.Open sql,conn,1,3
rs("lmid")=m_id
rs.update
rs.close
set rs=nothing
response.redirect "admin_news_lm_move.asp?action=show&move_after_id="&id
end sub '结束:顺序号上移函数:
'同意进行栏目移动
sub move_lm_ok() '同意进行移动时。
'更新数据库中[lm]表的顺序和栏目位置:
temp_sql="select id,lmid,id_desc from _temp_lm order by id_desc,id"
Set temp_rs = Server.CreateObject("ADODB.RecordSet")
temp_rs.Open temp_sql,conn,1,3
do while not temp_rs.eof
conn.execute("update [lm] set lmid='"&temp_rs("lmid")&"',id_desc="&temp_rs("id_desc")&" where id="&temp_rs("id"))
temp_rs.movenext
loop
temp_rs.close
set temp_rs=nothing
'取出二级子栏目,更新顺序和栏目和[news]相关文章
temp_sql2 = "select id,lmid from _temp_lm where lm2<>'' order by id_desc,id"
Set temp_rs2 = Server.CreateObject("ADODB.RecordSet")
temp_rs2.Open temp_sql2,conn,1,3
do while not temp_rs2.eof
'开始更新文章[news]的所属的二级子栏目:
conn.execute("update [news] set lm='"&trim(temp_rs2("lmid"))&"' where lm2='"&trim(cstr(temp_rs2("id")))&"'")
'取出三级子栏目,更新[lm]的顺序和栏目和更新[news]文章
temp_sql3 = "select id,lmid from _temp_lm where lm3<>'' and lmid='"&trim(cstr(temp_rs2("id")))&"' order by id_desc,id"
Set temp_rs3 = Server.CreateObject("ADODB.RecordSet")
temp_rs3.Open temp_sql3,conn,1,3
do while not temp_rs3.eof
'开始更新文章[news]的所属的三级子栏目:
conn.execute("update [news] set lm='"&trim(temp_rs2("lmid"))&"',lm2='"&trim(cstr(temp_rs2("id")))&"' where lm3='"&trim(cstr(temp_rs3("id")))&"'")
temp_rs3.movenext
loop
temp_rs3.close
set temp_rs3=nothing
temp_rs2.movenext
loop
temp_rs2.close
set temp_rs2=nothing
'conn.execute "drop table _temp_lm" '删除临时表
response.redirect "admin_news_lm_move.asp?action=show"
' response.redirect "admin_news_lm.asp?action=show"
end sub '结束栏目移动操作
%>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -