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

📄 frmreadermanage.frm

📁 图书管理系统
💻 FRM
📖 第 1 页 / 共 2 页
字号:
         TabIndex        =   8
         Top             =   840
         Width           =   1215
      End
      Begin VB.TextBox txtNum 
         DataField       =   "证号"
         DataMember      =   "ReaderData"
         DataSource      =   "Library_Manage"
         Height          =   270
         Left            =   2880
         TabIndex        =   7
         Top             =   480
         Width           =   1215
      End
      Begin VB.TextBox txtDept 
         DataField       =   "部门"
         DataMember      =   "ReaderData"
         DataSource      =   "Library_Manage"
         Height          =   270
         Left            =   840
         TabIndex        =   6
         Top             =   840
         Width           =   1215
      End
      Begin VB.TextBox txtName 
         DataField       =   "姓名"
         DataMember      =   "ReaderData"
         DataSource      =   "Library_Manage"
         Height          =   270
         Left            =   840
         TabIndex        =   5
         Top             =   480
         Width           =   1215
      End
      Begin VB.Label Label13 
         AutoSize        =   -1  'True
         Caption         =   "办证日期"
         DataField       =   "日期"
         DataMember      =   "ReaderData"
         DataSource      =   "Library_Manage"
         Height          =   180
         Left            =   480
         TabIndex        =   39
         Top             =   1200
         Width           =   720
      End
      Begin VB.Label Label12 
         AutoSize        =   -1  'True
         Caption         =   "有效期限"
         Height          =   180
         Left            =   -71400
         TabIndex        =   16
         Top             =   360
         Width           =   720
      End
      Begin VB.Label Label11 
         AutoSize        =   -1  'True
         Caption         =   "借书期限"
         Height          =   180
         Left            =   -72240
         TabIndex        =   15
         Top             =   360
         Width           =   720
      End
      Begin VB.Label Label10 
         AutoSize        =   -1  'True
         Caption         =   "借书数量"
         Height          =   180
         Left            =   -73080
         TabIndex        =   14
         Top             =   360
         Width           =   720
      End
      Begin VB.Label Label9 
         AutoSize        =   -1  'True
         Caption         =   "类别代号"
         Height          =   180
         Left            =   -73920
         TabIndex        =   13
         Top             =   360
         Width           =   720
      End
      Begin VB.Label Label8 
         AutoSize        =   -1  'True
         Caption         =   "学   生"
         Height          =   180
         Left            =   -74760
         TabIndex        =   12
         Top             =   1320
         Width           =   630
      End
      Begin VB.Label Label7 
         AutoSize        =   -1  'True
         Caption         =   "教   师"
         Height          =   180
         Left            =   -74760
         TabIndex        =   11
         Top             =   1080
         Width           =   630
      End
      Begin VB.Label Label6 
         AutoSize        =   -1  'True
         Caption         =   "馆   员"
         Height          =   180
         Left            =   -74760
         TabIndex        =   10
         Top             =   840
         Width           =   630
      End
      Begin VB.Label Label5 
         AutoSize        =   -1  'True
         Caption         =   "特殊读者"
         Height          =   180
         Left            =   -74760
         TabIndex        =   9
         Top             =   600
         Width           =   720
      End
      Begin VB.Label Label4 
         AutoSize        =   -1  'True
         Caption         =   "读者类别"
         Height          =   180
         Left            =   2160
         TabIndex        =   4
         Top             =   840
         Width           =   720
      End
      Begin VB.Label Label3 
         AutoSize        =   -1  'True
         Caption         =   "借阅证号"
         Height          =   180
         Left            =   2160
         TabIndex        =   3
         Top             =   480
         Width           =   720
      End
      Begin VB.Label Label2 
         AutoSize        =   -1  'True
         Caption         =   "部门"
         Height          =   180
         Left            =   480
         TabIndex        =   2
         Top             =   840
         Width           =   360
      End
      Begin VB.Label Label1 
         AutoSize        =   -1  'True
         Caption         =   "姓名"
         Height          =   180
         Left            =   480
         TabIndex        =   1
         Top             =   480
         Width           =   360
      End
   End
End
Attribute VB_Name = "ReaderManage"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Dim isAdding As Boolean     '定义窗体状态标志

Private Sub cmdExit_Click()
    Unload Me               '关闭读者管理窗体
End Sub

Private Sub cmdRefresh_Click()
    With Library_Manage.rsReaderData
        If .RecordCount > 0 Then
            .CancelUpdate       '取消前一步执行的操作
            .Requery            '重新读取记录集数据
            '重新执行数据绑定
            Set txtNum.DataSource = Library_Manage
            txtNum.DataMember = "ReaderData"
            txtNum.DataField = "证号"
            Set txtName.DataSource = Library_Manage
            txtName.DataMember = "ReaderData"
            txtName.DataField = "姓名"
            Set txtDept.DataSource = Library_Manage
            txtDept.DataMember = "ReaderData"
            txtDept.DataField = "部门"
            Set txtType.DataSource = Library_Manage
            txtType.DataMember = "ReaderData"
            txtType.DataField = "类号"
            
        End If
    End With
    cmdAdd.Enabled = True
    cmdDelete.Enabled = True
    isAdding = False
   cmdMove(0).Enabled = True
                    cmdMove(1).Enabled = True
                    cmdMove(2).Enabled = True
                    cmdMove(3).Enabled = True
                    txtNews.Enabled = True
    cmdMove(0).Value = True
End Sub

Private Sub cmdTSave_Click()
    '删除原有类别数据
    Library_Manage.Library_Manage_Con.Execute "TRUNCATE TABLE 读者类别"
    With Library_Manage.rsReaderType
        If .State = adStateClosed Then .Open
        '保存新的读者类别数据
        .AddNew
        .Fields("编号") = "0"
        .Fields("名称") = "特殊读者"
        .Fields("借书量") = Val(txtSp(1))
        .Fields("借书期") = Val(txtSp(2))
        .Fields("有效期") = Val(txtSp(3))
        .Update
        .AddNew
        .Fields("编号") = "1"
        .Fields("名称") = "管员"
        .Fields("借书量") = Val(txtL(1))
        .Fields("借书期") = Val(txtL(2))
        .Fields("有效期") = Val(txtL(3))
        .Update
        .AddNew
        .Fields("编号") = "2"
        .Fields("名称") = "教师"
        .Fields("借书量") = Val(txtT(1))
        .Fields("借书期") = Val(txtT(2))
        .Fields("有效期") = Val(txtT(3))
        .Update
        .AddNew
        .Fields("编号") = "3"
        .Fields("名称") = "学生"
        .Fields("借书量") = Val(txtSD(1))
        .Fields("借书期") = Val(txtSD(2))
        .Fields("有效期") = Val(txtSD(3))
        .Update
    End With
End Sub

Private Sub Form_Load()
    cmdMove(0).Value = True             '触发按钮单击事件
End Sub

Private Sub cmdAdd_Click()
    With Library_Manage.rsReaderData
        .AddNew                         '添加新记录
        txtNews = "记录:" & .AbsolutePosition & "/" & .RecordCount
    End With
    txtDate = Date                      '设置默认办证日期
    isAdding = True
    cmdAdd.Enabled = False              '在保存新记录之前禁用控件
    cmdDelete.Enabled = False
   cmdMove(0).Enabled = False
                    cmdMove(1).Enabled = False
                    cmdMove(2).Enabled = False
                    cmdMove(3).Enabled = False
                    txtNews.Enabled = False
End Sub

Private Sub cmdDelete_Click()
    With Library_Manage.rsReaderData
        If Not .EOF Then
            If MsgBox("将删除<" & Trim(txtName) & ">的数据,是否继续?", _
                       vbCritical + vbYesNo, "读者数据管理") = vbYes Then
                .Delete
                .MoveNext
                If .EOF And .RecordCount > 0 Then .MoveLast
            End If
        End If
    End With
End Sub

Private Sub cmdDSave_Click()
    On Error Resume Next
    Dim objCopy As New Recordset
    If Trim(txtName) = "" Then
        MsgBox "读者姓名不能为空!", vbCritical, "读者数据管理"
        txtName.SetFocus
        txtName = ""
    ElseIf Trim(txtDept) = "" Then
        MsgBox "读者所属系部不能为空!", vbCritical, "读者数据管理"
        txtDept.SetFocus
        txtDept = ""
    ElseIf Trim(txtNum) = "" Then
        MsgBox "借阅证编号不能为空!", vbCritical, "读者数据管理"
        txtNum.SetFocus
        txtNum = ""
     
    ElseIf Not Trim(txtType) Like "[0-3]" Then
        MsgBox "无效的读者类别编号!", vbCritical, "读者数据管理"
        txtType.SetFocus
        txtType.SelStart = 0
        txtType.SelLength = Len(txtType)
    Else
        '检查借阅证编号是否重复
        Set objCopy = Library_Manage.rsReaderData.Clone
        With objCopy
            If .RecordCount > 0 Then
                .MoveFirst
                .Find "证号='" & Trim(txtNum) & "'"
                If Not .EOF And .AbsolutePosition <> _
                        Library_Manage.rsReaderData.AbsolutePosition Then
                    MsgBox "借阅证编号:" & Trim(txtNum) _
                    & "已被使用,请检查编号是否输入正确!", _
                    vbCritical, "读者数据管理"
                    txtNum.SetFocus
                    txtNum.SelStart = 0
                    txtNum.SelLength = Len(txtNum)
                    Exit Sub
                Else
                    '保存记录
                    Library_Manage.rsReaderData.Update
                    MsgBox "数据保存成功!", vbInformation, "读者数据管理"
                    cmdAdd.Enabled = True
                    cmdDelete.Enabled = True
                    isAdding = False
                    cmdMove(0).Enabled = True
                    cmdMove(1).Enabled = True
                    cmdMove(2).Enabled = True
                    cmdMove(3).Enabled = True
                    txtNews.Enabled = True
                End If
            End If
        End With
    End If
End Sub

Private Sub cmdMove_Click(Index As Integer)
    With Library_Manage.rsReaderData
        If .State = adStateClosed Then .Open
        Select Case Index       '切换当前记录
            Case 0              '使第一个记录成为当前记录
                If .RecordCount > 0 And Not .BOF Then .MoveFirst
            Case 1              '使上一个记录成为当前记录
                If .RecordCount > 0 And Not .BOF Then
                    .MovePrevious
                    If .BOF Then .MoveFirst
                End If
            Case 2              '使下一个记录成为当前记录
                If .RecordCount > 0 And Not .EOF Then
                    .MoveNext
                    If .EOF Then .MoveLast
                End If
            Case 3              '使最后一个记录成为当前记录
                If .RecordCount > 0 And Not .EOF Then .MoveLast
        End Select
        If .BOF And .EOF Then   '显示当前记录编号和记录总数
            txtNews = "记录:无"
        Else
            txtNews = "记录:" & .AbsolutePosition & "/" & .RecordCount
        End If
    End With
End Sub




⌨️ 快捷键说明

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