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

📄 typeclass.asp

📁 好动西给大家分享
💻 ASP
字号:
<%
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
Class TypeManagerClass
	Public ID              '记录ID号
	Public typename        '类型名称
	Public tablename       '操作对象:表名
	Public field           '类型字段名
	Public attributename   '类型属性名称
	Public Actionconn      '数据库连接

	'BookManagerClass的私有属性
	Private action
	Private idd
	
	'构造函数
	Private Sub Class_initialize
		Reset()
	End Sub
	
	'解析函数
	Private Sub Class_terminate
		Reset()
		ActionConn.close
		Set ActionConn=Nothing
	End Sub


	'重置属性(初始化属性)
	Public Sub Reset()
		ID=0
		typename=""
		field=""
		tablename=""
		attributename=""
		action=Request.QueryString("action")
	End Sub
'# ----------------------------------------------------------------------------
'# 函数:pagehtmlForm
'# 描述:显示表单页面
'# 参数: -
'# 返回:html代码
'#-----------------------------------------------------------------------------
	Private Function PageHtmlForm()
		%>
		<div align="center"><form method="POST" action="?action=<%=action%>&id=<%=Id%>" name="myform">			
	<table border="0" width="300" id="table1" cellspacing="1">
		<tr>
			<td align="center" colspan="2" bgcolor="#006699">
			<font color="#FFFFFF"><%=attributename%><%if Request("action")="add" then
			Response.write "添加"
			else 
			Response.write "修改"
			end if%></font></td>
		</tr>
		<tr>
			<td align="right" width="145"><%=attributename%></td>
			<td width="186">
			<input type="text" name="typename" size="34" value="<%=typename%>"></td>
		</tr>
		<tr>
			<td width="291" colspan="2" align="right">
			<input type="submit" value=
			<%If action="add" Then
				Response.Write "添加"
			ElseIf action="modify" Then
				Response.Write "修改"
			End if 
			%> name="B3" class="FormText"><input type="button" value="返回列表" name="B2" onclick="location.href='?action=list';" class="FormText">&nbsp;&nbsp;
			</td>
		</tr>
		</table></form>
        </div>
		<%
		
	End Function
	
'# ----------------------------------------------------------------------------
'# 函数:PageHtmlList
'# 描述:信息列表页面
'# 参数: -
'# 返回:HTML
'#-----------------------------------------------------------------------------
	Private Function PageHtmlList()
		%>
		<form method="post" action="?action=delete" name="delForm">
		<div align="center">
		<table width="400"  border=1 class="table" cellpadding=0 cellspacing=0>
		<tr class="headtr">
			<td class="td" height="23" align="center" width="300"><%=attributename%></td>			
			<td class="td" height="23" align="center" width="100" >管理&nbsp;&nbsp;<input type="submit" class="button" value="删除" name="b1"></td>
		</tr>
		<%
		Dim Rs,Sql
		Set Rs=Server.Createobject("Adodb.Recordset")
		Sql="Select * From "&tablename&" order by id"
		Rs.Open Sql,Actionconn,3,2
		Do While not Rs.eof
		ID=Rs("ID")		
		typename=Rs(field)
		%>
		<tr>
			<td class="lefttd" height="20" align="left"><FONT color=#ff9900>·</FONT><%=typename%></td>
			<td class="lefttd" height="20" align="center">
				<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>
		<%
		Rs.movenext
		loop
		Rs.Close
		set Rs=nothing	
		%>
		</table>
		<BR>
		</div>
		</form>
		<% 
	End Function
'# ----------------------------------------------------------------------------
'# 函数:RequestForm
'# 描述:取得传递信息
'# 参数: -
'# 返回:
'# 完成时间:2005-11-14
'#-----------------------------------------------------------------------------
	Private Function RequestForm()
		action=indb(Request.QueryString("action"))
		'需要被删除的记录
		idd=indb(Request.Form("idd"))   
		ID=indb(Request.QueryString("id"))
		typename=indb(Request.Form("typename"))
	End Function
	
'# ----------------------------------------------------------------------------
'# 函数:Addpage
'# 描述:添加类型信息页面
'# 参数: -
'# 返回:
'# 日期:2005-11-14
'#-----------------------------------------------------------------------------
	Public Function AddPage()
		If LCase(Request.ServerVariables("request_method"))="post" Then
			RequestForm()
			pagination()			
		Else
			PageHtmlForm()
		End If
	End Function
'# ----------------------------------------------------------------------------
'# 函数:Pagination
'# 描述:内容分页的实现--->添加类型信息
'# 参数: -
'# 返回:
'# 日期:2005-11-14
'#-----------------------------------------------------------------------------
	Private Function Pagination()
        Add()
		If Err Then
			Call Go2_Error("类型信息添加失败")
		Else
			Call Go_Success("类型信息添加成功","?action=list")
		End If
	End Function
'# ----------------------------------------------------------------------------
'# 函数:Modifypage
'# 描述:修改类型信息页面
'# 参数: -
'# 返回:
'# 日期:2005-11-14
'#-----------------------------------------------------------------------------
	Public Function ModifyPage()
		RequestForm()
		If ID="" Then
			Response.Write "错误的参数"
			exit function
		End If
		If LCase(Request.ServerVariables("request_method"))="post" Then
			RequestForm()
			Modify()
		Else
			GetType(ID)
			PageHtmlForm()
		End If
	End Function
'# ----------------------------------------------------------------------------
'# 函数:listpage
'# 描述:类型列表页面
'# 参数: -
'# 返回:
'# 日期:2005-11-14
'#-----------------------------------------------------------------------------
	Public Function ListPage() 
		PageHtmlList()
	End Function	
'# ----------------------------------------------------------------------------
'# 函数:Deletepage
'# 描述:删除类型信息页面
'# 参数: -
'# 返回:
'# 日期:2005-11-14
'#-----------------------------------------------------------------------------
	Public Function DeletePage()
		If LCase(Request.ServerVariables("request_method"))="post" Then
			RequestForm()
			Delete()
		Else
			PageHtmlList()
		End If
	End Function
	
'# ----------------------------------------------------------------------------
'# 函数:Delete
'# 描述:删除类型
'# 参数: -
'# 返回:
'# 日期:2005-11-14
'#-----------------------------------------------------------------------------
	Private Function Delete()
		Dim Sql
		If ID<>"" Then
			Sql="Delete From "&tablename&" Where Id="&ID
		Else 
			Sql="Delete From "&tablename&" where Id in ("&idd&")"
		End If

		Actionconn.Execute(Sql)
		If Err Then
			Call Go2_Error("类型删除失败")
		Else
			Call Go_Success("类型删除成功","?action=list")
		End If
		
	End Function


'# ----------------------------------------------------------------------------
'# 函数:add
'# 描述:添加类型信息
'# 参数: -
'# 返回:
'# 日期:2005-11-14
'#-----------------------------------------------------------------------------
	Private Function Add()
		if Trim(typename)="" then
		   Go2_Error("类型不能为空!")
		End If
		
		sSql="insert into "&tablename&" ("&field&") Values "&_
		     "('"&typename&"')"
		Actionconn.Execute sSql
	End Function

'# ----------------------------------------------------------------------------
'# 函数:Modify
'# 描述:修改类型信息内容
'# 参数: -
'# 返回:
'# 日期:2005-11-14
'#-----------------------------------------------------------------------------
	Private Function Modify()
		if Trim(typename)="" then
		   Go2_Error("类型信息不能为空!")
		End If
		Dim Rs,Sql
		Set Rs=Server.Createobject("Adodb.Recordset")
		Sql="Select * From "&tablename&" Where ID="&ID
		Rs.Open Sql,Actionconn,3,2
		Rs(field)=typename
		Rs.Update
		Rs.Close
		Set Rs=Nothing
		If Err Then
			Call Go_Error("类型信息修改失败")
		Else
			Call Go_Success("类型信息修改成功","?action=list")
		End If
	End Function


'# ----------------------------------------------------------------------------
'# 函数:GetType
'# 描述:取得单个类型的属性
'# 参数: -
'# 返回:
'# 日期:2005-11-14
'#-----------------------------------------------------------------------------
	Public Function GetType(Gid)
		Dim Rs
		Set Rs=Actionconn.Execute("Select * From "&tablename&" Where ID='"&Gid&"'")
		if Not (Rs.eof and Rs.bof) then
		  typename=Rs(field)
		end if
		Rs.Close
		Set Rs=Nothing
	End Function
	
	
End Class

%>

⌨️ 快捷键说明

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