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

📄 frmbookadd.frm

📁 用vb实现的图书管理系统
💻 FRM
字号:
VERSION 5.00
Begin VB.Form frmBookAdd 
   Caption         =   "添加书籍信息"
   ClientHeight    =   7335
   ClientLeft      =   60
   ClientTop       =   450
   ClientWidth     =   6675
   LinkTopic       =   "Form5"
   ScaleHeight     =   7335
   ScaleWidth      =   6675
   StartUpPosition =   3  '窗口缺省
   Begin VB.CommandButton Command3 
      Caption         =   "添加"
      Height          =   495
      Left            =   2160
      TabIndex        =   16
      Top             =   6480
      Width           =   1335
   End
   Begin VB.CommandButton Command2 
      Caption         =   "退出"
      Height          =   495
      Left            =   3840
      TabIndex        =   15
      Top             =   6480
      Width           =   1335
   End
   Begin VB.CommandButton Command1 
      Caption         =   "清空"
      Height          =   495
      Left            =   480
      TabIndex        =   14
      Top             =   6480
      Width           =   1335
   End
   Begin VB.TextBox txtPress 
      Height          =   375
      Left            =   2280
      TabIndex        =   13
      Top             =   1440
      Width           =   2055
   End
   Begin VB.TextBox txtAuthor 
      Height          =   375
      Left            =   2280
      TabIndex        =   12
      Top             =   2280
      Width           =   2055
   End
   Begin VB.TextBox txtAddress 
      Height          =   375
      Left            =   2280
      TabIndex        =   11
      Top             =   3120
      Width           =   2055
   End
   Begin VB.TextBox txtDate 
      Height          =   375
      Left            =   2280
      TabIndex        =   10
      Top             =   3960
      Width           =   2055
   End
   Begin VB.TextBox txtPrice 
      Height          =   375
      Left            =   2280
      TabIndex        =   9
      Top             =   4800
      Width           =   2055
   End
   Begin VB.TextBox txtNumber 
      Height          =   375
      Left            =   2280
      TabIndex        =   8
      Top             =   5520
      Width           =   2055
   End
   Begin VB.TextBox txtName 
      Height          =   375
      Left            =   2280
      TabIndex        =   7
      Top             =   600
      Width           =   2055
   End
   Begin VB.Label Label7 
      Caption         =   "出版社"
      Height          =   375
      Left            =   840
      TabIndex        =   6
      Top             =   1440
      Width           =   1335
   End
   Begin VB.Label Label6 
      Caption         =   "作者"
      Height          =   375
      Left            =   840
      TabIndex        =   5
      Top             =   2280
      Width           =   1335
   End
   Begin VB.Label Label5 
      Caption         =   "地址"
      Height          =   375
      Left            =   840
      TabIndex        =   4
      Top             =   3120
      Width           =   1335
   End
   Begin VB.Label Label4 
      Caption         =   "出版日期"
      Height          =   375
      Left            =   840
      TabIndex        =   3
      Top             =   3960
      Width           =   1335
   End
   Begin VB.Label Label3 
      Caption         =   "价格"
      Height          =   375
      Left            =   840
      TabIndex        =   2
      Top             =   4800
      Width           =   1335
   End
   Begin VB.Label Label2 
      Caption         =   "图书编号"
      Height          =   375
      Left            =   840
      TabIndex        =   1
      Top             =   5520
      Width           =   1335
   End
   Begin VB.Label Label1 
      Caption         =   "名称"
      Height          =   375
      Left            =   840
      TabIndex        =   0
      Top             =   600
      Width           =   1335
   End
End
Attribute VB_Name = "frmBookAdd"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False


Private Sub Command1_Click()
txtName.Text = ""
txtPress.Text = ""
txtAuthor.Text = ""
txtAddress.Text = ""
txtDate.Text = ""
txtPrice.Text = ""
txtNumber.Text = ""

End Sub

Private Sub Command2_Click()
Unload Me

End Sub

Private Sub Command3_Click()
Dim conn As ADODB.Connection
Dim rs As New ADODB.Recordset
Dim sql As String
Dim N As Boolean
N = True
If Trim(txtName.Text) = "" Then
MsgBox "书名不能为空", vbOKOnly + vbExclamation, ""
txtName.SetFocus
N = False
End If
If Trim(txtPress.Text) = "" Then
MsgBox "出版社不能为空", vbOKOnly + vbExclamation, ""
txtPress.SetFocus
N = False
End If
If Trim(txtAuthor.Text) = "" Then
MsgBox "作者不能为空", vbOKOnly + vbExclamation, ""
txtAuthor.SetFocus
N = False
End If
If Trim(txtAddress.Text) = "" Then
MsgBox "地址不能为空", vbOKOnly + vbExclamation, ""
txtAddress.SetFocus
N = False
End If
If Trim(txtDate.Text) = "" Then
MsgBox "出版日期不能为空", vbOKOnly + vbExclamation, ""
txtDate.SetFocus
N = False
End If
If Trim(txtPrice.Text) = "" Then
MsgBox "价格不能为空", vbOKOnly + vbExclamation, ""
txtPrice.SetFocus
N = False
End If
If Trim(txtNumber.Text) = "" Then
MsgBox "图书编号不能为空", vbOKOnly + vbExclamation, ""
txtNumber.SetFocus
N = False
End If
If N = False Then
MsgBox "添加书籍信息失败", vbOKOnly
Else
Set conn = New ADODB.Connection
conn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=book.mdb;Persist Security Info=False"
conn.Open
sql = "select*from BookInfo where BookNumber='" + txtNumber.Text + "'"
rs.Open sql, conn, adOpenKeyset, adLockPessimistic

If rs.EOF Then
  rs.AddNew
  rs.Fields(0) = Trim(txtNumber.Text)
  rs.Fields(1) = Trim(txtName.Text)
  rs.Fields(2) = Trim(txtPress.Text)
  rs.Fields(3) = Trim(txtAuthor.Text)
  rs.Fields(4) = Trim(txtAddress.Text)
  rs.Fields(5) = Trim(txtDate.Text)
  rs.Fields(6) = Trim(txtPrice.Text)
  rs.Update
  MsgBox "添加书籍信息成功!", vbOKOnly, ""
  rs.Close
  Else
  MsgBox "图书编号重复!", vbOKOnly + vbExclamation, ""
  txtNumber.SetFocus
  txtNumber.Text = ""
  rs.Close
  End If
End If
  
End Sub

⌨️ 快捷键说明

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