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

📄 delfixed.frm

📁 感觉还可以了 大家看看 指点下 有什么不足的地方,大家多多指教啊
💻 FRM
字号:
VERSION 5.00
Begin VB.Form DelFixed 
   Caption         =   "删除"
   ClientHeight    =   2775
   ClientLeft      =   60
   ClientTop       =   450
   ClientWidth     =   3780
   LinkTopic       =   "Form1"
   ScaleHeight     =   2775
   ScaleWidth      =   3780
   StartUpPosition =   3  'Windows Default
   Begin VB.Frame Frame1 
      Caption         =   "删除资产记录"
      Height          =   2535
      Left            =   120
      TabIndex        =   0
      Top             =   120
      Width           =   3495
      Begin VB.TextBox FID 
         Appearance      =   0  'Flat
         Height          =   270
         Left            =   240
         TabIndex        =   3
         Top             =   720
         Width           =   3015
      End
      Begin VB.CommandButton Command1 
         Caption         =   "删除"
         Default         =   -1  'True
         Height          =   495
         Left            =   240
         TabIndex        =   2
         Top             =   1200
         Width           =   3015
      End
      Begin VB.CommandButton Command2 
         Cancel          =   -1  'True
         Caption         =   "退出"
         Height          =   495
         Left            =   240
         TabIndex        =   1
         Top             =   1800
         Width           =   3015
      End
      Begin VB.Label Label1 
         Caption         =   "欲删除固定资产ID编号"
         Height          =   255
         Left            =   240
         TabIndex        =   4
         Top             =   480
         Width           =   2775
      End
   End
End
Attribute VB_Name = "DelFixed"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit

Private Sub Command1_Click()
    Dim sql As String
    Dim rs As New ADODB.Recordset
    Dim i As Integer
    If FID.Text = "" Then       '固定资产编号对话框不可为空
        MsgBox "请输入固定资产编号!", vbExclamation
        FID.SetFocus
        Exit Sub
    End If
    
    If DbHandle.DbConnection Then       '检查输入的固定资产记录是否存在
        sql = "TBL_FIXED"
        rs.CursorType = adOpenDynamic
        rs.LockType = adLockOptimistic
        rs.Filter = "FIXED_ID='" & FID.Text & "'"
        rs.Open sql, DbFinance
        If DbHandle.resultcount(rs) <> 1 Then       '不存在固定资产记录删除失败,退出
            MsgBox "错误,不存在的固定资产记录!", vbExclamation
            FID.SetFocus
            rs.Close
            Set rs = Nothing
            DbHandle.DbClose
            Exit Sub
        End If
        rs.Delete       '找到这样的记录,删除记录,并且释放结果集,显示删除成功并且退出
        rs.Close
        Set rs = Nothing
        DbHandle.DbClose
        MsgBox "固定资产记录【" & FID.Text & "】删除成功。"
        Unload Me
    Else        '连接数据库失败退出
        MsgBox "数据库错误!", vbExclamation
        DbHandle.DbClose
        End
    End If
End Sub

Private Sub Command2_Click()
    Me.Hide     '返回主窗体
End Sub

Private Sub Form_Load()
    Me.Left = (Screen.Width - Me.ScaleWidth) / 2        '窗体居中显示
    Me.Top = (Screen.Height - Me.ScaleHeight) / 2
End Sub

Private Sub Form_Unload(Cancel As Integer)
    On Error Resume Next
    DbHandle.DbClose        '窗体关闭时关闭数据库连接
End Sub

⌨️ 快捷键说明

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