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

📄 frmqueryreader.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 frmQueryReader 
   Caption         =   "读者查询"
   ClientHeight    =   9090
   ClientLeft      =   60
   ClientTop       =   1560
   ClientWidth     =   15240
   Icon            =   "frmQueryReader.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)   =   "frmQueryReader.frx":0442
      Tab(0).ControlEnabled=   -1  'True
      Tab(0).Control(0)=   "Label2"
      Tab(0).Control(0).Enabled=   0   'False
      Tab(0).Control(1)=   "Label1"
      Tab(0).Control(1).Enabled=   0   'False
      Tab(0).Control(2)=   "DBGrid1"
      Tab(0).Control(2).Enabled=   0   'False
      Tab(0).Control(3)=   "comShort"
      Tab(0).Control(3).Enabled=   0   'False
      Tab(0).Control(4)=   "Frame1"
      Tab(0).Control(4).Enabled=   0   'False
      Tab(0).Control(5)=   "Data1"
      Tab(0).Control(5).Enabled=   0   'False
      Tab(0).Control(6)=   "cmdClose"
      Tab(0).Control(6).Enabled=   0   'False
      Tab(0).Control(7)=   "cmdQuery"
      Tab(0).Control(7).Enabled=   0   'False
      Tab(0).Control(8)=   "comSort"
      Tab(0).Control(8).Enabled=   0   'False
      Tab(0).Control(9)=   "txtContent"
      Tab(0).Control(9).Enabled=   0   'False
      Tab(0).ControlCount=   10
      Begin VB.TextBox txtContent 
         Height          =   270
         Left            =   960
         TabIndex        =   9
         Top             =   720
         Width           =   1455
      End
      Begin VB.ComboBox comSort 
         Height          =   300
         Left            =   3480
         Style           =   2  'Dropdown List
         TabIndex        =   8
         Top             =   705
         Width           =   1815
      End
      Begin VB.CommandButton cmdQuery 
         Caption         =   "查询(&Q)"
         Default         =   -1  'True
         Height          =   375
         Left            =   7200
         TabIndex        =   7
         Top             =   675
         Width           =   975
      End
      Begin VB.CommandButton cmdClose 
         Cancel          =   -1  'True
         Caption         =   "关闭(&C)"
         Height          =   375
         Left            =   8760
         TabIndex        =   6
         Top             =   675
         Width           =   975
      End
      Begin VB.Data Data1 
         Connect         =   "Access 2000;"
         DatabaseName    =   ""
         DefaultCursorType=   0  '缺省游标
         DefaultType     =   2  '使用 ODBC
         Exclusive       =   0   'False
         Height          =   375
         Left            =   120
         Options         =   0
         ReadOnly        =   0   'False
         RecordsetType   =   1  'Dynaset
         RecordSource    =   ""
         Top             =   8445
         Width           =   14775
      End
      Begin VB.Frame Frame1 
         Caption         =   "排序"
         Height          =   765
         Left            =   5520
         TabIndex        =   2
         Top             =   480
         Width           =   1215
         Begin VB.OptionButton optAscending 
            Caption         =   "升序"
            Height          =   180
            Left            =   240
            TabIndex        =   4
            Top             =   240
            Value           =   -1  'True
            Width           =   735
         End
         Begin VB.OptionButton optDescending 
            Caption         =   "降序"
            Height          =   180
            Left            =   240
            TabIndex        =   3
            Top             =   480
            Width           =   735
         End
      End
      Begin VB.ComboBox comShort 
         Height          =   300
         ItemData        =   "frmQueryReader.frx":045E
         Left            =   960
         List            =   "frmQueryReader.frx":0460
         Style           =   2  'Dropdown List
         TabIndex        =   1
         Top             =   1005
         Visible         =   0   'False
         Width           =   1455
      End
      Begin MSDBGrid.DBGrid DBGrid1 
         Bindings        =   "frmQueryReader.frx":0462
         Height          =   6975
         Left            =   120
         OleObjectBlob   =   "frmQueryReader.frx":0476
         TabIndex        =   5
         Top             =   1365
         Width           =   14775
      End
      Begin VB.Label Label1 
         AutoSize        =   -1  'True
         Caption         =   "查询内容:"
         Height          =   180
         Left            =   120
         TabIndex        =   11
         Top             =   765
         Width           =   810
      End
      Begin VB.Label Label2 
         AutoSize        =   -1  'True
         Caption         =   "选择类型:"
         Height          =   180
         Left            =   2640
         TabIndex        =   10
         Top             =   765
         Width           =   810
      End
   End
End
Attribute VB_Name = "frmQueryReader"
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 = "读者编号" Or comSort.Text = "读者姓名" Or comSort = "" Then
        If Trim(txtContent) = "" Then                   '检查有效性
            MsgBox "查询内容不能为空!", vbExclamation + vbOKOnly
            txtContent.SetFocus
            Exit Sub
        End If
        If comSort.Text = "读者编号" Then
            Dim strReaderNo As String
            strReaderNo = Trim(txtContent)
            strAppName = App.Path & "\读者库.mdb"
            strSQL = "select * from 读者表 where 读者编号='" & strReaderNo & "'"
            Data1.DatabaseName = strAppName
            Data1.RecordSource = strSQL
            Data1.Refresh
        ElseIf comSort.Text = "读者姓名" Then
            Dim strReaderName As String
            strReaderName = Trim(txtContent)
            strAppName = App.Path & "\读者库.mdb"
            strSQL = "select * from 读者表 where 读者姓名='" & strReaderName & "'"
            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          '降序
        If comSort.Text = "读者类别" Then
            strCardShort(0) = strCardShort(comShort.ListIndex + 1)
            strAppName = App.Path & "\读者库.mdb"
            strSQL = "select 读者编号,读者姓名,性别,年龄,身份证号码,联系电话,住址,单位部门,登记日期,借书次数,备注 from 读者表 where 读者类别='" & comShort.Text & "'"
            strSQL = strSQL & " order by 读者编号"
            If blnOrdering = False Then strSQL = strSQL & " desc"
            Data1.DatabaseName = strAppName
            Data1.RecordSource = strSQL
            DBGrid1.Caption = "读者类别为" & strCardShort(0) & "的用户"
            Data1.Refresh
        ElseIf comSort.Text = "单位部门" Then
            strCardShort(0) = strCardShort(comShort.ListIndex + 1)
            strAppName = App.Path & "\读者库.mdb"
            strSQL = "select 读者编号,读者姓名,性别,年龄,身份证号码,读者类别,联系电话,住址,登记日期,借书次数,备注 from 读者表 where 单位部门='" & comShort.Text & "'"
            strSQL = strSQL & " order by 读者编号"
            If blnOrdering = False Then strSQL = strSQL & " desc"
            Data1.DatabaseName = strAppName
            Data1.RecordSource = strSQL
            DBGrid1.Caption = "单位部门为" & comShort & "负责人为" & strCardShort(0) & "的用户"
            Data1.Refresh
        End If
    End If
    Exit Sub
QueryErr:
    MsgBox Err.Description
End Sub

Private Sub comSort_Click()
    If comSort.Text = "读者类别" Or comSort.Text = "单位部门" Then
        '给组合框赋初值和初始化
        txtContent.Visible = False
        comShort.Visible = True
        comShort.Left = 960
        comShort.Top = 720
        '清空组合框
        comShort.Clear
        Dim i, intCount As Integer
        If comSort.Text = "读者类别" Then
            '给组合框赋值
            strAppName = App.Path & "\读者库.mdb"
            Set db = DBEngine.OpenDatabase(strAppName, False, True)         '共享、只读
            strSQL = "select count(*) as 类别总数 from 读者类别表"
            Set rs = db.OpenRecordset(strSQL)
            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
        End If
        If comSort.Text = "单位部门" Then
            '给组合框赋值
            strAppName = App.Path & "\读者库.mdb"
            Set db = DBEngine.OpenDatabase(strAppName, False, True)         '共享、只读
            strSQL = "select count(*) as 部门总数 from 部门表"
            Set rs = db.OpenRecordset(strSQL)
            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
        End If
    Else
        comShort.Visible = False
        txtContent.Visible = True
        comShort.Left = 960
        comShort.Top = 1005
        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 "读者类别"
    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 + -