首页
印 像 新 闻 系 统
网站首页 公告信息 编程实例 PHP函数 摄影无界 全景展示 我的作品 意见专栏
 

记录排序简洁代码

【2006年07月03日 14:09:53】 【阅读:次】 【字体:大 中 小 默认】 【背景:#换背景 #换背景 #换背景 #换背景 #换背景 #换背景 #换背景 默认】

添加记录自动生成排序ID:

dim sqlCode,rsCode,TypeCode,SelfCode
   SqlCode="Select Top 1 yl_code from [yl_class] order by yl_code desc"
   Response.Write sql
   response.end
   Set rsCode=conn.execute(sqlCode)
   If rsCode.eof Then
    TypeCode=String(4-1,"0")&"1"
   Else
    SelfCode=int(right(rsCode(0),4))+1
    SelfCode=right(String(4-1,"0")&SelfCode,4)
    TypeCode=SelfCode
   End If
 Set rsCode=Nothing 

 

记录排序管理:

链接:

response.write " <a href=?action=up&colcode="&trim(rsinfoall("yl_code"))&"&mnid="&yl_id&">向下移动</a> | "
response.write "<a href=?action=down&colcode="&trim(rsinfoall("yl_code"))&"&mnid="&yl_id&">向上移动</a>"

处理代码:

<%

if Str.Get_Data("action")="up" or Str.Get_Data("action")="down" then
dim isup,ColumnCode,CodeLen,NBStr,WStr,TempStr,sql,rsupstr,sql1,sql2,sql3,rsstr
 if Str.Get_Data("action")="up" then
  IsUp=1
 else
  IsUp=0
 end if
 ColumnCode=Str.Get_Data("colcode")
 CodeLen=Len(ColumnCode)
 NBStr=String(CodeLen,"-")
set rsstr=server.CreateObject("adodb.recordset")
set Rsupstr=server.CreateObject("adodb.recordset")

 If ColumnCode<>"" And (Len(ColumnCode) Mod 4)=0 Then
  If CodeLen>4 Then WStr="and left(yl_code,"&CodeLen-4&")="&Left(ColumnCode,CodeLen-4)&""
  If IsUp Then
   SQL="select top 1 yl_code from [yl_class] where len(yl_code)="&CodeLen&" and yl_code<"&ColumnCode&" "&WStr& "  order by [yl_code] desc"
   Response.Write sql&"<br>"
             rsstr.Open sql,conn,1,1
    TempStr=rsstr("yl_code")
  Else
   SQL="select top 1 yl_code from [yl_class] where len(yl_code)="&CodeLen&" and yl_code>"&ColumnCode&" "&WStr& "  order by [yl_code]"
   Response.Write sql&"<br>"
             rsstr.Open sql,conn,1,1
    TempStr=rsstr("yl_code")
  End If
response.write TempStr&"<br>"&ColumnCode&"<br>"
response.end
  If TempStr<>"" And (Len(TempStr) Mod 4)=0 Then
   移动上层栏目
   SQL1="update  [yl_class] set yl_code="&NBStr&"+MID(yl_code,"&CodeLen+1&",len(yl_code)) where left(yl_code,"&CodeLen&")="&TempStr&""
   Response.Write sql&"<br>"
   rsupstr.Open sql1,conn,1,3
   更新目标栏目
   SQL2="update  [yl_class] set yl_code="&TempStr&"+MID(yl_code,"&CodeLen+1&",len(yl_code)) where left(yl_code,"&CodeLen&")="&ColumnCode&""
   Response.Write sql&"<br>"
   rsupstr.Open sql2,conn,1,3
   更新上层栏目
   SQL3="update  [yl_class] set yl_code="&ColumnCode&"+MID(yl_code,"&CodeLen+1&",len(yl_code)) where left(yl_code,"&CodeLen&")="&NBStr&""
   Response.Write sql&"<br>"
   conn.execute(sql)
   rsupstr.Open sql3,conn,1,3
  End If
  
 End If
response.write sql&"0<br>"
response.write sql1&"1<br>"
response.write sql2&"2<br>"
response.write sql3&"3<br>"
response.end
   
 response.Redirect(""&Request.Servervariables("HTTP_REFERER") &"")
 response.end()
End if
%>


(『印像空间』 【本文来源:『笔记』】 【作者:未知】 【录入:留印】)
限200字,剩余 字
关 键 字:
    
搜索条件: