?? clsmembershop.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 = "clsMembershop"
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 mvarshopId As Integer '局部復制
Private mvarshopName As String '局部復制
Private mvaraddress As String '局部復制
Private mvarleader As String '局部復制
Private mvarphone 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 phone(ByVal vData As String)
'向屬性指派值時使用,位于賦值語句的左邊。
'Syntax: X.phone = 5
mvarphone = vData
End Property
Public Property Get phone() As String
'檢索屬性值時使用,位于賦值語句的右邊。
'Syntax: Debug.Print X.phone
phone = mvarphone
End Property
Public Property Let leader(ByVal vData As String)
'向屬性指派值時使用,位于賦值語句的左邊。
'Syntax: X.leader = 5
mvarleader = vData
End Property
Public Property Get leader() As String
'檢索屬性值時使用,位于賦值語句的右邊。
'Syntax: Debug.Print X.leader
leader = mvarleader
End Property
Public Property Let address(ByVal vData As String)
'向屬性指派值時使用,位于賦值語句的左邊。
'Syntax: X.address = 5
mvaraddress = vData
End Property
Public Property Get address() As String
'檢索屬性值時使用,位于賦值語句的右邊。
'Syntax: Debug.Print X.address
address = mvaraddress
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 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
'***********************************************************************
'* 函數名:ShopNameIsExist
'* 功 能:當前店名是否已存在于數據庫中
'* 參 數:
'* 返回值:Boolean True 存在 False 不存在或數據查詢錯誤
'* 版 本:2006.01.01 顏志軍 初版
'***********************************************************************
Private Function ShopNameIsExist() As Boolean
'變量定義
Dim sql As String 'SQL
Dim rs As ADODB.Recordset '記錄集
'生成查詢SQL
sql = "SELECT * FROM membershop WHERE shopName = '" & shopName & _
"' AND shopId != " & CStr(shopId)
'執行查詢
ShopNameIsExist = False
On Error GoTo FUNEND
Set rs = g_conn.Execute(sql)
If Not rs.EOF Then
ShopNameIsExist = True
End If
rs.Close
Set rs = Nothing
FUNEND:
End Function
'***********************************************************************
'* 函數名:ShopIdIsExist
'* 功 能:當前店ID是否已存在于數據庫中
'* 參 數:
'* 返回值:Boolean True 存在 False 不存在或數據查詢錯誤
'* 版 本:2006.01.01 顏志軍 初版
'***********************************************************************
Private Function ShopIdIsExist() As Boolean
'變量定義
Dim sql As String 'SQL
Dim rs As ADODB.Recordset '記錄集
'生成查詢SQL
sql = "SELECT * FROM membershop WHERE shopId = " & CStr(shopId)
'執行查詢
ShopIdIsExist = False
On Error GoTo FUNEND
Set rs = g_conn.Execute(sql)
If Not rs.EOF Then
ShopIdIsExist = True
End If
rs.Close
Set rs = Nothing
FUNEND:
End Function
'***********************************************************************
'* 函數名:AppendNew
'* 功 能:追加當前連鎖店信息到數據庫
'* 參 數:
'* 返回值:DbOpResult 數據庫操作結果
'* 版 本:2006.01.01 顏志軍 初版
'***********************************************************************
Public Function AppendNew() As DbOpResult
'變量定義
Dim sql As String 'SQL
Dim affectLines As Long '影響行數
'檢查店名是否已存在
If ShopNameIsExist() Then
AppendNew = DbOpRecExist
Exit Function
End If
'生成SQL
sql = "INSERT INTO membershop(shopName, address, leader, phone, remark) VALUES('" & _
shopName & "','" & address & "','" & leader & "','" & phone & "','" & 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 ShopNameIsExist() Then
Update = DbOpRecExist
Exit Function
End If
'檢查當前店ID是否存在
If Not ShopIdIsExist() Then
Update = DbOpRecNoExist
Exit Function
End If
'生成SQL
sql = "UPDATE membershop SET shopName = '" & shopName & "'"
sql = sql & ", address = '" & address & "'"
sql = sql & ", leader = '" & leader & "'"
sql = sql & ", phone = '" & phone & "'"
sql = sql & ", remark = '" & remark & "'"
sql = sql & " WHERE shopId =" & CStr(shopId)
'執行更新
Update = DbOpNG
On Error Resume Next
g_conn.Execute sql, affectLines
If affectLines = 1 Then
Update = DbOpOk
End If
End Function
'***********************************************************************
'* 函數名:LoadByShopId
'* 功 能:從數據庫中載入指定連鎖店信息
'* 參 數:Integer 店ID
'* 返回值:DbOpResult 數據庫操作結果
'* 版 本:2006.01.02 顏志軍 初版
'***********************************************************************
Public Function LoadByShopId(ByVal curShopId As Integer) As DbOpResult
'變量定義
Dim sql As String 'SQL
Dim rs As ADODB.Recordset '記錄集
'生成查詢SQL
sql = "SELECT * FROM membershop WHERE shopId = " & CStr(curShopId)
'執行查詢
LoadByShopId = DbOpNG
On Error Resume Next
Set rs = g_conn.Execute(sql)
If Not rs.EOF Then
Me.shopId = rs("shopId")
Me.shopName = rs("shopName")
Me.address = rs("address")
Me.leader = rs("leader")
Me.phone = rs("phone")
Me.remark = rs("remark")
LoadByShopId = DbOpRecExist
Else
LoadByShopId = DbOpRecNoExist
End If
rs.Close
Set rs = Nothing
End Function
'***********************************************************************
'* 函數名:Delete
'* 功 能:從數據庫中刪除當前連鎖店
'* 參 數:
'* 返回值:DbOpResult 數據庫操作結果
'* 版 本:2006.01.02 顏志軍 初版
'***********************************************************************
Public Function Delete() As DbOpResult
'總公司不可刪除
If shopId = 1 Then
Delete = DbOpOnlyRec
Exit Function
End If
'變量定義
Dim sql As String 'SQL
Dim affectLines As Long '影響行數
'生成SQL
sql = "DELETE FROM membershop WHERE shopId = " & CStr(shopId)
'執行刪除
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 + -