📄 frm_zhigong_query.frm
字号:
VERSION 5.00
Begin VB.Form Frm_zhigong_query
BorderStyle = 1 'Fixed Single
Caption = "职工信息查询"
ClientHeight = 1755
ClientLeft = 4290
ClientTop = 3330
ClientWidth = 3735
Icon = "frm_zhigong_query.frx":0000
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 1755
ScaleWidth = 3735
StartUpPosition = 1 '所有者中心
Begin VB.CommandButton Command2
Cancel = -1 'True
Caption = "取消"
Height = 375
Left = 1980
TabIndex = 6
Top = 1260
Width = 975
End
Begin VB.CommandButton Command1
Caption = "确定"
Height = 375
Left = 600
TabIndex = 5
Top = 1260
Width = 975
End
Begin VB.ComboBox Combo2
Height = 300
Left = 1260
TabIndex = 4
Top = 780
Visible = 0 'False
Width = 2115
End
Begin VB.TextBox Text1
Height = 300
Left = 1260
TabIndex = 3
Top = 780
Width = 2115
End
Begin VB.ComboBox Combo1
Height = 300
Left = 1260
Style = 2 'Dropdown List
TabIndex = 1
Top = 300
Width = 2115
End
Begin VB.Label Label2
Caption = "查询内容"
Height = 255
Left = 240
TabIndex = 2
Top = 840
Width = 795
End
Begin VB.Label Label1
Caption = "查询条件"
Height = 255
Left = 240
TabIndex = 0
Top = 360
Width = 855
End
End
Attribute VB_Name = "Frm_zhigong_query"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub Combo1_Click()
Select Case Combo1
Case "姓名"
Text1.Visible = True
Combo2.Visible = False
Combo1.Tag = "xm"
Case "性别"
Text1.Visible = False
Combo2.Visible = True
Combo2.Clear
Combo2.AddItem "男"
Combo2.AddItem "女"
Combo2.ListIndex = 0
Combo1.Tag = "xb"
Case "部门"
Combo1.Tag = "bmmc"
Text1.Visible = False
Combo2.Visible = True
Combo2.Clear
Dim cn As ADODB.Connection
Dim rst As New ADODB.Recordset
Set cn = GetCn
rst.Open "select * from bumen", cn, 0, 1
If rst.BOF And rst.EOF Then
rst.Close
cn.Close
MsgBox "部门尚未添加!请先维护部门!", vbExclamation, "提示"
Exit Sub
End If
Do While Not rst.EOF
Combo2.AddItem rst(1)
Combo2.ItemData(Combo2.NewIndex) = rst(0)
rst.MoveNext
Loop
Combo2.ListIndex = 0
rst.Close
cn.Close
Case "学历"
Combo1.Tag = "xl"
Text1.Visible = False
Combo2.Visible = True
Combo2.Clear
Combo2.AddItem "高中"
Combo2.AddItem "大专"
Combo2.AddItem "大本"
Combo2.AddItem "硕士"
Combo2.AddItem "博士"
Combo2.ListIndex = 0
Case "职称"
Combo1.Tag = "zc"
Text1.Visible = False
Combo2.Visible = True
Combo2.Clear
Combo2.AddItem "一级职称"
Combo2.AddItem "二级职称"
Combo2.AddItem "三级职称"
Combo2.ListIndex = 0
End Select
End Sub
Private Sub Command1_Click()
Dim cn As ADODB.Connection
Dim rst As New ADODB.Recordset
Dim sql As String
Dim lt As ListItem
Set cn = GetCn
If Combo1 = "姓名" Then
sql = "select a.zgh,a.xm,a.xb,a.csrq,b.bmmc,a.xl,a.zc,a.zz,a.bz from zhigong a inner join bumen b on a.bmdm=b.bmdm where a.xm like '%" & Trim(Text1) & "% order by a.zgh'"
Else
sql = "select a.zgh,a.xm,a.xb,a.csrq,b.bmmc,a.xl,a.zc,a.zz,a.bz from zhigong a inner join bumen b on a.bmdm=b.bmdm where " & Combo1.Tag & "='" & Combo2 & "' order by a.zgh"
End If
rst.Open sql, cn, 0, 1
Frm_zhigong.ListView1.ListItems.Clear
If rst.BOF And rst.EOF Then
MsgBox "没有符合条件的记录!", vbExclamation, "提示"
Exit Sub
End If
Do While Not rst.EOF
Set lt = Frm_zhigong.ListView1.ListItems.Add(, , rst(0), 7, 7)
For i = 1 To rst.Fields.Count - 1
lt.SubItems(i) = Trim(rst(i) & "")
Next i
rst.MoveNext
Loop
rst.Close
cn.Close
Unload Me
End Sub
Private Sub Command2_Click()
Unload Me
End Sub
Private Sub Form_Load()
Combo1.AddItem "姓名"
Combo1.AddItem "性别"
Combo1.AddItem "部门"
Combo1.AddItem "学历"
Combo1.AddItem "职称"
Combo1.ListIndex = 0
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -