📄 stocklist.frm
字号:
VERSION 5.00
Object = "{5E9E78A0-531B-11CF-91F6-C2863C385E30}#1.0#0"; "MSFLXGRD.OCX"
Begin VB.Form frmStockList
BorderStyle = 3 'Fixed Dialog
Caption = "库存信息列表"
ClientHeight = 4410
ClientLeft = 30
ClientTop = 330
ClientWidth = 7875
LinkTopic = "Form1"
MaxButton = 0 'False
MDIChild = -1 'True
MinButton = 0 'False
ScaleHeight = 4410
ScaleWidth = 7875
ShowInTaskbar = 0 'False
Begin VB.Frame fraManage
Caption = "控制"
Height = 855
Left = 120
TabIndex = 1
Top = 3480
Width = 7575
Begin VB.CommandButton cmdDelete
Caption = "删除(&D).."
Height = 375
Left = 2040
TabIndex = 5
Top = 240
Width = 1215
End
Begin VB.CommandButton cmdAdd
Caption = "添加(&A).."
Height = 375
Left = 240
TabIndex = 4
Top = 240
Width = 1215
End
Begin VB.CommandButton cmdFind
Caption = "查找(&F).."
Height = 375
Left = 3840
TabIndex = 3
Top = 240
Width = 1215
End
Begin VB.CommandButton cmdShowAll
Caption = "显示所有记录(&A)"
Height = 375
Left = 5640
TabIndex = 2
Top = 240
Width = 1695
End
End
Begin MSFlexGridLib.MSFlexGrid grdList
Height = 3135
Left = 120
TabIndex = 0
Top = 120
Width = 7575
_ExtentX = 13361
_ExtentY = 5530
_Version = 393216
Cols = 4
FixedCols = 3
AllowUserResizing= 1
End
End
Attribute VB_Name = "frmStockList"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Dim mRs As ADODB.Recordset
Private Sub cmdAdd_Click()
frmStock.mbAddMode = True
frmStock.Show vbModal
End Sub
Private Sub cmdDelete_Click()
On Error GoTo errHandler
'Dim l As Long
' l = grdList.TextMatrix(grdList.Row, 1)
' gConn.Execute "delete from stock where 顺序号= " & l
'刷新整个FlexGrid
'Unload Me
' Load Me
'Me.SQL = "select * from stock"
' Me.Show
frmSt_Del.Show
Exit Sub
errHandler:
MsgBox Err.Description, vbCritical, "错误"
End Sub
Private Sub cmdEdit_Click()
frmStock.mnSerial = CLng(grdList.TextMatrix(grdList.Row, 1))
frmStock.mbAddMode = False
frmStock.Show vbModal
End Sub
Private Sub cmdFind_Click()
frmFind.SQL = mRs.Source
frmFind.Show vbModal
Unload Me
Load Me
If Trim(frmFind.msResultSQL) <> "" Then
Me.SQL = "select * from stock where " & frmFind.msResultSQL
End If
Me.Show
Unload frmFind
End Sub
Private Sub cmdShowAll_Click()
Unload Me
Load Me
Me.SQL = "select * from stock"
Me.Show
End Sub
Private Sub Form_Load()
Dim i As Integer
With grdList
.Cols = 8
.TextMatrix(0, 1) = ""
.TextMatrix(0, 2) = "商品名称"
.TextMatrix(0, 3) = "供应商名称"
.TextMatrix(0, 4) = "商品单价"
.TextMatrix(0, 5) = "进货数量"
.TextMatrix(0, 6) = "进货日期"
.TextMatrix(0, 7) = "备注"
'固定表头
.FixedRows = 1
'设置各列的对齐方式
For i = 0 To .Cols - 1
.ColAlignment(i) = 0
Next i
'表头项居中
.FillStyle = flexFillRepeat
.Col = 0
.Row = 0
.RowSel = 1
.ColSel = .Cols - 1
.CellAlignment = 4
'设置单元大小
.ColWidth(0) = 100
.ColWidth(1) = 0
.ColWidth(2) = 1000
.ColWidth(3) = 1000
.ColWidth(4) = 1000
.ColWidth(5) = 1000
.ColWidth(6) = 1000
.ColWidth(7) = 1000
.Row = 1
End With
Set mRs = New ADODB.Recordset
End Sub
Private Sub Form_Resize()
'让fraManage框架居中
fraManage.Left = (Me.ScaleWidth - fraManage.Width) / 2
fraManage.Top = Me.ScaleHeight - 200 - fraManage.Height
grdList.Top = 200
grdList.Width = Me.ScaleWidth - 200
grdList.Left = Me.ScaleLeft + 100
grdList.Height = Me.ScaleHeight - fraManage.Height - grdList.Top - 200
End Sub
Private Sub Form_Unload(Cancel As Integer)
If mRs.State <> adStateClosed Then mRs.Close
End Sub
Public Property Let SQL(ByVal vNewValue As Variant)
On Error GoTo errHandler
Dim j As Integer
Dim i As Integer
If mRs.State <> adStateClosed Then mRs.Close
mRs.Open CStr(vNewValue), gConn, adOpenStatic
With grdList
.Rows = 1
Do While Not mRs.EOF
.Rows = .Rows + 1
For i = 1 To mRs.Fields.Count
Select Case mRs.Fields(i - 1).Type
Case adDBDate
.TextMatrix(.Rows - 1, i) = Format(mRs.Fields(i - 1) & "", "yyyy-mm-dd")
Case Else
.TextMatrix(.Rows - 1, i) = mRs.Fields(i - 1) & ""
End Select
Next i
mRs.MoveNext
Loop
End With
Exit Property
errHandler:
MsgBox Err.Description, vbCritical, "错误"
End Property
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -