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

📄 frmgoods.frm

📁 visual basic +sql sever2000开发的商品进销存管理系统
💻 FRM
字号:
VERSION 5.00
Begin VB.Form frmGoods 
   BorderStyle     =   1  'Fixed Single
   Caption         =   "商品管理"
   ClientHeight    =   4455
   ClientLeft      =   45
   ClientTop       =   330
   ClientWidth     =   6930
   LinkTopic       =   "Form1"
   LockControls    =   -1  'True
   MaxButton       =   0   'False
   ScaleHeight     =   4455
   ScaleWidth      =   6930
   StartUpPosition =   1  '所有者中心
   Begin VB.Frame Frame1 
      Height          =   4545
      Left            =   0
      TabIndex        =   9
      Top             =   -90
      Width           =   6930
      Begin VB.TextBox txt 
         Height          =   270
         Index           =   2
         Left            =   3120
         MaxLength       =   50
         TabIndex        =   2
         Top             =   1170
         Width           =   1155
      End
      Begin VB.TextBox txt 
         Height          =   660
         Index           =   4
         Left            =   1260
         MaxLength       =   500
         MultiLine       =   -1  'True
         ScrollBars      =   2  'Vertical
         TabIndex        =   6
         Top             =   3105
         Width           =   5250
      End
      Begin VB.TextBox txt 
         Height          =   660
         Index           =   3
         Left            =   1260
         MaxLength       =   500
         MultiLine       =   -1  'True
         ScrollBars      =   2  'Vertical
         TabIndex        =   5
         Top             =   2334
         Width           =   5250
      End
      Begin VB.ComboBox cbo 
         Height          =   300
         Index           =   1
         Left            =   1260
         Style           =   2  'Dropdown List
         TabIndex        =   4
         Top             =   1935
         Width           =   5250
      End
      Begin VB.ComboBox cbo 
         Height          =   300
         Index           =   0
         Left            =   1260
         Style           =   2  'Dropdown List
         TabIndex        =   3
         Top             =   1545
         Width           =   5250
      End
      Begin VB.CommandButton cmdCancel 
         Cancel          =   -1  'True
         Caption         =   "取消(&C)"
         Height          =   375
         Left            =   5325
         TabIndex        =   8
         Top             =   3960
         Width           =   1080
      End
      Begin VB.CommandButton cmdGoods 
         Caption         =   "添加(&A)"
         Height          =   375
         Left            =   4020
         TabIndex        =   7
         Top             =   3960
         Width           =   1080
      End
      Begin VB.PictureBox picTitle 
         Appearance      =   0  'Flat
         BackColor       =   &H00808080&
         BorderStyle     =   0  'None
         ForeColor       =   &H80000008&
         Height          =   360
         Left            =   30
         ScaleHeight     =   360
         ScaleWidth      =   6870
         TabIndex        =   12
         TabStop         =   0   'False
         Top             =   90
         Width           =   6870
         Begin VB.Label lblTitle 
            AutoSize        =   -1  'True
            BackStyle       =   0  'Transparent
            Caption         =   "添加商品"
            BeginProperty Font 
               Name            =   "宋体"
               Size            =   10.5
               Charset         =   134
               Weight          =   700
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            ForeColor       =   &H00FFFFFF&
            Height          =   210
            Left            =   255
            TabIndex        =   13
            Top             =   90
            Width           =   900
         End
      End
      Begin VB.TextBox txt 
         Height          =   270
         Index           =   1
         Left            =   1260
         TabIndex        =   1
         Text            =   "0"
         Top             =   1176
         Width           =   1155
      End
      Begin VB.TextBox txt 
         Height          =   270
         Index           =   0
         Left            =   1260
         MaxLength       =   50
         TabIndex        =   0
         Top             =   810
         Width           =   5250
      End
      Begin VB.Label lbl 
         AutoSize        =   -1  'True
         BackStyle       =   0  'Transparent
         Caption         =   "商品备注"
         Height          =   180
         Index           =   6
         Left            =   450
         TabIndex        =   18
         Top             =   3150
         Width           =   720
      End
      Begin VB.Label lbl 
         AutoSize        =   -1  'True
         BackStyle       =   0  'Transparent
         Caption         =   "商品介绍"
         Height          =   180
         Index           =   5
         Left            =   450
         TabIndex        =   17
         Top             =   2400
         Width           =   720
      End
      Begin VB.Label lbl 
         AutoSize        =   -1  'True
         BackStyle       =   0  'Transparent
         Caption         =   "供货商"
         Height          =   180
         Index           =   4
         Left            =   450
         TabIndex        =   16
         Top             =   2016
         Width           =   540
      End
      Begin VB.Label lbl 
         AutoSize        =   -1  'True
         BackStyle       =   0  'Transparent
         Caption         =   "商品类型"
         Height          =   180
         Index           =   3
         Left            =   450
         TabIndex        =   15
         Top             =   1634
         Width           =   720
      End
      Begin VB.Label lbl 
         AutoSize        =   -1  'True
         BackStyle       =   0  'Transparent
         Caption         =   "单位"
         Height          =   180
         Index           =   2
         Left            =   2700
         TabIndex        =   14
         Top             =   1215
         Width           =   360
      End
      Begin VB.Label lbl 
         AutoSize        =   -1  'True
         BackStyle       =   0  'Transparent
         Caption         =   "库存数量"
         Height          =   180
         Index           =   1
         Left            =   450
         TabIndex        =   11
         Top             =   1252
         Width           =   720
      End
      Begin VB.Label lbl 
         AutoSize        =   -1  'True
         BackStyle       =   0  'Transparent
         Caption         =   "商品名称"
         Height          =   180
         Index           =   0
         Left            =   450
         TabIndex        =   10
         Top             =   870
         Width           =   720
      End
   End
End
Attribute VB_Name = "frmGoods"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Dim Goods As clsGoods     '商品对象

'验证用户输入的有效性
Private Function IsOK() As Boolean
  '除介绍和备注外的项目必须全部填写
  If cbo(0).Text = "" Or cbo(1).Text = "" Or txt(0) = "" Or txt(1) = "" Or txt(2) = "" Then
     MsgBox "除介绍和备注外,请把所有项目填写完整!", vbInformation
     Exit Function
  End If
    
  '库存数量必须为数字
  If Not IsNumeric(txt(1)) Then
     MsgBox "库存数量不是数字,请重新填写!", vbInformation
     txt(1).SetFocus
     Exit Function
  End If
  
  '返回函数值
  IsOK = True
End Function

Private Sub cmdGoods_Click()
  '用户输入无效则退出该过程的执行
  If Not IsOK Then Exit Sub
  
  '初始化商品对象
  Set Goods = New clsGoods
  With Goods
    '为商品对象的属性赋值
    .GoodsName = Trim(txt(0))
    .Amount = Val(txt(1))
    .UnitName = Trim(txt(2))
    .TypeId = cbo(0).ItemData(cbo(0).ListIndex)
    .SupplierID = cbo(1).ItemData(cbo(1).ListIndex)
    .Introduce = IIf(Trim(txt(3)) = "", "无", RTrim(txt(3)))
    .Remark = IIf(Trim(txt(4)) = "", "无", RTrim(txt(4)))
    '根据cmdGoods的Caption属性修改或添加商品对象
    Select Case cmdGoods.Caption
      Case "修改(&M)": UpdateGoods  '修改商品对象
      Case Else: AddNewGoods        '添加商品对象
    End Select
  End With
  txt(0).SetFocus
End Sub

'更新商品对象
Private Sub UpdateGoods()
  Dim UpdateResult As gxcUpdate   '更新结果
  '指定商品对象的ID属性
  Goods.ID = Me.Tag
  '更新商品对象并返回更新结果
  UpdateResult = Goods.Update
  
  Dim Goodses As New clsGoodses   '商品对象集
  '按照编号查询更新后的商品对象
  Goodses.Query Goods.ID
  '同步更新列表视图并弹出提示消息框
  ProcUpdateResult UpdateResult, Goodses.Item(1)
End Sub

'添加商品对象
Private Sub AddNewGoods()
  Dim AddNewResult As gxcAddNew   '添加结果
  '添加商品对象并返回添加结果
  AddNewResult = Goods.AddNew
  '添加成功之后的操作
  If AddNewResult = AddNewOK Then
     txt(0) = "": txt(1) = "0": txt(2) = "": txt(3) = "": txt(4) = ""
     
     Dim Goodses As New clsGoodses      '商品对象集
     '按照编号查询刚添加的商品对象
     Goodses.Query Goods.ID
     '当前操作处于浏览商品信息状态,则在列表视图上添加商品信息
     If CurrentOperation = BrowseGoods Then ShowObjInLvw Goodses.Item(1)
     MsgBox "添加成功!", vbInformation
     Exit Sub
  End If
  '添加失败后的操作(消息框提示用户)
  ProcAddNewResult AddNewResult
End Sub

Private Sub cmdCancel_Click()
  Unload Me
End Sub

Private Sub Form_Load()
  Dim GoodsTypes As New clsGoodsTypes   '商品类型对象集
  Dim Suppliers As New clsSuppliers     '供货商对象集
  Dim i As Long
  
  '检索所有商品类型
  GoodsTypes.Query
  '将商品类型名称和编号添加到组合框
  For i = 1 To GoodsTypes.Count
    cbo(0).AddItem GoodsTypes.Item(i).TypeName
    cbo(0).ItemData(i - 1) = GoodsTypes.Item(i).ID
  Next i
  '检索所有供货商
  Suppliers.Query
  '将供货商名称和编号添加到组合框
  For i = 1 To Suppliers.Count
    cbo(1).AddItem Suppliers.Item(i).SupplierName
    cbo(1).ItemData(i - 1) = Suppliers.Item(i).ID
  Next i
End Sub

'文本框获得焦点时选中所有文字
Private Sub txt_GotFocus(Index As Integer)
  txt(Index).SelStart = 0                   '选中文字的起始位置
  txt(Index).SelLength = Len(txt(Index))    '选中文字的长度
End Sub

⌨️ 快捷键说明

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