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

📄 b借书.frm

📁 数据库课程设计图书管理系统
💻 FRM
字号:
VERSION 5.00
Object = "{86CF1D34-0C5F-11D2-A9FC-0000F8754DA1}#2.0#0"; "MSCOMCT2.OCX"
Begin VB.Form B借书 
   BorderStyle     =   1  'Fixed Single
   Caption         =   "借书"
   ClientHeight    =   4515
   ClientLeft      =   45
   ClientTop       =   330
   ClientWidth     =   7635
   Icon            =   "B借书.frx":0000
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MinButton       =   0   'False
   ScaleHeight     =   4515
   ScaleWidth      =   7635
   StartUpPosition =   3  '窗口缺省
   Begin VB.Frame FrameBook 
      Caption         =   "借书信息"
      Height          =   4455
      Left            =   120
      TabIndex        =   7
      Top             =   0
      Width           =   7455
      Begin VB.Frame Frame1 
         BackColor       =   &H00C0C0C0&
         Height          =   2415
         Left            =   3480
         TabIndex        =   14
         Top             =   360
         Width           =   3855
         Begin VB.Label LblNum 
            BackColor       =   &H80000014&
            ForeColor       =   &H000000FF&
            Height          =   255
            Left            =   1200
            TabIndex        =   28
            Top             =   2040
            Width           =   2175
         End
         Begin VB.Label Label7 
            Caption         =   "数量:"
            Height          =   255
            Index           =   4
            Left            =   120
            TabIndex        =   27
            Top             =   2040
            Width           =   1095
         End
         Begin VB.Label Label7 
            Caption         =   "版次:"
            Height          =   255
            Index           =   3
            Left            =   120
            TabIndex        =   26
            Top             =   1680
            Width           =   1095
         End
         Begin VB.Label LblPubNo 
            BackColor       =   &H80000014&
            ForeColor       =   &H000000FF&
            Height          =   255
            Left            =   1200
            TabIndex        =   25
            Top             =   1680
            Width           =   2175
         End
         Begin VB.Label Label7 
            Caption         =   "作者:"
            Height          =   255
            Index           =   2
            Left            =   120
            TabIndex        =   24
            Top             =   1320
            Width           =   1095
         End
         Begin VB.Label LblAuthor 
            BackColor       =   &H80000014&
            ForeColor       =   &H000000FF&
            Height          =   255
            Left            =   1200
            TabIndex        =   23
            Top             =   1320
            Width           =   2175
         End
         Begin VB.Label LblBookName 
            BackColor       =   &H80000014&
            ForeColor       =   &H000000FF&
            Height          =   255
            Left            =   1200
            TabIndex        =   22
            Top             =   960
            Width           =   2175
         End
         Begin VB.Label Label7 
            Caption         =   "题名:"
            Height          =   255
            Index           =   1
            Left            =   120
            TabIndex        =   21
            Top             =   960
            Width           =   1095
         End
         Begin VB.Label LblNoReturn 
            BackColor       =   &H80000014&
            ForeColor       =   &H000000FF&
            Height          =   255
            Left            =   2880
            TabIndex        =   20
            Top             =   240
            Width           =   735
         End
         Begin VB.Label Label9 
            Caption         =   "未还图书:"
            Height          =   255
            Left            =   2040
            TabIndex        =   19
            Top             =   240
            Width           =   1095
         End
         Begin VB.Label LblValid 
            BackColor       =   &H80000014&
            ForeColor       =   &H000000FF&
            Height          =   255
            Left            =   1440
            TabIndex        =   18
            Top             =   600
            Width           =   735
         End
         Begin VB.Label Label7 
            Caption         =   "超期图书:"
            Height          =   255
            Index           =   0
            Left            =   120
            TabIndex        =   17
            Top             =   600
            Width           =   1335
         End
         Begin VB.Label Label3 
            Caption         =   "读者罚款:"
            Height          =   255
            Left            =   120
            TabIndex        =   16
            Top             =   240
            Width           =   1215
         End
         Begin VB.Label LblPenalty 
            BackColor       =   &H80000014&
            ForeColor       =   &H000000FF&
            Height          =   255
            Left            =   1320
            TabIndex        =   15
            Top             =   240
            Width           =   735
         End
      End
      Begin VB.CommandButton CmdExit 
         BackColor       =   &H00C0C0C0&
         Caption         =   "退出"
         Height          =   360
         Left            =   4800
         Style           =   1  'Graphical
         TabIndex        =   6
         Top             =   3960
         Width           =   800
      End
      Begin VB.CommandButton CmdCancel 
         BackColor       =   &H00C0C0C0&
         Caption         =   "取消"
         Height          =   360
         Left            =   3960
         Style           =   1  'Graphical
         TabIndex        =   5
         Top             =   3960
         Width           =   800
      End
      Begin VB.CommandButton CmdSave 
         BackColor       =   &H00C0C0C0&
         Caption         =   "借书"
         Height          =   360
         Left            =   3120
         Style           =   1  'Graphical
         TabIndex        =   4
         Top             =   3960
         Width           =   800
      End
      Begin VB.TextBox txtNum 
         BackColor       =   &H80000000&
         Enabled         =   0   'False
         Height          =   375
         Left            =   1200
         MaxLength       =   50
         TabIndex        =   8
         Text            =   "0"
         Top             =   2040
         Width           =   2175
      End
      Begin VB.TextBox txtNotes 
         Height          =   975
         Left            =   1200
         MultiLine       =   -1  'True
         ScrollBars      =   3  'Both
         TabIndex        =   3
         Top             =   2880
         Width           =   4575
      End
      Begin VB.TextBox txtReadNo 
         Height          =   375
         Left            =   1200
         MaxLength       =   10
         TabIndex        =   0
         Top             =   480
         Width           =   1695
      End
      Begin VB.TextBox txtBookNo 
         Height          =   375
         Left            =   1200
         MaxLength       =   12
         TabIndex        =   1
         Top             =   1080
         Width           =   1695
      End
      Begin MSComCtl2.DTPicker DTPicker1 
         Height          =   375
         Left            =   1200
         TabIndex        =   2
         Top             =   1560
         Width           =   1695
         _ExtentX        =   2990
         _ExtentY        =   661
         _Version        =   393216
         Format          =   71827457
         CurrentDate     =   39222
      End
      Begin VB.Label Label5 
         Caption         =   "罚款金额:"
         Height          =   375
         Index           =   2
         Left            =   240
         TabIndex        =   13
         Top             =   2040
         Width           =   975
      End
      Begin VB.Label Label6 
         Caption         =   "借书日期:"
         Height          =   375
         Index           =   1
         Left            =   240
         TabIndex        =   12
         Top             =   1560
         Width           =   975
      End
      Begin VB.Label Label1 
         Caption         =   $"B借书.frx":08CA
         Height          =   495
         Index           =   1
         Left            =   600
         TabIndex        =   11
         Top             =   2520
         Width           =   735
      End
      Begin VB.Label Label2 
         Caption         =   "读者号:"
         Height          =   255
         Left            =   405
         TabIndex        =   10
         Top             =   600
         Width           =   735
      End
      Begin VB.Label Label4 
         Caption         =   "图书号:"
         Height          =   255
         Left            =   405
         TabIndex        =   9
         Top             =   1200
         Width           =   735
      End
   End
End
Attribute VB_Name = "B借书"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim rs As ADODB.Recordset
Dim SQL As String
Dim msg As String
Dim Index As Integer

Private Sub Label8_Click(Index As Integer)

End Sub

Private Sub txtReadNo_Change()
    SQL = " select 罚款金额 from 读者信息表 where 读者号='" & Trim(txtReadNo.Text) & "'"
    Set rs = SelectSQL(SQL, msg)
    If rs.RecordCount > 0 Then
        Me.LblPenalty.Caption = rs.Fields("罚款金额")
    Else
        Me.LblPenalty.Caption = "无"
    End If
    SQL = " select count(*) as num from 借还信息表 where 读者号='" & Trim(txtReadNo.Text) & "'"
    SQL = SQL & " and 还书日期 is null "
    Set rs = SelectSQL(SQL, msg)
    If rs.RecordCount > 0 Then
        Me.LblNoReturn.Caption = rs.Fields("num")
    Else
        Me.LblNoReturn.Caption = "0"
    End If
    Dim validNum As Integer
    SQL = " select count(*) as num from 借还信息表 where 读者号='" & Trim(txtReadNo.Text) & "'"
    SQL = SQL & " and 还书日期 is null and 续借日期 is null "
    SQL = SQL & "and  datediff(day,借书日期,getdate())>" & Sys_BorrowLimite
    Set rs = SelectSQL(SQL, msg)
    If rs.RecordCount > 0 Then
        validNum = rs.Fields("num")
    End If
    SQL = " select count(*) as num from 借还信息表 where 读者号='" & Trim(txtReadNo.Text) & "'"
    SQL = SQL & " and 还书日期 is null and 续借日期 is not null "
    SQL = SQL & "and  datediff(day,借书日期,getdate())>" & Sys_BorrowLimite + Sys_ContinueLimite
    Set rs = SelectSQL(SQL, msg)
    If rs.RecordCount > 0 Then
        validNum = validNum + rs.Fields("num")
    Else
        Me.LblValid.Caption = "0"
    End If
    If validNum = 0 Then
        Me.LblValid.Caption = "0"
    Else
        Me.LblValid.Caption = validNum
    End If
    rs.Close
End Sub
Private Sub txtBookNo_Change()
    SQL = " select 题名,作者,版次,图书数量  from 图书信息表 where 图书号='" & Trim(txtBookNo.Text) & "'"
    Set rs = SelectSQL(SQL, msg)
    If rs.RecordCount > 0 Then
        Me.LblBookName.Caption = rs.Fields("题名")
        Me.LblAuthor.Caption = rs.Fields("作者")
        Me.LblPubNo.Caption = rs.Fields("版次")
        Me.LblNum.Caption = rs.Fields("图书数量")
    Else
        Me.LblBookName.Caption = "无"
        Me.LblAuthor.Caption = "无"
        Me.LblPubNo.Caption = "无"
        Me.LblNum.Caption = "0"
    End If
    rs.Close
End Sub
Private Sub CmdSave_Click()
    On Error GoTo ErrMsg
    If Not CheckData Then
        Exit Sub
    Else
        Call setData
        Call ExecuteSQL(SQL, msg)
        SQL = " update 图书信息表 set 图书数量=图书数量-1 where 图书号='"
        SQL = SQL & Trim(Me.txtBookNo.Text) & "'"
        Call ExecuteSQL(SQL, msg)
        MsgBox ("成功添加数据!")
        Call txtBookNo_Change
        Call txtReadNo_Change
    End If
    Exit Sub
ErrMsg:
    MsgBox Err.Description, vbExclamation, "出错"
End Sub
Private Function CheckData() As Boolean
    Dim msgt As String
    msgt = ""
    If Trim(Me.txtReadNo.Text) = "" Then
        msgt = "读者号为空; "
    ElseIf Trim(Me.txtBookNo.Text) = "" Then
        msgt = "图书号为空; "
    ElseIf Not Len(Trim(txtReadNo.Text)) = 10 Then
        msgt = "读者号不是10位; "
    ElseIf Not Len(Trim(txtBookNo.Text)) = 12 Then
        msgt = "图书号不是12位; "
    End If
    If Not msgt = "" Then
        MsgBox (msgt)
        CheckData = False
        Exit Function
    End If
    If (Me.LblPenalty.Caption = "无") Then
        MsgBox ("读者号输入错误!")
        CheckData = False
        Exit Function
    End If
    If CInt(Me.LblNum.Caption) < 1 Then
        MsgBox ("此书已被借出!")
        CheckData = False
        Exit Function
    End If
    
    If CDbl(Me.LblPenalty.Caption) > Sys_MaxPenalty Then
        MsgBox ("请读者先交罚款!")
        CheckData = False
        Exit Function
    End If
    If CInt(Me.LblValid.Caption) > 0 Then
        MsgBox ("请读者先归还超期的图书!")
        CheckData = False
        Exit Function
    End If
    If CInt(Me.LblNoReturn.Caption) >= Sys_MaxBorrow Then
        MsgBox ("读者借书已经超过最大数量!")
        CheckData = False
        Exit Function
    End If
    If (Me.LblBookName.Caption = "无") Then
        MsgBox ("图书号输入错误!")
        CheckData = False
        Exit Function
    End If
    CheckData = True
End Function
Private Sub setData()
    SQL = "insert into 借还信息表 (读者号,图书号,借书日期,备注) values('"
    SQL = SQL & Trim(Me.txtReadNo.Text) & "','"
    SQL = SQL & Trim(Me.txtBookNo.Text) & "','"
    SQL = SQL & Trim(Me.DTPicker1.Value) & "','"
    SQL = SQL & Trim(Me.txtNotes.Text) & "')"
End Sub
Private Sub cmdCancel_Click()
    Me.txtBookNo.Text = ""
    Me.txtReadNo.Text = ""
    Me.DTPicker1.Refresh
    Me.txtNotes.Text = ""
End Sub
Private Sub CmdExit_Click()
    图书管理系统.Enabled = True
    Unload Me
End Sub
Private Sub Form_Unload(Cancel As Integer)
    图书管理系统.Enabled = True
    Unload Me
End Sub

⌨️ 快捷键说明

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