📄 kucun.frm
字号:
VERSION 5.00
Object = "{5E9E78A0-531B-11CF-91F6-C2863C385E30}#1.0#0"; "MSFLXGRD.OCX"
Begin VB.Form Form8
BorderStyle = 3 'Fixed Dialog
Caption = "库存查询"
ClientHeight = 5160
ClientLeft = 45
ClientTop = 330
ClientWidth = 7965
LinkTopic = "Form8"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 5160
ScaleWidth = 7965
ShowInTaskbar = 0 'False
StartUpPosition = 3 '窗口缺省
Begin VB.PictureBox Picture1
Height = 255
Left = 120
ScaleHeight = 195
ScaleWidth = 5475
TabIndex = 15
Top = 4800
Visible = 0 'False
Width = 5535
End
Begin VB.Frame Frame4
Height = 1335
Left = 5760
TabIndex = 13
Top = 3720
Width = 2055
Begin VB.CommandButton Command3
Caption = "打印库存列表"
Height = 375
Left = 240
TabIndex = 16
Top = 720
Width = 1575
End
Begin VB.CommandButton Command5
Caption = "导出库存列表"
Height = 375
Left = 240
TabIndex = 14
Top = 240
Width = 1575
End
End
Begin VB.Data Data2
Caption = "Data2"
Connect = "Access 2000;"
DatabaseName = ""
DefaultCursorType= 0 '缺省游标
DefaultType = 2 '使用 ODBC
Exclusive = 0 'False
Height = 375
Left = 6480
Options = 0
ReadOnly = 0 'False
RecordsetType = 1 'Dynaset
RecordSource = ""
Top = 2040
Visible = 0 'False
Width = 1215
End
Begin VB.Data Data1
Caption = "Data1"
Connect = "Access 2000;"
DatabaseName = ""
DefaultCursorType= 0 '缺省游标
DefaultType = 2 '使用 ODBC
Exclusive = 0 'False
Height = 375
Left = 6480
Options = 0
ReadOnly = 0 'False
RecordsetType = 1 'Dynaset
RecordSource = ""
Top = 1680
Visible = 0 'False
Width = 1215
End
Begin VB.Frame Frame2
Caption = "显示区"
ForeColor = &H000000FF&
Height = 975
Left = 120
TabIndex = 2
Top = 3720
Width = 5535
Begin VB.Label Label6
Caption = "Label6"
Height = 255
Left = 4680
TabIndex = 12
Top = 480
Width = 735
End
Begin VB.Label Label5
Alignment = 1 'Right Justify
Caption = "Label5"
Height = 255
Left = 3960
TabIndex = 11
Top = 480
Width = 615
End
Begin VB.Label Label4
Caption = "库存为:"
ForeColor = &H000000FF&
Height = 255
Left = 3240
TabIndex = 10
Top = 480
Width = 735
End
Begin VB.Label Label3
Caption = "Label3"
ForeColor = &H00C00000&
Height = 255
Left = 240
TabIndex = 9
Top = 480
Width = 3135
End
End
Begin VB.Frame Frame1
Caption = "操作区"
ForeColor = &H00FF0000&
Height = 975
Left = 120
TabIndex = 1
Top = 2640
Width = 7695
Begin VB.ComboBox Combo1
Height = 300
Left = 840
TabIndex = 8
Text = "Combo1"
Top = 397
Width = 1335
End
Begin VB.ComboBox Combo2
Height = 300
Left = 2880
TabIndex = 7
Text = "Combo2"
Top = 397
Width = 2295
End
Begin VB.CommandButton Command2
Caption = "退出"
Height = 375
Left = 6480
TabIndex = 6
Top = 360
Width = 975
End
Begin VB.CommandButton Command1
Caption = "查询"
Height = 375
Left = 5280
TabIndex = 5
Top = 360
Width = 975
End
Begin VB.Label Label2
Caption = "产品:"
Height = 255
Left = 2280
TabIndex = 4
Top = 420
Width = 735
End
Begin VB.Label Label1
Caption = "品牌:"
Height = 255
Left = 240
TabIndex = 3
Top = 420
Width = 735
End
End
Begin MSFlexGridLib.MSFlexGrid MSFlexGrid1
Bindings = "Kucun.frx":0000
Height = 2535
Left = 120
TabIndex = 0
Top = 0
Width = 7695
_ExtentX = 13573
_ExtentY = 4471
_Version = 393216
FixedCols = 0
BackColor = 16777215
ForeColor = 0
BackColorBkg = 12632256
GridColor = 8421504
TextStyleFixed = 1
AllowUserResizing= 1
End
End
Attribute VB_Name = "Form8"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub Combo1_Click()
Combo2.Clear
If Data2.Recordset.RecordCount > 0 Then
Data2.Recordset.MoveFirst
End If
While Data2.Recordset.EOF = False
If Data2.Recordset.Fields("品牌") = Combo1.Text Then
Combo2.AddItem Data2.Recordset.Fields("产品")
End If
Data2.Recordset.MoveNext
Wend
Combo2.Text = Combo2.List(0)
Combo2.Enabled = True
End Sub
Private Sub Combo1_KeyPress(KeyAscii As Integer)
KeyAscii = 0
End Sub
Private Sub Combo2_Click()
Command1.Enabled = True
End Sub
Private Sub Combo2_KeyPress(KeyAscii As Integer)
KeyAscii = 0
End Sub
Private Sub Command1_Click()
Data2.Recordset.FindFirst "品牌+产品=" + "'" + Combo1.Text + Combo2.Text + "'"
Dim shuzi As Single
shuzi = Data2.Recordset.Fields("数量")
If Data2.Recordset.NoMatch = True Then
Else
Frame2.Enabled = True
Label3.Caption = "" + Data2.Recordset.Fields("品牌") + "牌" + Data2.Recordset.Fields("产品") + ""
Label5.Caption = shuzi
Label6.Caption = "" + Data2.Recordset.Fields("单位") + ""
Command1.Enabled = flash
Label3.Visible = True
Label4.Visible = True
Label5.Visible = True
Label6.Visible = True
End If
End Sub
Private Sub Command2_Click()
Unload Me
End Sub
Private Sub Command3_Click()
MSFlexGrid1.Row = 1
MSFlexGrid1.Col = 1
'Set Picture1.Picture = MSFlexGrid1.Picture
On Error GoTo trip
Printer.PaintPicture MSFlexGrid1.Picture, 0, 0
Printer.EndDoc
trip: MsgBox "系统缺陷,无法打印!", 0 + 16
Exit Sub
End Sub
Private Sub Command5_Click()
Call Toexcel
End Sub
Private Sub Data1_Reposition()
If Data1.Recordset.RecordCount > 0 Then
MSFlexGrid1.Enabled = True
Else
MSFlexGrid1.Enabled = False
End If
End Sub
Private Sub Form_Activate()
Data1.DatabaseName = App.Path + "\odb.dll"
Data1.RecordSource = "paizi"
Data1.Refresh
Data2.DatabaseName = App.Path + "\odb.dll"
Data2.RecordSource = "kucun"
Data2.Refresh
If Data1.Recordset.RecordCount > 0 Then
Data1.Recordset.MoveFirst
End If
While Data1.Recordset.EOF = False
Combo1.AddItem Data1.Recordset.Fields("品牌")
Data1.Recordset.MoveNext
Wend
Combo1.Text = Combo1.List(0)
If Data2.Recordset.RecordCount > 0 Then
Data2.Recordset.MoveFirst
End If
While Data2.Recordset.EOF = False
If Data2.Recordset.Fields("品牌") = Combo1.Text Then
Combo2.AddItem Data2.Recordset.Fields("产品")
End If
Data2.Recordset.MoveNext
Wend
Combo2.Text = Combo2.List(0)
Combo2.Enabled = False
Frame2.Enabled = False
Label3.Visible = False
Label4.Visible = False
Label5.Visible = False
Label6.Visible = False
Command1.Enabled = False
MSFlexGrid1.ColWidth(0) = 1200
MSFlexGrid1.ColWidth(1) = 1200
MSFlexGrid1.ColWidth(2) = 3000
MSFlexGrid1.ColWidth(3) = 1000
MSFlexGrid1.ColWidth(4) = 1000
End Sub
Private Sub MSFlexGrid1_Click()
rec = MSFlexGrid1.Row - 1
End Sub
Private Sub Toexcel()
On Error GoTo trip
Dim xlsApp As Excel.Application
Dim xlsBook As Excel.Workbook
Dim xlsSheet As Excel.Worksheet
Set xlsApp = New Excel.Application
Set xlsBook = xlsApp.Workbooks.Add
Set xlsSheet = xlsBook.Worksheets(1)
Dim i As Integer
Dim n As Integer
For i = 0 To Me.MSFlexGrid1.Rows - 1
For n = 0 To Me.MSFlexGrid1.Cols - 1
xlsSheet.Cells(i + 3, n + 1) = Me.MSFlexGrid1.TextMatrix(i, n)
Next
Next
xlsApp.Visible = True
trip: MsgBox "系统缺陷,无法导出!", 0 + 16
Exit Sub
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -