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

📄 frmaddproduct.frm

📁 数据库课程设计
💻 FRM
字号:
VERSION 5.00
Begin VB.Form frmAddProduct 
   Caption         =   "产品添加"
   ClientHeight    =   2835
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   6735
   LinkTopic       =   "Form1"
   ScaleHeight     =   2835
   ScaleWidth      =   6735
   StartUpPosition =   3  'Windows Default
   Begin VB.CommandButton Command1 
      Caption         =   "返回(&C)"
      Height          =   375
      Left            =   3600
      TabIndex        =   14
      Top             =   2280
      Width           =   1215
   End
   Begin VB.CommandButton cmdAdd 
      Caption         =   "添加(&A)"
      Height          =   375
      Left            =   1680
      TabIndex        =   13
      Top             =   2280
      Width           =   1215
   End
   Begin VB.Frame Frame1 
      Caption         =   "产品信息"
      Height          =   1935
      Left            =   120
      TabIndex        =   0
      Top             =   120
      Width           =   6495
      Begin VB.TextBox txtProduct 
         Height          =   285
         Index           =   1
         Left            =   4440
         TabIndex        =   12
         Text            =   "Text5"
         Top             =   480
         Width           =   1695
      End
      Begin VB.TextBox txtProduct 
         Height          =   285
         Index           =   4
         Left            =   1440
         TabIndex        =   8
         Text            =   "Text4"
         Top             =   1440
         Width           =   1215
      End
      Begin VB.TextBox txtProduct 
         Height          =   285
         Index           =   3
         Left            =   4440
         TabIndex        =   7
         Text            =   "Text3"
         Top             =   960
         Width           =   1215
      End
      Begin VB.TextBox txtProduct 
         Height          =   285
         Index           =   2
         Left            =   1440
         TabIndex        =   6
         Text            =   "Text2"
         Top             =   960
         Width           =   1215
      End
      Begin VB.TextBox txtProduct 
         Height          =   285
         Index           =   0
         Left            =   1440
         TabIndex        =   2
         Text            =   "Text1"
         Top             =   480
         Width           =   1815
      End
      Begin VB.Label Label6 
         Caption         =   "产品编号:"
         Height          =   255
         Left            =   3480
         TabIndex        =   11
         Top             =   480
         Width           =   975
      End
      Begin VB.Label Label5 
         Caption         =   "(元)"
         Height          =   255
         Index           =   1
         Left            =   5760
         TabIndex        =   10
         Top             =   960
         Width           =   375
      End
      Begin VB.Label Label5 
         Caption         =   "(元)"
         Height          =   255
         Index           =   0
         Left            =   2760
         TabIndex        =   9
         Top             =   960
         Width           =   375
      End
      Begin VB.Label Label4 
         Caption         =   "产品数量:"
         Height          =   375
         Left            =   480
         TabIndex        =   5
         Top             =   1440
         Width           =   975
      End
      Begin VB.Label Label3 
         Caption         =   "产品成本:"
         Height          =   255
         Left            =   3480
         TabIndex        =   4
         Top             =   960
         Width           =   1095
      End
      Begin VB.Label Label2 
         Caption         =   "产品价格:"
         Height          =   375
         Left            =   480
         TabIndex        =   3
         Top             =   960
         Width           =   1095
      End
      Begin VB.Label Label1 
         Caption         =   "产品名称:"
         Height          =   375
         Left            =   480
         TabIndex        =   1
         Top             =   480
         Width           =   975
      End
   End
End
Attribute VB_Name = "frmAddProduct"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit

Public sqlStr As String
Public msgText As String

Private Sub cmdAdd_Click()
 Dim rstProduct As ADODB.Recordset
 Dim i As Integer
  
 For i = 0 To 3
    If txtProduct(i).Text = "" Then
    
       MsgBox "请将信息填写完整", vbOKOnly + vbExclamation, "警告"
 
       Exit Sub
    
    End If
 Next i

 '添加新记录
 sqlStr = "select * from products"
 Set rstProduct = ExecuteSQL(sqlStr, msgText)
 rstProduct.AddNew
 rstProduct.Fields("productName") = txtProduct(0).Text
 rstProduct.Fields("productID") = txtProduct(1).Text
 rstProduct.Fields("price") = txtProduct(2).Text
 rstProduct.Fields("cost") = txtProduct(3).Text
 rstProduct.Fields("stored") = txtProduct(4).Text
 rstProduct.Update
 rstProduct.Close
     
 MsgBox "产品信息添加完成!", vbOKOnly + vbExclamation, "警告"
 
 For i = 0 To 4
    txtProduct(i).Text = ""
 Next i

End Sub

Private Sub Command1_Click()
Unload Me
End Sub

Private Sub Form_Load()
Dim i As Integer
For i = 0 To 4
   txtProduct(i).Text = ""
Next i
End Sub

⌨️ 快捷键说明

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