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

📄 frmwpzldj.frm

📁 物流管理系统实例程序
💻 FRM
字号:
VERSION 5.00
Object = "{F0D2F211-CCB0-11D0-A316-00AA00688B10}#1.0#0"; "MSDATLST.OCX"
Begin VB.Form frmWpzldj 
   BorderStyle     =   3  'Fixed Dialog
   Caption         =   "物品种类登记"
   ClientHeight    =   4095
   ClientLeft      =   1125
   ClientTop       =   1740
   ClientWidth     =   7215
   HelpContextID   =   2
   Icon            =   "frmWpzldj.frx":0000
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MinButton       =   0   'False
   ScaleHeight     =   4095
   ScaleWidth      =   7215
   ShowInTaskbar   =   0   'False
   StartUpPosition =   1  '所有者中心
   WhatsThisButton =   -1  'True
   WhatsThisHelp   =   -1  'True
   Begin VB.Frame Frame1 
      Height          =   3495
      Left            =   120
      TabIndex        =   6
      Top             =   0
      Width           =   6975
      Begin VB.TextBox txtSm 
         Height          =   1815
         Left            =   2640
         MaxLength       =   255
         MultiLine       =   -1  'True
         ScrollBars      =   2  'Vertical
         TabIndex        =   2
         Top             =   1440
         Width           =   4095
      End
      Begin VB.CommandButton cmdDel 
         Caption         =   "删除(&D)"
         Height          =   360
         Left            =   5400
         TabIndex        =   4
         Top             =   795
         Width           =   1275
      End
      Begin VB.CommandButton cmdAdd 
         Caption         =   "添加(&A)"
         Height          =   360
         Left            =   5400
         TabIndex        =   3
         Top             =   360
         Width           =   1275
      End
      Begin VB.TextBox txtLbID 
         Height          =   300
         Left            =   2640
         MaxLength       =   8
         TabIndex        =   1
         Top             =   600
         Width           =   2415
      End
      Begin MSDataListLib.DataList dblLblb 
         Height          =   2790
         Left            =   240
         TabIndex        =   0
         Top             =   480
         Width           =   2055
         _ExtentX        =   3625
         _ExtentY        =   4921
         _Version        =   393216
         ListField       =   ""
         BoundColumn     =   ""
      End
      Begin VB.Label Label1 
         AutoSize        =   -1  'True
         Caption         =   "说明:"
         Height          =   180
         Index           =   3
         Left            =   2640
         TabIndex        =   9
         Top             =   1200
         Width           =   450
      End
      Begin VB.Label Label1 
         AutoSize        =   -1  'True
         Caption         =   "类别ID:"
         Height          =   180
         Index           =   0
         Left            =   2640
         TabIndex        =   8
         Top             =   360
         Width           =   630
      End
      Begin VB.Label Label1 
         AutoSize        =   -1  'True
         Caption         =   "物品类别列表:"
         Height          =   180
         Index           =   2
         Left            =   240
         TabIndex        =   7
         Top             =   240
         Width           =   1170
      End
   End
   Begin VB.CommandButton cmdExit 
      Cancel          =   -1  'True
      Caption         =   "关闭"
      Height          =   360
      Left            =   5400
      TabIndex        =   5
      Tag             =   "确定"
      Top             =   3600
      Width           =   1260
   End
End
Attribute VB_Name = "frmWpzldj"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Dim WithEvents rs As ADODB.Recordset
Attribute rs.VB_VarHelpID = -1

Private Sub cmdAdd_Click()
        '追加新记录
        On Error Resume Next
        rs.AddNew
        rs("类别ID") = "新类别"
        rs("说明") = ""
        txtLbID.SetFocus
End Sub

Private Sub cmdDel_Click()
    On Error Resume Next
    '删除记录
    Dim intWpzs As Integer
    Dim rsWpzsTj As ADODB.Recordset
    Set rsWpzsTj = mCdt.rsWpzsTj_WpLB(rs("类别ID"))
    intWpzs = rsWpzsTj(0)
    rsWpzsTj.Close
    
    If intWpzs > 0 Then
        MsgBox "该物品类别下已有物品,不能被删除!", vbInformation
        Exit Sub
    End If
    
    If Not (rs.EOF Or rs.BOF) Then
        rs.Delete
        rs.MoveNext
    End If
End Sub

Private Sub cmdExit_Click()
    On Error Resume Next
    rs.Update
    Unload Me
End Sub

Private Sub dblLblb_Click()
    On Error Resume Next
    Dim strLbID As String
    strLbID = dblLblb.Text
    rs.MoveFirst
    rs.Find "类别ID='" & strLbID & "'"
End Sub

Private Sub Form_Load()
    On Error Resume Next
    Set rs = mCdt.rsWPLBDJ
    Set dblLblb.RowSource = rs
    dblLblb.ListField = "类别ID"
    Set txtLbID.DataSource = rs
    txtLbID.DataField = "类别ID"
    Set txtSm.DataSource = rs
    txtSm.DataField = "说明"
End Sub

Private Sub Form_Unload(Cancel As Integer)
    On Error Resume Next
    rs.Close
    Set rs = Nothing
End Sub

Private Sub rs_MoveComplete(ByVal adReason As ADODB.EventReasonEnum, ByVal pError As ADODB.Error, adStatus As ADODB.EventStatusEnum, ByVal pRecordset As ADODB.Recordset)
    rsRefresh
End Sub

Private Sub txtLbID_GotFocus()
    txtLbID.SelStart = 0
    txtLbID.SelLength = Len(txtLbID)
End Sub

Private Sub txtLbID_LostFocus()
    '检验数据
    On Error Resume Next
    If Trim(txtLbID) = "" Then
        MsgBox "类别ID不能为空字串!", vbExclamation
        txtLbID.SetFocus
        Exit Sub
    End If
    
    rs.Update
    
    Select Case Err
        Case 0
            rsRefresh
        Case -2147467259
            MsgBox "类别ID发生重名冲突!", vbExclamation
            txtLbID.SetFocus
        Case Else
            txtLbID.SetFocus
    End Select
End Sub

Private Sub rsRefresh()
    On Error Resume Next
    If rs.AbsolutePosition < 1 Then
        txtLbID.Enabled = False
        txtSm.Enabled = False
        cmdDel.Enabled = False
    Else
        txtLbID.Enabled = True
        txtSm.Enabled = True
        cmdDel.Enabled = True
    End If
End Sub

Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
    On Error Resume Next
    If rs.BOF Or rs.EOF Then
        Exit Sub
    End If
    
    If (rs.EditMode = adEditAdd Or rs.EditMode = adEditInProgress) Then
        Cancel = 1
    End If
End Sub

⌨️ 快捷键说明

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