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

📄 form5.frm

📁 VB和ACCESS作的图书馆管理软件
💻 FRM
字号:
VERSION 5.00
Begin VB.Form Form5 
   Caption         =   "添加书籍系统"
   ClientHeight    =   5730
   ClientLeft      =   60
   ClientTop       =   450
   ClientWidth     =   5580
   LinkTopic       =   "Form5"
   ScaleHeight     =   5730
   ScaleWidth      =   5580
   StartUpPosition =   3  'Windows Default
   Begin VB.Frame Frame1 
      Caption         =   "添加书籍"
      Height          =   4695
      Left            =   480
      TabIndex        =   0
      Top             =   720
      Width           =   4095
      Begin VB.TextBox Text6 
         Height          =   375
         Left            =   1320
         TabIndex        =   13
         Top             =   3120
         Width           =   2055
      End
      Begin VB.TextBox Text5 
         Height          =   375
         Left            =   1320
         TabIndex        =   12
         Top             =   2520
         Width           =   2055
      End
      Begin VB.CommandButton Command2 
         Caption         =   "退出"
         Height          =   375
         Left            =   2640
         TabIndex        =   10
         Top             =   3960
         Width           =   855
      End
      Begin VB.CommandButton Command1 
         Caption         =   "确定"
         Height          =   375
         Left            =   720
         TabIndex        =   9
         Top             =   3960
         Width           =   975
      End
      Begin VB.TextBox Text4 
         Height          =   375
         Left            =   1320
         TabIndex        =   8
         Top             =   2040
         Width           =   2055
      End
      Begin VB.TextBox Text3 
         Height          =   375
         Left            =   1320
         TabIndex        =   7
         Top             =   1560
         Width           =   2055
      End
      Begin VB.TextBox Text2 
         Height          =   375
         Left            =   1320
         TabIndex        =   6
         Top             =   1080
         Width           =   2055
      End
      Begin VB.TextBox Text1 
         Height          =   375
         Left            =   1320
         TabIndex        =   5
         Top             =   600
         Width           =   2055
      End
      Begin VB.Label Label6 
         Caption         =   "出版社"
         Height          =   375
         Left            =   360
         TabIndex        =   14
         Top             =   3120
         Width           =   855
      End
      Begin VB.Label Label5 
         Caption         =   "数量"
         Height          =   375
         Left            =   360
         TabIndex        =   11
         Top             =   2640
         Width           =   735
      End
      Begin VB.Label Label4 
         Caption         =   "作者"
         Height          =   255
         Left            =   480
         TabIndex        =   4
         Top             =   2160
         Width           =   615
      End
      Begin VB.Label Label3 
         Caption         =   "价格"
         Height          =   255
         Left            =   480
         TabIndex        =   3
         Top             =   1680
         Width           =   735
      End
      Begin VB.Label Label2 
         Caption         =   "书籍ID"
         Height          =   255
         Left            =   480
         TabIndex        =   2
         Top             =   1200
         Width           =   615
      End
      Begin VB.Label Label1 
         Caption         =   "书籍名称"
         Height          =   255
         Left            =   480
         TabIndex        =   1
         Top             =   720
         Width           =   855
      End
   End
End
Attribute VB_Name = "Form5"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub Command1_Click()
   Dim cnn1 As ADODB.Connection
   Dim userpword As ADODB.Recordset
   Dim strcnn As String
   
    If Trim(Text1.Text) = "" Then
        MsgBox "请输入书籍名称!", vbOKOnly + vbExclamation, "警告"
        Text1.SetFocus
        Exit Sub
    Else
        strcnn = "Provider=MSDASQL.1;Persist Security Info=False;Data Source=db1"
        Set cnn1 = New ADODB.Connection
        cnn1.Open strcnn
        Set userpword = New ADODB.Recordset
        userpword.LockType = adLockOptimistic
        userpword.Open "select * from address", cnn1, , , adCmdText
        While (userpword.EOF = False)
            If Trim(userpword.Fields(0)) = Trim(Text1.Text) Then
                MsgBox "书籍已经存在,请重新输入书名!", vbOKOnly + vbExclamation, "警告"
                Text1.SetFocus
                Text1.Text = ""
                Text2.Text = ""
                Text3.Text = ""
                Text4.Text = ""
                Exit Sub
            Else
                userpword.MoveNext
            End If
        Wend
    End If
    
    
        If Text2.Text = "" Then
            MsgBox "编号不能为空!", vbOKOnly + vbExclamation, "警告"
            Text2.SetFocus
            Text2.Text = ""
        Else
        If Text3.Text = "" Then
            MsgBox "价格不能为空!", vbOKOnly + vbExclamation, "警告"
            Text3.SetFocus
            Text3.Text = ""
        Else
        If Text3.Text = "" Then
            MsgBox "作者名不能为空!", vbOKOnly + vbExclamation, "警告"
            Text3.SetFocus
            Text3.Text = ""
        Else
        If Text4.Text = "" Then
         MsgBox "出版社不能为空!", vbOKOnly + vbExclamation, "警告"
            Text4.SetFocus
            Text4.Text = ""
        Else
            userpword.AddNew
            userpword.Fields(0) = Trim(Text1.Text)
            userpword.Fields(1) = Trim(Text2.Text)
            userpword.Fields(2) = Trim(Text3.Text)
            userpword.Fields(3) = Trim(Text4.Text)
            userpword.Fields(4) = Trim(Text5.Text)
            userpword.Update
            userpword.Close
            MsgBox "添加成功!", vbOKOnly + vbExclamation, "添加用户"
        End If
        End If
        End If
    End If

End Sub

Private Sub Command2_Click()
    Unload Me
    Form4.Show
End Sub

⌨️ 快捷键说明

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