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

📄 frmborrow.frm

📁 中小型图书馆管理系统开发
💻 FRM
字号:
VERSION 5.00
Begin VB.Form frmBorrow 
   Caption         =   "借书"
   ClientHeight    =   3150
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   4740
   LinkTopic       =   "Form1"
   ScaleHeight     =   3150
   ScaleWidth      =   4740
   StartUpPosition =   3  'Windows Default
   Begin VB.CommandButton Command2 
      Caption         =   "退出(&X)"
      Height          =   375
      Left            =   2400
      TabIndex        =   12
      Top             =   2640
      Width           =   1335
   End
   Begin VB.CommandButton Command1 
      Caption         =   "借阅(&B)"
      Height          =   375
      Left            =   720
      TabIndex        =   11
      Top             =   2640
      Width           =   1335
   End
   Begin VB.Frame Frame2 
      Caption         =   "借阅图书"
      Height          =   855
      Left            =   120
      TabIndex        =   8
      Top             =   1680
      Width           =   4455
      Begin VB.TextBox txtBookid 
         Height          =   375
         Left            =   1680
         TabIndex        =   9
         Top             =   240
         Width           =   1575
      End
      Begin VB.Label Label1 
         Caption         =   "输入图书编号:"
         Height          =   255
         Left            =   240
         TabIndex        =   10
         Top             =   360
         Width           =   1335
      End
   End
   Begin VB.Frame Frame1 
      Caption         =   "读者ID:"
      Height          =   1455
      Left            =   120
      TabIndex        =   0
      Top             =   120
      Width           =   4455
      Begin VB.Label lblTotal 
         Caption         =   "Label1"
         ForeColor       =   &H00800000&
         Height          =   255
         Left            =   3360
         TabIndex        =   7
         Top             =   1080
         Width           =   1095
      End
      Begin VB.Label lblID 
         Caption         =   "Label1"
         ForeColor       =   &H000000C0&
         Height          =   255
         Left            =   960
         TabIndex        =   6
         Top             =   360
         Width           =   1455
      End
      Begin VB.Label lbl 
         Caption         =   "读者ID:"
         ForeColor       =   &H00800000&
         Height          =   255
         Left            =   240
         TabIndex        =   5
         Top             =   360
         Width           =   855
      End
      Begin VB.Label lblTotalc 
         Caption         =   "已借阅数量:"
         ForeColor       =   &H00800000&
         Height          =   255
         Left            =   2280
         TabIndex        =   4
         Top             =   1080
         Width           =   1095
      End
      Begin VB.Label lblAge 
         BackColor       =   &H80000013&
         Caption         =   "年龄:"
         ForeColor       =   &H00800000&
         Height          =   255
         Left            =   2280
         TabIndex        =   3
         Top             =   720
         Width           =   1095
      End
      Begin VB.Label lblName 
         Caption         =   "姓名:"
         ForeColor       =   &H00800000&
         Height          =   255
         Left            =   240
         TabIndex        =   2
         Top             =   720
         Width           =   1215
      End
      Begin VB.Label lblSex 
         Caption         =   "性别:"
         ForeColor       =   &H00800000&
         Height          =   255
         Left            =   240
         TabIndex        =   1
         Top             =   1080
         Width           =   1215
      End
   End
End
Attribute VB_Name = "frmBorrow"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False

Dim readerID As String

Dim conn As New ADODB.Connection
Dim cmd As New ADODB.Command
Dim rs As New ADODB.Recordset
Dim sql As String

Private Sub Command1_Click()
    Dim dueTime As String
    Dim lendTime As String
    
    '得到借书日期
    lendTime = Format(Date, "yyyy-mm-dd")
    
    '计算应归还图书的日期
    dueTime = Format(DateAdd("m", 2, Date), "yyyy-mm-dd")
        
    sql = "INSERT INTO lendbook(bookid,readerid,lendtime,duetime) VALUES('" & txtBookid.Text & "','" & lblID & _
    "','" & lendTime & "','" & dueTime & "')"
    
    cmd.CommandText = sql
    
    rs.Open cmd, , adOpenKeyset
    
    MsgBox "借阅完毕!!"
    
    
End Sub

Private Sub Command2_Click()
Me.Visible = False
End Sub

Private Sub Form_Load()

'窗体居中显示

Me.Top = (Screen.Height - Me.Height) \ 2
Me.Left = (Screen.Width - Me.Width) \ 2

readerID = frmBorrowBook.txtReaderID.Text
frmBorrowBook.Visible = False

'使用Connection对象与具体的数据库文件相连接
conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\db\library.mdb"

'每个Command必须与一个Connection对象连接
Set cmd.ActiveConnection = conn

'设置命令的类型是使用SQL语句
cmd.CommandType = adCmdText

'设置具体的SQL语句
sql = "SELECT * FROM readers where id=" & readerID
cmd.CommandText = sql

'执行SQL语句,建立打开记录集
rs.Open cmd, , adOpenKeyset

If rs.RecordCount = 0 Then
  MsgBox "该读者不存在!!"
  frmBorrowBook.Show
  frmBorrowBook.txtReaderID.SetFocus
  Exit Sub
Else
  lblID.Caption = rs.Fields("id")
  lblName.Caption = "姓名:" & rs.Fields("name")
  lblAge.Caption = "年龄:" & rs.Fields("age")
  lblSex.Caption = "性别:" & rs.Fields("sex")
  lblTotal.Caption = rs.Fields("total")
End If

rs.Close

End Sub

⌨️ 快捷键说明

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