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

📄 frmappendmerchandise.frm

📁 VB数据库设计的代码。需要根据自己的数据库再作调整
💻 FRM
字号:
VERSION 5.00
Begin VB.Form frmAppendMerchandise 
   BorderStyle     =   1  'Fixed Single
   Caption         =   "补货信息"
   ClientHeight    =   3075
   ClientLeft      =   45
   ClientTop       =   330
   ClientWidth     =   4050
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MinButton       =   0   'False
   ScaleHeight     =   3075
   ScaleWidth      =   4050
   StartUpPosition =   1  '所有者中心
   Begin VB.CommandButton cmdCancle 
      Caption         =   "放弃"
      Height          =   375
      Left            =   2378
      TabIndex        =   11
      Top             =   2520
      Width           =   735
   End
   Begin VB.CommandButton cmdApply 
      Caption         =   "申请"
      Height          =   375
      Left            =   938
      TabIndex        =   10
      Top             =   2520
      Width           =   735
   End
   Begin VB.TextBox txtAppendCount 
      Height          =   300
      Left            =   1440
      TabIndex        =   9
      Text            =   "Text1"
      Top             =   1680
      Width           =   2415
   End
   Begin VB.TextBox txtApplyCount 
      Height          =   300
      Left            =   1440
      TabIndex        =   7
      Text            =   "txtApplyCount"
      Top             =   1290
      Width           =   2415
   End
   Begin VB.ComboBox cmbMerchandise 
      Height          =   300
      Left            =   1440
      Style           =   2  'Dropdown List
      TabIndex        =   6
      Top             =   900
      Width           =   2415
   End
   Begin VB.ComboBox cmbMerchandiseKind 
      Height          =   300
      Left            =   1440
      Style           =   2  'Dropdown List
      TabIndex        =   5
      Top             =   510
      Width           =   2415
   End
   Begin VB.ComboBox cmbShopName 
      Height          =   300
      Left            =   1440
      Style           =   2  'Dropdown List
      TabIndex        =   4
      Top             =   120
      Width           =   2415
   End
   Begin VB.Label lblErrorInfo 
      Caption         =   "lblErrorInfo"
      ForeColor       =   &H000000FF&
      Height          =   255
      Left            =   120
      TabIndex        =   12
      Top             =   2040
      Width           =   3735
   End
   Begin VB.Label Label5 
      AutoSize        =   -1  'True
      Caption         =   "实际补货数量"
      Height          =   180
      Left            =   120
      TabIndex        =   8
      Top             =   1740
      Width           =   1080
   End
   Begin VB.Label Label4 
      AutoSize        =   -1  'True
      Caption         =   "申请补货数量"
      Height          =   180
      Left            =   120
      TabIndex        =   3
      Top             =   1350
      Width           =   1080
   End
   Begin VB.Label Label3 
      AutoSize        =   -1  'True
      Caption         =   "商 品 名 称"
      Height          =   180
      Left            =   120
      TabIndex        =   2
      Top             =   960
      Width           =   990
   End
   Begin VB.Label Label2 
      AutoSize        =   -1  'True
      Caption         =   "商 品 类 别"
      Height          =   180
      Left            =   120
      TabIndex        =   1
      Top             =   570
      Width           =   990
   End
   Begin VB.Label Label1 
      AutoSize        =   -1  'True
      Caption         =   "申请补货店名"
      Height          =   180
      Left            =   120
      TabIndex        =   0
      Top             =   180
      Width           =   1080
   End
End
Attribute VB_Name = "frmAppendMerchandise"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit

Private m_OpModiFlag As Boolean             '修改操作标志
Private m_Apply As clsAppendMerchandise     '当前商品
Private m_CurrentUser As clsOpuser          '当前操作用户

'***********************************************************************
'* 过程名:IniComboxShop
'* 功  能:初始化连锁店下拉框
'* 参  数:
'* 版  本:2006.01.04 颜志军 初版
'***********************************************************************
Private Sub IniComboxShop()
    '变量定义
    Dim shopList As clsMembershopSet        '连锁店集合
    Dim singleShop As clsMembershop         '连锁店
    Dim index As Integer                    '索引
    Dim curIndex As Integer                 '当前显示项
    
    '生成类别集合
    Set shopList = New clsMembershopSet
    
    '初始化COMBOX列表
    index = 0
    curIndex = 0
    For Each singleShop In shopList
        If singleShop.shopId > 1 Then
            cmbShopName.AddItem singleShop.shopName, index
            cmbShopName.ItemData(index) = singleShop.shopId
            If m_CurrentUser.shopId = singleShop.shopId Then
                curIndex = index
            End If
            index = index + 1
        End If
    Next
    
    '初始化显示项
    If cmbShopName.ListCount > 0 Then
        cmbShopName.ListIndex = curIndex
    End If
End Sub

'***********************************************************************
'* 过程名:IniComboxKind
'* 功  能:初始化商品类别下拉框
'* 参  数:
'* 版  本:2006.01.04 颜志军 初版
'***********************************************************************
Private Sub IniComboxKind()
    '变量定义
    Dim kindList As clsMerchandisekindSet   '商品类别集合
    Dim singleKind As clsMerchandisekind    '商品类别
    Dim index As Integer                    '索引
    
    '生成类别集合
    Set kindList = New clsMerchandisekindSet
    
    '初始化COMBOX列表
    index = 0
    For Each singleKind In kindList
        cmbMerchandiseKind.AddItem singleKind.kindName, index
        cmbMerchandiseKind.ItemData(index) = singleKind.kindId
        index = index + 1
    Next
    
    '初始化显示项
    If cmbMerchandiseKind.ListCount > 0 Then
        cmbMerchandiseKind.ListIndex = 0
    End If
End Sub

'***********************************************************************
'* 过程名:IniComboxMerchandise
'* 功  能:初始化商品名称下拉框
'* 参  数:
'* 版  本:2006.01.04 颜志军 初版
'***********************************************************************
Private Sub IniComboxMerchandise()
    '变量定义
    Dim merchandiseList As clsMerchandiseinfoSet    '商品集合
    Dim merchandise As clsMerchandiseinfo           '商品
    Dim merchandiseKind As Integer                  '商品类别
    Dim index As Integer                            '索引
    
    '生成商品集合
    Set merchandiseList = New clsMerchandiseinfoSet
    If cmbMerchandiseKind.ListIndex >= 0 Then
        merchandiseKind = cmbMerchandiseKind.ItemData(cmbMerchandiseKind.ListIndex)
        merchandiseList.LoadSetByKindId merchandiseKind
    End If
    
    '清除原有项
    cmbMerchandise.Clear
    
    '初始化COMBOX列表
    index = 0
    For Each merchandise In merchandiseList
        cmbMerchandise.AddItem merchandise.merchandiseName, index
        cmbMerchandise.ItemData(index) = merchandise.merchandiseId
        index = index + 1
    Next
    
    '初始化显示项
    If cmbMerchandise.ListCount > 0 Then
        cmbMerchandise.ListIndex = 0
    End If
End Sub

'***********************************************************************
'* 过程名:DspInfo
'* 功  能:显示补货信息
'* 参  数:
'* 版  本:2006.01.04 颜志军 初版
'***********************************************************************
Private Sub DspInfo()
    '清空错误信息显示标签
    lblErrorInfo.Caption = ""
    
    '连锁店下拉框
    IniComboxShop
    '商品类别下拉框
    IniComboxKind
    '商品名称下拉框
    IniComboxMerchandise
    
    '其它控件显示设定
    If m_OpModiFlag Then    '修改
        txtApplyCount.Text = m_Apply.applyCount
        If m_CurrentUser.userRank < 4 Then
            If m_Apply.appendCount >= 0 Then
                txtAppendCount.Text = m_Apply.appendCount
            Else
                txtAppendCount.Text = m_Apply.applyCount
            End If
        ElseIf m_CurrentUser.userRank = 4 Then
            If m_Apply.appendCount >= 0 Then
                txtAppendCount.Text = m_Apply.appendCount
            Else
                txtAppendCount.Text = ""
            End If
        End If
    Else    '新增
        txtApplyCount.Text = ""
        txtAppendCount.Text = ""
    End If
    
    '控件可用状态控制
    SetCtlSate
End Sub

'***********************************************************************
'* 过程名:SetCtlSate
'* 功  能:设定控件状态
'* 参  数:
'* 版  本:2006.01.04 颜志军 初版
'***********************************************************************
Private Sub SetCtlSate()
    If m_CurrentUser.userRank = 4 Then  '店操作员
        cmbShopName.Enabled = False
        txtAppendCount.Enabled = False
        cmdApply.Caption = "申请"
    Else
        cmdApply.Caption = "核准"
        cmbShopName.Enabled = False
        cmbMerchandiseKind.Enabled = False
        cmbMerchandise.Enabled = False
        txtApplyCount.Enabled = False
    End If
    
    '已核准申请,不可修改
    If m_OpModiFlag And m_Apply.appendCount >= 0 Then
        cmbMerchandiseKind.Enabled = False
        cmbMerchandise.Enabled = False
        txtApplyCount.Enabled = False
        txtAppendCount.Enabled = False
        cmdApply.Enabled = False
    End If
End Sub

'***********************************************************************
'* 函数名:CheckInput
'* 功  能:检查输入信息
'* 参  数:
'* 返回值:Boolean                  True 通过 False 未通过
'* 版  本:2006.01.03 颜志军 初版
'***********************************************************************
Private Function CheckInput() As Boolean
    If m_CurrentUser.userRank = 4 Then
        If IsEmpty(Trim(txtApplyCount.Text)) Or Trim(txtApplyCount.Text) = "" Then
            lblErrorInfo.Caption = "必须输入补货数量!"
            CheckInput = False
        ElseIf IsEmpty(Trim(cmbMerchandise.Text)) Or Trim(cmbMerchandise.Text) = "" Then
            lblErrorInfo.Caption = "必须选择商品!"
            CheckInput = False
        Else
            CheckInput = True
        End If
    Else
        If IsEmpty(Trim(txtAppendCount.Text)) Or Trim(txtAppendCount.Text) = "" _
              Then
            lblErrorInfo.Caption = "必须输入核准补货数量!"
            CheckInput = False
        Else
            CheckInput = True
        End If
    End If
End Function

'***********************************************************************
'* 函数名:UpdateObject
'* 功  能:更新设定信息到对象
'* 参  数:
'* 返回值:Boolean
'* 版  本:2006.01.04 颜志军 初版
'***********************************************************************
Private Function UpdateObject() As Boolean
    m_Apply.shopId = m_CurrentUser.shopId
    If CheckInput() Then
        m_Apply.merchandiseId = cmbMerchandise.ItemData(cmbMerchandise.ListIndex)
        m_Apply.applyCount = CInt(Trim(txtApplyCount.Text))
        If m_CurrentUser.userRank < 4 Then
            m_Apply.appendCount = CInt(Trim(txtAppendCount.Text))
        End If
        UpdateObject = True
    Else
        UpdateObject = False
    End If
End Function

'***********************************************************************
'* 过程名:ShowDlg
'* 功  能:显示对话框
'* 参  数:
'* 版  本:2006.01.04 颜志军 初版
'***********************************************************************
Public Sub ShowDlg(ByRef curApply As clsAppendMerchandise, _
            ByVal opFlag As Boolean, _
            ByVal currentUser As clsOpuser)
    Set m_Apply = curApply
    Set m_CurrentUser = currentUser
    m_OpModiFlag = opFlag
    DspInfo
    Me.Show vbModal
End Sub

'***********************************************************************
'* 过程名:cmbMerchandiseKind_Click
'* 功  能:商品类别选择框CLICK事件响应
'* 参  数:
'* 版  本:2006.01.04 颜志军 初版
'***********************************************************************
Private Sub cmbMerchandiseKind_Click()
    IniComboxMerchandise
End Sub

'***********************************************************************
'* 过程名:cmdApply_Click
'* 功  能:cmdApply按钮CLICK事件响应
'* 参  数:
'* 版  本:2006.01.04 颜志军 初版
'***********************************************************************
Private Sub cmdApply_Click()
    '更新信息
    If Not UpdateObject() Then
        Exit Sub
    End If
    
    '变量定义
    Dim DbOpResult As DbOpResult
    
    If m_CurrentUser.userRank = 4 Then '店操作员,申请操作
        If m_OpModiFlag Then    '修改
            DbOpResult = m_Apply.Update
        Else    '追加
            DbOpResult = m_Apply.AppendNew
        End If
    Else '核准操作
        DbOpResult = m_Apply.UpdateAllow
    End If
    
    '检查结果
    Select Case DbOpResult
    Case DbOpNG
        lblErrorInfo = "数据库操作失败!"
    Case DbOpRecNoExist
        lblErrorInfo = "补货ID不存在!"
    Case DbOpOk
        Unload Me
    End Select
End Sub

'***********************************************************************
'* 过程名:cmdCancle_Click
'* 功  能:cmdCancle按钮CLICK事件响应
'* 参  数:
'* 版  本:2006.01.04 颜志军 初版
'***********************************************************************
Private Sub cmdCancle_Click()
    Unload Me
End Sub

⌨️ 快捷键说明

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