📄 warehouselistform.frm
字号:
Attribute VB_Name = "WarehouseListForm"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
'**************************************
'* 模 块 名 称 :仓库列表管理用户操作界面
'* 功 能 描 述 :仓库列表管理用户操作界面
'* 程序员姓名 : 陈齐国
'* 最后修改人 : 陈齐国
'* 最后修改时间:2005/08/22
'**************************************
Option Explicit
Private m_warehouseDAO As WarehouseDAO ' 仓库数据库操作类
Private m_recordset As ADODB.Recordset ' 数据操作数据集对象
Private q As Integer '判断是否查询
Private m_idList As String ' 在执行查询时查询到的ID列表字符串
'**************************************
'* 功 能 描 述 :窗体加载函数
'* 输 入 参 数 :无
'* 输 出 能 数 :无
'**************************************
Private Sub Form_Load()
Set m_warehouseDAO = New WarehouseDAO
Set m_recordset = New ADODB.Recordset
Me.caption = MainForm.g_application.m_applicationName + "仓库列表管理"
RefreshListTitle
refreshlist
Me.Height = 4890
Me.Width = 7455
SetToCenter Me
End Sub
Private Sub Form_Resize()
hfg_houseList.Height = Me.Height - 1420
hfg_houseList.Width = Me.Width - 300
' Image1.Stretch = False
If (hfg_houseList.Height > hfg_houseList.Height - 300) Or (hfg_houseList.Width > hfg_houseList.Width - 200) Then
hfg_houseList.Height = hfg_houseList.Height + 400
hfg_houseList.Width = hfg_houseList.Width + 200
End If
End Sub
Private Sub hfg_houseList_DblClick()
' 修改
WarehouseSingleForm.m_operatorType = 1
If Trim(hfg_houseList.TextMatrix(hfg_houseList.row, 6)) <> "" Then
WarehouseSingleForm.m_warehouseId = Trim(hfg_houseList.TextMatrix(hfg_houseList.row, 6))
WarehouseSingleForm.show 1
If q = 1 Then
RefreshQueryList
Else
refreshlist
End If
End If
End Sub
'**************************************
'* 功 能 描 述 :工具栏按钮的单击操作按钮
'* 输 入 参 数 :无
'* 输 出 能 数 :无
'**************************************
Private Sub SzToolbar_ButtonClick(ByVal Button As MSComctlLib.Button)
Select Case Button.Key
Case "xz" ' 新增
WarehouseSingleForm.m_operatorType = 0
WarehouseSingleForm.show 1
refreshlist
Case "xg" ' 修改
WarehouseSingleForm.m_operatorType = 1
If Trim(hfg_houseList.TextMatrix(hfg_houseList.row, 6)) <> "" Then
WarehouseSingleForm.m_warehouseId = Trim(hfg_houseList.TextMatrix(hfg_houseList.row, 6))
WarehouseSingleForm.show 1
If q = 1 Then
RefreshQueryList
Else
refreshlist
End If
End If
Case "sc" ' 删除
Call delete
Call refreshlist
Case "kw" '库位
If Trim(hfg_houseList.TextMatrix(hfg_houseList.row, 6)) <> "" Then
positionlistform.whid = Trim(hfg_houseList.TextMatrix(hfg_houseList.row, 6))
positionlistform.show
End If
Case "cx"
q = 1
Call Query
Case "sx" '刷 新
q = 0
Call refreshlist
Case "tc" '退 出
Unload Me
End Select
End Sub
'**************************************
'* 功 能 描 述 :刷新仓库列表
'* 输 入 参 数 :无
'* 输 出 能 数 :无
'**************************************
Private Sub refreshlist()
Dim currentrow As Integer ' 当前插入的行
m_warehouseDAO.FindAll m_recordset
' Set hfg_houseList.DataSource = m_recordset ' 数据源绑定到显示控件
hfg_houseList.clear
hfg_houseList.Rows = 2
RefreshListTitle
With m_recordset
' hfg_houseList.Rows = m_recordset.RecordCount
currentrow = 1
Do While Not .EOF
If currentrow > hfg_houseList.Rows - 1 Then
hfg_houseList.AddItem ""
End If
'[>>自定义填充内容
hfg_houseList.TextMatrix(currentrow, 0) = Trim(.Fields("仓库名称"))
hfg_houseList.TextMatrix(currentrow, 1) = Trim(.Fields("仓库地址"))
hfg_houseList.TextMatrix(currentrow, 2) = Trim(.Fields("仓库负责人"))
hfg_houseList.TextMatrix(currentrow, 3) = Trim(.Fields("电话"))
hfg_houseList.TextMatrix(currentrow, 4) = Trim(.Fields("仓库编码"))
hfg_houseList.TextMatrix(currentrow, 5) = Trim(.Fields("备注"))
hfg_houseList.TextMatrix(currentrow, 6) = Trim(.Fields("warehouseid"))
'<<]
'设置数据行高度(Fixed)
hfg_houseList.RowHeight(currentrow) = 200
'动态集指针加1,同时将计数器加1(Fixed)
.MoveNext
currentrow = currentrow + 1
Loop
End With
Text1.text = Trim(m_recordset.RecordCount)
m_recordset.Close
End Sub
'**************************************
'* 功 能 描 述 :删除一条记录
'* 输 入 参 数 :无
'* 输 出 能 数 :无
'**************************************
Private Sub delete()
If Trim(hfg_houseList.TextMatrix(hfg_houseList.row, 6)) = "" Then
MainForm.g_msgText = "请选择一条记录!"
HMsgBox MainForm.g_msgText, 0, 1
End If
Dim ret As String
MainForm.g_msgText = "确定删除这条记录吗?"
ret = HMsgBox(MainForm.g_msgText, 2, 2)
If ret = 1 Then
m_warehouseDAO.DeleteById m_recordset, _
Trim(hfg_houseList.TextMatrix(hfg_houseList.row, 6))
End If
End Sub
'**************************************
'* 功 能 描 述 :刷新列表的标题栏
'* 输 入 参 数 :无
'* 输 出 能 数 :无
'**************************************
Private Sub RefreshListTitle()
hfg_houseList.TextMatrix(0, 0) = "仓库名称"
hfg_houseList.TextMatrix(0, 1) = "仓库地址"
hfg_houseList.TextMatrix(0, 2) = "仓库负责人"
hfg_houseList.TextMatrix(0, 3) = "电话"
hfg_houseList.TextMatrix(0, 4) = "仓库编码"
hfg_houseList.TextMatrix(0, 5) = "备注"
hfg_houseList.TextMatrix(0, 6) = "仓库ID"
'设置列对齐方式 7-右对齐 5-居中对齐 2-左对齐
hfg_houseList.ColAlignment(0) = 2
hfg_houseList.ColAlignment(1) = 2
hfg_houseList.ColAlignment(2) = 2
hfg_houseList.ColAlignment(3) = 2
hfg_houseList.ColAlignment(4) = 2
hfg_houseList.ColAlignment(5) = 2
hfg_houseList.ColAlignment(6) = 2
hfg_houseList.ColWidth(6) = 1
End Sub
'**************************************
'* 功 能 描 述 :查询记录
'* 输 入 参 数 :无
'* 输 出 能 数 :无
'**************************************
Private Sub Query()
QueryFom.m_currentQuery = QUERY_WAREHOUSE
QueryFom.m_operateType = 1
QueryFom.show vbModal
m_idList = MainForm.g_application.m_queryResultId
RefreshQueryList ' 显示查询到的结果
End Sub
Private Sub RefreshQueryList()
Dim ret As Boolean
' 显示查询到的结果
On Error GoTo EXITFUN
MainForm.g_application.m_databaseCon.m_adoConnection.BeginTrans ' 开始事务
InsertQueryIdList m_idList ' 把要显示的记录ID列表插入临时表
ret = m_warehouseDAO.warehouse_findByIdList(m_recordset) ' 查找记录
MainForm.g_application.m_databaseCon.m_adoConnection.CommitTrans ' 提交事务
hfg_houseList.clear
hfg_houseList.Rows = 2
RefreshListTitle
If ret Then
GetRecordToList m_recordset
End If
Text1.text = Trim(m_recordset.RecordCount)
m_recordset.Close
Exit Sub
EXITFUN:
MainForm.g_application.m_databaseCon.m_adoConnection.RollbackTrans ' 回滚事务
End Sub
'**************************************
'* 功 能 描 述 :从数据集中取出记录在列表中显示
'* 输 入 参 数 :无
'* 输 出 能 数 :无
'**************************************
Private Sub GetRecordToList(recSet As ADODB.Recordset)
Dim currentrow As Integer
With m_recordset
' hfg_houseList.Rows = m_recordset.RecordCount
currentrow = 1
Do While Not .EOF
If currentrow > hfg_houseList.Rows - 1 Then
hfg_houseList.AddItem ""
End If
'[>>自定义填充内容
hfg_houseList.TextMatrix(currentrow, 6) = Trim(.Fields("warehouseid"))
hfg_houseList.TextMatrix(currentrow, 0) = Trim(.Fields("仓库名称"))
hfg_houseList.TextMatrix(currentrow, 1) = Trim(.Fields("仓库地址"))
hfg_houseList.TextMatrix(currentrow, 2) = Trim(.Fields("仓库负责人"))
hfg_houseList.TextMatrix(currentrow, 3) = Trim(.Fields("电话"))
hfg_houseList.TextMatrix(currentrow, 4) = Trim(.Fields("仓库编码"))
hfg_houseList.TextMatrix(currentrow, 5) = Trim(.Fields("备注"))
'<<]
'设置数据行高度(Fixed)
hfg_houseList.RowHeight(currentrow) = 300
'动态集指针加1,同时将计数器加1(Fixed)
.MoveNext
currentrow = currentrow + 1
Loop
End With
Text1.text = Trim(m_recordset.RecordCount)
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -