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

📄 frmborrowman.frm

📁 在VB中开发的连接SQL的图书管理系统。
💻 FRM
字号:
VERSION 5.00
Object = "{67397AA1-7FB1-11D0-B148-00A0C922E820}#6.0#0"; "MSADODC.OCX"
Object = "{CDE57A40-8B86-11D0-B3C6-00A0C90AEA82}#1.0#0"; "MSDATGRD.OCX"
Begin VB.Form frmBorrowMan 
   BorderStyle     =   1  'Fixed Single
   Caption         =   "借阅管理"
   ClientHeight    =   6150
   ClientLeft      =   45
   ClientTop       =   435
   ClientWidth     =   11190
   Icon            =   "frmBorrowMan.frx":0000
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MinButton       =   0   'False
   ScaleHeight     =   6150
   ScaleWidth      =   11190
   StartUpPosition =   2  '屏幕中心
   Begin VB.CommandButton cmdLoss 
      Caption         =   "丢 失"
      Height          =   495
      Left            =   4920
      TabIndex        =   3
      Top             =   5400
      Width           =   1215
   End
   Begin VB.CommandButton cmdBack 
      Cancel          =   -1  'True
      Caption         =   "返 回"
      Height          =   495
      Left            =   9000
      TabIndex        =   6
      Top             =   5400
      Width           =   1215
   End
   Begin VB.CommandButton cmdRenew 
      Caption         =   "续 借"
      Height          =   495
      Left            =   2880
      TabIndex        =   2
      Top             =   5400
      Width           =   1215
   End
   Begin VB.CommandButton cmdReturn 
      Caption         =   "归 还"
      Height          =   495
      Left            =   6960
      TabIndex        =   4
      Top             =   5400
      Width           =   1215
   End
   Begin VB.CommandButton cmdAdd 
      Caption         =   "借 阅"
      Height          =   495
      Left            =   840
      TabIndex        =   1
      Top             =   5400
      Width           =   1215
   End
   Begin MSAdodcLib.Adodc adoBorrow 
      Height          =   375
      Left            =   3360
      Top             =   0
      Visible         =   0   'False
      Width           =   2415
      _ExtentX        =   4260
      _ExtentY        =   661
      ConnectMode     =   0
      CursorLocation  =   3
      IsolationLevel  =   -1
      ConnectionTimeout=   15
      CommandTimeout  =   30
      CursorType      =   3
      LockType        =   3
      CommandType     =   8
      CursorOptions   =   0
      CacheSize       =   50
      MaxRecords      =   0
      BOFAction       =   0
      EOFAction       =   0
      ConnectStringType=   1
      Appearance      =   1
      BackColor       =   -2147483643
      ForeColor       =   -2147483640
      Orientation     =   0
      Enabled         =   -1
      Connect         =   ""
      OLEDBString     =   ""
      OLEDBFile       =   ""
      DataSourceName  =   ""
      OtherAttributes =   ""
      UserName        =   ""
      Password        =   ""
      RecordSource    =   ""
      Caption         =   "连接dtgBorrow"
      BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "宋体"
         Size            =   9
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      _Version        =   393216
   End
   Begin VB.ComboBox cboState 
      Height          =   300
      ItemData        =   "frmBorrowMan.frx":044A
      Left            =   1200
      List            =   "frmBorrowMan.frx":045A
      Style           =   2  'Dropdown List
      TabIndex        =   7
      Top             =   97
      Width           =   1455
   End
   Begin MSDataGridLib.DataGrid dtgBorrow 
      Bindings        =   "frmBorrowMan.frx":0476
      Height          =   4575
      Left            =   120
      TabIndex        =   0
      Top             =   480
      Width           =   10815
      _ExtentX        =   19076
      _ExtentY        =   8070
      _Version        =   393216
      AllowUpdate     =   0   'False
      HeadLines       =   1
      RowHeight       =   15
      BeginProperty HeadFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "宋体"
         Size            =   9
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "宋体"
         Size            =   9
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ColumnCount     =   2
      BeginProperty Column00 
         DataField       =   ""
         Caption         =   ""
         BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
            Type            =   0
            Format          =   ""
            HaveTrueFalseNull=   0
            FirstDayOfWeek  =   0
            FirstWeekOfYear =   0
            LCID            =   2052
            SubFormatType   =   0
         EndProperty
      EndProperty
      BeginProperty Column01 
         DataField       =   ""
         Caption         =   ""
         BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
            Type            =   0
            Format          =   ""
            HaveTrueFalseNull=   0
            FirstDayOfWeek  =   0
            FirstWeekOfYear =   0
            LCID            =   2052
            SubFormatType   =   0
         EndProperty
      EndProperty
      SplitCount      =   1
      BeginProperty Split0 
         MarqueeStyle    =   3
         BeginProperty Column00 
         EndProperty
         BeginProperty Column01 
         EndProperty
      EndProperty
   End
   Begin VB.Label Label1 
      Caption         =   "图书借阅"
      Height          =   255
      Left            =   240
      TabIndex        =   5
      Top             =   120
      Width           =   855
   End
End
Attribute VB_Name = "frmBorrowMan"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
'定义condition变量
Dim condition As String
  
'网格控件加载函数
Private Sub adoBorrowRefresh()
  '设置ADO控件adoBorrowRefresh的连接字符串
  adoBorrow.ConnectionString = CONSTR
  '设置数据源
  Dim tmpRecordSource As String
  tmpRecordSource = "SELECT br.CardNo AS 借阅证号, c.Reader AS 读者姓名, br.BookNo AS 图书编号," _
                  + " bk.BookName AS 图书名称, br.BorrowDate AS 借阅日期, br.RenewDate AS 续借日期," _
                  + " br.ReturnDate AS 归还日期, br.Fine AS 罚金" _
                  + " FROM BorrowInfo br, CardInfo c, BookInfo bk" _
                  + " WHERE br.CardNo = c.CardNo AND br.BookNo = bk.BookNo" _
                  + condition + " ORDER BY br.CardNo, br.BookNo"
  adoBorrow.RecordSource = tmpRecordSource
  adoBorrow.Refresh
  '设置列宽
  With dtgBorrow
  .Columns(0).Width = 1000
  .Columns(1).Width = 1500
  .Columns(2).Width = 1200
  .Columns(3).Width = 1500
  .Columns(4).Width = 1500
  .Columns(5).Width = 1500
  .Columns(6).Width = 1500
  .Columns(7).Width = 800
  End With
End Sub

'窗体装载事件
Private Sub Form_Load()
  '设置证件状态
  cboState.ListIndex = 0

  '给objBorrowInfo初始化
  objBorrowInfo.Init

  '给两个condition初始化
  condition = ""

  '调用adoBorrowRefresh过程
  Call adoBorrowRefresh
  
  '如果没有选择记录,则不需要做任何操作
  If adoBorrow.Recordset.BOF Or adoBorrow.Recordset.EOF Then
    Exit Sub
  End If
  '刷新BorrowInfo的信息,主要为是否过期,且有多少罚金
  objBorrowInfo.UpdateAllState 2
  adoBorrow.Refresh
End Sub

'单击cboState控件
Private Sub cboState_Click()
  If cboState.ListIndex = 0 Then
    '如果选择全部
    condition = ""
  Else
    '如果选择其他
    condition = " AND br.BorrowState = " + Trim(Str(cboState.ListIndex - 1))
  End If

  '调用adoBorrowRefresh过程
  Call adoBorrowRefresh
End Sub

'借阅按钮
Private Sub cmdAdd_Click()
  '给借阅窗口赋值
  frmBorrowEdit.txtCNo = ""
  frmBorrowEdit.txtReader = ""
  frmBorrowEdit.txtTypeName = ""
  frmBorrowEdit.txtMaxCount = ""
  frmBorrowEdit.txtMaxDays = ""
  frmBorrowEdit.txtBCount = ""
  '启动编辑窗体
  frmBorrowEdit.Show 1
  '刷新adoBorrow控件
  adoBorrow.Refresh
End Sub

'续借按钮
Private Sub cmdRenew_Click()
  '如果没有选择记录,则不需要做任何操作
  If adoBorrow.Recordset.BOF Or adoBorrow.Recordset.EOF Then
    MsgBox "请选择需要续借的书籍", vbInformation, "信息提示"
    Exit Sub
  End If
  '读取objBorrowInfo的信息
  objBorrowInfo.GetInfo dtgBorrow.Columns(2).Text
  '如果这本书不是在借阅状态下,是不能续借的
  If objBorrowInfo.BorrowState <> 0 Then
    MsgBox "此书不是在借阅状态,不能续借", vbInformation, "信息提示"
    Exit Sub
  End If

  '续借
  Dim IsRenew As Integer
  IsRenew = MsgBox("是否续借所选择的书籍", vbYesNo + vbQuestion + vbDefaultButton1, "是否续借")
  If IsRenew = vbYes Then
    '更新续借日期
    objBorrowInfo.UpdateDate dtgBorrow.Columns(2).Text, Now, 3
    '更新归还日期
    objCardInfo.GetInfo dtgBorrow.Columns(0).Text
    objCardType.GetInfo objCardType.GetTypeName(objCardInfo.CTypeID)
    objBorrowInfo.UpdateDate dtgBorrow.Columns(2).Text, Now + objCardType.RenewDays, 4
    '更新借阅状态
    objBorrowInfo.UpdateState dtgBorrow.Columns(2).Text, 1
    '显示续借成功信息
    MsgBox "续借成功", vbInformation, "信息提示"
  End If
  '刷新
  adoBorrow.Refresh
End Sub

'丢失按钮
Private Sub cmdLoss_Click()
  '如果没有选择记录,则不需要做任何操作
  If adoBorrow.Recordset.BOF Or adoBorrow.Recordset.EOF Then
    MsgBox "请选择丢失书籍的记录", vbInformation, "信息提示"
    Exit Sub
  End If

  '丢失
  Dim IsLoss As Integer
  IsLoss = MsgBox("此书是否已经丢失?", vbYesNo + vbQuestion + vbDefaultButton1, "是否丢失")
  If IsLoss = vbYes Then
    '丢失处理
    Dim bPrice As Single
    objBookInfo.GetInfo dtgBorrow.Columns(2).Text
    bPrice = 10 * objBookInfo.Price
    If MsgBox("你所借的书已经丢失,请交罚金!" + vbCrLf + "罚金为" _
              + Str(bPrice) + "元" + vbCrLf + "是否交罚金", _
              vbQuestion + vbYesNo + vbDefaultButton2, "请交罚金") = vbNo Then
      Exit Sub
    End If
    '删除丢失书籍借阅记录
    objBorrowInfo.Delete dtgBorrow.Columns(2).Text
    '删除丢失书籍记录
    objBookInfo.Delete dtgBorrow.Columns(2).Text
    '信息提示
    MsgBox "此丢失书籍信息已经删除", vbInformation, "信息提示"
  End If
  '刷新
  adoBorrow.Refresh
End Sub

'归还按钮
Private Sub cmdReturn_Click()
  '如果没有选择记录,则不需要做任何操作
  If adoBorrow.Recordset.BOF Or adoBorrow.Recordset.EOF Then
    MsgBox "请选择需要归还书籍的记录", vbInformation, "信息提示"
    Exit Sub
  End If

  '归还
  Dim IsReturn As Integer
  IsReturn = MsgBox("是否归还所选择的书籍", vbYesNo + vbQuestion + vbDefaultButton1, "是否归还")
  If IsReturn = vbYes Then
    objBorrowInfo.GetInfo dtgBorrow.Columns(2).Text
    '过期处理
    If objBorrowInfo.BorrowState = 2 Then
      If MsgBox("您所借的书已经过期,请交罚金!" + vbCrLf + "罚金为" _
                + Str(0.3 * (Now - objBorrowInfo.ReturnDate)) + vbCrLf + "元" + vbCrLf _
                + "是否交罚金", vbQuestion + vbYesNo + vbDefaultButton2, "请交罚金") = vbNo Then
        Exit Sub
      End If
    End If
    objBorrowInfo.Delete dtgBorrow.Columns(2).Text
    MsgBox "此书已经归还", vbInformation, "信息提示"
  End If
  '刷新
  adoBorrow.Refresh
End Sub

'返回按钮
Private Sub cmdBack_Click()
  Unload Me
End Sub

⌨️ 快捷键说明

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