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

📄 frmaddgood.frm

📁 库存信息管理系统.本系统要实现的功能如下:商品类别信息管理,商品信息管理,库存操作信息管理,各种报表信息打印,数据表信息导出,操作员管理.
💻 FRM
字号:
VERSION 5.00
Begin VB.Form FrmAddGood 
   BorderStyle     =   3  'Fixed Dialog
   Caption         =   "商品信息添加"
   ClientHeight    =   6495
   ClientLeft      =   45
   ClientTop       =   330
   ClientWidth     =   6465
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MDIChild        =   -1  'True
   MinButton       =   0   'False
   ScaleHeight     =   6495
   ScaleWidth      =   6465
   ShowInTaskbar   =   0   'False
   Begin VB.CommandButton Command2 
      Caption         =   "退出"
      Height          =   375
      Left            =   3600
      TabIndex        =   15
      Top             =   5400
      Width           =   1215
   End
   Begin VB.CommandButton Command1 
      Caption         =   "添加"
      Height          =   375
      Left            =   1680
      TabIndex        =   14
      Top             =   5400
      Width           =   1095
   End
   Begin VB.Frame Frame1 
      Caption         =   "商品信息添加"
      Height          =   5055
      Left            =   120
      TabIndex        =   0
      Top             =   120
      Width           =   5895
      Begin VB.TextBox txtIntroduction 
         Height          =   1455
         Left            =   1440
         MultiLine       =   -1  'True
         ScrollBars      =   2  'Vertical
         TabIndex        =   13
         Top             =   3360
         Width           =   3255
      End
      Begin VB.TextBox txtStock 
         Height          =   270
         Left            =   1440
         TabIndex        =   11
         Top             =   2760
         Width           =   1695
      End
      Begin VB.TextBox txtPrice 
         Height          =   375
         Left            =   1440
         TabIndex        =   8
         Top             =   2040
         Width           =   1575
      End
      Begin VB.ComboBox CB_GoodUnit 
         Height          =   300
         Left            =   1440
         TabIndex        =   5
         Top             =   1440
         Width           =   1215
      End
      Begin VB.ComboBox CB_GoodClass 
         Height          =   300
         Left            =   1440
         TabIndex        =   4
         Top             =   840
         Width           =   2535
      End
      Begin VB.TextBox txtGoodName 
         Height          =   375
         Left            =   1440
         TabIndex        =   2
         Top             =   240
         Width           =   2535
      End
      Begin VB.Label Label7 
         Caption         =   "商品介绍:"
         Height          =   495
         Left            =   240
         TabIndex        =   12
         Top             =   3360
         Width           =   1095
      End
      Begin VB.Label Label6 
         Caption         =   "商品库存:"
         Height          =   495
         Left            =   240
         TabIndex        =   10
         Top             =   2760
         Width           =   1095
      End
      Begin VB.Label Label5 
         Caption         =   "元"
         Height          =   375
         Left            =   3120
         TabIndex        =   9
         Top             =   2040
         Width           =   615
      End
      Begin VB.Label Label4 
         Caption         =   "商品单价:"
         Height          =   495
         Left            =   240
         TabIndex        =   7
         Top             =   2040
         Width           =   1095
      End
      Begin VB.Label Label3 
         Caption         =   "商品单位:"
         Height          =   495
         Left            =   240
         TabIndex        =   6
         Top             =   1440
         Width           =   1095
      End
      Begin VB.Label Label2 
         Caption         =   "商品类别:"
         Height          =   495
         Left            =   240
         TabIndex        =   3
         Top             =   960
         Width           =   1095
      End
      Begin VB.Label Label1 
         Caption         =   "商品名称:"
         Height          =   495
         Left            =   240
         TabIndex        =   1
         Top             =   360
         Width           =   1095
      End
   End
End
Attribute VB_Name = "FrmAddGood"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub Command1_Click()
  Dim sql As String
  Dim goodInfoRs As ADODB.Recordset
  Dim goodNameRs As ADODB.Recordset
  Dim goodClassInfoArray As Variant
  
  If Me.txtGoodName.Text = "" Then
    MsgBox "请输入商品名称!"
    Me.txtGoodName.SetFocus
    Exit Sub
  End If
  
  If Me.CB_GoodClass.Text = "" Then
    MsgBox "请选择商品类别!"
    Exit Sub
  End If

  If Me.CB_GoodUnit.Text = "" Then
    MsgBox "请选择商品单位信息!"
    Exit Sub
  End If
  
  
  If Me.txtPrice.Text = "" Then
    MsgBox "请输入商品单价!"
    Me.txtPrice.SetFocus
    Exit Sub
  End If
  If Me.txtStock.Text = "" Then
    MsgBox "请输入商品库存信息!"
    Me.txtStock.SetFocus
    Exit Sub
  End If
  
  Call check_condatabase
  sql = "select goodName from goodInfo where goodName = '" & Me.txtGoodName.Text & "'"
  Set goodNameRs = cn.Execute(sql)
  If Not goodNameRs.EOF Then
    MsgBox "对不起,此商品名称的信息系统已经存在了!"
    Exit Sub
  End If
  goodNameRs.Close
  Set goodNameRs = Nothing
  
  sql = "select * from goodInfo"
  Set goodInfoRs = New ADODB.Recordset
  Set goodInfoRs.ActiveConnection = cn
  goodInfoRs.LockType = adLockOptimistic
  goodInfoRs.CursorType = adOpenKeyset
  goodInfoRs.Open sql
  
  goodInfoRs.AddNew '添加新商品信息
  goodInfoRs("goodName") = Me.txtGoodName.Text
  goodClassInfoArray = Split(Me.CB_GoodClass.Text, "-")
  goodInfoRs("goodClassId") = CInt(goodClassInfoArray(0))
  goodInfoRs("goodUnit") = Me.CB_GoodUnit.Text
  goodInfoRs("oneGoodPrice") = CCur(Me.txtPrice.Text)
  goodInfoRs("stock") = CInt(Me.txtStock.Text)
  goodInfoRs("goodIntroduction") = Me.txtIntroduction.Text
  goodInfoRs("addTime") = Now
  goodInfoRs.Update
  
  MsgBox "商品信息添加成功!"
  Me.txtGoodName.Text = ""
  Me.CB_GoodClass.Text = ""
  Me.CB_GoodUnit.Text = ""
  Me.txtPrice.Text = ""
  Me.txtStock.Text = ""
  Me.txtIntroduction.Text = ""
  Me.txtGoodName.SetFocus
  
  
  
End Sub

Private Sub Command2_Click()
  Unload Me
End Sub

Private Sub Form_Load()
  Dim goodClassRs As ADODB.Recordset '保存所有商品类别的结果集
  Dim goodUnitNameRs As ADODB.Recordset '保存商品单位的结果集
  Dim sql As String '查询sql
  
  Call check_condatabase '连接数据库
  
  sql = "select unitName from unitName"
  Set goodUnitNameRs = cn.Execute(sql)
  While Not goodUnitNameRs.EOF
    Me.CB_GoodUnit.AddItem goodUnitNameRs("unitName")
    goodUnitNameRs.MoveNext
  Wend
  sql = "select * from goodClass"
  Set goodClassRs = cn.Execute(sql)
  While Not goodClassRs.EOF
    Me.CB_GoodClass.AddItem (goodClassRs("goodClassId") & "-" & goodClassRs("goodClassName"))
    goodClassRs.MoveNext
  Wend
End Sub

⌨️ 快捷键说明

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