⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 main_fzfind.frm

📁 本软件可适用于各大、中、小型企业的人力资源管理。
💻 FRM
字号:
VERSION 5.00
Begin VB.Form main_fzfind 
   BorderStyle     =   3  'Fixed Dialog
   Caption         =   "万能查询器"
   ClientHeight    =   4440
   ClientLeft      =   45
   ClientTop       =   330
   ClientWidth     =   6840
   Icon            =   "main_fzfind.frx":0000
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MinButton       =   0   'False
   ScaleHeight     =   4440
   ScaleWidth      =   6840
   ShowInTaskbar   =   0   'False
   StartUpPosition =   2  '屏幕中心
   Begin VB.ListBox List1 
      Height          =   2040
      Left            =   75
      TabIndex        =   15
      Top             =   2325
      Width           =   6690
   End
   Begin VB.CommandButton cmdExit 
      Caption         =   "退出"
      Height          =   360
      Left            =   5265
      TabIndex        =   0
      Top             =   1815
      Width           =   1260
   End
   Begin VB.CommandButton cmdAll 
      Caption         =   "查询所有"
      Height          =   360
      Left            =   4020
      TabIndex        =   14
      Top             =   1815
      Width           =   1260
   End
   Begin VB.CommandButton cmdFind 
      Caption         =   "查询"
      Enabled         =   0   'False
      Height          =   360
      Left            =   2775
      TabIndex        =   1
      Top             =   1815
      Width           =   1260
   End
   Begin VB.CommandButton cmdDel 
      Caption         =   "清除"
      Enabled         =   0   'False
      Height          =   360
      Left            =   1530
      TabIndex        =   13
      Top             =   1815
      Width           =   1260
   End
   Begin VB.CommandButton cmdAdd 
      Caption         =   "增加"
      Height          =   360
      Left            =   285
      TabIndex        =   12
      Top             =   1815
      Width           =   1260
   End
   Begin VB.Frame Frame2 
      Height          =   540
      Left            =   75
      TabIndex        =   8
      Top             =   1185
      Width           =   6645
      Begin VB.OptionButton Opt2 
         Caption         =   "或者"
         Height          =   225
         Left            =   4485
         TabIndex        =   11
         Tag             =   "or"
         Top             =   210
         Width           =   1275
      End
      Begin VB.OptionButton Opt1 
         Caption         =   "并且"
         Height          =   225
         Left            =   2130
         TabIndex        =   10
         Tag             =   "and"
         Top             =   210
         Width           =   1275
      End
      Begin VB.Label Label1 
         BackStyle       =   0  'Transparent
         Caption         =   "查找逻辑"
         Height          =   210
         Left            =   180
         TabIndex        =   9
         Top             =   225
         Width           =   735
      End
   End
   Begin VB.Frame Frame1 
      Height          =   1155
      Left            =   75
      TabIndex        =   2
      Top             =   30
      Width           =   6645
      Begin VB.ComboBox cboFields 
         BackColor       =   &H80000018&
         Height          =   300
         Left            =   945
         Style           =   2  'Dropdown List
         TabIndex        =   5
         Top             =   255
         Width           =   2295
      End
      Begin VB.TextBox txtdata 
         BackColor       =   &H80000018&
         Height          =   300
         Left            =   945
         TabIndex        =   4
         Top             =   690
         Width           =   5490
      End
      Begin VB.ComboBox cboOperator 
         BackColor       =   &H80000018&
         Height          =   300
         Left            =   4140
         Style           =   2  'Dropdown List
         TabIndex        =   3
         Top             =   225
         Width           =   2295
      End
      Begin VB.Label Label3 
         Caption         =   "字段名称                             运算符"
         ForeColor       =   &H00FF0000&
         Height          =   285
         Left            =   135
         TabIndex        =   7
         Top             =   315
         Width           =   5280
      End
      Begin VB.Label Label4 
         Caption         =   "关 键 字"
         ForeColor       =   &H00FF0000&
         Height          =   255
         Left            =   135
         TabIndex        =   6
         Top             =   720
         Width           =   1155
      End
   End
End
Attribute VB_Name = "main_fzfind"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim fld
Dim rs As New ADODB.Recordset
Private Sub cmdAdd_Click()
  Dim myval As String
  If cboFields.text = "" Then
    MsgBox "系统不允许字段名称为空!", , "提示窗口"
    Exit Sub
  End If
  If cboOperator.text = "" Then
    MsgBox "系统不允许运算符为空!", , "提示窗口"
    Exit Sub
  End If
  If txtdata.text = "" Then
    MsgBox "系统不允许关键字为空!", , "提示窗口"
    Exit Sub
  End If
  rs.Open tb1, Cnn, adOpenKeyset, adLockOptimistic
  Select Case rs.Fields(cboFields.ListIndex).Type
    Case 129, 200, 201       '字符型
      If cboOperator.text = "like" Then
         myval = "like + '%'+'" + txtdata + "'+'%'"
      Else
         myval = cboOperator & "'" + txtdata + "'"
      End If
    Case 135                  '日期型
      If cboOperator.text = "like" Then
         MsgBox "日期型数据不能选用“Like”作为运算符!", , "提示窗口"
         cboOperator.ListIndex = 1
      End If
      If IsDate(txtdata) = False Then
         MsgBox "请输入正确的日期!", , "提示窗口"
         rs.Close
         Exit Sub
      End If
      myval = cboOperator & "'" + txtdata + "'"
    Case 131, 20, 3, 6        '数值型数据
      If IsNumeric(txtdata) = False Then
         MsgBox "请输入正确的数据!", , "提示窗口"
         rs.Close
         Exit Sub
      End If
      If cboOperator.text = "like" Then
         MsgBox "数字数据不能选用“Like”作为运算符!"
         cboOperator.ListIndex = 1
      End If
      myval = cboOperator & txtdata
    Case 11
      If txtdata <> 0 Or txtdata <> 1 Then
        MsgBox "只能输入0或1!", , "提示窗口"
        rs.Close
        Exit Sub
      End If
  End Select
  If List1.ListCount > 0 Then
     If Opt1.Value = False And Opt2.Value = False Then
       MsgBox "必须选择一个逻辑值!", , "提示窗口"
       Opt1.Value = True
     End If
     If Opt1.Value = True Then
        List1.AddItem Opt1.Tag & " " & tb1 & "." & cboFields & " " & myval
     End If
     If Opt2.Value = True Then
        List1.AddItem Opt2.Tag & " " & tb1 & "." & cboFields & " " & myval
     End If
  Else
     List1.AddItem tb1 & "." & cboFields & " " & myval
  End If
  cmdFind.Enabled = True
  rs.Close
End Sub
Private Sub Form_Load()
  rs.Open tb1, Cnn, adOpenKeyset, adLockOptimistic
  Set fld = rs.Fields
  For Each fld In rs.Fields
      '向combo控件中添加字段
      cboFields.AddItem fld.Name
  Next
  rs.Close
  cboFields.ListIndex = 0
  '向cboOperator中添加查询条件
  cboOperator.AddItem ("like")
  cboOperator.AddItem (">")
  cboOperator.AddItem ("=")
  cboOperator.AddItem (">=")
  cboOperator.AddItem ("<")
  cboOperator.AddItem ("<=")
  cboOperator.AddItem ("<>")
  cboOperator.ListIndex = 0
End Sub
Private Sub List1_Click()
  cmdDel.Enabled = True
End Sub
Private Sub cmdFind_Click()        '查询
  Dim intX As Integer   '声明计数器变量。
  For intX = 1 To List1.ListCount
     txtsql = txtsql & " " & List1.List(intX)
  Next intX
  Select Case Left(List1.List(0), 3)
    Case "and"
      sql1 = tb1 & " where " & Right(List1.List(0), Len(List1.List(0)) - 3) & Trim(txtsql)
    Case "or"
      sql1 = tb1 & " where " & Right(List1.List(0), Len(List1.List(0)) - 2) & Trim(txtsql)
    Case Else
      sql1 = tb1 & " where " & List1.List(0) & Trim(txtsql)
  End Select
  Unload Me
End Sub
Private Sub cmdAll_Click()
  sql1 = tb1
  Unload Me
End Sub
Private Sub cmdDel_Click()
  List1.RemoveItem (List1.ListIndex)
  cmdDel.Enabled = False
  If List1.ListCount = 0 Then cmdFind.Enabled = False
End Sub
Private Sub cmdExit_Click()
  Unload Me
End Sub

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -