?? typeclass.asp
字號:
<%
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">
</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" >管理 <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 + -