<%
'##################################################################                                                                 
'★         web08.net - 威博购物系统                                              
'★  版权所有: web08.net                                                                                                       
'★  程序制作: 威博网络技术公司                                     
'★           email:web08net@hotmail.com                           
'★            Q Q :645095280,475980829
'★	       电话:021-55520018                                                                                                         
'★  相关网址: [产品介绍] http://www.021web.com.cn/gwxt.html
'★            [支持论坛] http://bbs.web08.net/                                                                                     
'★  主页地址: http://www.web08.net/  
'★		http://www.021web.com.cn/			                                                                 
'###################################################################
%>
<%
Class Cls_Dbclass
	Private web_Conn,web_DbType,web_RecType,web_RecSql,web_RecTerm
	Private S_Order,web_count,web_orderField
	Private web_Sql,web_Field,web_Table,web_Where,web_OrderBy,web_Id
	Private web_RecCount,web_PageCount,ResultSet_Sql
	Private web_Cm,web_WhereOther,web_Order,web_Size,web_Mm 'MSSQL

	'================================================================
	' Class_Initialize
	'================================================================
	Private Sub Class_Initialize
		web_Order=">"
		web_Size="MAX"
		web_WhereOther=""
	End Sub

	'================================================================
	' Conn
	'================================================================
	Public Property Let Conn(ByVal objConn)
		Set web_Conn=objConn
	End Property

	'================================================================
	' DbType
	'================================================================ 
	Public Property Let DbType(ByVal strDbType)
		web_DbType=strDbType
	End Property

	'================================================================
	' Count
	'================================================================ 
	Public Property Let Count(ByVal strcount)
		web_count=strcount
		If web_count=0 then
			web_count=""
		Else
			web_count="top "&web_count
		End if
	End Property

	'================================================================
	' Count
	'================================================================ 
	Public Property Let Where(ByVal strwhere)
		web_Where=strwhere
		If Web_where<>"" then
			web_where="where "&web_where
		Else
		End IF 
	End Property

	'================================================================
	' OrderType
	'================================================================
	Public Property Let OrderType(ByVal val)
		S_Order=val
		If S_order<>"" then
			S_Order=replace(S_order,"1","Desc")
			S_Order=replace(S_order,"0","Asc")
		End if 
	End Property

	'================================================================
	' OrderField
	'================================================================
	Public Property Let OrderField(ByVal val)
		web_orderField=val
	End Property

	Private Function SetOrder()
		dim v_tmp,v_tmp1
		v_tmp=split(S_order,",")
		v_tmp1=split(web_OrderField,",")
		If web_OrderField="" then
			SetOrder=""
		Else
			For i=0 to ubound(v_tmp1)
				SetOrder=SetOrder&","&v_tmp1(i)&" "&v_tmp(i)
			Next
			SetOrder=replace(SetOrder,","," ",1,1)
			SetOrder="order by"&SetOrder
		End IF 
	End Function

	'================================================================
	' Sql
	'================================================================
	Public Property Let Sql(ByVal str_sql)  
		web_Sql=Split(str_sql,"$")
		web_Field=web_Sql(0)
		web_Table=web_Sql(1)
		web_Id=web_Sql(2)
	End Property

	'================================================================
	' ResultSet
	'================================================================
	Public Property Get ResultSet()
		web_OrderBy=SetOrder()
		Select Case web_DbType
			Case "AC" 
				Set web_Rs=Server.CreateObject ("adodb.RecordSet")
				ResultSet_Sql="SELECT "&web_Field&" FROM "&web_Table&" "&web_Where&" "&web_OrderBy
				web_Rs.Open ResultSet_Sql,web_Conn,1,1,&H0001
				web_Rs.AbsolutePosition=(web_CurrPage-1)*web_PageSize+1
			Case "MSSQL" 
				ResultSet_Sql="SELECT "&web_count&" "&web_Field&" FROM "&web_Table&" "&web_Where&" "&web_OrderBy
				Set web_Rs=web_Conn.execute(ResultSet_Sql)
			Case "MSSQL_SP" 
				Set web_Rs=server.CreateObject("Adodb.RecordSet")
				Set web_Cm=Server.CreateObject("Adodb.Command")
				web_Cm.CommandType=4
				web_Cm.ActiveConnection=web_Conn
				web_Cm.CommandText="SP_webPage"
				web_Cm.parameters(1)=web_CurrPage
				web_Cm.parameters(2)=web_PageSize
				web_Cm.parameters(3)=web_Field
				web_Cm.parameters(4)=web_Table
				web_Cm.parameters(5)=web_Where
				web_Cm.parameters(6)=web_WhereOther
				web_Cm.parameters(7)=web_OrderBy
				web_Cm.parameters(8)=web_Id
				web_Cm.parameters(9)=web_Size
				web_Cm.parameters(10)=web_Order
				web_Rs.CursorLocation=1
				web_Rs.LockType=1
				web_Rs.Open web_Cm
			Case Else
				Set web_Rs = Server.CreateObject ("adodb.RecordSet")
				ResultSet_Sql="SELECT "&web_Field&" FROM "&web_Table&" "&web_Where&" "&web_OrderBy
				web_Rs.Open ResultSet_Sql,web_Conn,1,1,&H0001
				web_Rs.AbsolutePosition=(web_CurrPage-1)*web_PageSize+1
		End Select
		ResultSet=web_Rs.GetRows()
		web_Rs.close
		Set web_Rs=Nothing
	End Property

	'================================================================
	' 
	'================================================================
	Private Function CheckNum(ByVal strStr,ByVal intStartNum,ByVal intEndNum)
		CheckNum=intStartNum
		If IsNumeric(strStr) Then CheckNum=Clng(strStr)        
		If intEndNum>-1Then
			If CheckNum<intStartNum Then CheckNum=intStartNum
			If CheckNum>intEndNum Then CheckNum=intEndNum
		End If
	End Function

	'================================================================
	' Class_Terminate 
	'================================================================
	Private Sub Class_Terminate()
		If IsObject(web_Conn) Then 
			web_Conn.Close
			Set web_Conn=Nothing
		End If
	End Sub

 End Class
%> 

 
 

