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

📄 frmproductslist.frm

📁 一个关于进销存的源代码
💻 FRM
字号:
VERSION 5.00
Begin VB.Form frmProductsList 
   Caption         =   "商品管理"
   ClientHeight    =   5325
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   4335
   LinkTopic       =   "Form1"
   ScaleHeight     =   5325
   ScaleWidth      =   4335
   StartUpPosition =   2  '屏幕中心
   Begin VB.Frame Frame3 
      Caption         =   "--操作栏--"
      Height          =   735
      Left            =   120
      TabIndex        =   10
      Top             =   4200
      Width           =   4095
      Begin VB.CommandButton CmdUp 
         Caption         =   "保存"
         Height          =   375
         Left            =   1680
         TabIndex        =   16
         Top             =   240
         Width           =   735
      End
      Begin VB.CommandButton CmdClose 
         Caption         =   "关闭"
         Height          =   375
         Left            =   3240
         TabIndex        =   15
         Top             =   240
         Width           =   735
      End
      Begin VB.CommandButton CmdDel 
         Caption         =   "删除"
         Height          =   375
         Left            =   2460
         TabIndex        =   14
         Top             =   240
         Width           =   735
      End
      Begin VB.CommandButton CmdSave 
         Caption         =   "保存"
         Height          =   375
         Left            =   1680
         TabIndex        =   13
         Top             =   240
         Width           =   735
      End
      Begin VB.CommandButton CmdEdit 
         Caption         =   "修改"
         Height          =   375
         Left            =   900
         TabIndex        =   12
         Top             =   240
         Width           =   735
      End
      Begin VB.CommandButton CmdAdd 
         Caption         =   "添加"
         Height          =   375
         Left            =   120
         TabIndex        =   11
         Top             =   240
         Width           =   735
      End
   End
   Begin VB.Frame Frame2 
      Caption         =   "--商品信息--"
      Height          =   2895
      Left            =   480
      TabIndex        =   3
      Top             =   1200
      Width           =   3255
      Begin VB.TextBox Text6 
         Height          =   300
         Left            =   1200
         TabIndex        =   9
         Top             =   2400
         Width           =   1815
      End
      Begin VB.TextBox Text5 
         Height          =   300
         Left            =   1200
         TabIndex        =   8
         Top             =   1968
         Width           =   1815
      End
      Begin VB.TextBox Text4 
         Height          =   300
         Left            =   1200
         TabIndex        =   7
         Top             =   1560
         Width           =   1815
      End
      Begin VB.TextBox Text3 
         Height          =   300
         Left            =   1200
         TabIndex        =   6
         Top             =   1104
         Width           =   1815
      End
      Begin VB.TextBox Text2 
         Height          =   300
         Left            =   1200
         TabIndex        =   5
         Top             =   672
         Width           =   1815
      End
      Begin VB.TextBox Text1 
         Height          =   300
         Left            =   1200
         TabIndex        =   4
         Top             =   240
         Width           =   1815
      End
      Begin VB.Label Label8 
         Caption         =   "备注"
         Height          =   255
         Left            =   240
         TabIndex        =   24
         Top             =   2460
         Width           =   975
      End
      Begin VB.Label Label7 
         Caption         =   "库存量"
         Height          =   255
         Left            =   240
         TabIndex        =   23
         Top             =   2028
         Width           =   615
      End
      Begin VB.Label Label6 
         Caption         =   "商品规格"
         Height          =   255
         Left            =   240
         TabIndex        =   22
         Top             =   1596
         Width           =   855
      End
      Begin VB.Label Label5 
         Caption         =   "供应商"
         Height          =   255
         Left            =   240
         TabIndex        =   21
         Top             =   1164
         Width           =   735
      End
      Begin VB.Label Label4 
         Caption         =   "零售价"
         Height          =   255
         Left            =   240
         TabIndex        =   20
         Top             =   732
         Width           =   615
      End
      Begin VB.Label Label3 
         Caption         =   "商品代码"
         Height          =   255
         Left            =   240
         TabIndex        =   19
         Top             =   300
         Width           =   735
      End
   End
   Begin VB.Frame Frame1 
      Caption         =   "--商品浏览--"
      Height          =   975
      Left            =   480
      TabIndex        =   0
      Top             =   120
      Width           =   3255
      Begin VB.ComboBox Combo2 
         Height          =   300
         Left            =   1200
         TabIndex        =   2
         Top             =   600
         Width           =   1815
      End
      Begin VB.ComboBox Combo1 
         Height          =   300
         Left            =   1200
         TabIndex        =   1
         Top             =   240
         Width           =   1815
      End
      Begin VB.Label Label2 
         Caption         =   "商品名称"
         Height          =   255
         Left            =   240
         TabIndex        =   18
         Top             =   600
         Width           =   855
      End
      Begin VB.Label Label1 
         Caption         =   "商品类别"
         Height          =   255
         Left            =   240
         TabIndex        =   17
         Top             =   240
         Width           =   735
      End
   End
End
Attribute VB_Name = "frmProductsList"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Private Sub CmdAdd_Click()
    
    
    
    CmdAdd.Enabled = False
    CmdEdit.Enabled = False
    CmdUp.Visible = False
    CmdSave.Visible = True
    CmdSave.Enabled = True
    
    CmdDel.Enabled = False
    CmdClose.Enabled = True
    
    Combo2.Clear
    ttshow (1)
    ttcls
End Sub

Private Sub CmdClose_Click()
    Unload Me
End Sub

Private Sub CmdDel_Click()
    If Combo1.Text = "" Or Combo2.Text = "" Then
         MsgBox "请选择要删除的商品名称或商品类别", vbOKCancel
         Exit Sub
     End If
     Dim ts As String
     ts = MsgBox("是否删除商品-" & Combo2.Text, vbOKCancel)
     If ts = vbOK Then
            Dim rdst As New ADODB.Recordset
                rdst.Open "delete * from productsList where 商品名称='" & Combo2.Text & "'", g_conn
     ttcls
     Combo2.Clear
     Combo1_click
     End If
End Sub

Private Sub CmdEdit_Click()
    Combo1.Enabled = False
    Combo2.Enabled = False
    CmdAdd.Enabled = False
    CmdEdit.Enabled = False
    
    CmdSave.Visible = False
    
    CmdDel.Enabled = False
    
    CmdUp.Visible = True
    CmdUp.Enabled = True
    ttshow (1)
End Sub

Private Sub CmdSave_Click()
     If Combo1.Text = "" Or Combo2.Text = "" Then
         MsgBox "请输入商品名称和商品类别", vbOKCancel
         Exit Sub
     End If
     Dim ts As String
     ts = MsgBox("是否确定保存商品-" & Combo2.Text, vbOKOnly)
     If ts = vbOK Then
        Dim rdst As New ADODB.Recordset
           rdst.Open "select * from productsList where 商品名称='" & Combo2.Text & "'", g_conn
               If rdst.EOF = False Then
                  MsgBox "商品-" & Combo2.Text & "-已经存在,添加失败!", vbOKOnly
                        ttcls
                        Combo2.Clear
                        CmdAdd.Enabled = True
                        CmdEdit.Enabled = True
                        CmdSave.Enabled = False
                        CmdUp.Enabled = False
                        CmdDel.Enabled = True
                        CmdClose.Enabled = True
                        ttshow (0)
                  Exit Sub
               Else
                 Set rdst = Nothing
                 rdst.Open "insert into productslist values('" & UCase(Text1.Text) & "','" & Text2.Text & "','" & Combo2.Text & "','" & Combo1.Text & "','" & Text3.Text & "','" & Text4.Text & "','" & Text5.Text & "','" & Text6.Text & "')", g_conn
                 MsgBox "保存商品-" & Combo2.Text & "-成功", vbOKOnly
                        ttcls
                        Combo2.Clear
                        CmdAdd.Enabled = True
                        CmdEdit.Enabled = True
                        CmdSave.Enabled = False
                        CmdUp.Enabled = False
                        CmdDel.Enabled = True
                        CmdClose.Enabled = True
                        ttshow (0)
               End If
      End If
End Sub

Private Sub CmdUp_Click()
     If Combo1.Text = "" Or Combo2.Text = "" Then
         MsgBox "请选择要更新的商品名称或商品类别", vbOKCancel
         Exit Sub
     End If
     Dim ts As String
     ts = MsgBox("确定对-" & Combo2.Text & "-信息进行更新?", vbOKCancel)
        If ts = vbOK Then
               Dim rdst As New ADODB.Recordset
                  rdst.Open "update productslist set 商品代码='" & UCase(Text1.Text) & "',零售价='" & Text2.Text & "',供应商='" & Text3.Text & "',商品规格='" & Text4.Text & "',库存量='" & Text5.Text & "',备注='" & Text6.Text & "' where 商品名称='" & Combo2.Text & "'", g_conn
               MsgBox "数据更新成功", vbOKOnly
               CmdAdd.Enabled = True
               CmdEdit.Enabled = True
               CmdSave.Enabled = False
               CmdUp.Enabled = False
               CmdDel.Enabled = True
               CmdClose.Enabled = True
               Combo1.Enabled = True
               Combo2.Enabled = True
               ttshow (0)
        End If
End Sub

Private Sub Combo1_click()
'商品名称
    Combo2.Clear
    ttcls
    Dim rdst As New ADODB.Recordset
    rdst.Open "select * from productslist where 商品类别 = '" & Combo1.Text & "'order by 商品名称 desc", g_conn
        Do While Not rdst.EOF
                If Combo2.List(0) <> rdst!商品名称 Then
                     Combo2.AddItem rdst!商品名称, 0
                End If
            rdst.MoveNext
        Loop
    Combo2.AddItem "", 0
End Sub

Private Sub Combo2_Click()
     On Error Resume Next
     ttcls
     Dim rdst As New ADODB.Recordset
     rdst.Open "select * from productslist where 商品名称='" & Combo2.Text & "'", g_conn
         Text1.Text = rdst.Fields(0).Value
         Text2.Text = rdst.Fields(1).Value
         Text3.Text = rdst.Fields(4).Value
         Text4.Text = rdst.Fields(5).Value
         Text5.Text = rdst.Fields(6).Value
         Text6.Text = rdst.Fields(7).Value
            
End Sub

Private Sub Command1_Click()
    
End Sub

Private Sub Form_Load()
     ttshow (0)
'商品类别
     Combo1.Clear
     CmdSave.Enabled = False
     CmdUp.Enabled = False
     Dim rdst As New ADODB.Recordset
     rdst.Open "select * from Productslist order by 商品类别 desc", g_conn
         Do While Not rdst.EOF
                If Combo1.List(0) <> rdst!商品类别 Then
                   Combo1.AddItem rdst!商品类别, 0
                End If
            rdst.MoveNext
         Loop
     Combo1.AddItem "", 0
     
End Sub

Private Sub ttcls()
    Text1.Text = ""
    Text2.Text = ""
    Text3.Text = ""
    Text4.Text = ""
    Text5.Text = ""
    Text6.Text = ""
End Sub


Private Sub ttshow(xx As Boolean)
    If xx = True Then
        Text1.Enabled = True
        Text2.Enabled = True
        Text3.Enabled = True
        Text4.Enabled = True
        Text5.Enabled = True
        Text6.Enabled = True
    Else
        Text1.Enabled = False
        Text2.Enabled = False
        Text3.Enabled = False
        Text4.Enabled = False
        Text5.Enabled = False
        Text6.Enabled = False
    End If
End Sub

⌨️ 快捷键说明

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