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

📄 frmdbbackup.frm

📁 企业人事管理系统,有考勤,人员管理等功能,值得研究,也是我付费弄来的,绝对超值
💻 FRM
字号:
VERSION 5.00
Object = "{F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.2#0"; "COMDLG32.OCX"
Object = "{0D452EE1-E08F-101A-852E-02608C4D0BB4}#2.0#0"; "FM20.DLL"
Object = "{BDC217C8-ED16-11CD-956C-0000C04E4C0A}#1.1#0"; "TABCTL32.OCX"
Begin VB.Form frmDBBackup 
   BorderStyle     =   1  'Fixed Single
   Caption         =   "数据备份管理"
   ClientHeight    =   5580
   ClientLeft      =   45
   ClientTop       =   330
   ClientWidth     =   6660
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MinButton       =   0   'False
   ScaleHeight     =   5580
   ScaleWidth      =   6660
   StartUpPosition =   1  '所有者中心
   Begin VB.CommandButton cmdWait 
      Caption         =   "备份中......"
      Height          =   735
      Left            =   1920
      TabIndex        =   12
      Top             =   2280
      Visible         =   0   'False
      Width           =   2295
   End
   Begin TabDlg.SSTab SSTab1 
      Height          =   5535
      Left            =   0
      TabIndex        =   0
      Top             =   0
      Width           =   6615
      _ExtentX        =   11668
      _ExtentY        =   9763
      _Version        =   393216
      Tabs            =   2
      Tab             =   1
      TabHeight       =   520
      TabCaption(0)   =   "每日备份"
      TabPicture(0)   =   "frmDBBackup.frx":0000
      Tab(0).ControlEnabled=   0   'False
      Tab(0).Control(0)=   "Frame2"
      Tab(0).Control(0).Enabled=   0   'False
      Tab(0).ControlCount=   1
      TabCaption(1)   =   "手动备份"
      TabPicture(1)   =   "frmDBBackup.frx":001C
      Tab(1).ControlEnabled=   -1  'True
      Tab(1).Control(0)=   "Frame1"
      Tab(1).Control(0).Enabled=   0   'False
      Tab(1).ControlCount=   1
      Begin VB.Frame Frame2 
         Height          =   5055
         Left            =   -74880
         TabIndex        =   7
         Top             =   360
         Width           =   6375
         Begin VB.ListBox lstDB 
            Height          =   4560
            Left            =   120
            TabIndex        =   8
            Top             =   240
            Width           =   3255
         End
         Begin MSForms.CommandButton cmdExit 
            Height          =   495
            Left            =   3960
            TabIndex        =   14
            Top             =   4080
            Width           =   1575
            Caption         =   "退出"
            Size            =   "2778;873"
            FontName        =   "宋体"
            FontHeight      =   180
            FontCharSet     =   134
            FontPitchAndFamily=   34
            ParagraphAlign  =   3
         End
         Begin MSForms.CommandButton cmdRefresh 
            Height          =   495
            Left            =   3960
            TabIndex        =   13
            Top             =   3450
            Width           =   1575
            Caption         =   "刷新列表"
            Size            =   "2778;873"
            FontName        =   "宋体"
            FontHeight      =   180
            FontCharSet     =   134
            FontPitchAndFamily=   34
            ParagraphAlign  =   3
         End
         Begin MSForms.CommandButton cmdBKDay 
            Height          =   495
            Left            =   3960
            TabIndex        =   11
            Top             =   1560
            Width           =   1575
            Caption         =   "备份数据"
            Size            =   "2778;873"
            FontName        =   "宋体"
            FontHeight      =   180
            FontCharSet     =   134
            FontPitchAndFamily=   34
            ParagraphAlign  =   3
         End
         Begin MSForms.CommandButton cmdDel 
            Height          =   495
            Left            =   3960
            TabIndex        =   10
            Top             =   2820
            Width           =   1575
            Caption         =   "删除所选"
            Size            =   "2778;873"
            FontName        =   "宋体"
            FontHeight      =   180
            FontCharSet     =   134
            FontPitchAndFamily=   34
            ParagraphAlign  =   3
         End
         Begin MSForms.CommandButton cmdRTDay 
            Height          =   495
            Left            =   3960
            TabIndex        =   9
            Top             =   2190
            Width           =   1575
            Caption         =   "恢复数据"
            Size            =   "2778;873"
            FontName        =   "宋体"
            FontHeight      =   180
            FontCharSet     =   134
            FontPitchAndFamily=   34
            ParagraphAlign  =   3
         End
      End
      Begin VB.Frame Frame1 
         Caption         =   "数据备份"
         Height          =   1575
         Left            =   120
         TabIndex        =   1
         Top             =   480
         Width           =   6255
         Begin VB.TextBox txtPath 
            Height          =   270
            Left            =   1080
            TabIndex        =   3
            Top             =   1080
            Width           =   4095
         End
         Begin VB.CommandButton cmdPath 
            Caption         =   "..."
            Height          =   255
            Left            =   5280
            TabIndex        =   2
            Top             =   1080
            Width           =   735
         End
         Begin VB.Label Label1 
            Caption         =   "备份路径"
            Height          =   255
            Left            =   120
            TabIndex        =   6
            Top             =   1080
            Width           =   735
         End
         Begin MSForms.CommandButton cmdBackup 
            Height          =   495
            Left            =   2520
            TabIndex        =   5
            Top             =   240
            Width           =   1575
            Caption         =   "备份数据"
            Size            =   "2778;873"
            FontName        =   "宋体"
            FontHeight      =   180
            FontCharSet     =   134
            FontPitchAndFamily=   34
            ParagraphAlign  =   3
         End
         Begin MSForms.CommandButton CommandButton1 
            Height          =   495
            Left            =   4320
            TabIndex        =   4
            Top             =   240
            Width           =   1575
            Caption         =   "恢复数据"
            Size            =   "2778;873"
            FontName        =   "宋体"
            FontHeight      =   180
            FontCharSet     =   134
            FontPitchAndFamily=   34
            ParagraphAlign  =   3
         End
      End
   End
   Begin MSComDlg.CommonDialog cdgBackup 
      Left            =   2160
      Top             =   2400
      _ExtentX        =   847
      _ExtentY        =   847
      _Version        =   393216
   End
End
Attribute VB_Name = "frmDBBackup"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub cmdBackup_Click()
 Dim fso As FileSystemObject
 
 cdgBackup.Filter = "Access数据库文件(*.mdb)|*.mdb"
 cdgBackup.ShowSave
  
  If cdgBackup.FileName = "" Then Exit Sub
  
  If MsgBox("你真的要备份数据库吗?", vbQuestion + vbYesNo) = vbNo Then Exit Sub
  cmdWait.Visible = True
  DoEvents
  Set fso = New FileSystemObject
  fso.CopyFile App.path & "\rsmsdb.mdb", cdgBackup.FileName, True
  Set fso = Nothing
  cmdWait.Visible = False
  MsgBox "备份完毕"

End Sub
'生成每日备份的文件名
Private Function makefilename()
  fname = Date
  fname = Replace(fname, "-", "")
  fname = Replace(fname, " ", "")
  fname = fname & ".mdb"
  makefilename = fname
End Function




Private Sub cmdBKDay_Click()
  
  Dim fso As FileSystemObject
  Dim strFileName As String
  
  Set fso = New FileSystemObject
   If Not fso.FolderExists(pDBBkFldPath) Then
     fso.CreateFolder (pDBBkFldPath)
   End If
  strFileName = makefilename
  For i = 0 To lstDB.ListCount - 1
  '如果今天已经备份过
    If strFileName = lstDB.List(i) Then
     '询问要不要备份
       If MsgBox("数据已经备份,要重新备份吗?", vbQuestion + vbYesNo) = vbYes Then
          cmdWait.Visible = True
          DoEvents
          
         fso.CopyFile App.path & "\rsmsdb.mdb", pDBBkFldPath & "\" & strFileName, True
         Set fso = Nothing
         cmdWait.Visible = False
         MsgBox "备份完毕"
         Call loadDBList
       End If
      Exit Sub
    End If
  Next
  
  '没有备份过
  cmdWait.Visible = True
  DoEvents
  fso.CopyFile App.path & "\rsmsdb.mdb", pDBBkFldPath & "\" & strFileName, False
  Set fso = Nothing
  cmdWait.Visible = False
  MsgBox "备份完毕"
  Call loadDBList
  
End Sub

Private Sub cmdDel_Click()
  Dim fso As FileSystemObject
  
  Dim dbbkpath As String
  If lstDB.ListIndex = -1 Then Exit Sub
  dbbkpath = pDBBkFldPath & "\" & lstDB.List(lstDB.ListIndex)
  '询问要不要删除
  If MsgBox("你真的要删除" & dbbkpath & "数据库吗?", vbQuestion + vbYesNo) = vbNo Then Exit Sub
  Set fso = New FileSystemObject
  fso.DeleteFile dbbkpath
  Set fso = Nothing
  Call loadDBList
  
End Sub


Private Sub cmdExit_Click()
  Unload Me
End Sub

Private Sub cmdRefresh_Click()
Call loadDBList
End Sub

Private Sub cmdRTDay_Click()
   Dim fso As FileSystemObject
   
   '如果没有文件退出
   If lstDB.ListIndex = -1 Then Exit Sub
   
  
  '备份数据库的全路径
  Dim dbbkpath As String
  dbbkpath = pDBBkFldPath & "\" & lstDB.List(lstDB.ListIndex)
  
  '询问要不要恢复
  If MsgBox("你真的要恢复数据库吗?", vbQuestion + vbYesNo) = vbNo Then Exit Sub
  cmdWait.Visible = True
  DoEvents
  Set fso = New FileSystemObject
  fso.CopyFile dbbkpath, App.path & "\rsmsdb.mdb", True
  Set fso = Nothing
  cmdWait.Visible = False
  MsgBox "数据库已经恢复"

End Sub

Private Sub CommandButton1_Click()
  cdgBackup.Filter = "Access数据库文件(*.mdb)|*.mdb"
  cdgBackup.ShowOpen
  If cdgBackup.FileName = "" Then Exit Sub
   '询问要不要恢复
  If MsgBox("你真的要恢复数据库吗?", vbQuestion + vbYesNo) = vbNo Then Exit Sub
  cmdWait.Visible = True
  DoEvents
  Set fso = New FileSystemObject
  fso.CopyFile cdgBackup.FileName, App.path & "\rsmsdb.mdb", True
  Set fso = Nothing
  cmdWait.Visible = False
  MsgBox "数据库已经恢复"
  
End Sub

Private Sub Form_Load()
  If pDBBkFldPath = "" Then
  pDBBkFldPath = App.path & "\DBBackup"
  End If
  
  txtPath = pDBBkFldPath
  Call loadDBList
  
  
  
End Sub

Private Sub loadDBList()
  Dim fso As FileSystemObject
  Dim fld As Folder
  Dim fl As File

  
  Set fso = New FileSystemObject
  If Not fso.FolderExists(pDBBkFldPath) Then
     Set fso = Nothing
     Exit Sub
   Else
    Set fld = fso.GetFolder(pDBBkFldPath)
    lstDB.Clear
    For Each fl In fld.Files
      lstDB.AddItem fl.Name
    Next
    Set fso = Nothing
  End If
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 + -