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

📄 news_class_list.asp

📁 航空订票系统基于asp.net和sql2005包含数据库和图片
💻 ASP
📖 第 1 页 / 共 2 页
字号:
<!--#include file="../global/inc/CheckSession.asp"-->
<!--#include file="../global/inc/global.inc.asp"-->
<%
		Rem 类别管理
		Dim cmd, oDict, oTemplate	
		'全局变量		
		Dim strSQL,ClassId
		'ClassFatherId 为总分类id号		
		Dim ClassFatherId:ClassFatherId = Request.QueryString("ClassFatherId")
		'输出类名
		ClassName = ReturnTitle(ClassFatherId)
		'设置标题
		Sub SetTitle()
			dict("#FatherTitleId#") = ClassFatherId
			dict("#FatherTitle#") = ClassName
			oDict("template") = oTemplate.ReplaceMacros(oDict("template"),dict)
		End Sub
		
		Set oDict = Server.CreateObject("Scripting.Dictionary")
		set dict = server.CreateObject("scripting.dictionary")
		'类实例化
		Set oTemplate = New Cls_Template	
		'获取动作参数
		cmd = Request("cmd")		
		select case cmd
		case "delete"
			Delete
		case "save"
			Save
		case "add"
			Add
		'列表操作	
		case "News_EditDel"
			News_EditDel
		end select		
		oDict("template") = oTemplate.Load(server.MapPath("news_class_list.asp"))
		oDict("template") = oTemplate.GetPart(oDict("template"),chr(60) & "!--body-->",chr(60) & "!--//body-->")
		'处理信息
		select case cmd
		case "edit"
			ShowEdit
		case "new"
			ShowNew
		case else
			ShowList
		end select		
		'显示内容
		SetTitle
		Response.Write oDict("template")		
		'销毁对象
		Set oDict = Nothing
		Set oDictSession = Nothing
		Set oTemplate = Nothing
		Response.End			
'----------------------------------------------------------
'页面相关处理函数说明
'
'
'
'
'__________________________________________________________		
	function Add()
		dim oRs,sql,ClassName
		FatherId = Request.Form("FatherId")
		ClassName = Request("ClassName")
		'格式化数据
		ClassName = FormatString(ClassName)
	    oConn_Start
		sql = "Select ClassId From Sm_Class Where ClassType="&ClassFatherId&" And ClassName = '"&ClassName&"' And FatherId="&Clng(FatherId)
		Set oRs = oConn.Execute(sql)
		if Not oRs.eof then
			Set oRs = Nothing
			oConn_Close
			InfoErrorWrite("分类中已经存在同样的类名\n请输入其他分类")
		end if		
		oRs.close
		Set oRs = Nothing
		oConn.Execute("Insert Into Sm_Class(ClassName,FatherId,ClassType) Values('"&ClassName&"',"&FatherId&","&ClassFatherId&")")
		oConn_Close			
		response.Redirect "news_class_list.asp?ClassFatherId="&ClassFatherId
	end function

	function Save()
		dim sql,oRs,ClassId,ClassName
		FatherId = Request("FatherId")
		ClassId = Request("ClassId")
		ClassName = Request("ClassName")		
		
		ClassName = FormatString(ClassName)
		sql = "select ClassId From Sm_Class Where ClassId= "&Clng(ClassId)		
	    oConn_Start
		set oRs = oConn.Execute(sql)
		If oRs.Eof Then
			Set oRs = Nothing
			oConn_Close
			InfoErrorWrite("系统中找不到该项目")
		Else 
			oConn.Execute("Update Sm_Class Set ClassName = '"&ClassName&"',FatherId="&FatherId&" Where ClassId ="&Clng(ClassId))
		End If		
		oRs.close
		oConn_Close
		response.Redirect "news_class_list.asp?ClassFatherId="&ClassFatherId
	end function

	function Delete()
		dim ClassId,sql
		ClassId = cint(Request("ClassId"))
		oConn_Start
		sql = "Delete From Sm_Class Where ClassId = "&ClassId
		oConn.execute sql
		oConn_Close
		response.Redirect("news_class_list.asp?ClassFatherId="&ClassFatherId)
	end function
	'________________________________________________
	'删除类别
	Sub DeleteClass(id) 
		  
		strSQL="delete from [Sm_Class] where ClassId="&cstr(id)
		DELSQL(id)
		'response.Write(strSql)
		'response.End()
		Oconn.execute strSQL
	End sub
	'循环操作其子类Id
	Sub DELSQL(ID)	
		'StrSql = "delete from [Sm_Class] where ClassId=5"
		Dim RsTmp
		Set RsTmp = Server.CreateObject("ADODB.Recordset")
		RsTmp.Open "Select * From Sm_Class Where FatherId = "& ID,oConn,1,1
		Do While Not RsTmp.EOF
			strSQL = strSQL & " Or ClassId = "& RsTmp("ClassId")
			'response.Write(strSql&"<br>")
			Call DELSQL(RsTmp("ClassId"))
		RsTmp.MoveNext
		Loop	
	End Sub
	'修改类别
	Sub ModifyClass(id)
		Dim ClassName
		ClassName=Request.Form("ClassName"&id)		
		sql="Update [Sm_Class] set ClassName='"&ClassName&"' Where ClassId="&id
		'response.write sql
		oConn.execute sql
	End Sub
	
	'循环操作数据函数
	Sub News_EditDel
		oConn_Start
		if not isempty(request("selAnnounce")) then
			dim idlist,act
			idlist=request("selAnnounce")
			act=Request.Form("act")
			'response.Write(idlist&act)
			'response.End()
			dim idarr '定义储存数组
			dim id
			if act="删 除" then
				   if instr(idlist,",")>0 then
						 idArr=split(idlist)
						 for i = 0 to ubound(idarr)
						   id=clng(idarr(i))
							 call DeleteClass(id)
						   next
				   else
						call DeleteClass(clng(idlist))
				   end if


			 elseif act="修 改" then
				if instr(idlist,",")>0 then
					 idArr=split(idlist)		 
					 for i = 0 to ubound(idarr)
						 id=clng(idarr(i))
						 call ModifyClass(id)
					 next
				else
					  call ModifyClass(clng(idlist))
				end if
			end if
		else
			call InfoErrorWrite("至少应该选择一项信息才能操作")
		end if	
		oConn_Close
		Call InfoErrorDisplay("修改成功","news_class_list.asp?ClassFatherId="&ClassFatherId)
	End Sub	
'关于显示的操作函数	
	function ShowEdit()
		dim id,oRs,sql,classId
		dim body,dict     
		ClassId = cint(Request("ClassId"))  
		set dict = server.CreateObject("scripting.dictionary")      
		body  = oTemplate.GetPart(oDict("template"),"<!--edit-->","<!--//edit-->")		
	    oConn_Start
		sql = "select * From Sm_Class where ClassId = " & ClassId & ""
		'response.Write(sql)
		Set oRs = oConn.Execute(sql)

		if oRs.eof then
			Set oRs = Nothing
			oConn_Close
			InfoErrorWrite("系统出错找不到该项")			
		end if			
		dict("#cmd#") = "save"
		ClassId = oRs("FatherId")
		dict("#options#") = selectTreeList(0,0,ClassId,ClassFatherId)
		'Response.Write(oRs("FatherId")&ClassFatherId)
		If oRs("FatherId")=0 Then 
		dict("#options#") = dict("#options#") + "<Option value=0 selected>顶级分类</option>"
		End If
		dict("#classid#") = Null2Space(oRs("classid"))
        dict("#ClassName#") = oRs("ClassName")

		dict("#input#") = "修改"
		oRs.close
		set oRs = nothing
		body = oTemplate.ReplaceMacros(body,dict)
		oDict("template") = oTemplate.ReplacePart(oDict("template"),"<!--list-->","<!--//list-->",body)
		oConn_Close
		set dict = nothing
	end function

	function ShowNew()
		dim id,sql
		dim body,dict        
		body  = oTemplate.GetPart(oDict("template"),"<!--edit-->","<!--//edit-->")
		set dict = server.CreateObject("scripting.dictionary")	    
		dict("#cmd#") = "add"
		oConn_Start
		dict("#options#") = "<Option value=0>顶级分类</option>"+selectTreeList(0,0,0,ClassFatherId)
		oConn_Close
		dict("#classid#") = ""
        dict("#ClassName#") = ""
		dict("#input#") = "添加"
		body = oTemplate.ReplaceMacros(body,dict)

⌨️ 快捷键说明

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