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

📄 main.frm

📁 这个是完整的数据库商品管理系统,有完整的源代码,本人测试过了,非常好用.里面还有详细的说明!
💻 FRM
字号:
VERSION 5.00
Begin VB.MDIForm frmMain 
   BackColor       =   &H8000000C&
   Caption         =   "商品销售管理系统"
   ClientHeight    =   5295
   ClientLeft      =   165
   ClientTop       =   735
   ClientWidth     =   7335
   LinkTopic       =   "MDIForm1"
   StartUpPosition =   3  '窗口缺省
   Begin VB.Menu mnuSystem 
      Caption         =   "系统(&S)"
      Begin VB.Menu mnuSystemUser 
         Caption         =   "用户管理(&U)"
      End
      Begin VB.Menu mnuSystemLogin 
         Caption         =   "重新登录(&L)..."
      End
      Begin VB.Menu mnuSystemBar 
         Caption         =   "-"
      End
      Begin VB.Menu mnuSystemExit 
         Caption         =   "退出(&X)"
      End
   End
   Begin VB.Menu mnuProduct 
      Caption         =   "商品信息(&P)"
      Begin VB.Menu mnuProductAdd 
         Caption         =   "添加商品信息(&A)"
      End
      Begin VB.Menu mnuProductList 
         Caption         =   "显示商品列表(&L)"
      End
      Begin VB.Menu mnuProductChart 
         Caption         =   "商品库存状态(&S)"
      End
      Begin VB.Menu mnuProductFind 
         Caption         =   "查询商品信息(&F)..."
      End
   End
   Begin VB.Menu mnuStock 
      Caption         =   "进货(S)"
      Begin VB.Menu mnuStockAdd 
         Caption         =   "添加进货信息(&A)"
      End
      Begin VB.Menu mnuStockList 
         Caption         =   "显示进货列表(&L)"
      End
      Begin VB.Menu mnuStockFind 
         Caption         =   "查询进货信息(&F)..."
      End
   End
   Begin VB.Menu mnuSell 
      Caption         =   "销售(&I)"
      Begin VB.Menu mnuSellAdd 
         Caption         =   "添加销售信息(&A)"
      End
      Begin VB.Menu mnuSellList 
         Caption         =   "显示销售列表(&L)"
      End
      Begin VB.Menu mnuSellFind 
         Caption         =   "查询销售信息(&C)..."
      End
   End
   Begin VB.Menu mnuHelp 
      Caption         =   "帮助(&H)"
      Begin VB.Menu mnuHelpAbout 
         Caption         =   "关于(&A)..."
      End
   End
End
Attribute VB_Name = "frmMain"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit

Private Sub MDIForm_Load()
    On Error GoTo errHandler
     
    '取得上次退出时窗体的位置,并将当前窗口的位置还原
    Me.Left = GetSetting(App.Title, "Settings", "MainLeft", 1000)
    Me.Top = GetSetting(App.Title, "Settings", "MainTop", 1000)
    Me.Width = GetSetting(App.Title, "Settings", "MainWidth", 6500)
    Me.Height = GetSetting(App.Title, "Settings", "MainHeight", 6500)
    
    '根据不同的身份,来确定不同的菜单项的可用性
    Select Case gnUserType
        Case 0: '若为管理员
            mnuSystem.Visible = True
            mnuProduct.Visible = True
            mnuStock.Visible = True
            mnuSell.Visible = True
            mnuHelp.Visible = True
        Case 1: '若为仓管人员
            mnuSystem.Visible = False
            mnuProduct.Visible = False
            mnuStock.Visible = True
            mnuSell.Visible = False
            mnuHelp.Visible = True
        Case 2: '若为销售人员
            mnuSystem.Visible = False
            mnuProduct.Visible = False
            mnuStock.Visible = False
            mnuSell.Visible = True
            mnuHelp.Visible = True
        End Select
    
    Exit Sub
    
errHandler:
    MsgBox Err.Description, vbCritical, "错误"
End Sub

Private Sub MDIForm_Unload(Cancel As Integer)
    '在注册表中保存窗体退出时的位置
    If Me.WindowState <> vbMinimized Then
        SaveSetting App.Title, "Settings", "MainLeft", Me.Left
        SaveSetting App.Title, "Settings", "MainTop", Me.Top
        SaveSetting App.Title, "Settings", "MainWidth", Me.Width
        SaveSetting App.Title, "Settings", "MainHeight", Me.Height
    End If
    
    On Error Resume Next
    '关闭数据连接
    gConn.Close
End Sub


Private Sub mnuHelpAbout_Click()
    frmAbout.Show vbModal
End Sub

Private Sub mnuProductAdd_Click()
    frmProduct.mbAddMode = True
    frmProduct.Show vbModal
End Sub

Private Sub mnuProductChart_Click()
    '以图形方式显示商品的库存数量
    Dim rs As New ADODB.Recordset
    rs.Open "select * from products", gConn, adOpenStatic

    Load frmChart
    frmChart.Caption = "当前商品的库存状态"
    
    '给MS Chart控件赋数值
    Dim arr()
    ReDim arr(1 To rs.RecordCount, 1 To 2)
    Dim i As Integer
    i = 1
    rs.MoveFirst
    Dim str As String
    While Not rs.EOF
        str = Trim(rs("商品名称"))
        arr(i, 1) = "" & str & ""
        arr(i, 2) = rs("库存数量")
        i = i + 1
        rs.MoveNext
    Wend
            
    With frmChart.charReport
        .Title = "当前商品的库存状态"
        .ChartData = arr
    End With
    
    rs.Close
    
    frmChart.Show vbModal
End Sub

Private Sub mnuProductFind_Click()
    mnuProductList_Click
    frmProductList.cmdFind.Value = True
End Sub

Private Sub mnuProductList_Click()
    Load frmProductList
    frmProductList.SQL = "select * from products"
    frmProductList.Show
End Sub

Private Sub mnuSellAdd_Click()
    frmSell.mbAddMode = True
    frmSell.Show vbModal
End Sub

Private Sub mnuSellFind_Click()
    mnuSellList_Click
    frmSellList.cmdFind.Value = True
End Sub

Private Sub mnuSellList_Click()
    Load frmSellList
    frmSellList.SQL = "select * from sell"
    frmSellList.Show
End Sub

Private Sub mnuStockAdd_Click()
    frmStock.mbAddMode = True
    frmStock.Show vbModal
End Sub

Private Sub mnuStockFind_Click()
    mnuStockList_Click
    frmStockList.cmdFind.Value = True
End Sub

Private Sub mnuStockList_Click()
    Load frmStockList
    frmStockList.SQL = "select * from stock"
    frmStockList.Show
End Sub

Private Sub mnuSystemExit_Click()
    Unload Me
End Sub

Private Sub mnuSystemLogin_Click()
    Unload Me
    frmLogin.Show
End Sub

Private Sub mnuSystemUser_Click()
    frmUser.Show
End Sub

⌨️ 快捷键说明

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