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

📄 form4.frm

📁 经过几个月的设计和开发
💻 FRM
字号:
VERSION 5.00
Begin VB.Form Form4 
   Appearance      =   0  'Flat
   AutoRedraw      =   -1  'True
   BackColor       =   &H00C0FFFF&
   BorderStyle     =   0  'None
   Caption         =   "借书管理"
   ClientHeight    =   3315
   ClientLeft      =   4920
   ClientTop       =   3450
   ClientWidth     =   4965
   Icon            =   "Form4.frx":0000
   LinkTopic       =   "Form4"
   ScaleHeight     =   221
   ScaleMode       =   3  'Pixel
   ScaleWidth      =   331
   ShowInTaskbar   =   0   'False
   Begin VB.TextBox Text2 
      Height          =   270
      Left            =   1320
      TabIndex        =   8
      Top             =   1320
      Width           =   2175
   End
   Begin VB.TextBox Text1 
      Height          =   270
      Left            =   1320
      TabIndex        =   7
      Top             =   960
      Width           =   2175
   End
   Begin 计算机图书管理系统2008.xp_canvas xp_canvas1 
      Height          =   2055
      Left            =   1200
      TabIndex        =   0
      Top             =   720
      Width           =   3795
      _ExtentX        =   10134
      _ExtentY        =   7011
      Begin 计算机图书管理系统2008.xpcmdbutton Command2 
         Height          =   375
         Left            =   2040
         TabIndex        =   2
         Top             =   1320
         Width           =   1455
         _ExtentX        =   2778
         _ExtentY        =   661
         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 计算机图书管理系统2008.xpcmdbutton Command1 
         Height          =   375
         Left            =   360
         TabIndex        =   1
         Top             =   1320
         Width           =   1455
         _ExtentX        =   2566
         _ExtentY        =   661
         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
   End
   Begin 计算机图书管理系统2008.xptopbuttons xptopbuttons1 
      Height          =   315
      Left            =   4560
      Top             =   120
      Width           =   315
      _ExtentX        =   556
      _ExtentY        =   556
   End
   Begin 计算机图书管理系统2008.xptopbuttons xptopbuttons2 
      Height          =   315
      Left            =   4200
      Top             =   120
      Width           =   315
      _ExtentX        =   556
      _ExtentY        =   556
      Value           =   2
   End
   Begin VB.Image Image2 
      Height          =   1545
      Left            =   0
      Picture         =   "Form4.frx":0CCA
      Top             =   2880
      Width           =   12765
   End
   Begin VB.Image Image1 
      Height          =   660
      Left            =   0
      Picture         =   "Form4.frx":2BAA4
      Top             =   0
      Width           =   5580
   End
   Begin VB.Label Label3 
      BackColor       =   &H00C0FFFF&
      Height          =   375
      Left            =   120
      TabIndex        =   6
      Top             =   2400
      Width           =   1095
   End
   Begin VB.Label Label4 
      BackColor       =   &H00C0FFFF&
      Caption         =   "借书总数"
      Height          =   375
      Left            =   120
      TabIndex        =   5
      Top             =   1920
      Width           =   1095
   End
   Begin VB.Label Label2 
      BackColor       =   &H00C0FFFF&
      Caption         =   "图书编号"
      Height          =   375
      Left            =   120
      TabIndex        =   4
      Top             =   1440
      Width           =   1095
   End
   Begin VB.Label Label1 
      BackColor       =   &H00C0FFFF&
      Caption         =   "工   号"
      Height          =   375
      Left            =   120
      TabIndex        =   3
      Top             =   960
      Width           =   1095
   End
End
Attribute VB_Name = "Form4"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
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 + -