Code/Resource
Windows Develop
Linux-Unix program
Internet-Socket-Network
Web Server
Browser Client
Ftp Server
Ftp Client
Browser Plugins
Proxy Server
Email Server
Email Client
WEB Mail
Firewall-Security
Telnet Server
Telnet Client
ICQ-IM-Chat
Search Engine
Sniffer Package capture
Remote Control
xml-soap-webservice
P2P
WEB(ASP,PHP,...)
TCP/IP Stack
SNMP
Grid Computing
SilverLight
DNS
Cluster Service
Network Security
Communication-Mobile
Game Program
Editor
Multimedia program
Graph program
Compiler program
Compress-Decompress algrithms
Crypt_Decrypt algrithms
Mathimatics-Numerical algorithms
MultiLanguage
Disk/Storage
Java Develop
assembly language
Applications
Other systems
Database system
Embeded-SCM Develop
FlashMX/Flex
source in ebook
Delphi VCL
OS Develop
MiddleWare
MPI
MacOS develop
LabView
ELanguage
Software/Tools
E-Books
Artical/Document
clsSells.cls
Package: vb+access.rar [view]
Upload User: czxfzx
Upload Date: 2015-02-25
Package Size: 749k
Code Size: 5k
Category:
ERP-EIP-OA-Portal
Development Platform:
Visual Basic
- VERSION 1.0 CLASS
- BEGIN
- MultiUse = -1 'True
- Persistable = 0 'NotPersistable
- DataBindingBehavior = 0 'vbNone
- DataSourceBehavior = 0 'vbNone
- MTSTransactionMode = 0 'NotAnMTSObject
- END
- Attribute VB_Name = "clsSells"
- Attribute VB_GlobalNameSpace = False
- Attribute VB_Creatable = True
- Attribute VB_PredeclaredId = False
- Attribute VB_Exposed = False
- Attribute VB_Ext_KEY = "SavedWithClassBuilder6" ,"Yes"
- Attribute VB_Ext_KEY = "Collection" ,"clsSell"
- Attribute VB_Ext_KEY = "Member0" ,"clsSell"
- Attribute VB_Ext_KEY = "Top_Level" ,"Yes"
- Option Explicit
- '局部变量,保存集合
- Private mCol As Collection
- Public Function Find(Optional lgnID As Long = -1, Optional lngTypeId As Long = 0) As clsSells
- Dim rs As Recordset
- Dim index As Long
- Dim obj As clsSell
- '按输入的参数查询,并返回一个集合类
- Dim strSQL As String
- '构造SQL语句
- strSQL = "Select * from Sell, Merchandise, MerchandiseType WHERE "
- strSQL = strSQL & " M_TypeId_N = MT_ID_N AND S_MerchandiseId_N=M_ID_N "
- If lgnID <> -1 Then
- strSQL = strSQL & " AND S_ID_N=" & lgnID
- End If
- If lngTypeId <> 0 Then
- strSQL = strSQL & " AND M_TypeId_N=" & lngTypeId
- End If
- strSQL = strSQL & " AND S_ID_N>0"
- '清空当前集合
- Me.Clear
- Set rs = g_Conn.Execute(strSQL)
- '往集合中添加查询结果
- For index = 1 To rs.RecordCount
- Set obj = New clsSell
- With obj
- .ID = rs("S_ID_N").Value
- .MerchandiseID = rs("S_MerchandiseID_N").Value
- .RegDate = rs("S_RegDate_D").Value
- .Count = rs("S_Count_N").Value
- .SellPrice = rs("S_SellPrice_N").Value
- .OperatorId = rs("S_OperatorId_S").Value
- .Remark = Trim(rs("S_Remark_R").Value)
- .MerchName = GetValueByID("Merchandise", "M_ID_N", .MerchandiseID, "M_Name_S")
- End With
- Me.AddEx obj
- Set obj = Nothing
- rs.MoveNext
- Next index
- Set rs = Nothing
- Set Find = Me
- End Function
- Public Function FindStorage(Optional IsDesc As Boolean = True, _
- Optional nCount As Integer = 10) As clsSells
- Dim rs As Recordset
- Dim index As Long
- Dim obj As clsSell
- '按输入的参数查询,并返回一个集合类
- Dim strSQL As String
- Dim strOrder As String
- If nCount <= 0 Then nCount = 10
- strOrder = IIf(IsDesc, "DESC", "ASC")
- '构造SQL语句
- strSQL = "Select M_ID_N, M_Name_S, MT_Name_S, "
- strSQL = strSQL & " COUNT(S_Count_N) AS RegTimes, "
- strSQL = strSQL & " SUM(S_SellPrice_N * S_Count_N) AS TotalPrice "
- strSQL = strSQL & " FROM Sell, Merchandise, MerchandiseType "
- strSQL = strSQL & " WHERE "
- strSQL = strSQL & " M_TypeId_N = MT_ID_N AND S_MerchandiseId_N=M_ID_N "
- strSQL = strSQL & " GROUP BY M_ID_N, M_Name_S, MT_Name_S "
- '清空当前集合
- Me.Clear
- '排序
- Set rs = g_Conn.Execute(strSQL)
- rs.Sort = "TotalPrice " & strOrder
- Dim aa, bb As Double
- '往集合中添加前nCount条查询结果
- nCount = IIf(nCount < rs.RecordCount, nCount, rs.RecordCount)
- For index = 1 To nCount
- Set obj = New clsSell
- With obj
- '此时ID属性中仅存用于区分的商品ID,而非Sell表中的ID
- .ID = rs("M_ID_N").Value
- .MerchName = Trim(rs("M_Name_S").Value)
- .TypeName = Trim(rs("MT_Name_S").Value)
- .RegTimes = rs("RegTimes").Value
- .TotalPrice = rs("TotalPrice").Value
- End With
- Me.AddEx obj
- Set obj = Nothing
- rs.MoveNext
- Next index
- Set rs = Nothing
- Set FindStorage = Me
- End Function
- Public Sub AddEx(obj As clsSell)
- mCol.Add obj, "A" & obj.ID
- '在加入对象是,最好同时加入其“KEY”属性
- '“KEY”属性不可以是数字型,因此在前面随便加
- '一个字母,此处加了一个“A”
- End Sub
- '清除集合中的全部元素
- Public Sub Clear()
- '注意!在清除时必须倒序清除,否则要出错!
- Dim i As Long
- For i = mCol.Count To 1 Step -1
- mCol.Remove i
- Next i
- End Sub
- Public Function Add(ID As Long, Optional sKey As String) As clsSell
- '创建新对象
- Dim objNewMember As clsSell
- Set objNewMember = New clsSell
- '设置传入方法的属性
- objNewMember.ID = ID
- objNewMember.ID = ID
- If Len(sKey) = 0 Then
- mCol.Add objNewMember
- Else
- mCol.Add objNewMember, sKey
- End If
- '返回已创建的对象
- Set Add = objNewMember
- Set objNewMember = Nothing
- End Function
- Public Property Get Item(vntIndexKey As Variant) As clsSell
- '引用集合中的一个元素时使用。
- 'vntIndexKey 包含集合的索引或关键字,
- '这是为什么要声明为 Variant 的原因
- '语法:Set foo = x.Item(xyz) or Set foo = x.Item(5)
- Set Item = mCol(vntIndexKey)
- End Property
- Public Property Get Count() As Long
- '检索集合中的元素数时使用。语法:Debug.Print x.Count
- Count = mCol.Count
- End Property
- Public Sub Remove(vntIndexKey As Variant)
- '删除集合中的元素时使用。
- 'vntIndexKey 包含索引或关键字,这是为什么要声明为 Variant 的原因
- '语法:x.Remove(xyz)
- mCol.Remove vntIndexKey
- End Sub
- Public Property Get NewEnum() As IUnknown
- Attribute NewEnum.VB_UserMemId = -4
- Attribute NewEnum.VB_MemberFlags = "40"
- '本属性允许用 For...Each 语法枚举该集合。
- Set NewEnum = mCol.[_NewEnum]
- End Property
- Private Sub Class_Initialize()
- '创建类后创建集合
- Set mCol = New Collection
- End Sub
- Private Sub Class_Terminate()
- '类终止后破坏集合
- Set mCol = Nothing
- End Sub