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

📄 frm_cxct.frm

📁 PMS是一个生产管理系统,功能强大,供大家享用,希望大家支持!!
💻 FRM
字号:
VERSION 5.00
Begin VB.Form Frm_Cxct 
   Caption         =   "查询"
   ClientHeight    =   1560
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   5805
   LinkTopic       =   "Form1"
   LockControls    =   -1  'True
   MaxButton       =   0   'False
   ScaleHeight     =   1560
   ScaleWidth      =   5805
   StartUpPosition =   2  '屏幕中心
   Begin VB.CommandButton Cmd_Exit 
      Caption         =   "退出"
      Height          =   350
      Left            =   4785
      TabIndex        =   8
      Top             =   1170
      Width           =   960
   End
   Begin VB.CommandButton Cmd_Cx 
      Caption         =   "查询"
      Height          =   350
      Left            =   3690
      TabIndex        =   7
      Top             =   1170
      Width           =   960
   End
   Begin VB.Frame Frame1 
      Height          =   1095
      Left            =   45
      TabIndex        =   0
      Top             =   -30
      Width           =   5685
      Begin VB.TextBox Txt_Key 
         Height          =   300
         Left            =   975
         TabIndex        =   6
         Top             =   645
         Width           =   4500
      End
      Begin VB.ComboBox Cbx_Oper 
         Height          =   300
         Left            =   3615
         TabIndex        =   4
         Text            =   "Cbx_Oper"
         Top             =   195
         Width           =   1845
      End
      Begin VB.ComboBox Cbx_Field 
         Height          =   300
         ItemData        =   "Frm_Cxct.frx":0000
         Left            =   975
         List            =   "Frm_Cxct.frx":0002
         TabIndex        =   2
         Text            =   "Cbx_Field"
         Top             =   210
         Width           =   1725
      End
      Begin VB.Label Label3 
         Caption         =   "关键字"
         Height          =   240
         Left            =   135
         TabIndex        =   5
         Top             =   675
         Width           =   825
      End
      Begin VB.Label Label2 
         Caption         =   "运算符"
         Height          =   210
         Left            =   2895
         TabIndex        =   3
         Top             =   255
         Width           =   780
      End
      Begin VB.Label Label1 
         Caption         =   "字段名称"
         Height          =   240
         Left            =   105
         TabIndex        =   1
         Top             =   255
         Width           =   855
      End
   End
End
Attribute VB_Name = "Frm_Cxct"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim Fld
Dim rs As New ADODB.Recordset
Dim Fld1
Dim i As Integer

Private Sub Cbx_Field_GotFocus()
Cbx_Field.BackColor = &HFFFF80
End Sub

Private Sub Cbx_Field_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = 13 Then Cbx_Oper.SetFocus
End Sub

Private Sub Cbx_Field_LostFocus()
Cbx_Field.BackColor = &HFFFFFF
End Sub

Private Sub Cbx_Oper_GotFocus()
Cbx_Oper.BackColor = &HFFFF80
End Sub

Private Sub Cbx_Oper_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = 13 Then Txt_Key.SetFocus
End Sub

Private Sub Cbx_Oper_LostFocus()
Cbx_Oper.BackColor = &HFFFFFF
End Sub

Private Sub Cmd_Cx_Click()   '查询
 rs.Open "select * from " & Tb, cnn, adOpenKeyset, adLockOptimistic
   Fld1 = rs.Fields.Item(Cbx_Field.ListIndex).Name
   Select Case rs.Fields(Cbx_Field.ListIndex).Type
    Case 129
      If Cbx_Oper.Text = "like" Then
         sql = "select * from " & Tb & " where " & Tb & "." & Fld1 & " like+ '%'+'" + Txt_Key + "'+'%'"
      Else
         sql = "Select * from" & Tb & " where " & Tb & "." & Fld1 & Cbx_Oper & "'" + Txt_Key + "'"
      End If
    Case 200  '字符数据
      If Cbx_Oper.Text = "like" Then
         sql = "select * from " & Tb & " where " & Tb & "." & Fld1 & " like+ '%'+'" + Txt_Key + "'+'%'"
      Else
         sql = "select * from " & Tb & " where " & Tb & "." & Fld1 & Cbx_Oper & "'" + Txt_Key + "'"
      End If
    Case 135    '日期数据
      If Cbx_Oper.Text = "like" Then
         MsgBox "日期型数据不能选用“Like”作为运算符!", , "提示窗口"
         Cbx_Oper.ListIndex = 1
      End If
      If IsDate(Txt_Key) = False Then
         MsgBox "请输入正确的日期!", , "提示窗口"
         rs.Close
         Exit Sub
      End If
      sql = "select * from " & Tb & " where " & Tb & "." & Fld1 & Cbx_Oper & "'" + Txt_Key + "'"
    Case 6     '货币数据
      If IsNumeric(Txt_Key) = False Then
         MsgBox "请输入正确的数据!", , "提示窗口"
         rs.Close
         Exit Sub
      End If
      If Cbx_Oper.Text = "like" Then
         MsgBox "货币数据不能选用“Like”作为运算符!", , "提示窗口"
         Cbx_Oper.ListIndex = 1
      End If
      sql = "select * from " & Tb & " where " & Tb & "." & Fld1 & Txt_Key
   Case 131     '数字数据
      If Cbx_Oper.Text = "like" Then
         MsgBox "数字数据不能选用“Like”作为运算符!", , "提示窗口"
         Cbx_Oper.ListIndex = 1
      End If
      If IsNumeric(Txt_Key) = False Then
         MsgBox "请输入正确的数据!", , "提示窗口"
         rs.Close
         Exit Sub
      End If
      sql = "select * from " & Tb & " where " & Tb & "." & Fld1 & Cbx_Oper & Txt_Key
  End Select
  rs.Close
  Unload Me
End Sub

Private Sub Cmd_Exit_Click()
  Unload Me
End Sub

Private Sub Form_Load()
  rs.Open "select * from " & Tb, cnn, adOpenKeyset, adLockOptimistic
  If Tb = "tb_SCGL_scjhd" Then
    For i = 0 To rs.Fields.Count - 1
       '向控件中添加数据项
       Cbx_Field.AddItem Frm_Jhgl_Scjhd.Dgr_Scjhd.Columns(i).Caption
    Next i
  ElseIf Tb = "tb_SCGL_scsb" Then
    For i = 0 To rs.Fields.Count - 1
       Cbx_Field.AddItem Frm_Sbgl_Sbda.Dgr_Scsb.Columns(i).Caption
    Next i
  ElseIf Tb = "tb_SCGL_sbbf" Then
    For i = 0 To rs.Fields.Count - 1
      Cbx_Field.AddItem Frm_Sbgl_Sbbf.Dgr_Sbbf.Columns(i).Caption
    Next i
  ElseIf Tb = "tb_SCGL_sbwx" Then
    For i = 0 To rs.Fields.Count - 1
      Cbx_Field.AddItem Frm_Sbgl_Sbwx.Dgr_Sbwx.Columns(i).Caption
    Next i
  ElseIf Tb = "tb_SCGL_wlrk" Then
     For i = 0 To rs.Fields.Count - 1
        Cbx_Field.AddItem Frm_Kcgl_Wlrk.Dgr_Wlrk.Columns(i).Caption
     Next i
  ElseIf Tb = "tb_SCGL_cprk" Then    ''产品入库
     For i = 0 To rs.Fields.Count - 1
        Cbx_Field.AddItem Frm_Kcgl_Cprk.Dgr_Cprk.Columns(i).Caption
     Next i
  ElseIf Tb = "tb_SCGL_wlxq" Then    '物料需求
     For i = 0 To rs.Fields.Count - 1
        Cbx_Field.AddItem Frm_Jhgl_Wlxq.Dgr_Wlxq.Columns(i).Caption
     Next i
  ElseIf Tb = "tb_SCGL_Scll" Then
     For i = 0 To rs.Fields.Count - 1
        Cbx_Field.AddItem Frm_Kcgl_Scll.Dgr_Scll.Columns(i).Caption
     Next i
  End If

  rs.Close
  Cbx_Field.ListIndex = 0
  '向Cbx_Oper中添加查询条件
  Cbx_Oper.AddItem ("like")
  Cbx_Oper.AddItem (">")
  Cbx_Oper.AddItem ("=")
  Cbx_Oper.AddItem (">=")
  Cbx_Oper.AddItem ("<")
  Cbx_Oper.AddItem ("<=")
  Cbx_Oper.AddItem ("<>")
  Cbx_Oper.ListIndex = 0
End Sub

Private Sub Txt_Key_GotFocus()
  Txt_Key.BackColor = &HFFFF80
End Sub

Private Sub Txt_Key_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = 13 Then Cmd_Cx.SetFocus
End Sub

Private Sub Txt_Key_LostFocus()
  Txt_Key.BackColor = &HFFFFFF
End Sub

⌨️ 快捷键说明

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