📄 chahuo.frm
字号:
VERSION 5.00
Object = "{F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.2#0"; "comdlg32.ocx"
Object = "{5E9E78A0-531B-11CF-91F6-C2863C385E30}#1.0#0"; "msflxgrd.ocx"
Begin VB.Form frmchahuo
BorderStyle = 3 'Fixed Dialog
Caption = "货品查询"
ClientHeight = 7380
ClientLeft = 45
ClientTop = 405
ClientWidth = 9885
Icon = "chahuo.frx":0000
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 7380
ScaleWidth = 9885
ShowInTaskbar = 0 'False
StartUpPosition = 2 '屏幕中心
Begin MSComDlg.CommonDialog dlg2
Left = 4560
Top = 3120
_ExtentX = 847
_ExtentY = 847
_Version = 393216
End
Begin VB.CommandButton cmdClose
Caption = "关闭(&C)"
Height = 345
Left = 8640
TabIndex = 9
Top = 6960
Width = 1155
End
Begin VB.CommandButton cmdQing
Caption = "清空(&D)"
Height = 345
Left = 7200
TabIndex = 8
Top = 6960
Width = 1215
End
Begin VB.CommandButton cmdDaoChu
Caption = "导出(&D)"
Height = 345
Left = 5760
TabIndex = 7
Top = 6960
Width = 1215
End
Begin VB.Frame Frame2
Caption = "搜索条件"
Height = 735
Left = 120
TabIndex = 12
Top = 120
Width = 6375
Begin VB.CommandButton cmdQuan
Caption = "全部记录(&A)"
Height = 345
Left = 5040
TabIndex = 3
Top = 285
Width = 1215
End
Begin VB.CommandButton cmdcha
Caption = "查找(&S)"
Height = 345
Left = 3720
TabIndex = 2
Top = 285
Width = 1215
End
Begin VB.TextBox txtCha
Height = 300
Left = 2100
TabIndex = 1
Top = 300
Width = 1515
End
Begin VB.ComboBox cmbCha
Height = 300
Left = 480
Style = 2 'Dropdown List
TabIndex = 0
Top = 300
Width = 1515
End
End
Begin VB.Frame Frame1
Caption = "搜索结果"
Height = 5835
Left = 120
TabIndex = 11
Top = 960
Width = 9675
Begin MSFlexGridLib.MSFlexGrid Grid1
Height = 5415
Left = 120
TabIndex = 6
Top = 240
Width = 9435
_ExtentX = 16642
_ExtentY = 9551
_Version = 393216
Cols = 22
ScrollTrack = -1 'True
FocusRect = 0
SelectionMode = 1
AllowUserResizing= 3
Appearance = 0
End
End
Begin VB.Frame Frame3
Caption = "选择排序"
Height = 735
Left = 6600
TabIndex = 10
Top = 120
Width = 3135
Begin VB.ComboBox cmbPaixu
Height = 300
Left = 120
Style = 2 'Dropdown List
TabIndex = 4
Top = 300
Width = 1515
End
Begin VB.CommandButton cmdPaixu
Caption = "排序(&P)"
Height = 345
Left = 1680
TabIndex = 5
Top = 278
Width = 1215
End
End
Begin MSComDlg.CommonDialog Dialog1
Left = 5220
Top = 3420
_ExtentX = 847
_ExtentY = 847
_Version = 393216
End
End
Attribute VB_Name = "frmchahuo"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Dim strsql As String
Private Sub cmbCha_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
txtcha.SetFocus
Exit Sub
End If
End Sub
Private Sub cmdclose_Click()
Unload Me
End Sub
Private Sub cmdqing_Click()
Dim rs As New ADODB.Recordset
strsql = "select " & sqlZiduan & " from Huopin where hNo=''"
rs.open strsql, cn
fuzhi Grid1, rs
End Sub
Private Sub Form_Load()
Dim rs As New ADODB.Recordset
Dim i As Integer
For i = 0 To UBound(ChahuoStr)
cmbCha.AddItem ChahuoStr(i, 0)
cmbPaixu.AddItem ChahuoStr(i, 0)
Next i
cmbCha.ListIndex = 0
cmbPaixu.ListIndex = 0
strsql = "select " & sqlZiduan & " from Huopin where hNo=''"
rs.open strsql, cn
fuzhi Grid1, rs
End Sub
Private Sub cmdcha_Click() '查询按钮
Dim rs As New ADODB.Recordset
Select Case cmbCha.ListIndex
Case 0
strsql = "select " & sqlZiduan & " from Huopin where hNo like '%" & Trim(txtcha.Text) & "%' order by hNo"
Case 1
strsql = "select " & sqlZiduan & " from Huopin where hLeibie like '%" & Trim(txtcha.Text) & "%' order by hLeibie"
Case 2
strsql = "select " & sqlZiduan & " from Huopin where hPinpai like '%" & Trim(txtcha.Text) & "%' order by hPinpai"
Case 3
strsql = "select " & sqlZiduan & " from Huopin where hName like '%" & Trim(txtcha.Text) & "%' order by hName"
Case 4
strsql = "select " & sqlZiduan & " from Huopin where hGuige like '%" & Trim(txtcha.Text) & "%' order by hGuige"
Case 5
strsql = "select " & sqlZiduan & " from Huopin where hRukujia like '%" & Trim(txtcha.Text) & "%' order by hRukujia"
' Case 6
' strsql = "select " & sqlZiduan & " from Huopin where hXiaojia like '%" & Trim(txtCha.Text) & "%' order by hXiaojia"
' Case 7
' strsql = "select " & sqlZiduan & " from Huopin where hTime like '%" & Trim(txtCha.Text) & "%' order by hTime"
' Case 8
' strsql = "select " & sqlZiduan & " from Huopin where hBak like '%" & Trim(txtCha.Text) & "%' order by hBak"
End Select
rs.open strsql, cn
fuzhi Grid1, rs
End Sub
Private Sub cmdPaixu_Click()
Dim rs As New ADODB.Recordset
Dim n As Integer
n = InStr(strsql, "order by")
If n = 0 Then 'n=0说明是没有找到order by ,那么就是Form_Load中的strSql,这样没有记录的,只要有记录的一定要有排序
Exit Sub
End If
strsql = Mid(strsql, 1, n + 8) & ChahuoStr(cmbPaixu.ListIndex, 1)
' MsgBox strSql
rs.open strsql, cn
fuzhi Grid1, rs
End Sub
Private Sub cmdQuan_Click()
Dim rs As New ADODB.Recordset
strsql = "select " & sqlZiduan & " from Huopin order by hNo"
rs.open strsql, cn
fuzhi Grid1, rs
End Sub
Private Sub txtcha_KeyPress(KeyAscii As Integer)
If Trim(txtcha.Text) <> "" And KeyAscii = 13 Then
cmdcha_Click
Exit Sub
End If
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -