📄 clssalerecday.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 = "clsSalerecDay"
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 mvarrecid As Long '局部复制
Private mvarshopId As Integer '局部复制
Private mvarmerchandiseId As Integer '局部复制
Private mvarmerchandiseName As String '局部复制
Private mvarshopName As String '局部复制
Private mvarsaledate As Date '局部复制
Private mvarmerchandiseCount As Integer '局部复制
Public Property Let merchandiseCount(ByVal vData As Integer)
'向属性指派值时使用,位于赋值语句的左边。
'Syntax: X.merchandiseCount = 5
mvarmerchandiseCount = vData
End Property
Public Property Get merchandiseCount() As Integer
'检索属性值时使用,位于赋值语句的右边。
'Syntax: Debug.Print X.merchandiseCount
merchandiseCount = mvarmerchandiseCount
End Property
Public Property Let saledate(ByVal vData As Date)
'向属性指派值时使用,位于赋值语句的左边。
'Syntax: X.saledate = 5
mvarsaledate = vData
End Property
Public Property Get saledate() As Date
'检索属性值时使用,位于赋值语句的右边。
'Syntax: Debug.Print X.saledate
saledate = mvarsaledate
End Property
Public Property Let shopName(ByVal vData As String)
'向属性指派值时使用,位于赋值语句的左边。
'Syntax: X.shopName = 5
mvarshopName = vData
End Property
Public Property Get shopName() As String
'检索属性值时使用,位于赋值语句的右边。
'Syntax: Debug.Print X.shopName
shopName = mvarshopName
End Property
Public Property Let merchandiseName(ByVal vData As String)
'向属性指派值时使用,位于赋值语句的左边。
'Syntax: X.merchandiseName = 5
mvarmerchandiseName = vData
End Property
Public Property Get merchandiseName() As String
'检索属性值时使用,位于赋值语句的右边。
'Syntax: Debug.Print X.merchandiseName
merchandiseName = mvarmerchandiseName
End Property
Public Property Let merchandiseId(ByVal vData As Integer)
'向属性指派值时使用,位于赋值语句的左边。
'Syntax: X.merchandiseId = 5
mvarmerchandiseId = vData
End Property
Public Property Get merchandiseId() As Integer
'检索属性值时使用,位于赋值语句的右边。
'Syntax: Debug.Print X.merchandiseId
merchandiseId = mvarmerchandiseId
End Property
Public Property Let shopId(ByVal vData As Integer)
'向属性指派值时使用,位于赋值语句的左边。
'Syntax: X.shopId = 5
mvarshopId = vData
End Property
Public Property Get shopId() As Integer
'检索属性值时使用,位于赋值语句的右边。
'Syntax: Debug.Print X.shopId
shopId = mvarshopId
End Property
Public Property Let recid(ByVal vData As Long)
'向属性指派值时使用,位于赋值语句的左边。
'Syntax: X.recid = 5
mvarrecid = vData
End Property
Public Property Get recid() As Long
'检索属性值时使用,位于赋值语句的右边。
'Syntax: Debug.Print X.recid
recid = mvarrecid
End Property
'***********************************************************************
'* 函数名:RecIdIsExist
'* 功 能:当前日报ID是否已存在于数据库中
'* 参 数:
'* 返回值:Boolean True 存在 False 不存在或数据查询错误
'* 版 本:2006.01.04 颜志军 初版
'***********************************************************************
Private Function RecIdIsExist() As Boolean
'变量定义
Dim sql As String 'SQL
Dim rs As ADODB.Recordset '记录集
'生成查询SQL
sql = "SELECT * FROM salerecday WHERE recid = " & CStr(recid)
'执行查询
RecIdIsExist = False
On Error GoTo FUNEND
Set rs = g_conn.Execute(sql)
If Not rs.EOF Then
RecIdIsExist = True
End If
rs.Close
Set rs = Nothing
FUNEND:
End Function
'***********************************************************************
'* 函数名:ReportIsExist
'* 功 能:当前日报是否已存在于数据库中
'* 参 数:
'* 返回值:Boolean True 存在 False 不存在或数据查询错误
'* 版 本:2006.01.04 颜志军 初版
'***********************************************************************
Private Function ReportIsExist() As Boolean
'变量定义
Dim sql As String 'SQL
Dim rs As ADODB.Recordset '记录集
'生成查询SQL
sql = "SELECT * FROM salerecday WHERE shopId = " & CStr(shopId)
sql = sql & " AND merchandiseId = " & CStr(merchandiseId)
sql = sql & " AND saledate = '" & CStr(saledate) & "'"
If recid > 0 Then
sql = sql & " AND recid !=" & CStr(recid)
End If
'执行查询
ReportIsExist = False
On Error GoTo FUNEND
Set rs = g_conn.Execute(sql)
If Not rs.EOF Then
ReportIsExist = True
End If
rs.Close
Set rs = Nothing
FUNEND:
End Function
'***********************************************************************
'* 函数名:LoadById
'* 功 能:从数据库中载入指定销售日报ID信息
'* 参 数:Long 商品销售日报ID
'* 返回值:DbOpResult 数据库操作结果
'* 版 本:2006.01.05 颜志军 初版
'***********************************************************************
Public Function LoadById(ByVal curId As Long) As DbOpResult
'变量定义
Dim sql As String 'SQL
Dim rs As ADODB.Recordset '记录集
'生成查询SQL
sql = "SELECT * FROM view_salerecday WHERE recid = " & CStr(curId)
'执行查询
LoadById = DbOpNG
On Error Resume Next
Set rs = g_conn.Execute(sql)
If Not rs.EOF Then
Me.merchandiseCount = rs("merchandiseCount")
Me.merchandiseId = rs("merchandiseId")
Me.merchandiseName = rs("merchandiseName")
Me.recid = rs("recid")
Me.saledate = rs("saledate")
Me.shopId = rs("shopId")
Me.shopName = rs("shopName")
LoadById = DbOpRecExist
Else
LoadById = DbOpRecNoExist
End If
rs.Close
Set rs = Nothing
End Function
'***********************************************************************
'* 函数名:AppendNew
'* 功 能:追加当前商品日报信息到数据库
'* 参 数:
'* 返回值:DbOpResult 数据库操作结果
'* 版 本:2006.01.05 颜志军 初版
'***********************************************************************
Public Function AppendNew() As DbOpResult
'变量定义
Dim sql As String 'SQL
Dim affectLines As Long '影响行数
'检查当前日报是否已存在
If ReportIsExist() Then
AppendNew = DbOpRecExist
Exit Function
End If
'生成SQL
sql = "INSERT INTO salerecday(shopId, merchandiseId, saledate, merchandiseCount)"
sql = sql & " VALUES(" & CStr(shopId) & "," & CStr(merchandiseId) & ",'" _
& CStr(saledate) & "'," & merchandiseCount & ")"
'执行插入
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.05 颜志军 初版
'***********************************************************************
Public Function Update() As DbOpResult
'变量定义
Dim sql As String 'SQL
Dim affectLines As Long '影响行数
'检查当前商品日报ID是否存在
If Not RecIdIsExist() Then
Update = DbOpRecNoExist
Exit Function
End If
'检查当前日报是否已存在
If ReportIsExist() Then
Update = DbOpRecExist
Exit Function
End If
'生成SQL
sql = "UPDATE salerecday SET shopId = " & CStr(shopId)
sql = sql & ", merchandiseId = " & CStr(merchandiseId)
sql = sql & ", saledate = '" & CStr(saledate) & "'"
sql = sql & ", merchandiseCount = " & CStr(merchandiseCount)
sql = sql & " WHERE recid =" & CStr(recid)
'执行更新
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.05 颜志军 初版
'***********************************************************************
Public Function Delete() As DbOpResult
'变量定义
Dim sql As String 'SQL
Dim affectLines As Long '影响行数
'生成SQL
sql = "DELETE FROM salerecday WHERE recid = " & CStr(recid)
'执行删除
Delete = DbOpNG
On Error Resume Next
g_conn.Execute sql, affectLines
If affectLines = 1 Then
Delete = DbOpOk
End If
End Function
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -