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

📄 frmmtype.frm

📁 《超市进销存管理系统的开发与实现》 2、开发工具 Microsoft Visual Basic 6.0 3、运行环境 (1)、硬件环境 486DX/66MHz或更高
💻 FRM
字号:
VERSION 5.00
Begin VB.Form frmMType 
   BorderStyle     =   3  'Fixed Dialog
   Caption         =   "商品类型信息"
   ClientHeight    =   3180
   ClientLeft      =   2760
   ClientTop       =   3750
   ClientWidth     =   5655
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MinButton       =   0   'False
   ScaleHeight     =   3180
   ScaleWidth      =   5655
   ShowInTaskbar   =   0   'False
   Begin VB.Frame fraMerchType 
      Caption         =   "商品类型信息"
      Height          =   2175
      Left            =   240
      TabIndex        =   4
      Top             =   240
      Width           =   5055
      Begin VB.TextBox txtName 
         Height          =   375
         Left            =   1200
         MaxLength       =   18
         TabIndex        =   0
         Text            =   "txtName"
         Top             =   263
         Width           =   2535
      End
      Begin VB.TextBox txtRemark 
         Height          =   1215
         Left            =   1200
         MultiLine       =   -1  'True
         ScrollBars      =   2  'Vertical
         TabIndex        =   1
         Text            =   "frmMType.frx":0000
         Top             =   840
         Width           =   3735
      End
      Begin VB.Label Label2 
         AutoSize        =   -1  'True
         Caption         =   "说明"
         Height          =   180
         Left            =   360
         TabIndex        =   6
         Top             =   840
         Width           =   360
      End
      Begin VB.Label Label1 
         AutoSize        =   -1  'True
         Caption         =   "类型名"
         Height          =   180
         Left            =   360
         TabIndex        =   5
         Top             =   360
         Width           =   540
      End
   End
   Begin VB.CommandButton CancelButton 
      Caption         =   "取消"
      Height          =   330
      Left            =   4200
      TabIndex        =   3
      Top             =   2640
      Width           =   1215
   End
   Begin VB.CommandButton OKButton 
      Caption         =   "确定"
      Height          =   330
      Left            =   2760
      TabIndex        =   2
      Top             =   2640
      Width           =   1215
   End
End
Attribute VB_Name = "frmMType"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False

Option Explicit
Private OK As Boolean             '确定用户按了OK还是CANCEL按钮
Private m_obj As clsMType         '数据对象,用来存储用户输入数据
Public m_ViewType As gxcViewType  '显示状态,指添加还是修改

'根据是“新增”还是“修改”,确定显示内容
Private Sub SetStatus()
  
  '设置控件默认值
  Call SetDefaultValue
  
  '设置状态
  Select Case m_ViewType
  Case vtadd    '添加
    CancelButton.Visible = True
    OKButton.Caption = "确定"
  Case vtModify '修改
    CancelButton.Visible = True
    OKButton.Caption = "保存"
  End Select

End Sub

'打开对话框,并传出用户输入数据
Public Function ShowDlg(ByRef obj As Object, _
                        ByVal eViewType As gxcViewType _
                        ) As Boolean
  '保存数据
  Set m_obj = obj         '用户输入数据存放于此对象中
  m_ViewType = eViewType  '对话框状态
  
  '根据新增、编辑或查看设置显示内容
  SetStatus
  
  '显示对话框
  OK = False
  Me.Show vbModal
  If OK = False Then Exit Function
  
  '保存数据
  Set obj = m_obj
  
  '返回并释放对话框
  ShowDlg = True
  Unload Me
  
End Function

'设置控件默认值
Private Sub SetDefaultValue()
  Dim ctl As Control
  Dim i As Integer
 
 '如果是新增,则清空所有文本框
 '此处判断 m_obj为空与判断m_ViewType = vtAdd等效,但更安全
  If m_obj Is Nothing Then
    For Each ctl In Controls
      If TypeOf ctl Is TextBox Then
        ctl.Text = ""
      End If
    Next
  Else  '用传入对象的值更新数据
    With m_obj
      txtName.Text = .TypeName
      txtRemark.Text = .Remark
    End With
  End If
  
End Sub

'检查输入有效性
Private Function CheckValid() As Boolean
  If txtName.Text = "" _
    Or txtRemark.Text = "" Then
    MsgBox "请填写完毕以上各项内容"
    CheckValid = False
    Exit Function
  End If
  
  CheckValid = True
  
End Function

'保存数据
Private Sub SaveValue()
  '给“成员变量”对象赋值
  With m_obj
    '注意以下利用RealString函数替换去除输入中的单引号
    .TypeName = RealString(txtName.Text)
    .Remark = RealString(txtRemark.Text)
  End With

End Sub

'取消按钮
Private Sub CancelButton_Click()
  Unload Me
End Sub

'确定按钮
Private Sub OKButton_Click()
  OK = True
  
  '检测输入有效性
  If Not CheckValid Then Exit Sub
  
  '如果是新增状态,则初始化一个数据对象
  If m_ViewType = vtadd Then Set m_obj = New clsMType
  
  '保存用户输入
  SaveValue
  Me.Hide
  
End Sub

⌨️ 快捷键说明

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