📄 frmdatarestore.frm
字号:
VERSION 5.00
Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "MSCOMCTL.OCX"
Begin VB.Form frmDataRestore
Caption = "数据恢复"
ClientHeight = 3285
ClientLeft = 60
ClientTop = 345
ClientWidth = 5850
Icon = "frmDataRestore.frx":0000
LinkTopic = "Form1"
LockControls = -1 'True
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 3285
ScaleWidth = 5850
StartUpPosition = 2 '屏幕中心
Begin VB.CommandButton cmdCancel
Cancel = -1 'True
Caption = "取消(&C)"
Height = 375
Left = 3461
TabIndex = 7
Top = 2640
Width = 975
End
Begin VB.CommandButton cmdOK
Caption = "确定(&E)"
Default = -1 'True
Height = 375
Left = 1414
TabIndex = 6
Top = 2640
Width = 975
End
Begin MSComctlLib.ProgressBar ProgressBar1
Height = 375
Left = 818
TabIndex = 5
Top = 1920
Visible = 0 'False
Width = 4215
_ExtentX = 7435
_ExtentY = 661
_Version = 393216
Appearance = 1
End
Begin VB.Frame Frame1
Height = 1335
Left = 758
TabIndex = 0
Top = 240
Width = 4335
Begin VB.CheckBox chkRestoreData
Caption = "恢复数据库"
Height = 255
Left = 2520
TabIndex = 4
Top = 840
Value = 1 'Checked
Width = 1215
End
Begin VB.CheckBox chkRestoreSystem
Caption = "恢复系统库"
Height = 255
Left = 2520
TabIndex = 3
Top = 360
Value = 1 'Checked
Width = 1215
End
Begin VB.OptionButton optRestoreHard
Caption = "从硬盘恢复"
Height = 255
Left = 600
TabIndex = 2
Top = 840
Width = 1215
End
Begin VB.OptionButton optRestoreFloppy
Caption = "从软盘恢复"
Height = 255
Left = 600
TabIndex = 1
Top = 360
Value = -1 'True
Width = 1215
End
End
End
Attribute VB_Name = "frmDataRestore"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Dim fso As New FileSystemObject
Dim drv As Drive
Private Sub cmdCancel_Click()
Unload Me
End Sub
Private Sub cmdOK_Click()
Dim strAppName As String, strOldName As String, i As Integer
If optRestoreFloppy.Value = True Then '从软盘恢复
Set drv = fso.GetDrive("A:")
If Not drv.IsReady Then
MsgBox "驱动器没有准备好!", vbCritical + vbOKOnly, "数据恢复"
Exit Sub
End If
If Not fso.FolderExists("A:\Backup") Then
MsgBox "备份文件夹不存在!", vbCritical + vbOKOnly, "数据恢复"
Exit Sub
End If
If chkRestoreSystem.Value = Checked Then '恢复系统库
strAppName = App.Path & "\权限表.mdb"
strOldName = "A:\Backup\权限表.mdb"
RestoreFileAll strOldName, strAppName
strAppName = App.Path & "\用户档案.mdb"
strOldName = "A:\Backup\用户档案.mdb"
RestoreFileAll strOldName, strAppName
strAppName = App.Path & "\水费标准库.mdb"
strOldName = "A:\Backup\水费标准库.mdb"
RestoreFileAll strOldName, strAppName
End If
If chkRestoreData.Value = Checked Then '恢复数据库
strAppName = App.Path & "\Main" & Year(Now) & Month(Now) & ".mdb"
strOldName = "A:\Backup\Main" & Year(Now) & Month(Now) & ".mdb"
RestoreFileAll strOldName, strAppName
End If
'设置进度条
ProgressBar1.Visible = True
ProgressBar1.Min = 1: ProgressBar1.Max = 100
For i = 1 To 100
ProgressBar1.Value = i
Next
ProgressBar1.Visible = False
ElseIf optRestoreHard.Value = True Then '从硬盘恢复
If Not fso.FolderExists(App.Path & "\Backup") Then
MsgBox "备份文件夹不存在!", vbCritical + vbOKOnly, "数据恢复"
Exit Sub
End If
If chkRestoreSystem.Value = Checked Then '恢复系统库
strAppName = App.Path & "\权限表.mdb"
strOldName = App.Path & "\Backup\权限表.mdb"
RestoreFileAll strOldName, strAppName
strAppName = App.Path & "\用户档案.mdb"
strOldName = App.Path & "\Backup\用户档案.mdb"
RestoreFileAll strOldName, strAppName
strAppName = App.Path & "\水费标准库.mdb"
strOldName = App.Path & "\Backup\水费标准库.mdb"
RestoreFileAll strOldName, strAppName
End If
If chkRestoreData.Value = Checked Then '恢复数据库
strAppName = App.Path & "\Main" & Year(Now) & Month(Now) & ".mdb"
strOldName = App.Path & "\Backup\Main" & Year(Now) & Month(Now) & ".mdb"
RestoreFileAll strOldName, strAppName
End If
'设置进度条
ProgressBar1.Visible = True
ProgressBar1.Min = 1: ProgressBar1.Max = 100
For i = 1 To 100
ProgressBar1.Value = i
Next
ProgressBar1.Visible = False
End If
MsgBox "恢复完毕!", vbInformation + vbOKOnly, "数据恢复"
Unload Me
End Sub
Private Sub RestoreFileAll(strOldName As String, strAppName As String)
If Not fso.FileExists(strOldName) Then
MsgBox strOldName & "不存在!", vbCritical + vbOKOnly, "数据恢复"
Exit Sub
End If
fso.CopyFile strOldName, strAppName
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -