⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 category_class.asp

📁 这是我根据动网新闻核心自行设计的校园新闻系统
💻 ASP
📖 第 1 页 / 共 2 页
字号:
		dim downl
		downl=""
		dlist=List(dlid)
		for i=1 to ubound(dlist)
			downl=downl&"<option value='"&dlist(i,2)&"'"
			if dlist(i,2)=dcategoryid then
				downl=downl&" selected"
			end if
			downl=downl&">"&dlist(i,0)&"</option>"
		next
		Response.write downl
	End Function


	'=============================================
	'
	'返回上一级CategoryId
	'最后修改:2004-03-31
	'BY:czy
	'
	'=============================================
	Public Function GetUpCategoryId(CategoryId)
		If Len(CategoryId)=5 Then
			GetUpCategoryId=""
		Else
			GetUpCategoryId=Left(CategoryId,Len(Categoryid)-5)
		End If
	End Function

	'=============================================
	'
	'返回CategoryName
	'最后修改:2004-03-31
	'BY:czy
	'
	'=============================================
	Public Function GetCategoryName(id)
		Dim RSGetCN
		Dim CategoryName
		Set RSGetCN=ActionConn.execute("Select CategoryName from category where id="&id)
		CategoryName=RSGetCN("CategoryName")
		RSGetCN.Close
		Set RSGetCN=nothing
		GetCategoryName=CategoryName
	End Function

	'=============================================
	'
	'返回CategoryType
	'最后修改:2004-03-31
	'BY:czy
	'
	'=============================================
	Public Function GetCategoryType(id)
		Dim RSGetCT
		Dim CategoryType
		Set RSGetCT=ActionConn.execute("Select CategoryType from category where id="&id)
		CategoryType=RSGetCT("CategoryType")
		RSGetCT.Close
		Set RSGetCT=nothing
		GetCategoryType=CategoryType
	End Function

	'=============================================
	'
	'返回CategoryType
	'最后修改:2004-03-31
	'BY:czy
	'
	'=============================================
	Public Function GetCategoryOrder(id)
		Dim RSGetCO
		Dim CategoryOrder
		Set RSGetCO=ActionConn.execute("Select CategoryOrder from category where id="&id)
		CategoryOrder=RSGetCO("CategoryOrder")
		RSGetCO.Close
		Set RSGetCO=nothing
		GetCategoryOrder=CategoryOrder
	End Function

	'=============================================
	'
	'修改CategoryOrder来修改排序
	'最后修改:2004-03-31
	'BY:czy
	'
	'=============================================
	public function SetCategoryOrder(action,id)
	Dim CategoryId
	Dim CategoryOrder
	Dim UpCategoryId
	Dim LenUpCategoryId
	Dim CategoryType
		CategoryId=GetCategoryId(id)
		CategoryOrder=GetCategoryOrder(id)
		CategoryType=GetCategoryType(id)
		UpCategoryId=GetUpCategoryId(CategoryId)
		LenUpCategoryId=Len(UpCategoryId)

	If action="up" Then
		'获取上一行的信息
		Set rs_get_up_id=ActionConn.execute("select TOP 1 id,CategoryOrder from category where left(categoryid,"&LenUpCategoryId&")='"&UpCategoryId&"' and len(categoryid)="&len(CategoryId)&" and CategoryOrder<"&CategoryOrder&" and CategoryType='"&CategoryType&"' order by CategoryOrder desc")
		If Not rs_get_up_id.eof Then
			Dim up_id
			Dim up_CategoryOrder
			up_id=rs_get_up_id("id")
			up_CategoryOrder=rs_get_up_id("CategoryOrder")
			rs_get_up_id.close
			Set rs_get_up_id=nothing

			'把上一个CategoryOrder改成本身的CategoryOrder
			conn.execute("update category set CategoryOrder="&CategoryOrder&" where id="&up_id&" and CategoryType='"&CategoryType&"'")
			'把本身的CategoryOrder改成上一个CategoryOrder
			conn.execute("update category set CategoryOrder="&up_CategoryOrder&" where id="&id&" and CategoryType='"&CategoryType&"'")
		End If
	ElseIf action="down" Then
		'获取下一行的信息
		Set rs_get_down_id=ActionConn.execute("select TOP 1 id,CategoryOrder from category where left(categoryid,"&LenUpCategoryId&")='"&UpCategoryId&"' and len(categoryid)="&len(CategoryId)&" and CategoryOrder>"&CategoryOrder&" and CategoryType='"&CategoryType&"' order by CategoryOrder")
		If Not rs_get_down_id.eof Then
			Dim down_id
			Dim down_CategoryOrder
			down_id=rs_get_down_id("id")
			down_CategoryOrder=rs_get_down_id("CategoryOrder")
			rs_get_down_id.close
			Set rs_get_down_id=nothing

			'把下一个CategoryOrder改成本身的CategoryOrder
			conn.execute("update category set CategoryOrder="&CategoryOrder&" where id="&down_id&" and CategoryType='"&CategoryType&"'")
			'把本身的CategoryOrder改成下一个CategoryOrder
			conn.execute("update category set CategoryOrder="&down_CategoryOrder&" where id="&id&" and CategoryType='"&CategoryType&"'")
		End If

	End If

	end function

'# ----------------------------------------------------------------------------
'# 函数:GetNextCategoryID
'# 描述:调用下级分类
'# 参数: ntype-类型(v,h),v为横向调用,h为竖向调用,cid-调用cid的下级分类
'# 返回:
'# 作者:雷の龙
'# 日期:2004
'#-----------------------------------------------------------------------------
	Public Function  GetNextCategoryID(cid,ntype)
		Dim rs
		Set rs=ActionConn.execute("select categoryid from category where id="&cid)
		Dim ctid
		If Not rs.eof Then
			ctid=rs(0)
		End If
		Set rs=ActionConn.execute("select * from category where len(categoryid)="&Len(ctid)+5&" and left(categoryid,"&Len(ctid)&")='"&ctid&"'")
		If ntype="v" Then
		%>
		<table width=100% border=0 cellpadding=0 cellspacing=0>
		<tr>
			<td class="td"></td>
		</tr>
		</table>
		<%			
		End If

	End Function

'# ----------------------------------------------------------------------------
'# 函数:DeleteID()
'# 描述:根据输入的id删除记录
'# 参数: did-分类id
'# 返回:
'#-----------------------------------------------------------------------------
Public Function DeleteID(did) 
	If did<>"-1" Then
		Set rs=ActionConn.execute("select categoryid from category where id="&did)
		did=rs(0)
	else
		did="-1"
	End If
	Delete(did)
End Function
'# ----------------------------------------------------------------------------
'# 函数:GetCategoryID
'# 描述:通过ID值取得CategoryID值
'# 参数: -
'# 返回:
'#-----------------------------------------------------------------------------
	Public Function GetCategoryID(gid) 
		Dim rs
		Set rs=ActionConn.Execute("select categoryid from category where id="&gid)
		If Not rs.eof Then
			GetCategoryID=rs(0)
		else
			GetCategoryID=""
		End If
		rs.close
		Set rs=Nothing
	End Function
'==========================================================================
'
'以下为新闻类别专用
'
'==========================================================================

	'# ----------------------------------------------------------------------------
	'# 函数:NewsCheckList
	'# 描述:新闻的栏目
	'# 参数:cid
	'# 返回:复选框列表
	'#-----------------------------------------------------------------------------
	Public Function NewsCheckList(cid) 
		dim dlist
		Dim zero
		Dim i
		Dim n
		Dim cidlength
		dlist=List(cid)
		Response.Write "<table width=100% style='border:0px'; cellpadding=0 cellspacing=0 class='table'>"
		for i=1 to ubound(dlist)
			zero=""
			cidlength=Len(dlist(i,2))
			for n=2 to Cidlength/5
				zero=zero&"  "
			next
			Response.Write "<tr><td height=25>"&zero&"<input type='checkbox' class='checkbox' name='category' value='"&dlist(i,1)&"'>"&dlist(i,3)&"</td></tr>"
		next
		Response.Write "</table>"
	End Function
	'# ----------------------------------------------------------------------------
	'# 函数:NewsCheckedList
	'# 描述:新闻的栏目
	'# 参数:cid,chked-需要选中的类别
	'# 返回:复选框列表
	'#-----------------------------------------------------------------------------
	Public Function NewsCheckedList(cid,chked) 
		dim dlist
		Dim zero
		Dim i
		Dim n
		Dim cidlength
		dlist=List(cid)
		Response.Write "<table width=100% style='border:0px'; cellpadding=0 cellspacing=0 class='table'>"
		for i=1 to ubound(dlist)
			zero=""
			cidlength=Len(dlist(i,2))
			for n=2 to Cidlength/5
				zero=zero&"  "
			next
			Response.Write "<tr><td height=25>"&zero&"<input type='checkbox' class='checkbox' name='category' value='"&dlist(i,1)&"'"
			If InStr(chked,dlist(i,1)&",")>0 Then
				Response.Write " checked"
			End If
			Response.Write ">"&dlist(i,3)&"</td></tr>"
		next
		Response.Write "</table>"
	End Function
'# ----------------------------------------------------------------------------
'# 函数:NewsDownListID
'# 描述:新闻栏目下拉列表
'# 参数:dlid -,chked-可以显示的栏目
'# 返回:
'#-----------------------------------------------------------------------------
	Public Function NewsDownListID(dlid,chked)
		dim dlist
		dim downl
		downl=""
		dlist=List(dlid)
		for i=1 to ubound(dlist)
			If InStr(chked,dlist(i,1)&",")>0 Then
				downl=downl&"<option value='"&dlist(i,1)&"'>"&dlist(i,0)&"</option>"
			End If
		next
		Response.write downl
	End Function
'# ----------------------------------------------------------------------------
'# 函数:NewsDownList
'# 描述:新闻栏目下拉列表
'# 参数:dlid -,chked-可以显示的栏目
'# 返回:
'#-----------------------------------------------------------------------------
	Public Function NewsDownList(dlid,chked)
		dim dlist
		dim downl
		downl=""
		dlist=List(dlid)
		for i=1 to ubound(dlist)
			If InStr(chked,dlist(i,1)&",")>0 Then
				downl=downl&"<option value='"&dlist(i,2)&"'>"&dlist(i,0)&"</option>"
			End If
		next
		Response.write downl
	End Function
'# ----------------------------------------------------------------------------
'# 函数:NewsDownListSelected()
'# 描述:新闻用选定下拉列表
'# 参数: -
'# 返回:
'#-----------------------------------------------------------------------------
	Public Function NewsDownListSelected(dlid,dcategoryid,chked)
		dim dlist
		dim downl
		downl=""
		dlist=List(dlid)
		for i=1 to ubound(dlist)
			If InStr(chked,dlist(i,1)&",")>0 Then
				downl=downl&"<option value='"&dlist(i,2)&"'"
				if dlist(i,2)=dcategoryid then
					downl=downl&" selected"
				end if
				downl=downl&">"&dlist(i,0)&"</option>"
			End If
		next
		Response.write downl
	End Function
'# ----------------------------------------------------------------------------
'# 函数:NewsModify
'# 描述:
'# 参数: -
'# 返回:
'#-----------------------------------------------------------------------------
	Public Function NewsModify(nid,nname,ntemplate) 
		CategoryName=nname
		CategoryID=GetCategoryID(nid)
		Modify(CategoryID)
		ActionConn.Execute("update newscategory set template='"&ntemplate&"' where ctid="&nid)
	End Function
end class


%>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -