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

📄 library.frm

📁 用vb 编写的学校图书馆管理系统
💻 FRM
📖 第 1 页 / 共 2 页
字号:
      End
      Begin VB.TextBox sname 
         DataField       =   "姓名"
         DataSource      =   "stuData"
         Height          =   285
         Left            =   3240
         Locked          =   -1  'True
         TabIndex        =   10
         Top             =   540
         Width           =   1215
      End
      Begin VB.TextBox class 
         DataField       =   "班别"
         DataSource      =   "stuData"
         Height          =   285
         Left            =   4200
         Locked          =   -1  'True
         TabIndex        =   9
         Top             =   1020
         Width           =   1575
      End
      Begin VB.TextBox bname 
         DataField       =   "书名"
         DataSource      =   "bookData"
         Height          =   285
         Left            =   840
         Locked          =   -1  'True
         TabIndex        =   8
         Top             =   1500
         Width           =   3255
      End
      Begin VB.TextBox author 
         DataField       =   "作者"
         DataSource      =   "bookData"
         Height          =   285
         Left            =   840
         Locked          =   -1  'True
         TabIndex        =   7
         Top             =   1980
         Width           =   3255
      End
      Begin VB.TextBox priter 
         DataField       =   "出版社"
         DataSource      =   "bookData"
         Height          =   285
         Left            =   840
         Locked          =   -1  'True
         TabIndex        =   6
         Top             =   2340
         Width           =   3255
      End
      Begin VB.TextBox totol 
         DataField       =   "总数"
         DataSource      =   "bookData"
         Height          =   285
         Left            =   840
         Locked          =   -1  'True
         TabIndex        =   5
         Top             =   2700
         Width           =   735
      End
      Begin VB.TextBox left 
         DataField       =   "在库数目"
         DataSource      =   "bookData"
         Height          =   285
         Left            =   2760
         Locked          =   -1  'True
         TabIndex        =   4
         Top             =   2700
         Width           =   735
      End
      Begin VB.CommandButton Command1 
         Caption         =   "确定"
         Enabled         =   0   'False
         Height          =   375
         Left            =   4800
         TabIndex        =   3
         Top             =   2580
         Width           =   735
      End
      Begin VB.TextBox sex 
         DataField       =   "性别"
         DataSource      =   "stuData"
         Height          =   285
         Left            =   3240
         Locked          =   -1  'True
         TabIndex        =   2
         Top             =   1020
         Width           =   375
      End
      Begin VB.TextBox bo 
         DataField       =   "借书数"
         DataSource      =   "stuData"
         Height          =   285
         Left            =   5400
         Locked          =   -1  'True
         TabIndex        =   1
         Top             =   540
         Width           =   375
      End
      Begin VB.Label Label13 
         Caption         =   "查询关键字"
         Height          =   255
         Left            =   -72960
         TabIndex        =   30
         Top             =   480
         Width           =   1215
      End
      Begin VB.Label Label12 
         Caption         =   "查询方式:"
         Height          =   255
         Left            =   -74760
         TabIndex        =   28
         Top             =   480
         Width           =   975
      End
      Begin VB.Label Label1 
         Caption         =   "学号"
         Height          =   255
         Left            =   240
         TabIndex        =   21
         Top             =   540
         Width           =   495
      End
      Begin VB.Label Label2 
         Caption         =   "书号"
         Height          =   255
         Left            =   240
         TabIndex        =   20
         Top             =   1020
         Width           =   495
      End
      Begin VB.Label Label3 
         Caption         =   "姓名"
         Height          =   255
         Left            =   2760
         TabIndex        =   19
         Top             =   540
         Width           =   495
      End
      Begin VB.Label Label4 
         Caption         =   "班别"
         Height          =   255
         Left            =   3720
         TabIndex        =   18
         Top             =   1020
         Width           =   495
      End
      Begin VB.Label Label5 
         Caption         =   "书名"
         Height          =   255
         Left            =   240
         TabIndex        =   17
         Top             =   1500
         Width           =   495
      End
      Begin VB.Label Label6 
         Caption         =   "作者"
         Height          =   255
         Left            =   240
         TabIndex        =   16
         Top             =   1980
         Width           =   615
      End
      Begin VB.Label Label7 
         Caption         =   "出版社"
         Height          =   375
         Left            =   240
         TabIndex        =   15
         Top             =   2340
         Width           =   615
      End
      Begin VB.Label Label8 
         Caption         =   "总数"
         Height          =   255
         Left            =   240
         TabIndex        =   14
         Top             =   2700
         Width           =   495
      End
      Begin VB.Label Label9 
         Caption         =   "在库数目"
         Height          =   255
         Left            =   1920
         TabIndex        =   13
         Top             =   2700
         Width           =   735
      End
      Begin VB.Label Label10 
         Caption         =   "性别"
         Height          =   255
         Left            =   2760
         TabIndex        =   12
         Top             =   1020
         Width           =   375
      End
      Begin VB.Label Label11 
         Caption         =   "已借书数"
         Height          =   255
         Left            =   4560
         TabIndex        =   11
         Top             =   540
         Width           =   735
      End
   End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Dim condition As String
Dim operate As Byte
Private Sub bnum_Change()
If Len(bnum.Text) = 6 Then
    condition = "书号='" & bnum.Text & "'"
    bookData.Recordset.FindFirst condition

    If operate = 1 Then '要进行的是还书操作
        snum.Enabled = True
        snum.Clear
        condition = "书号='" & bnum.Text & "'"
        lendData.Recordset.FindFirst condition
        Do While Not lendData.Recordset.NoMatch
            snum.AddItem lendData.Recordset.Fields("学号")
            lendData.Recordset.FindNext condition
        Loop
    End If

Else
    bookData.Recordset.MoveFirst
End If

Call comfirmdata
End Sub
Private Sub booklist_Click()
bookData.Recordset.MoveFirst
condition = "书号='" & left(booklist.List(booklist.ListIndex), 6) & "'"
bookData.Recordset.FindFirst condition
End Sub
Private Sub Command1_Click()
If operate = 0 Then
    condition = "学号='" & snum.Text & "' and 书号='" & bnum.Text & "'"
    lendData.Recordset.FindFirst condition
    If lendData.Recordset.NoMatch = False Then
        MsgBox "读者已借有该书"
        Exit Sub
    End If
    If stuData.Recordset.Fields("借书数") < 3 Then
        stuData.Recordset.Edit
        stuData.Recordset.Fields("借书数") = stuData.Recordset.Fields("借书数") + 1
        stuData.Recordset.Update
    Else
        MsgBox "该读者已经借了三本书"
    Exit Sub
    End If

    If bookData.Recordset.Fields("在库数目") > 0 Then
        bookData.Recordset.Edit
        bookData.Recordset.Fields("在库数目") = bookData.Recordset.Fields("在库数目") - 1
        bookData.Recordset.Update
    Else
        MsgBox "该书已全部借出"
    Exit Sub
    End If

    lendData.Recordset.AddNew
    lendData.Recordset.Fields("学号") = stuData.Recordset.Fields("学号")
    lendData.Recordset.Fields("书号") = bookData.Recordset.Fields("书号")
    lendData.Recordset.Update
    MsgBox "操作成功"
Else
    condition = "学号='" & snum.Text & "' and 书号='" & bnum.Text & "'"
    lendData.Recordset.FindFirst condition
    If lendData.Recordset.NoMatch = True Then
        MsgBox "指定的借书记录不存在"
        Exit Sub
    End If
        stuData.Recordset.Edit
        stuData.Recordset.Fields("借书数") = stuData.Recordset.Fields("借书数") - 1
        stuData.Recordset.Update
    

        bookData.Recordset.Edit
        bookData.Recordset.Fields("在库数目") = bookData.Recordset.Fields("在库数目") + 1
        bookData.Recordset.Update

        condition = "书号='" & bnum.Text & "' and " & "学号='" & snum.Text & "'"
        lendData.Recordset.FindFirst condition
        lendData.Recordset.Delete

        MsgBox "操作成功"
        snum.Clear
        
        Call snum_Change
End If
Command1.Enabled = False
End Sub
Private Sub Command2_Click()
Dim table As Recordset
Set table = bookData.Recordset
table.MoveFirst
Do
    If InStr(table.Fields(way.Text), keyword.Text) Then
        booklist.AddItem table.Fields("书号") & " " & table.Fields("书名")
    End If
        table.MoveNext
Loop Until table.EOF
End Sub
Private Sub Command3_Click()
booklist.Clear
End Sub
Private Sub Command4_Click()
bookData.Recordset.AddNew
bookData.Recordset.Fields("书号") = " "
bookData.Recordset.Fields("书名") = " "
bookData.Recordset.Update
bookgrid.Refresh
End Sub

Private Sub Command5_Click()
bookData.Recordset.Delete
bookgrid.Refresh
End Sub
Private Sub Command8_Click()
stuData.Recordset.AddNew
stuData.Recordset.Fields("学号") = " "
stuData.Recordset.Fields("姓名") = " "
stuData.Recordset.Update
stugrid.Refresh
End Sub
Private Sub Command9_Click()
stuData.Recordset.Delete
stugrid.Refresh
End Sub
Private Sub Form_Load()
operate = 0
stuData.DatabaseName = App.Path + "\library.mdb"
bookData.DatabaseName = App.Path + "\library.mdb"
lendData.DatabaseName = App.Path + "\library.mdb"
End Sub
Private Sub Option1_Click(Index As Integer)
operate = Index
If Index = 1 Then
snum.Clear
snum.Enabled = False
Else
snum.Enabled = True
End If
End Sub
Private Sub snum_Change()
If Len(snum.Text) = 8 Then
    condition = "学号='" & snum.Text & "'"
    stuData.Recordset.FindFirst condition
Else
    stuData.Recordset.MoveFirst
End If
    Call comfirmdata
End Sub
Private Sub snum_Click()
Call snum_Change
End Sub
Public Sub comfirmdata() '确认数据的合法性
If sname.Text <> " " And bname.Text <> " " Then
Command1.Enabled = True
Else
Command1.Enabled = False
End If
End Sub

⌨️ 快捷键说明

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