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

📄 form4.frm

📁 小小图书管理系统是功能完善,已经可以实用于小型单位或科室的图书管理.系统界面美观,操作方便,代码带有详尽的注释,相信大家一定会喜欢
💻 FRM
字号:
VERSION 5.00
Begin VB.Form Form4 
   Appearance      =   0  'Flat
   AutoRedraw      =   -1  'True
   BackColor       =   &H80000005&
   BorderStyle     =   0  'None
   Caption         =   "借书管理"
   ClientHeight    =   3975
   ClientLeft      =   4920
   ClientTop       =   3450
   ClientWidth     =   5745
   LinkTopic       =   "Form4"
   ScaleHeight     =   265
   ScaleMode       =   3  'Pixel
   ScaleWidth      =   383
   ShowInTaskbar   =   0   'False
   Begin Project1.xp_canvas xp_canvas1 
      Height          =   3975
      Left            =   0
      TabIndex        =   0
      Top             =   0
      Width           =   5745
      _ExtentX        =   10134
      _ExtentY        =   7011
      Caption         =   "借书管理"
      Icon            =   "Form4.frx":0000
      Begin Project1.xpcmdbutton Command2 
         Height          =   495
         Left            =   3000
         TabIndex        =   3
         Top             =   3240
         Width           =   1695
         _ExtentX        =   2990
         _ExtentY        =   873
         Caption         =   "退  出"
         BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "MS Sans Serif"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
      End
      Begin Project1.xpcmdbutton Command1 
         Height          =   495
         Left            =   840
         TabIndex        =   2
         Top             =   3240
         Width           =   1695
         _ExtentX        =   2990
         _ExtentY        =   873
         Caption         =   "借      出"
         BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "MS Sans Serif"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
      End
      Begin VB.Frame Frame1 
         Height          =   2295
         Left            =   360
         TabIndex        =   1
         Top             =   840
         Width           =   4815
         Begin VB.TextBox Text2 
            Height          =   495
            Left            =   1440
            TabIndex        =   9
            Top             =   960
            Width           =   2175
         End
         Begin VB.TextBox Text1 
            Height          =   495
            Left            =   1440
            TabIndex        =   8
            Top             =   240
            Width           =   2175
         End
         Begin VB.Label Label4 
            Caption         =   "借书总数"
            Height          =   375
            Left            =   120
            TabIndex        =   7
            Top             =   1680
            Width           =   1095
         End
         Begin VB.Label Label2 
            Caption         =   "图书编号"
            Height          =   375
            Left            =   120
            TabIndex        =   6
            Top             =   1020
            Width           =   1095
         End
         Begin VB.Label Label1 
            Caption         =   " 工   号"
            Height          =   375
            Left            =   120
            TabIndex        =   5
            Top             =   300
            Width           =   1095
         End
         Begin VB.Label Label3 
            Height          =   375
            Left            =   1680
            TabIndex        =   4
            Top             =   1680
            Width           =   1095
         End
      End
      Begin Project1.xptopbuttons xptopbuttons2 
         Height          =   315
         Left            =   4920
         Top             =   120
         Width           =   315
         _ExtentX        =   556
         _ExtentY        =   556
         Value           =   2
      End
      Begin Project1.xptopbuttons xptopbuttons1 
         Height          =   315
         Left            =   5280
         Top             =   120
         Width           =   315
         _ExtentX        =   556
         _ExtentY        =   556
      End
   End
End
Attribute VB_Name = "Form4"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
'*******************************************
'        “ 借书管理窗体“
'  此窗体主要功能:添加图书借阅信息
'
'
'作者:朱宏梅
'制作日期: 2004-5-30
'********************************************
Option Explicit

Private Sub Command1_Click()               '借出图书
Dim sql, sql1, sql2 As String
Dim num As Integer
sql = "select * from record"
sql1 = "select * from worker where [工号]=?"
sql2 = "select * from book where [图书编码]=?"
Dim param1, param2, param3, param4 As ADODB.Parameter
Dim cmd1, cmd2, cmd3, cmd4 As ADODB.Command
Set cmd1 = New ADODB.Command
Set cmd2 = New ADODB.Command
Set cmd3 = New ADODB.Command
Set cmd4 = New ADODB.Command
Set param1 = New ADODB.Parameter
Set param2 = New ADODB.Parameter
Set param3 = New ADODB.Parameter
Set param4 = New ADODB.Parameter
'工号及书号检测
'检验工号及书号的合法性
    With param1
      .Direction = adParamInput
      .Type = adBSTR
      .Size = 8
      .Value = Text1.Text
    End With
    
    cmd1.Parameters.Append param1
    cmd1.CommandText = sql1
    cmd1.CommandType = adCmdText
   Set cmd1.ActiveConnection = con
   Set rst = cmd1.Execute
   If rst.RecordCount <= 0 Then
     frmMsg.Show
     frmMsg.notice.Visible = True
  frmMsg.Text1.Text = "没有此工号!"
     Exit Sub
   End If
   
    
    With param2
      .Direction = adParamInput
      .Type = adBSTR
      .Size = 8
      .Value = Text2.Text
    End With
    
    cmd2.Parameters.Append param2
    cmd2.CommandText = sql2
    cmd2.CommandType = adCmdText
   Set cmd2.ActiveConnection = con
   Set rst1 = cmd2.Execute
   If rst1.RecordCount <= 0 Then
      frmMsg.Show
      frmMsg.notice.Visible = True
  frmMsg.Text1.Text = "没有此图书编号!"
      Exit Sub
   End If
   
   sql2 = "select * from record where [图书编码]=?"
    rst1.Close
    With param3
      .Direction = adParamInput
      .Type = adBSTR
      .Size = 8
      .Value = Text2.Text
    End With
    
     cmd3.Parameters.Append param3
     cmd3.CommandText = sql2
     cmd3.CommandType = adCmdText
   Set cmd3.ActiveConnection = con
   Set rst1 = cmd3.Execute
   '图书状态检测
   If rst1.RecordCount > 0 Then
      frmMsg.Show
      frmMsg.notice.Visible = True
  frmMsg.Text1.Text = "此图书已经被借阅!"
      Exit Sub
    End If
    
    sql1 = "select * from record where [工号]=?"
    rst.Close
    With param4
      .Direction = adParamInput
      .Type = adBSTR
      .Size = 8
      .Value = Text1.Text
    End With
    
    cmd4.Parameters.Append param4
    cmd4.CommandText = sql1
    cmd4.CommandType = adCmdText
   Set cmd4.ActiveConnection = con
   Set rst = cmd4.Execute
    '规定可借阅图书数目检测
    If rst.RecordCount = 0 Then
        num = rst.RecordCount + 1
        Label3.Caption = str(num)
    ElseIf rst.RecordCount <= 3 Then
       num = rst.RecordCount + 1
       Label3.Caption = str(num)
    ElseIf rst.RecordCount > 3 Then
      frmMsg.Show
      frmMsg.notice.Visible = True
  frmMsg.Text1.Text = "借阅图书已超限(>4)!"
      Label3.Caption = str(rst.RecordCount)
      Exit Sub
    End If
       
    rst.Close
    rst.Open sql, con, adOpenDynamic, adLockOptimistic
  
    rst.AddNew
    rst![工号] = Text1.Text
    rst![图书编码] = Text2.Text
    rst![借阅时间] = Date
    rst.Update
    frmMsg.Show
    frmMsg.info.Visible = True
  frmMsg.Text1.Text = "借阅成功!"

End Sub

Private Sub Command2_Click()
Unload Me
End Sub

Private Sub Form_Load()
Dim sql1, sql2 As String
sql1 = "select * from book"
sql2 = "select * from worker"
Set rst = New ADODB.Recordset
Set rst1 = New ADODB.Recordset
Call connect_db
rst.Open sql2, con, adOpenDynamic, adLockOptimistic
rst1.Open sql1, con, adOpenDynamic, adLockOptimistic
End Sub


Private Sub xptopbuttons1_Click()
Unload Me
End Sub

Private Sub xptopbuttons2_Click()
Me.WindowState = 1
End Sub

⌨️ 快捷键说明

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