📄 frmsearch.frm
字号:
VERSION 5.00
Begin VB.Form FrmSearch
BorderStyle = 1 'Fixed Single
Caption = "Search"
ClientHeight = 2715
ClientLeft = 45
ClientTop = 330
ClientWidth = 5670
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 2715
ScaleWidth = 5670
StartUpPosition = 3 'Windows Default
Begin VB.TextBox Txtsql
Appearance = 0 'Flat
BackColor = &H8000000F&
BorderStyle = 0 'None
Height = 285
Left = 240
Locked = -1 'True
TabIndex = 15
Top = 2280
Width = 5175
End
Begin VB.CommandButton CmdCancel
Caption = "取消"
Height = 495
Left = 4320
TabIndex = 14
Top = 1590
Width = 1095
End
Begin VB.OptionButton Opt
Appearance = 0 'Flat
Caption = "无"
ForeColor = &H80000008&
Height = 255
Index = 0
Left = 240
TabIndex = 13
Top = 1320
Value = -1 'True
Width = 1095
End
Begin VB.OptionButton Opt
Appearance = 0 'Flat
Caption = "或"
ForeColor = &H80000008&
Height = 255
Index = 2
Left = 2760
TabIndex = 12
Top = 1320
Width = 1335
End
Begin VB.OptionButton Opt
Appearance = 0 'Flat
Caption = "和"
ForeColor = &H80000008&
Height = 255
Index = 1
Left = 1500
TabIndex = 11
Top = 1320
Width = 1095
End
Begin VB.TextBox Txt2
Appearance = 0 'Flat
Enabled = 0 'False
Height = 285
Left = 2640
TabIndex = 10
Top = 1800
Width = 1455
End
Begin VB.ComboBox Cmb4
Appearance = 0 'Flat
Enabled = 0 'False
Height = 315
Left = 1800
Style = 2 'Dropdown List
TabIndex = 9
Top = 1800
Width = 615
End
Begin VB.ComboBox Cmb3
Appearance = 0 'Flat
Enabled = 0 'False
Height = 315
ItemData = "FrmSearch.frx":0000
Left = 240
List = "FrmSearch.frx":0002
Style = 2 'Dropdown List
TabIndex = 8
Top = 1800
Width = 1335
End
Begin VB.TextBox Txt1
Appearance = 0 'Flat
Height = 285
Left = 2640
TabIndex = 7
Top = 840
Width = 1455
End
Begin VB.ComboBox Cmb2
Appearance = 0 'Flat
Height = 315
Left = 1800
Style = 2 'Dropdown List
TabIndex = 6
Top = 840
Width = 615
End
Begin VB.ComboBox Cmb1
Appearance = 0 'Flat
Height = 315
ItemData = "FrmSearch.frx":0004
Left = 240
List = "FrmSearch.frx":0006
Style = 2 'Dropdown List
TabIndex = 5
Top = 840
Width = 1335
End
Begin VB.Frame Frame1
Height = 615
Left = 240
TabIndex = 1
Top = 120
Width = 4215
Begin VB.OptionButton Optsex
Appearance = 0 'Flat
BackColor = &H80000000&
Caption = "女"
ForeColor = &H80000008&
Height = 255
Index = 2
Left = 2640
TabIndex = 4
Top = 240
Width = 1095
End
Begin VB.OptionButton Optsex
Appearance = 0 'Flat
Caption = "男"
ForeColor = &H80000008&
Height = 255
Index = 1
Left = 1380
TabIndex = 3
Top = 240
Width = 975
End
Begin VB.OptionButton Optsex
Appearance = 0 'Flat
Caption = "所有"
ForeColor = &H80000008&
Height = 255
Index = 0
Left = 120
TabIndex = 2
Top = 240
Value = -1 'True
Width = 975
End
End
Begin VB.CommandButton CmdOK
Caption = "查询"
Height = 495
Left = 4320
TabIndex = 0
Top = 840
Width = 1095
End
End
Attribute VB_Name = "FrmSearch"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Private Sub Cmb1_Click()
With Cmb1
If .Text = "职工编号" Or .Text = "交通补助" Or .Text = "加班补助" Or .Text = "工资编号" Or .Text = "假条编号" Or .Text = "身份证号" Or .Text = "出生日期" Or .Text = "中止日期" Or .Text = "Edit" Or .Text = "年份" Or .Text = "月份" Or .Text = "天数" Or .Text = "基本工资" Or .Text = "总工资" Or .Text = "考勤扣除" Or .Text = "扣税" Or .Text = "总扣除" Or .Text = "保险扣除" Then
Cmb2.Clear
Cmb2.AddItem ">"
Cmb2.AddItem "="
Cmb2.AddItem "<"
Cmb2.ListIndex = 0
Else
Cmb2.Clear
Cmb2.AddItem "等于"
Cmb2.AddItem "相似"
Cmb2.ListIndex = 0
End If
End With
End Sub
Private Sub Cmb3_Click()
With Cmb3
If .Text = "职工编号" Or .Text = "工资编号" Or .Text = "假条编号" Or .Text = "身份证号" Or .Text = "出生日期" Or .Text = "中止日期" Or .Text = "Edit" Or .Text = "年份" Or .Text = "月份" Or .Text = "天数" Or .Text = "基本工资" Or .Text = "总工资" Or .Text = "考勤扣除" Or .Text = "扣税" Or .Text = "总扣除" Or .Text = "保险扣除" Then
Cmb4.Clear
Cmb4.AddItem ">"
Cmb4.AddItem "="
Cmb4.AddItem "<"
Cmb4.ListIndex = 0
Else
Cmb4.Clear
Cmb4.AddItem "等于"
Cmb4.AddItem "相似"
Cmb4.ListIndex = 0
End If
End With
End Sub
Private Sub CmdCancel_Click()
Me.Hide
FrmMain.Enabled = True
End Sub
Private Sub cmdOK_Click()
Dim mysqls, str As String
Err.Clear
If Txt1.Text = "" Then Exit Sub:
mysqls = "select * from " + FrmMain.cutable + " where "
If Cmb2.Text = "等于" Then
mysqls = mysqls + Cmb1.Text + "=""" + Txt1.Text + """"
ElseIf Cmb2.Text = "相似" Then
mysqls = mysqls + Cmb1.Text + " Like """ + Txt1.Text + """"
Else
mysqls = mysqls + Cmb1.Text + Cmb2.Text + Txt1.Text
End If
If Frame1.Enabled = True Then
str = ""
If Optsex(1).Value Then
str = " and 性别=" + """男"""
ElseIf Optsex(2) Then
str = " and 性别=" + """女"""
End If
End If
mysqls = mysqls + str
If Not Opt(0) Then
If Opt(1).Value Then
str = " and "
ElseIf Opt(2).Value Then
str = " or "
End If
mysqls = mysqls + str + Cmb3.Text
If Cmb2.Text = "等于" Then
mysqls = mysqls + "=""" + Txt2.Text + """"
ElseIf Cmb2.Text = "相似" Then
mysqls = mysqls + " Like """ + Txt2.Text + """"
Else
mysqls = mysqls + Cmb4.Text + Txt2.Text
End If
End If
FrmMain.DataA.RecordSource = mysqls
On Error GoTo exp:
Txtsql.Text = mysqls
FrmMain.DataA.Refresh
Exit Sub
exp:
Txtsql.Text = "搜索语句错误:" + mysqls
End Sub
Private Sub Form_Activate()
Dim i As Integer
Cmb1.Clear
Cmb3.Clear
Txt1.Text = ""
Txt2.Text = ""
For i = 0 To FrmMain.DBGA.Columns.Count - 4
If FrmMain.DBGA.Columns(i).Visible = True Then
Cmb1.AddItem (FrmMain.DBGA.Columns(i).Caption)
Cmb3.AddItem (FrmMain.DBGA.Columns(i).Caption)
End If
Next i
Cmb1.ListIndex = 0
Cmb3.ListIndex = 0
If FrmMain.cutable = "employee" Then
Frame1.Enabled = True
Else
Frame1.Enabled = False
End If
End Sub
Private Sub Form_Load()
Cmb2.AddItem "="
Cmb4.AddItem "="
Cmb2.AddItem ">"
Cmb4.AddItem ">"
Cmb2.AddItem "<"
Cmb4.AddItem "<"
Cmb2.ListIndex = 0
Cmb4.ListIndex = 0
End Sub
Private Sub Opt_Click(Index As Integer)
Cmb3.Enabled = Not Opt(0).Value
Cmb4.Enabled = Not Opt(0).Value
Txt2.Enabled = Not Opt(0).Value
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -