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

📄 frmdg.frm

📁 财务管理系统的基本功能的实现
💻 FRM
字号:
VERSION 5.00
Begin VB.Form frmdg 
   Caption         =   "删除工资记录"
   ClientHeight    =   2175
   ClientLeft      =   60
   ClientTop       =   450
   ClientWidth     =   4395
   LinkTopic       =   "Form1"
   ScaleHeight     =   2175
   ScaleWidth      =   4395
   StartUpPosition =   3  '窗口缺省
   Begin VB.TextBox Text1 
      Height          =   390
      Left            =   1320
      TabIndex        =   4
      Top             =   120
      Width           =   2655
   End
   Begin VB.ComboBox Combo1 
      Height          =   300
      ItemData        =   "frmdg.frx":0000
      Left            =   1320
      List            =   "frmdg.frx":0002
      TabIndex        =   3
      Top             =   825
      Width           =   1215
   End
   Begin VB.ComboBox Combo2 
      Height          =   300
      Left            =   2880
      TabIndex        =   2
      Top             =   840
      Width           =   855
   End
   Begin VB.CommandButton Command1 
      Caption         =   "删除"
      Default         =   -1  'True
      Height          =   495
      Left            =   720
      TabIndex        =   1
      Top             =   1560
      Width           =   855
   End
   Begin VB.CommandButton Command2 
      Caption         =   "取消"
      Height          =   495
      Left            =   2640
      TabIndex        =   0
      Top             =   1560
      Width           =   855
   End
   Begin VB.Label Label1 
      AutoSize        =   -1  'True
      BackStyle       =   0  'Transparent
      Caption         =   "职工ID"
      Height          =   180
      Left            =   360
      TabIndex        =   8
      Top             =   240
      Width           =   540
   End
   Begin VB.Label Label3 
      AutoSize        =   -1  'True
      BackStyle       =   0  'Transparent
      Caption         =   "工资月份"
      Height          =   180
      Left            =   360
      TabIndex        =   7
      Top             =   840
      Width           =   720
   End
   Begin VB.Label Label4 
      Caption         =   "年"
      Height          =   255
      Left            =   2640
      TabIndex        =   6
      Top             =   870
      Width           =   255
   End
   Begin VB.Label Label5 
      Caption         =   "月"
      Height          =   255
      Left            =   3840
      TabIndex        =   5
      Top             =   870
      Width           =   255
   End
End
Attribute VB_Name = "frmdg"
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 paydate As String
    
    If Text1.Text = "" Then     '检查输入数据有效性
        MsgBox "职工ID不能为空!", vbCritical
        Text1.SetFocus
        Exit Sub
    End If
    If Combo1.ListIndex = -1 Then
        MsgBox "年份必须选择!", vbCritical
        Combo1.SetFocus
        Exit Sub
    End If
    If Combo2.ListIndex = -1 Then
        MsgBox "月份必须选择!", vbCritical
        Combo2.SetFocus
        Exit Sub
    End If
    paydate = Combo1.List(Combo1.ListIndex) & "-" & Combo2.List(Combo2.ListIndex)
    '组合年月成为一体的日期
    If DbHandle.DbConnection Then
        sql = "TBL_USER"        '从职工表中判断是否存在输入的职工ID
        rs.CursorType = adOpenDynamic
        rs.LockType = adLockOptimistic
        rs.Filter = "USER_ID='" & Text1.Text & "'"
        rs.Open sql, DbFinance
        If DbHandle.resultcount(rs) <> 1 Then       '不存在提示出错,并且释放数据库,退出
            MsgBox "错误,不存在的职工ID号!", vbExclamation
            Text1.SetFocus
            rs.Close
            Set rs = Nothing
            DbHandle.DbClose
            Exit Sub
        End If
        rs.Close        '存在输入职工ID,在工资表中查看工资记录是否存在
        sql = "TBL_PAY"
        rs.CursorType = adOpenDynamic
        rs.LockType = adLockOptimistic
        rs.Filter = "PAY_USER='" & Text1.Text & "' AND PAY_DATE='" & paydate & "'"
        rs.Open sql, DbFinance
        If DbHandle.resultcount(rs) <> 1 Then       '不存在,无法删除
            MsgBox "工资记录不存在!", vbExclamation
            rs.Close
            DbHandle.DbClose
            Exit Sub
        End If
        rs.Delete       '存在,删除工资记录,提示成功,返回主窗体
        rs.Close
        DbHandle.DbClose
        MsgBox "工资记录已经成功删除!"
        Unload Me
    Else        '数据库连接出错,退出
        MsgBox "数据库错误!", vbExclamation
        DbHandle.DbClose
        End
    End If
End Sub

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

Private Sub Form_Load()
    Dim i As Long
    
    Me.Left = (Screen.Width - Me.ScaleWidth) / 2        '窗体居中显示
    Me.Top = (Screen.Height - Me.ScaleHeight) / 2
    For i = 2003 To 2030        '设置年月下拉列表2003-2030年间
        Combo1.AddItem Trim(Str(i))
    Next i
    For i = 1 To 12     '1-12月间
        Combo2.AddItem Trim(Str(i))
    Next i
    Text1.Text = ""     '设置窗体元素初始化属性
    Combo1.Text = ""
    Combo2.Text = ""
End Sub

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

Private Sub Frame1_DragDrop(Source As Control, X As Single, Y As Single)

End Sub

⌨️ 快捷键说明

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