📄 clsmerchandisekind.cls
字号:
VERSION 1.0 CLASS
BEGIN
MultiUse = -1 'True
Persistable = 0 'NotPersistable
DataBindingBehavior = 0 'vbNone
DataSourceBehavior = 0 'vbNone
MTSTransactionMode = 0 'NotAnMTSObject
END
Attribute VB_Name = "clsMerchandisekind"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = True
Attribute VB_Ext_KEY = "SavedWithClassBuilder6" ,"Yes"
Attribute VB_Ext_KEY = "Top_Level" ,"Yes"
Option Explicit
'保持属性值的局部变量
Private mvarkindId As Integer '局部复制
Private mvarkindName As String '局部复制
Private mvarremark As String '局部复制
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 kindName(ByVal vData As String)
'向属性指派值时使用,位于赋值语句的左边。
'Syntax: X.kindName = 5
mvarkindName = vData
End Property
Public Property Get kindName() As String
'检索属性值时使用,位于赋值语句的右边。
'Syntax: Debug.Print X.kindName
kindName = mvarkindName
End Property
Public Property Let kindId(ByVal vData As Integer)
'向属性指派值时使用,位于赋值语句的左边。
'Syntax: X.kindId = 5
mvarkindId = vData
End Property
Public Property Get kindId() As Integer
'检索属性值时使用,位于赋值语句的右边。
'Syntax: Debug.Print X.kindId
kindId = mvarkindId
End Property
'***********************************************************************
'* 函数名:KindNameIsExist
'* 功 能:当前商品种类是否已存在于数据库中
'* 参 数:
'* 返回值:Boolean True 存在 False 不存在或数据查询错误
'* 版 本:2006.01.03 颜志军 初版
'***********************************************************************
Private Function KindNameIsExist() As Boolean
'变量定义
Dim sql As String 'SQL
Dim rs As ADODB.Recordset '记录集
'生成查询SQL
sql = "SELECT * FROM merchandisekind WHERE kindName = '" & kindName _
& "' AND kindId != " & CStr(kindId)
'执行查询
KindNameIsExist = False
On Error GoTo FUNEND
Set rs = g_conn.Execute(sql)
If Not rs.EOF Then
KindNameIsExist = True
End If
rs.Close
Set rs = Nothing
FUNEND:
End Function
'***********************************************************************
'* 函数名:kindIdIsExist
'* 功 能:当前商品种类ID是否已存在于数据库中
'* 参 数:
'* 返回值:Boolean True 存在 False 不存在或数据查询错误
'* 版 本:2006.01.03 颜志军 初版
'***********************************************************************
Private Function kindIdIsExist() As Boolean
'变量定义
Dim sql As String 'SQL
Dim rs As ADODB.Recordset '记录集
'生成查询SQL
sql = "SELECT * FROM merchandisekind WHERE kindId = " & kindId
'执行查询
kindIdIsExist = False
On Error GoTo FUNEND
Set rs = g_conn.Execute(sql)
If Not rs.EOF Then
kindIdIsExist = True
End If
rs.Close
Set rs = Nothing
FUNEND:
End Function
'***********************************************************************
'* 函数名:AppendNew
'* 功 能:追加当前商品种类信息到数据库
'* 参 数:
'* 返回值:DbOpResult 数据库操作结果
'* 版 本:2006.01.03 颜志军 初版
'***********************************************************************
Public Function AppendNew() As DbOpResult
'变量定义
Dim sql As String 'SQL
Dim affectLines As Long '影响行数
'检查商品种类是否已存在
If KindNameIsExist() Then
AppendNew = DbOpRecExist
Exit Function
End If
'生成SQL
sql = "INSERT INTO merchandisekind(kindName, remark) VALUES('" & _
kindName & "','" & remark & "')"
'执行插入
AppendNew = DbOpNG
On Error Resume Next
g_conn.Execute sql, affectLines
If affectLines = 1 Then
AppendNew = DbOpOk
End If
End Function
'***********************************************************************
'* 函数名:Update
'* 功 能:更新当前商品种类信息到数据库
'* 参 数:
'* 返回值:DbOpResult 数据库操作结果
'* 版 本:2006.01.01 颜志军 初版
'***********************************************************************
Public Function Update() As DbOpResult
'变量定义
Dim sql As String 'SQL
Dim affectLines As Long '影响行数
'检查当前商品类别名是否已存在
If KindNameIsExist() Then
Update = DbOpRecExist
Exit Function
End If
'检查当前商品种类ID是否存在
If Not kindIdIsExist() Then
Update = DbOpRecNoExist
Exit Function
End If
'生成SQL
sql = "UPDATE merchandisekind SET kindName = '" & kindName & "'"
sql = sql & ", remark = '" & remark & "'"
sql = sql & " WHERE kindId =" & CStr(kindId)
'执行更新
Update = DbOpNG
On Error Resume Next
g_conn.Execute sql, affectLines
If affectLines = 1 Then
Update = DbOpOk
End If
End Function
'***********************************************************************
'* 函数名:Delete
'* 功 能:从数据库中删除当前商品种类
'* 参 数:
'* 返回值:DbOpResult 数据库操作结果
'* 版 本:2006.01.03 颜志军 初版
'***********************************************************************
Public Function Delete() As DbOpResult
'变量定义
Dim sql As String 'SQL
Dim affectLines As Long '影响行数
'生成SQL
sql = "DELETE FROM merchandisekind WHERE kindId = " & CStr(kindId)
'执行删除
Delete = DbOpNG
On Error Resume Next
g_conn.Execute sql, affectLines
If affectLines = 1 Then
Delete = DbOpOk
End If
End Function
'***********************************************************************
'* 函数名:LoadByKindId
'* 功 能:从数据库中载入指定商品类别信息
'* 参 数:String 登陆用户名
'* 返回值:DbOpResult 数据库操作结果
'* 版 本:2006.01.03 颜志军 初版
'***********************************************************************
Public Function LoadByKindId(ByVal curKindId As Integer) As DbOpResult
'变量定义
Dim sql As String 'SQL
Dim rs As ADODB.Recordset '记录集
'生成查询SQL
sql = "SELECT * FROM merchandisekind WHERE kindId = " & CStr(curKindId)
'执行查询
LoadByKindId = DbOpNG
On Error Resume Next
Set rs = g_conn.Execute(sql)
If Not rs.EOF Then
Me.kindId = rs("kindId")
Me.kindName = rs("kindName")
Me.remark = rs("remark")
LoadByKindId = DbOpRecExist
Else
LoadByKindId = DbOpRecNoExist
End If
rs.Close
Set rs = Nothing
End Function
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -