📄 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 + -