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
clsBuys.cls
Package: vb+access.rar [view]
Upload User: czxfzx
Upload Date: 2015-02-25
Package Size: 749k
Code Size: 6k
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 = "clsBuys"
- 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" ,"clsBuy"
- Attribute VB_Ext_KEY = "Member0" ,"clsBuy"
- 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 clsBuys
- Dim rs As Recordset
- Dim index As Long
- Dim obj As clsBuy
- '按输入的参数查询,并返回一个集合类
- Dim strSQL As String
- '构造SQL语句
- strSQL = "Select * from Buy, Merchandise, MerchandiseType WHERE "
- strSQL = strSQL & " M_TypeId_N = MT_ID_N AND B_MerchandiseId_N=M_ID_N "
- If lgnID <> -1 Then
- strSQL = strSQL & " AND B_ID_N=" & lgnID
- End If
- If lngTypeId <> 0 Then
- strSQL = strSQL & " AND M_TypeId_N=" & lngTypeId
- End If
- strSQL = strSQL & " AND B_ID_N>0"
- '清空当前集合
- Me.Clear
- Set rs = g_Conn.Execute(strSQL)
- '往集合中添加查询结果
- For index = 1 To rs.RecordCount
- Set obj = New clsBuy
- With obj
- .ID = rs("B_ID_N").Value
- .ProviderId = rs("B_ProviderId_N").Value '供应商ID
- .MerchandiseID = rs("B_MerchandiseId_N").Value '商品ID
- .StockDate = rs("B_StockDate_D").Value '进货时间
- .Deliver = rs("B_Deliver_S").Value '送货人姓名
- .Consignee = rs("B_Consignee_S").Value '经手人姓名
- .Count = rs("B_Count_N").Value '购入量
- .StockPrice = rs("B_StockPrice_N").Value '进货单价
- .OperatorId = rs("B_OperatorId_S").Value '操作员Id
- .Remark = Trim(rs("B_Remark_R").Value) '备注
- .MerchName = Trim(rs("M_Name_S"))
- .ProviderName = GetValueByID("Provider", "P_ID_N", .ProviderId, "P_Name_S")
- End With
- Me.AddEx obj
- Set obj = Nothing
- rs.MoveNext
- Next index
- Set rs = Nothing
- Set Find = Me
- End Function
- '统计各种商品的进货次数和进货总价格,并最后按进货总价格来排序,最多返回前nCount条记录
- Public Function FindStorage(Optional IsDesc As Boolean = True, _
- Optional nCount As Integer = 10) As clsBuys
- Dim rs As Recordset
- Dim index As Long
- Dim obj As clsBuy
- '按输入的参数查询,并返回一个集合类
- 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(B_Count_N) AS StockTimes, "
- strSQL = strSQL & " SUM(B_StockPrice_N * B_Count_N) AS TotalPrice "
- strSQL = strSQL & " FROM Buy, Merchandise, MerchandiseType "
- strSQL = strSQL & " WHERE "
- strSQL = strSQL & " M_TypeId_N = MT_ID_N AND B_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
- '往集合中添加前nCount条查询结果
- nCount = IIf(nCount < rs.RecordCount, nCount, rs.RecordCount)
- For index = 1 To nCount
- Set obj = New clsBuy
- 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)
- .StockTimes = rs("StockTimes").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 clsBuy)
- 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 clsBuy
- '创建新对象
- Dim objNewMember As clsBuy
- Set objNewMember = New clsBuy
- '设置传入方法的属性
- 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 clsBuy
- '引用集合中的一个元素时使用。
- '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