?? mdlmembershop.bas
字號:
Attribute VB_Name = "mdlMemberShop"
Option Explicit
'***********************************************************************
'* 過程名:AppendNewShop
'* 功 能:追加新店
'* 參 數:ListView 列表控件
'* 版 本:2006.01.02 顏志軍 初版
'***********************************************************************
Public Sub AppendNewShop(ByRef lvListViewCtl As ListView)
Dim memShop As clsOpShopInfo
Set memShop = New clsOpShopInfo
memShop.AppendNewShop g_currentUser
UpdateListViewInMemberShop lvListViewCtl
End Sub
'***********************************************************************
'* 過程名:EditShop
'* 功 能:編輯連鎖店信息
'* 參 數:ListView 列表控件
'* 版 本:2006.01.02 顏志軍 初版
'***********************************************************************
Public Sub EditShop(ByRef lvListViewCtl As ListView)
'變量定義
Dim currentSelShopId As String '當前選擇店ID
Dim currentSelShop As clsMembershop '當前選擇店
Dim opShop As clsOpShopInfo '連鎖店操作對象
'取得當前選擇
If lvListViewCtl.SelectedItem Is Nothing Then
MsgBox "請選擇要編輯的連鎖店!", vbExclamation Or vbOKOnly, "警告"
Else
currentSelShopId = Trim(lvListViewCtl.SelectedItem.Text)
Set currentSelShop = New clsMembershop
If currentSelShop.LoadByShopId(CInt(currentSelShopId)) = DbOpRecExist Then
Set opShop = New clsOpShopInfo
opShop.EditShop currentSelShop, g_currentUser
lvListViewCtl.ListItems.Remove lvListViewCtl.SelectedItem.index
UpdateListViewInMemberShop lvListViewCtl
Else
MsgBox "讀取連鎖店信息失敗!", vbExclamation Or vbOKOnly, "警告"
End If
End If
End Sub
'***********************************************************************
'* 過程名:IniListViewInMemberShop
'* 功 能:以連鎖店列表初始化ListView
'* 參 數:ListView 列表控件
'* 版 本:2006.01.02 顏志軍 初版
'***********************************************************************
Public Sub IniListViewInMemberShop(ByRef lvListViewCtl As ListView)
If g_listViewState = MEMBERSHOPLIST Then
UpdateListViewInMemberShop lvListViewCtl
Else
'變量定義
Dim shopSet As clsMembershopSet
Dim memShop As clsMembershop
Dim curListItem As ListItem
'取得店集合
Set shopSet = New clsMembershopSet
'清除現有顯示
lvListViewCtl.ColumnHeaders.Clear
lvListViewCtl.ListItems.Clear
'設定表頭
lvListViewCtl.ColumnHeaders.Add , "店ID", "店ID"
lvListViewCtl.ColumnHeaders.Add , "店名", "店名"
lvListViewCtl.ColumnHeaders.Add , "地址", "地址"
lvListViewCtl.ColumnHeaders.Add , "店長", "店長"
lvListViewCtl.ColumnHeaders.Add , "電話", "電話"
lvListViewCtl.ColumnHeaders.Add , "備注", "備注"
'明細顯示
For Each memShop In shopSet
Set curListItem = lvListViewCtl.ListItems.Add(, , CStr(memShop.shopId))
curListItem.SubItems(1) = memShop.shopName
curListItem.SubItems(2) = memShop.address
curListItem.SubItems(3) = memShop.leader
curListItem.SubItems(4) = memShop.phone
curListItem.SubItems(5) = memShop.remark
Next
End If
g_listViewState = MEMBERSHOPLIST
End Sub
'***********************************************************************
'* 過程名:UpdateListViewInMemberShop
'* 功 能:更新店列表
'* 參 數:ListView 列表控件
'* 版 本:2006.01.02 顏志軍 初版
'***********************************************************************
Public Sub UpdateListViewInMemberShop(ByRef lvListViewCtl As ListView)
'變量定義
Dim shopSet As clsMembershopSet
Dim memShop As clsMembershop
Dim curListItem As ListItem
Dim iLoop As Integer
'取得連鎖店集合
Set shopSet = New clsMembershopSet
'明細更新
For Each memShop In shopSet
For iLoop = 1 To lvListViewCtl.ListItems.Count
If memShop.shopId = lvListViewCtl.ListItems.Item(iLoop).Text Then
GoTo CHECKAGAIN
End If
Next
Set curListItem = lvListViewCtl.ListItems.Add(, , memShop.shopId)
curListItem.SubItems(1) = memShop.shopName
curListItem.SubItems(2) = memShop.address
curListItem.SubItems(3) = memShop.leader
curListItem.SubItems(4) = memShop.phone
curListItem.SubItems(5) = memShop.remark
CHECKAGAIN:
Next
End Sub
'***********************************************************************
'* 過程名:RemoveShop
'* 功 能:刪除連鎖店
'* 參 數:ListView 列表控件
'* 版 本:2006.01.01 顏志軍 初版
'***********************************************************************
Public Sub RemoveShop(ByRef lvListViewCtl As ListView)
'變量定義
Dim currentSelShopId As String '當前選擇店ID
Dim currentSelShop As clsMembershop '當前選擇店
Dim opShop As clsOpShopInfo '連鎖店操作對象
If Not lvListViewCtl.SelectedItem Is Nothing Then
currentSelShopId = lvListViewCtl.SelectedItem.Text
If MsgBox("刪除ID為[" & currentSelShopId & "]的連鎖店嗎?", vbQuestion Or _
vbYesNo, "詢問") = vbYes Then
Set currentSelShop = New clsMembershop
If currentSelShop.LoadByShopId(CInt(currentSelShopId)) = DbOpRecExist Then
Set opShop = New clsOpShopInfo
If opShop.RemoveShop(currentSelShop, g_currentUser) Then
lvListViewCtl.ListItems.Remove lvListViewCtl.SelectedItem.index
Exit Sub
End If
End If
MsgBox "刪除連鎖店失敗!", vbExclamation Or vbOKOnly, "警告"
End If
Else
MsgBox "請先選擇要刪除的連鎖店!", vbExclamation Or vbOKOnly, "警告"
End If
End Sub
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -