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

📄 news_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,NewsId,ClassId,thisurl
		'获取搜索字段开始
		ClassId = Request("ClassId")
		Key = Request("Key")
		'获取搜索字段结束
		'ClassFatherId 为总分类id号
		Dim ClassFatherId:ClassFatherId = Request.QueryString("ClassFatherId")
		'Response.Write(ClassFatherId)
		'Response.End()
		'输出类名
		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_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 oTemplate = Nothing
		Response.End			
'----------------------------------------------------------
'页面相关处理函数说明
'
'
'
'
'__________________________________________________________		
	function Add()
		dim oRs,sql
		Dim NewsId,ValidFlag,ClassId,Addtime,Title,Keyword,Content
		ValidFlag = Request.Form("ValidFlag")
		ClassId = Request.Form("ClassId")
		Addtime = Request.Form("Addtime")
		If Not IsNot(Addtime,"d") Then
			InfoErrorWrite("日期格式有错")
		End If
		Title = Request.Form("Title")
		Title = Request.Form("Title")
		
		For i = 1 To Request.Form("Content").Count
			Content = Content & Request.Form("Content")(i)
		Next	

	    oConn_Start
		sql = "Select * From Sm_Content Order by NewsId Desc"
		Set oRs = Server.CreateObject("Adodb.RecordSet")
		oRs.Open sql,oConn,1,3
		oRs.Addnew
			oRs("ValidFlag") = ValidFlag			
			oRs("ClassId") = ClassId
			oRs("DateCreated") = Addtime
			oRs("Title") = Title
			oRs("Content") = Content
			oRs("NewsType") = ClassFatherId
		oRs.Update
		oRs.close
		Set oRs = Nothing
		oConn_Close			
		response.Redirect "news_list.asp?ClassFatherId="&ClassFatherId
	end function

	function Save()
		dim sql,oRs
		Dim NewsId,ValidFlag,ClassId,Addtime,Title,Keyword,Content
		NewsId = Request("NewsId")
		ValidFlag = Request.Form("ValidFlag")
		ClassId = Request.Form("ClassId")
		'Response.Write(ClassId)
		'Response.End()
		Addtime = Request.Form("Addtime")
		If Not IsNot(Addtime,"d") Then
			InfoErrorWrite("日期格式有错")
		End If
		Title = Request.Form("Title")
		Title = FormatString(Title)
		For i = 1 To Request.Form("Content").Count
			Content = Content & Request.Form("Content")(i)
		Next
			
		'数据操作
		sql = "select * From Sm_Content Where NewsId= "&Clng(NewsId)		
		
	    oConn_Start
		set oRs = Server.CreateObject("Adodb.RecordSet")
		oRs.open sql,oConn,1,3
		If oRs.Eof Then
			oRs.Close
			Set oRs = Nothing
			oConn_Close
			InfoErrorWrite("系统中找不到该项目")
		Else 
			oRs("ValidFlag") = ValidFlag			
			oRs("ClassId") = ClassId
			oRs("DateCreated") = Addtime
			oRs("Title") = Title
			oRs("Content") = Content
			oRs.Update
		End If		
		oRs.close
		Set oRs = Nothing
		oConn_Close
		response.Redirect "news_list.asp?ClassFatherId="&ClassFatherId
	end function

	function Delete()
		dim NewsId,sql
		NewsId = cint(Request("NewsId"))
		oConn_Start
		sql = "Delete From Sm_Content Where NewsId = "&NewsId
		oConn.execute sql
		oConn_Close
		response.Redirect("news_list.asp?ClassFatherId="&ClassFatherId)
	end function
	'________________________________________________
	'删除新闻
	Sub DeleteClass(id) 
		  
		strSQL="delete from [Sm_Content] where NewsId="&cstr(id)
		'DELSQL(id)
		'response.Write(strSql)
		'response.End()
		Oconn.execute strSQL
	End sub
	'修改新闻
	Sub ModifyClass(id)
		Dim Title,ValidFlag,ClassId
		Title=Request.Form("Title"&id)		
		ValidFlag = Request.Form("ValidFlag"&id)
		ClassId = Request.Form("ClassId"&id)
		sql="Update [Sm_Content] set Title='"&Title&"',ValidFlag="&ValidFlag&",ClassId="&ClassId&" Where NewsId="&id
		'response.write sql
		'response.End()
		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_list.asp?ClassFatherId="&ClassFatherId)
	End Sub	
'关于显示的操作函数	
	function ShowEdit()
		dim id,oRs,sql,NewsId
		dim body,dict     
		NewsId = cint(Request("NewsId"))        
		body  = oTemplate.GetPart(oDict("template"),"<!--edit-->","<!--//edit-->")
		set dict = server.CreateObject("scripting.dictionary")
	    oConn_Start
		sql = "select * from Sm_Content where NewsId = " & NewsId 
		Set oRs = oConn.Execute(sql)

		if oRs.eof then
			Set oRs = Nothing
			oConn_Close
			InfoErrorWrite("系统出错找不到该项")			
		end if			
		dict("#cmd#") = "save"
		If oRs("ValidFlag")=1 then
			 dict("#check1#") = " checked" 
		Else
			 dict("#check2#") = " checked"
		End If		
		dict("#options#") = selectTreeList(0,0,oRs("ClassId"),ClassFatherId)
		dict("#Addtime#") = Null2Space(oRs("DateCreated"))
		dict("#Title#") = Null2Space(oRs("Title"))
		dict("#Content#") = Null2Space(Server.HTMLEncode(oRs("Content")&""))
		dict("#NewsId#") = oRs("NewsId")
        dict("#input#") = "修改"&ClassName		
		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"
		dict("#NewsId#") = ""
		oConn_Start
        dict("#options#") = selectTreeList(0,0,0,ClassFatherId)
		oConn_Close
		dict("#check1#") =" checked" 
		dict("#check4#") =" checked" 
		dict("#Title#") = ""
		dict("#Author#") = ""
		dict("#Intro#") = ""
		dict("#Source#") = "神马整形后台"
		dict("#Content#") = ""
		dict("#Keyword#") = ""
		dict("#Addtime#") = now()
		dict("#input#") = "添加"&ClassName
		body = oTemplate.ReplaceMacros(body,dict)
		oDict("template") = oTemplate.ReplacePart(oDict("template"),"<!--list-->","<!--//list-->",body)
		set dict = nothing
	end function

	function ShowList()
		dim pagesize

⌨️ 快捷键说明

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