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

📄 frmmntenanceedit.frm

📁 vb与access数据库的操作实例
💻 FRM
字号:
VERSION 5.00
Begin VB.Form FrmMntenanceEdit 
   Caption         =   "编辑设备维护信息"
   ClientHeight    =   3525
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   6180
   LinkTopic       =   "Form1"
   ScaleHeight     =   3525
   ScaleWidth      =   6180
   StartUpPosition =   2  '屏幕中心
   Begin VB.TextBox txtMnSum 
      Height          =   330
      Left            =   1080
      TabIndex        =   18
      Text            =   "0"
      Top             =   1920
      Width           =   1575
   End
   Begin VB.TextBox txtMnName 
      Height          =   330
      Left            =   4320
      TabIndex        =   12
      Top             =   2355
      Width           =   1575
   End
   Begin VB.TextBox txtMnDate 
      Height          =   330
      Left            =   1080
      TabIndex        =   11
      Top             =   2355
      Width           =   1575
   End
   Begin VB.CommandButton Cmd_Exit 
      Caption         =   "取 消"
      Height          =   375
      Left            =   3443
      TabIndex        =   8
      Top             =   3000
      Width           =   1215
   End
   Begin VB.CommandButton Cmd_OK 
      Caption         =   "确 定"
      Height          =   375
      Left            =   1523
      TabIndex        =   7
      Top             =   3000
      Width           =   1215
   End
   Begin VB.Frame Frame1 
      Caption         =   "设备信息"
      Height          =   1695
      Left            =   120
      TabIndex        =   0
      Top             =   120
      Width           =   5895
      Begin VB.CommandButton Cmd_DeviceSel 
         Caption         =   "选择"
         Height          =   375
         Left            =   2760
         TabIndex        =   17
         Top             =   285
         Width           =   735
      End
      Begin VB.TextBox txtId 
         Enabled         =   0   'False
         Height          =   330
         Left            =   960
         TabIndex        =   15
         Top             =   285
         Width           =   1575
      End
      Begin VB.TextBox txtUnit 
         Enabled         =   0   'False
         Height          =   330
         Left            =   4200
         TabIndex        =   10
         Top             =   1200
         Width           =   1575
      End
      Begin VB.TextBox txtTypeName 
         Enabled         =   0   'False
         Height          =   330
         Left            =   960
         TabIndex        =   9
         Top             =   1200
         Width           =   1575
      End
      Begin VB.TextBox txtModel 
         Enabled         =   0   'False
         Height          =   330
         Left            =   4200
         TabIndex        =   5
         Top             =   765
         Width           =   1575
      End
      Begin VB.TextBox txtName 
         Enabled         =   0   'False
         Height          =   330
         Left            =   960
         TabIndex        =   2
         Top             =   765
         Width           =   1575
      End
      Begin VB.Label Label4 
         AutoSize        =   -1  'True
         Caption         =   "设备编号"
         Height          =   180
         Left            =   120
         TabIndex        =   16
         Top             =   360
         Width           =   720
      End
      Begin VB.Label Label8 
         AutoSize        =   -1  'True
         Caption         =   "分类名称"
         Height          =   180
         Left            =   120
         TabIndex        =   6
         Top             =   1275
         Width           =   720
      End
      Begin VB.Label Label5 
         AutoSize        =   -1  'True
         Caption         =   "设备型号"
         Height          =   180
         Left            =   3360
         TabIndex        =   4
         Top             =   840
         Width           =   720
      End
      Begin VB.Label Label3 
         AutoSize        =   -1  'True
         Caption         =   "计量单位"
         Height          =   180
         Left            =   3360
         TabIndex        =   3
         Top             =   1245
         Width           =   720
      End
      Begin VB.Label Label1 
         AutoSize        =   -1  'True
         Caption         =   "设备名称"
         Height          =   180
         Left            =   120
         TabIndex        =   1
         Top             =   840
         Width           =   720
      End
   End
   Begin VB.Label Label6 
      AutoSize        =   -1  'True
      Caption         =   "维护费用"
      Height          =   180
      Left            =   240
      TabIndex        =   19
      Top             =   1995
      Width           =   720
   End
   Begin VB.Label Label2 
      AutoSize        =   -1  'True
      Caption         =   "维护日期"
      Height          =   180
      Left            =   240
      TabIndex        =   14
      Top             =   2430
      Width           =   720
   End
   Begin VB.Label Label9 
      AutoSize        =   -1  'True
      Caption         =   "维 护 人"
      Height          =   180
      Left            =   3480
      TabIndex        =   13
      Top             =   2430
      Width           =   720
   End
End
Attribute VB_Name = "FrmMntenanceEdit"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Public Modify As Boolean '插入=false,修改=true
Public OriId As Long  '维护编号

Private Sub Cmd_DeviceSel_Click()
  FrmDeviceSel.nFlag = 1   '设置选择设备
  FrmDeviceSel.Show 1      '设备选择窗体
  '读取指定对象信息
  txtId = Trim(MyDeviceSel.Id)          '设备编号
  txtName = Trim(MyDeviceSel.Name)      '设备名称
  txtModel = Trim(MyDeviceSel.Model)    '设备型号
  '取得分类名称
  If MyType.GetInfo(MyDeviceSel.TypeId) = True Then
    txtTypeName = Trim(MyType.TypeName)
  Else
    txtTypeName = ""
  End If
  txtUnit = Trim(MyDeviceSel.Unit)      '计量单位
End Sub

Private Sub Cmd_Exit_Click()
  Unload Me
End Sub

Private Sub Cmd_OK_Click()
  '检查用户录入数据的有效性
  If Len(Trim(txtId)) = 0 Then
    MsgBox ("请选择设备")
    Cmd_DeviceSel.SetFocus
    Exit Sub
  End If
  If Len(Trim(txtMnName)) = 0 Then
    MsgBox "请输入维护人员"
    txtMnName.SetFocus
    Exit Sub
  End If
  If Len(Trim(txtMnDate)) = 0 Then
    MsgBox "请输入维护日期"
    txtMnDate.SetFocus
    Exit Sub
  End If
  '把用户录入的数据赋值到数据库对象变量中
  With MyMaintenance
    .DevId = MakeStr(txtId)
    .MnName = MakeStr(txtMnName)
    .MnDate = MakeStr(txtMnDate)
    .MnSum = Val(txtMnSum)
    '根据变量Modify的值,决定是插入新数据,还是修改已有的数据
    If Modify = False Then
      .Insert
    Else
      .Update (OriId)
    End If
  End With
  '关闭窗口
  Unload Me
End Sub

⌨️ 快捷键说明

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