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

📄 template_class.asp

📁 这是我根据动网新闻核心自行设计的校园新闻系统
💻 ASP
字号:
<%
pageadmin=10
%>
<%
'本类需要以下文件的支持
'../../inc/conn.asp
'../../inc/function.asp
'../category/category_class.asp

'使用完后需要释放的对象:conn,ct
Class LBTemplate
	Public Id
	Public Name
	Public Code
	Public CategoryType
	Public Categoryid
	Public OrderId
	Public DateAndTime

	Public Version
	Public ActionConn

	Private ct
	Private action
	Private idd

	'构造函数
	Private Sub Class_initialize
		Set Actionconn=Conn
		Set ct=new LBCategory
		ct.categorytype="新闻模板"
		Reset()
	End Sub
	
	'解析函数
	Private Sub Class_terminate
		Reset()
	End Sub

	'重置属性
	Public Sub Reset()
		Version="Lbnow Create @ 2004-4-12 And Last Update @ 2004-4-12"
		Id=0
		Name=""
		Code=""
		CategoryType="新闻模板"
		CategoryId=Request.QueryString("categoryid")
		OrderId=100
		DateAndTime=Now()
		action=Request.QueryString("action")
	End Sub
'# ----------------------------------------------------------------------------
'# 函数:PageHtmlForm
'# 描述:页面表单
'# 参数: -
'# 返回:
'# 日期:2004
'#-----------------------------------------------------------------------------
	Private Function PageHtmlForm() 
		%>
		<form method="post" action="?action=<%=action%>&id=<%=Id%>" name="form1">
		<div align="center">
			<table width=100% border=1 class="table" cellpadding=0 cellspacing=0>
			<tr height="30">
				<td class="lefttd" align="center">模板名称</td>
				<td class="righttd">&nbsp;&nbsp;<input type="text" size="30" name="name" class="text" value="<%=Name%>"></td>
			</tr>
			<tr height="30">
				<td class="lefttd" align="center">所属分类</td>
				<td class="righttd">
				&nbsp;&nbsp;
				<select class="select" name="categoryid" size="1">
				<%
				ct.downlistselected "-1",categoryid
				%>
				</select>
				</td>
			</tr>
			<tr height="300">
				<td class="lefttd" align="center">模板代码</td>
				<td class="righttd">&nbsp;&nbsp;<textarea class="textarea" name="code" rows="18" cols="60"><%=Code%></textarea></td>
			</tr>
			</table>
			<BR>
			<table width=100% style="border:0px" class="table" cellpadding=0 cellspacing=0>
			<tr>
				<td class="td" align="center"><input type="button" onclick="fsub();" class="button" value=
				<%If action="add" Then
					Response.Write "添加模板"
				ElseIf action="modify" Then
					Response.Write "修改模板"
				End if 
				%>
				>&nbsp;&nbsp;<input type="reset" class="button" value="取消">
				&nbsp;&nbsp;<input type="button" name="b2" onclick="fview();" class="button" value="预览">
				&nbsp;&nbsp;<input type="button" class="button" value="返回列表" onclick="location.href='?action=list';"></td>
			</tr>
		<SCRIPT LANGUAGE="JavaScript">
		<!--
		function fsub()
		{
			form1.action="?action=<%=action%>&id=<%=Id%>";
			form1.target="_self";
			form1.submit();
		}
		function fview()
		{
			form1.action="template_view.asp";
			form1.target="_blank";
			form1.submit();
		}
		//-->
		</SCRIPT>
			</table>
		</div>
		</form>
		<%
	End Function
'# ----------------------------------------------------------------------------
'# 函数:PageHtmlList
'# 描述:
'# 参数: -
'# 返回:

'# 日期:2004
'#-----------------------------------------------------------------------------
	Public Function PageHtmlList 
		%>
		<form method="post" action="?action=delete" name="form1">
		<div align="center">
		<%
		Dim rs
		Dim rss
		Set rs=ActionConn.execute("select categoryname,categoryid from category where categorytype='"&categorytype&"'")
		Do While Not rs.eof
		%>
		<table width=100% style="border:0px" class="table" cellpadding=0 cellspacing=0>
		<tr>
			<td class="td" height="30"><font class="headtext"><%=rs(0)%></font></td>
		</tr>
		</table>
		<table width=100% border=1 class="table" cellpadding=0 cellspacing=0>
		<tr class="headtr">
			<td class="td" align="center">模板名称</td>
			<td class="td" align="center" width="100">所属分类</td>
			<td class="td" align="center" width="130">创建时间</td>
			<td class="td" align="center" width="100">管理&nbsp;<input type="submit" class="button" value="删除"></td>
		</tr>
		<%
		Set rss=ActionConn.Execute("select id,name,dateandtime from template where categoryid='"&rs(1)&"' and categorytype='"&categorytype&"'")
		Do While Not rss.eof
		Id=rss(0)
		Name=rss(1)
		DateAndTime=rss(2)
		%>
		<tr>
		  <td class="td">&nbsp;&nbsp;<%=Name%></td>
		  <td class="td" align="center"><%=rs(0)%></td>
		  <td class="td" align="center"><%=DateAndTime%></td>
		  <td class="td">
			<table width=100% border=0 cellpadding=0 cellspacing=0>
			<tr>
				<td class="td" align="center"><a title="" href="?action=modify&id=<%=Id%>">修改</a></td>
				<td class="td" align="center"><input type="checkbox" class="checkbox" name="idd" value="<%=Id%>"></td>
			</tr>
			</table>
		  </td>
		</tr>
		<%
		rss.movenext
		loop
		rss.close
		%>
		</table>
		<BR>
		<%
		rs.movenext
		loop
		Set rss=Nothing
		rs.Close
		Set rs = Nothing
		%>
		</div>
		</form>
		<%
	End Function
'# ----------------------------------------------------------------------------
'# 函数:RequestForm
'# 描述:取得参数
'# 参数: -
'# 返回:

'# 日期:2004
'#-----------------------------------------------------------------------------
	Private Function RequestForm()
		Id=indb(Request.QueryString("Id"))
		Name=indb(Request.Form("name"))
		Code=indb(Request.Form("code"))
		Categoryid=indb(Request.Form("categoryid"))
		idd=indb(Request.Form("idd"))
	End Function
'# ----------------------------------------------------------------------------
'# 函数:gettemplate
'# 描述:
'# 参数: -
'# 返回:

'# 日期:2004
'#-----------------------------------------------------------------------------
	Public Function GetTemplate(gid) 
		Dim rs
		Set rs=ActionConn.execute("select * from template where id="&gid)
		If Not rs.eof Then
			Id=rs("id")
			Name=rs("name")
			Code=rs("code")
			Categoryid=rs("Categoryid")
			CategoryType=rs("categorytype")
			orderid=rs("orderid")
			DateAndTime=rs("dateandtime")
		End If
		Set rs = Nothing
	End Function
'# ----------------------------------------------------------------------------
'# 函数:AddPage
'# 描述:添加模板页面
'# 参数: -
'# 返回:

'# 日期:2004
'#-----------------------------------------------------------------------------
	Public Function AddPage()
		If LCase(Request.ServerVariables("request_method"))="post" Then
			RequestForm()
			Add()
		Else
			PageHtmlForm()
		End If
	End Function
'# ----------------------------------------------------------------------------
'# 函数:ModifyPage
'# 描述:修改模板页面
'# 参数: -
'# 返回:

'# 日期:2004
'#-----------------------------------------------------------------------------
	Public Function ModifyPage() 
		Id=Request.QueryString("Id")
		If Id="" Then
			Response.Write "错误的参数"
			exit function 
		End If
		If LCase(Request.ServerVariables("request_method"))="post" Then
			RequestForm()
			Modify()
		Else
			GetTemplate(Id)
			PageHtmlForm()
		End If
	End Function
'# ----------------------------------------------------------------------------
'# 函数:ListPage
'# 描述:模板列表页面
'# 参数: -
'# 返回:

'# 日期:2004
'#-----------------------------------------------------------------------------
	Public Function ListPage() 
		PageHtmlList()
	End Function
'# ----------------------------------------------------------------------------
'# 函数:Deletepage
'# 描述:删除模板页面
'# 参数: -
'# 返回:

'# 日期:2004-04-09
'#-----------------------------------------------------------------------------
	Public Function DeletePage()
		If LCase(Request.ServerVariables("request_method"))="post" Then
			RequestForm()
			Delete()
		Else
			PageHtmlList()
		End If
	End Function
'# ----------------------------------------------------------------------------
'# 函数:Add
'# 描述:添加模板
'# 参数: -
'# 返回:

'# 日期:2004
'#-----------------------------------------------------------------------------
	Private Function Add()
		If Name="" Then
			Response.Write "<script>alert('模板名称不能为空');history.back();</script>"
			exit function
		End If
		If Categoryid="" Then
			Response.Write "<script>alert('模板分类不能为空');history.back();</script>"
			exit function
		End If
		Dim rs
		Set rs=Conn.execute("select max(id) from template")
		If IsNull(rs(0)) Or rs(0)="" Then
			Id=1
		Else
			Id=rs(0)+1
		End If
		rs.Close
		Set rs = Nothing
		ActionConn.execute("insert into template (id,name,code,categorytype,categoryid,orderid,dateandtime) values ("&Id&",'"&name&"','"&code&"','"&categorytype&"','"&categoryid&"',"&Id&",'"&Now()&"')")
		If err Then
			Call showError("模板添加失败")
		Else
			Call showSuccess("模板添加成功","?action=add&categoryid="&CategoryId)
		End If
	End Function
'# ----------------------------------------------------------------------------
'# 函数:Modify
'# 描述:修改模板
'# 参数: -
'# 返回:

'# 日期:2004
'#-----------------------------------------------------------------------------
	Private Function Modify()
		If Name="" Then
			Response.Write "<script>alert('模板名称不能为空');history.back();</script>"
			exit function
		End If
		If Categoryid="" Then
			Response.Write "<script>alert('模板分类不能为空');history.back();</script>"
			exit function
		End If
		If Id="" Then
			Response.Write "<script>alert('参数错误');history.back();</script>"
			exit function
		End If

		ActionConn.execute("update template set name='"&Name&"',categoryid='"&Categoryid&"',code='"&Code&"' where id="&Id)
		If err Then
			Call showError("模板修改失败")
		Else
			Call showSuccess("模板修改成功","?action=list")
		End If
	End Function
'# ----------------------------------------------------------------------------
'# 函数:Delete
'# 描述:删除模板
'# 参数: -
'# 返回:

'# 日期:2004-4-12
'#-----------------------------------------------------------------------------
	Private Function Delete()
		Dim Sql
		If Id="-1" Then
			Sql="Delete * From template Where Categorytype='"&CategoryType&"'"
		ElseIf Id<>"" Then
			Sql="Delete * From template Where Id="&Id
		ElseIf idd<>"" Then
			Sql="Delete * From template where Id in ("&idd&")"
		else
			Call showError("请选择要删除的模板")
		End If
		Actionconn.Execute(Sql)
		If Err Then
			Call ShowError("模板删除失败")
		Else
			Call ShowSuccess("模板删除成功","?action=list")
		End If
	End Function
'# ----------------------------------------------------------------------------
'# 函数:DownList()
'# 描述:
'# 参数: -
'# 返回:

'# 日期:2004
'#-----------------------------------------------------------------------------
	Public Function DownList() 
		Dim rs
		Set rs=ActionConn.execute("select * from template where categorytype='"&categorytype&"'")
		Do While not rs.eof
			%>
			<option value="<%=rs("id")%>"><%=rs("name")%></option>
			<%
			rs.MoveNext
		loop
		rs.Close
		Set rs = Nothing
	End Function
'# ----------------------------------------------------------------------------
'# 函数:DownListSelected(tid)
'# 描述:
'# 参数: -
'# 返回:

'# 日期:2004
'#-----------------------------------------------------------------------------
	Public Function DownListSelected(tid) 

		Dim rs
		Set rs=ActionConn.execute("select * from template where categorytype='"&categorytype&"'")
		Do While not rs.eof
			
			%>
			<option value="<%=rs("id")%>"<%If rs("id")=cint(tid) Then Response.Write " selected"%>><%=rs("name")%></option>
			<%
			rs.MoveNext
		loop
		rs.Close
		Set rs = Nothing
	End Function
End Class
%>

⌨️ 快捷键说明

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