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

📄 admin_classmateinfoclass.asp

📁 WAP网上购物系统源程序,,有兴趣的朋友,一起研究一下..交流经眼
💻 ASP
字号:
<%
Class DataGrid
	Private obj_RecordSet ' recordset
	Private int_PageSize ' 每页纪录数
	'两个数组保存数据库字段名和中文名称
	Private Arr_Field ' 数据库字段
	Private Arr_FieldName ' 字段显示名称()
	Private Arr_FieldWidth ' 字段显示宽度
	Private str_TitleColor ' 表头颜色#efffce
	Private str_Url '请求的URL
	Private str_Error ' 出错信息

	Private Sub Class_Initialize()
		int_PageSize = 10
		str_TitleColor = "#ffffff"
		str_Error = ""
	End Sub

	'-----------------------------------
	'数据源,暂时只支持RecordSet
	'-----------------------------------
	
	Public Property Let dataSource(obj)
		set obj_RecordSet = obj
	End Property

	Public Property Let pageSize(intvalue)
		int_PageSize = intvalue
	End Property

	Public Property Get pageSize
		PageSize= int_Categoryid
	End Property

	Public Property Let Fields(Arr)
		Arr_Field = Arr
	End Property

	Public Property Get Fields
		Fields= Arr_Field
	End Property

	Public Property Let fieldsName(Arr)
		Arr_FieldName = Arr
	End Property

	Public Property Get fieldsName
		fieldsName= Arr_FieldName
	End Property

	Public Property Let fieldWidth(Arr)
		Arr_FieldWidth = Arr
	End Property

	Public Property Get fieldWidth
		fieldWidth= Arr_FieldWidth
	End Property

	Public Property Let titleColor(strvalue)
		str_TitleColor = strvalue
	End Property

	Public Property Get titleColor
		titleColor= str_TitleColor
	End Property

	'-----------------------------------------------------
	'这个属性是为了保存Url路径
	'如果当前路径带有参数,那么就用&Page=x,否则就用?Page=x
	'------------------------------------------------------

	Public Property Let Url(Strvalue)
		str_Url = Strvalue
	End Property

	Public Property Get Url
		Url= str_Url
	End Property


	'================================================================
	'方法
	'================================================================
	'----------------------------------------------------------------
	'显示当前错误
	'----------------------------------------------------------------

	Private Sub ShowLastError()
		response.Write(str_Error)
	End Sub
	
	'----------------------------------------------------------------
	'Generate()
	'利用ado分页
	'-----------------------------------------------------------------

	Public Sub Generate()
		'----检查参数--------------------------
		Check
		'---------变量声明-----------------------------------
		Dim FieldCount '显示字段
		FieldCount = Ubound(Arr_Field) + 1
		Dim CurrentPage '当前页
		Dim PgCount '总页数
		Dim RecCount '记录数,本来用rs.recordCount可以取到,保存下来效率会比较高
		Dim HasOtherParam 'URL是否包含其他参数
		Dim PageParam '当前分页Url参数
		Dim PageInfomation '当前分页状态信息
		Dim Seperator '设置分隔符
		Seperator = "  " 
		
		'-------------处理Url参数---------------------------
		if instr(str_Url,"?")>0 then
			HasOtherParam = true
			PageParam = "&Page="
		else
			HasOtherParam = false
			PageParam = "?Page="
		end if

		'----------获取当前页--------------------------------
		CurrentPage = request.QueryString("Page")
		if CurrentPage="" then
			CurrentPage=1
		else
			CurrentPage=Cint(CurrentPage)
		end if

		'-----------处理数据源------------------------------
		obj_RecordSet.PageSize = int_PageSize
		RecCount = obj_RecordSet.RecordCount
		PgCount = obj_RecordSet.PageCount 
		IF obj_RecordSet.Eof Then
			Response.Write("<center><font stlye='font-size:14px;' color='#ff0000'>对不起,没有记录!</font></center>")
		Else
		'-----------处理ADO分页----------------------------
			IF CurrentPage < 1 Then 
				CurrentPage = 1
			Else
				If CurrentPage>PgCount Then
					CurrentPage = PgCount
				End If
			End IF
			obj_RecordSet.absolutepage = CurrentPage
			Response.Write("<table  border='0' cellpadding='0' cellspacing='0' style='font-size:12px;' align='center' bgcolor='#FFFFFF'>") 
			'---------------翻页链接-----------------------------
			Dim FirstLink,PrevLink,NextLink,LastLink '定义向上和向下翻的变量

			'-----------------------首页-------------------------
			if CurrentPage>1 then
				FirstLink = "<a href='" & URL & PageParam & "1'>首页</a>"
				PrevLink = "<a href='" & URL & PageParam & Cstr(CurrentPage-1) & "'>上一页</a>"
			else
				FirstLink = "首页"
				PrevLink = "上一页"
			end if

			'------------下一页----------------
			if CurrentPage<PgCount then
				NextLink = "<a href='" & URL & PageParam & Cstr(CurrentPage+1) & "'>下一页</a>"
				LastLink = "<a href='" & URL & PageParam & PgCount & "'>尾页</a>"
			else
				NextLink = "下一页"
				LastLink = "尾页"
			end if
			PageInfomation = FirstLink & Seperator & PrevLink & Seperator & NextLink & Seperator & LastLink & Seperator & "每页" & Cstr(int_PageSize) & "条记录" & Seperator & "共" & PgCount & "页" & Seperator & "目前第" & CurrentPage & "页" & Seperator
			Response.Write("<tr><td align=center>")
			Response.Write("<table cellpadding=1 cellsapcing=0 border=1 style='border-collapse:collapse;' align=center  bordercolor='#CCCCCC' width='100%'>")

			'---------------设置表头-----------------
			Response.Write("<tr bgcolor='" & str_TitleColor & "'>")
			Dim i
			For i=0 to FieldCount -1
				Response.Write("<td style='font-size:12px;font-weight:bold;padding:5px;' align='center' width='" & Arr_FieldWidth(i) & "'>" & Arr_FieldName(i) & "</td>")
			Next
			'Response.Write("</tr>")

			Response.Write("<td align='center' width=80><font style='font-size:14px;'><b>操作</b></font></td>")
			Response.Write("</tr>")
			'---------------------输出内容---------------------------------
			i=0
			While (not obj_RecordSet.EOF) and i<int_PageSize
				Dim Cursor
				Response.Write("<tr>")
				For Cursor = 0 to FieldCount -1
					if Cursor=0	then
						Response.Write("<td align='center' style='line-height:1.5;'><a href='admin_user_info_show.asp?username="&obj_RecordSet(Arr_Field(Cursor))&"'>"&obj_RecordSet(Arr_Field(Cursor))&"</a></td>")
					elseif Cursor=FieldCount -1 then
						Response.Write("<td align='center' style='line-height:1.5;'>" & Sortusertype(obj_RecordSet(Arr_Field(Cursor))) & "</td>")
					else
						Response.Write("<td align='center' style='line-height:1.5;'>" & obj_RecordSet(Arr_Field(Cursor)) & "</td>")
					end if
				Next
				'Response.Write("</tr>")
				i=i+1
				Response.Write("<td align='center'><font style='font-size:12px;'><a href='admin_user_info_edit.asp?username="&obj_RecordSet(Arr_Field(0))&"'>Edit</a> <a href='admin_user_info_del.asp?username="&obj_RecordSet(Arr_Field(0))&"'>Del</a></font></td>")
				Response.Write("</tr>")
				obj_RecordSet.MoveNext
			Wend
			'------------------------输出分页条------------------------------------
			Response.Write("<tr><td align='right' style='line-height:1.5;padding:5px;' colspan='" & Cstr(FieldCount) & "'>" & PageInfomation & "</td></tr>")
			response.Write("</table></td></tr></table>")
		End IF
	End Sub
	
	'----------检查参数是否正确---------------
	
	Private Function Sortusertype(usertype)
		Select Case usertype
			Case 1
				Sortusertype="影音好友"
			Case 2
				Sortusertype="准影音用户"
			Case 3
				Sortusertype="影音成员"
			Case 4
				Sortusertype="Wap影音嘉宾"
			Case Else
				Sortusertype="未知"
		End Select
	End Function
	Private Sub Check()
		if Ubound(Arr_Field)<>Ubound(Arr_FieldName) then
			str_Error="Fields数组和FieldName数组维数必须相同"
		end if
		if isempty(obj_RecordSet) then
			str_Error="数据源不能为空,请设置dataSource属性"
		end if
		if int_PageSize="" then
			str_Error="数据源不能为空"
		end if
		ShowLastError
	End Sub
End Class
%>

⌨️ 快捷键说明

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