if Child>0 then
dim rsPrevOrderID
'得到与本栏目同级的最后一个栏目的OrderID
set rsPrevOrderID=ELOOK.Execute("select Max(OrderID) From [Elook_Class] where ParentID=" & ParentID)
PrevOrderID=rsPrevOrderID(0)
set trs=ELOOK.Execute("select ClassID From [Elook_Class] where ParentID=" & ParentID & " and OrderID=" & PrevOrderID)
PrevID=trs(0)
'得到同一父栏目但比本栏目级数大的子栏目的最大OrderID,如果比前一个值大,则改用这个值。
set rsPrevOrderID=ELOOK.Execute("select Max(OrderID) From [Elook_Class] where ParentPath like '" & ParentPath & ",%'")
if (not(rsPrevOrderID.bof and rsPrevOrderID.eof)) then
if not IsNull(rsPrevOrderID(0)) then
if rsPrevOrderID(0)>PrevOrderID then
PrevOrderID=rsPrevOrderID(0)
end if
end if
end if
else
PrevID=0
end if
end if
dim ClassID,ClassName,IsIndexShow,ShowOnTop,Setting,Readme,ClassMaster,ClassPicUrl,LinkUrl,PrevOrderID
dim sql,rs,trs
dim RootID,ParentDepth,ParentPath,ParentStr,ParentName,MaxClassID,MaxRootID,ForeignLink
dim PrevID,NextID,Child
ClassName=FilterGetString(ELOOK.CheckStr(trim(request("ClassName")))) 'Function.asp911行
ForeignLink=FilterGetString(ELOOK.CheckStr(trim(request("ForeignLink"))))
IsIndexShow=trim(request("IsIndexShow"))
'是否为首页调用
If IsIndexShow="" Then
IsIndexShow=1
Else
IsIndexShow=Cint(IsIndexShow)
End If
'该栏目介绍
Readme=FilterGetString(ELOOK.CheckStr(trim(request("Readme"))))
if ClassName="" then
FoundErr=True
ErrCodes=ErrCodes & "<br><li>栏目名称不能为空!</li>"
end if
'此栏目是否为外部链接,如果是,则不能在此栏目下添加
if ParentID="-9" then
FoundErr=True
ErrCodes=ErrCodes & "<br><li>不能在外部栏目里添加子栏目!</li>"
end if
if FoundErr=True then
exit sub
end if
'选取ClassID最大的,为了使要添加的栏目的CLASSID为下一个
set rs = ELOOK.Execute("select Max(ClassID) From [Elook_Class]")
MaxClassID=rs(0)
if isnull(MaxClassID) then
MaxClassID=0
end if
rs.close
'将要添加的ID加1,也就是取下一个ID
ClassID=MaxClassID+1
set rs=ELOOK.Execute("select max(rootid) From [Elook_Class]")
MaxRootID=rs(0)
if isnull(MaxRootID) then
MaxRootID=0
end if
rs.close
RootID=MaxRootID+1
那个OrderID和ROOTID都不知道有什么用,怎么算出来的,高手指点一下!!
[此贴子已经被作者于2005-12-14 14:54:21编辑过]
if ParentID>0 then
sql="select * From [Elook_Class] where ClassID=" & ParentID & ""
rs.open sql,conn,1,1
if rs.bof and rs.eof then
FoundErr=True
ErrCodes=ErrCodes & "<br><li>所属栏目已经被删除!</li>"
end if
if FoundErr=True then
rs.close
set rs=nothing
exit sub
else
RootID=rs("RootID")
ParentName=rs("ClassName")
ParentDepth=rs("Depth")
ParentPath=rs("ParentPath")
Child=rs("Child")
ParentPath=ParentPath & "," & ParentID '得到此栏目的父级栏目路径
PrevOrderID=rs("OrderID")
if Child>0 then
dim rsPrevOrderID
'得到与本栏目同级的最后一个栏目的OrderID
set rsPrevOrderID=ELOOK.Execute("select Max(OrderID) From [Elook_Class] where ParentID=" & ParentID)
PrevOrderID=rsPrevOrderID(0)
set trs=ELOOK.Execute("select ClassID From [Elook_Class] where ParentID=" & ParentID & " and OrderID=" & PrevOrderID)
PrevID=trs(0)
'得到同一父栏目但比本栏目级数大的子栏目的最大OrderID,如果比前一个值大,则改用这个值。
set rsPrevOrderID=ELOOK.Execute("select Max(OrderID) From [Elook_Class] where ParentPath like '" & ParentPath & ",%'")
if (not(rsPrevOrderID.bof and rsPrevOrderID.eof)) then
if not IsNull(rsPrevOrderID(0)) then
if rsPrevOrderID(0)>PrevOrderID then
PrevOrderID=rsPrevOrderID(0)
end if
end if
end if
else
PrevID=0
end if
end if
rs.close