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

📄 frmquerycard.frm

📁 本人用VB 6.0和ACCESS编写的图书管理系统
💻 FRM
字号:
VERSION 5.00
Object = "{00028C01-0000-0000-0000-000000000046}#1.0#0"; "DBGRID32.OCX"
Object = "{BDC217C8-ED16-11CD-956C-0000C04E4C0A}#1.1#0"; "TABCTL32.OCX"
Begin VB.Form frmQueryCard 
   Caption         =   "借书证查询"
   ClientHeight    =   9090
   ClientLeft      =   60
   ClientTop       =   1560
   ClientWidth     =   15240
   Icon            =   "frmQueryCard.frx":0000
   LinkTopic       =   "Form1"
   LockControls    =   -1  'True
   MDIChild        =   -1  'True
   ScaleHeight     =   9090
   ScaleWidth      =   15240
   WindowState     =   2  'Maximized
   Begin TabDlg.SSTab SSTab1 
      Height          =   8895
      Left            =   120
      TabIndex        =   0
      Top             =   120
      Width           =   15015
      _ExtentX        =   26485
      _ExtentY        =   15690
      _Version        =   393216
      Tabs            =   1
      TabHeight       =   520
      ForeColor       =   4227327
      BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "华文行楷"
         Size            =   14.25
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      TabCaption(0)   =   "借书证查询"
      TabPicture(0)   =   "frmQueryCard.frx":0442
      Tab(0).ControlEnabled=   -1  'True
      Tab(0).Control(0)=   "Label1"
      Tab(0).Control(0).Enabled=   0   'False
      Tab(0).Control(1)=   "Label2"
      Tab(0).Control(1).Enabled=   0   'False
      Tab(0).Control(2)=   "txtContent"
      Tab(0).Control(2).Enabled=   0   'False
      Tab(0).Control(3)=   "comSort"
      Tab(0).Control(3).Enabled=   0   'False
      Tab(0).Control(4)=   "cmdQuery"
      Tab(0).Control(4).Enabled=   0   'False
      Tab(0).Control(5)=   "cmdClose"
      Tab(0).Control(5).Enabled=   0   'False
      Tab(0).Control(6)=   "DBGrid1"
      Tab(0).Control(6).Enabled=   0   'False
      Tab(0).Control(7)=   "Data1"
      Tab(0).Control(7).Enabled=   0   'False
      Tab(0).Control(8)=   "Frame1"
      Tab(0).Control(8).Enabled=   0   'False
      Tab(0).Control(9)=   "comShort"
      Tab(0).Control(9).Enabled=   0   'False
      Tab(0).ControlCount=   10
      Begin VB.ComboBox comShort 
         Height          =   300
         ItemData        =   "frmQueryCard.frx":045E
         Left            =   1080
         List            =   "frmQueryCard.frx":0460
         Style           =   2  'Dropdown List
         TabIndex        =   11
         Top             =   960
         Visible         =   0   'False
         Width           =   1455
      End
      Begin VB.Frame Frame1 
         Caption         =   "排序"
         Height          =   765
         Left            =   5640
         TabIndex        =   8
         Top             =   428
         Width           =   1215
         Begin VB.OptionButton optDescending 
            Caption         =   "降序"
            Height          =   180
            Left            =   240
            TabIndex        =   10
            Top             =   480
            Width           =   735
         End
         Begin VB.OptionButton optAscending 
            Caption         =   "升序"
            Height          =   180
            Left            =   240
            TabIndex        =   9
            Top             =   240
            Value           =   -1  'True
            Width           =   735
         End
      End
      Begin VB.Data Data1 
         Connect         =   "Access 2000;"
         DatabaseName    =   ""
         DefaultCursorType=   0  '缺省游标
         DefaultType     =   2  '使用 ODBC
         Exclusive       =   0   'False
         Height          =   375
         Left            =   240
         Options         =   0
         ReadOnly        =   0   'False
         RecordsetType   =   1  'Dynaset
         RecordSource    =   ""
         Top             =   8400
         Width           =   14535
      End
      Begin MSDBGrid.DBGrid DBGrid1 
         Bindings        =   "frmQueryCard.frx":0462
         Height          =   6975
         Left            =   240
         OleObjectBlob   =   "frmQueryCard.frx":0476
         TabIndex        =   7
         Top             =   1320
         Width           =   14535
      End
      Begin VB.CommandButton cmdClose 
         Cancel          =   -1  'True
         Caption         =   "关闭(&C)"
         Height          =   375
         Left            =   8880
         TabIndex        =   6
         Top             =   623
         Width           =   975
      End
      Begin VB.CommandButton cmdQuery 
         Caption         =   "查询(&Q)"
         Default         =   -1  'True
         Height          =   375
         Left            =   7320
         TabIndex        =   5
         Top             =   623
         Width           =   975
      End
      Begin VB.ComboBox comSort 
         Height          =   300
         Left            =   3600
         Style           =   2  'Dropdown List
         TabIndex        =   4
         Top             =   660
         Width           =   1815
      End
      Begin VB.TextBox txtContent 
         Height          =   270
         Left            =   1080
         TabIndex        =   2
         Top             =   675
         Width           =   1455
      End
      Begin VB.Label Label2 
         AutoSize        =   -1  'True
         Caption         =   "选择类型:"
         Height          =   180
         Left            =   2760
         TabIndex        =   3
         Top             =   720
         Width           =   810
      End
      Begin VB.Label Label1 
         AutoSize        =   -1  'True
         Caption         =   "查询内容:"
         Height          =   180
         Left            =   240
         TabIndex        =   1
         Top             =   720
         Width           =   810
      End
   End
End
Attribute VB_Name = "frmQueryCard"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Dim db As Database, rs As Recordset
Dim strAppName, strSQL As String, strCardShort() As String

Private Sub cmdClose_Click()
    Unload Me
End Sub

Private Sub cmdQuery_Click()
    On Error GoTo QueryErr
    If comSort.Text <> "借书证类型" Then
        If Trim(txtContent) = "" Then                   '检查有效性
            MsgBox "查询内容不能为空!", vbExclamation + vbOKOnly
            txtContent.SetFocus
            Exit Sub
        End If
        If comSort.Text = "借书证号" Then
            Dim strCardNo As String
            strCardNo = Trim(txtContent)
            strAppName = App.Path & "\借书证库.mdb"
            strSQL = "select 借书证号,姓名,性别,年龄,班级,登记日期,借书证类型,押金,借阅数量 from 借书证表 where 借书证号='" & strCardNo & "'"
            Data1.DatabaseName = strAppName
            Data1.RecordSource = strSQL
            Data1.Refresh
        ElseIf comSort.Text = "姓名" Then
            Dim strCardName As String
            strCardName = Trim(txtContent)
            strAppName = App.Path & "\借书证库.mdb"
            strSQL = "select 借书证号,姓名,性别,年龄,班级,登记日期,借书证类型,押金,借阅数量 from 借书证表 where 姓名='" & strCardName & "'"
            Data1.DatabaseName = strAppName
            Data1.RecordSource = strSQL
            Data1.Refresh
        End If
    Else
        Dim blnOrdering As Boolean
        If optAscending.Value = True Then blnOrdering = True            '升序
        If optDescending.Value = True Then blnOrdering = False          '降序
        strCardShort(0) = strCardShort(comShort.ListIndex + 1)
        strAppName = App.Path & "\借书证库.mdb"
        strSQL = "select 借书证号,姓名,性别,年龄,班级,登记日期,押金,借阅数量 from 借书证表 where 借书证类型='" & strCardShort(0) & "'"
        strSQL = strSQL & " order by 借书证号"
        If blnOrdering = False Then strSQL = strSQL & " desc"
        Data1.DatabaseName = strAppName
        Data1.RecordSource = strSQL
        DBGrid1.Caption = "借书证类型为" & strCardShort(0) & "的用户"
        Data1.Refresh
    End If
    Exit Sub
QueryErr:
    MsgBox Err.Description
End Sub

Private Sub comSort_Click()
    If comSort.Text = "借书证类型" Then
        '给组合框赋初值和初始化
        txtContent.Visible = False
        comShort.Visible = True
        comShort.Left = 1080
        comShort.Top = 675
        '清空组合框
        comShort.Clear
        '给组合框赋值
        strAppName = App.Path & "\借书证库.mdb"
        Set db = DBEngine.OpenDatabase(strAppName, False, True)         '共享、只读
        strSQL = "select count(*) as 类型总数 from 借书证类型表"
        Set rs = db.OpenRecordset(strSQL)
        Dim i, intCount As Integer
        intCount = rs.Fields("类型总数")
        rs.Close
        Set rs = Nothing
        ReDim Preserve strCardShort(intCount) As String
        strSQL = "select 借书证类型,类型名称 from 借书证类型表"
        Set rs = db.OpenRecordset(strSQL)
        rs.MoveFirst
        For i = 1 To intCount
            strCardShort(i) = rs.Fields("借书证类型")
            comShort.AddItem rs.Fields("类型名称")
            rs.MoveNext
        Next i
        rs.Close
        Set rs = Nothing
        db.Close
        Set db = Nothing
    Else
        comShort.Visible = False
        txtContent.Visible = True
        comShort.Left = 1080
        comShort.Top = 960
        txtContent.SetFocus
        SendKeys "{Home}+{End}"
    End If
End Sub

Private Sub Data1_Reposition()
    Data1.Caption = "借书证记录:" & Data1.Recordset.AbsolutePosition + 1
End Sub

Private Sub Form_Activate()
    txtContent.SetFocus
End Sub

Private Sub Form_Load()
    OFFCAT.Play "wave"
    comSort.AddItem "借书证号"
    comSort.AddItem "姓名"
    comSort.AddItem "借书证类型"
End Sub

Private Sub Form_Resize()
    SSTab1.Left = (Me.Width - SSTab1.Width) / 2
End Sub

⌨️ 快捷键说明

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