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
clsMerch.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 = "clsMerch"
- 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 = "Top_Level" ,"Yes"
- Option Explicit
- '保持属性值的局部变量
- Private mvarID As Long '商品编号
- Private mvarMerchName As String '商品名称
- Private mvarIntroduce As String '商品介绍
- Private mvarTypeId As Long '商品类型ID
- Private mvarStorage As Long '库存量
- Private mvarUnitID As Long '单位编号
- Private mvarRemark As String '备注
- Private mvarTypeName As String '商品类型名称
- Public Property Let TypeName(ByVal vData As String)
- '向属性指派值时使用,位于赋值语句的左边。
- 'Syntax: X.TypeName = 5
- mvarTypeName = vData
- End Property
- Public Property Get TypeName() As String
- '检索属性值时使用,位于赋值语句的右边。
- 'Syntax: Debug.Print X.TypeName
- TypeName = mvarTypeName
- End Property
- Public Property Let Remark(ByVal vData As String)
- '向属性指派值时使用,位于赋值语句的左边。
- 'Syntax: X.Remark = 5
- mvarRemark = vData
- End Property
- Public Property Get Remark() As String
- '检索属性值时使用,位于赋值语句的右边。
- 'Syntax: Debug.Print X.Remark
- Remark = mvarRemark
- End Property
- Public Property Let UnitID(ByVal vData As Long)
- '向属性指派值时使用,位于赋值语句的左边。
- 'Syntax: X.UnitID = 5
- mvarUnitID = vData
- End Property
- Public Property Get UnitID() As Long
- '检索属性值时使用,位于赋值语句的右边。
- 'Syntax: Debug.Print X.UnitID
- UnitID = mvarUnitID
- End Property
- Public Property Let Storage(ByVal vData As Long)
- '向属性指派值时使用,位于赋值语句的左边。
- 'Syntax: X.Storage = 5
- mvarStorage = vData
- End Property
- Public Property Get Storage() As Long
- '检索属性值时使用,位于赋值语句的右边。
- 'Syntax: Debug.Print X.Storage
- Storage = mvarStorage
- End Property
- Public Property Let TypeId(ByVal vData As Long)
- '向属性指派值时使用,位于赋值语句的左边。
- 'Syntax: X.TypeId = 5
- mvarTypeId = vData
- End Property
- Public Property Get TypeId() As Long
- '检索属性值时使用,位于赋值语句的右边。
- 'Syntax: Debug.Print X.TypeId
- TypeId = mvarTypeId
- End Property
- Public Property Let Introduce(ByVal vData As String)
- '向属性指派值时使用,位于赋值语句的左边。
- 'Syntax: X.Introduce = 5
- mvarIntroduce = vData
- End Property
- Public Property Get Introduce() As String
- '检索属性值时使用,位于赋值语句的右边。
- 'Syntax: Debug.Print X.Introduce
- Introduce = mvarIntroduce
- End Property
- Public Property Let MerchName(ByVal vData As String)
- '向属性指派值时使用,位于赋值语句的左边。
- 'Syntax: X.MerchName = 5
- mvarMerchName = vData
- End Property
- Public Property Get MerchName() As String
- '检索属性值时使用,位于赋值语句的右边。
- 'Syntax: Debug.Print X.MerchName
- MerchName = mvarMerchName
- End Property
- Public Property Let ID(ByVal vData As Long)
- '向属性指派值时使用,位于赋值语句的左边。
- 'Syntax: X.ID = 5
- mvarID = vData
- End Property
- Public Property Get ID() As Long
- '检索属性值时使用,位于赋值语句的右边。
- 'Syntax: Debug.Print X.ID
- ID = mvarID
- End Property
- Public Function AddNew() As gxcAddNew
- Dim strSQL As String
- '检测输入名称是否存在
- If ExistByName("Merchandise", "M_Name_S", Me.MerchName) Then
- AddNew = DuplicateName_AddNew
- Exit Function
- End If
- strSQL = "INSERT INTO Merchandise(M_Name_S, M_Introduce_S, M_TypeId_N, M_Remark_R) "
- strSQL = strSQL & " VALUES("
- strSQL = strSQL & "'" & Me.MerchName & "'" '商品名称
- strSQL = strSQL & ",'" & Me.Introduce & "'" '商品介绍
- strSQL = strSQL & ",'" & Me.TypeId & "'" '商品类型ID
- strSQL = strSQL & ",'" & Me.Remark & "'" '备注
- strSQL = strSQL & ")"
- '执行SQL语句
- g_Conn.Execute strSQL
- '如果发生错误,则返回AddNewFail,表示未成功添加
- If Err.Number = 0 Then
- Me.ID = MaxID("Merchandise", "M_ID_N")
- AddNew = AddNewOK
- Else
- AddNew = AddNewFail
- End If
- End Function
- Public Function Update() As gxcUpdate
- Dim strSQL As String
- '通过ID判断是否存在该记录,即该记录是否被其它商品端删除
- '如果不存在该记录,则返回相应的操作结果给调用者
- If Not ExistByID("Merchandise", "M_ID_N", Me.ID) Then
- Update = RecordNotExist
- Exit Function
- End If
- '通过名称判断是否存在相同名称的记录,如果存在相同的名称,
- '则返回调用者“存在相同名称”的信息
- If ExistByNameExceptID("Merchandise", _
- "M_ID_N", Me.ID, _
- "M_NAME_S", Me.MerchName) Then
- Update = DuplicateName_Update
- Exit Function
- End If
- '构造SQL语句,注意需调用RealString函数去除字符串中的单引号
- strSQL = "Update Merchandise SET "
- strSQL = strSQL & "M_Name_S='" & RealString(Me.MerchName) & "',"
- strSQL = strSQL & "M_Introduce_S='" & RealString(Me.Introduce) & "',"
- strSQL = strSQL & "M_TypeId_N='" & Me.TypeId & "',"
- strSQL = strSQL & "M_Storage_N='" & Me.Storage & "',"
- strSQL = strSQL & "M_UnitId_N='" & Me.UnitID & "',"
- strSQL = strSQL & "M_Remark_R='" & Me.Remark & "' "
- strSQL = strSQL & " WHERE M_ID_N=" & Me.ID
- g_Conn.Execute strSQL '执行SQL语句
- '根据是否出错,返回给调用者相应的信息
- Update = IIf(Err.Number = 0, UpdateOK, UpdateFail)
- End Function
- Public Function Delete(Optional lngID As Long = -1) As gxcDelete
- Dim strSQL As String
- '如果已传入了要删除的ID,则按此ID删除
- If lngID <> -1 Then Me.ID = lngID
- '以下四个操作要同时发生
- g_Conn.BeginTrans
- '删除Buy表中的相关记录
- strSQL = "DELETE FROM Buy WHERE B_MerchandiseID_N=" & Me.ID
- g_Conn.Execute strSQL
- '删除Sell表中的相关记录
- strSQL = "DELETE FROM Sell WHERE S_MerchandiseID_N =" & Me.ID
- g_Conn.Execute strSQL
- '删除Dispose表中的记录
- strSQL = "DELETE FROM Dispose WHERE D_MerchandiseID_N=" & Me.ID
- '删除Merchandise表中的信息
- strSQL = "DELETE FROM Merchandise WHERE M_ID_N=" & Me.ID
- g_Conn.Execute strSQL
- g_Conn.CommitTrans
- '如果发生错误,则返回FALSE,表示未删除成功
- Delete = IIf(Err.Number = 0, DeleteOK, DeleteFail)
- End Function