📄 frmsjhf.frm
字号:
VERSION 5.00
Object = "{BDC217C8-ED16-11CD-956C-0000C04E4C0A}#1.1#0"; "TABCTL32.OCX"
Begin VB.Form frmSjhf
BorderStyle = 1 'Fixed Single
Caption = "数据恢复"
ClientHeight = 3375
ClientLeft = 45
ClientTop = 450
ClientWidth = 5730
Icon = "frmSjhf.frx":0000
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 3375
ScaleWidth = 5730
StartUpPosition = 2 '屏幕中心
Begin TabDlg.SSTab SSTab1
Height = 3375
Left = 0
TabIndex = 0
Top = 0
Width = 5775
_ExtentX = 10186
_ExtentY = 5953
_Version = 393216
Tabs = 2
TabsPerRow = 2
TabHeight = 520
TabCaption(0) = "还原数据库"
TabPicture(0) = "frmSjhf.frx":3072
Tab(0).ControlEnabled= -1 'True
Tab(0).Control(0)= "Label1"
Tab(0).Control(0).Enabled= 0 'False
Tab(0).Control(1)= "Label3"
Tab(0).Control(1).Enabled= 0 'False
Tab(0).Control(2)= "txtFl"
Tab(0).Control(2).Enabled= 0 'False
Tab(0).Control(3)= "Command1"
Tab(0).Control(3).Enabled= 0 'False
Tab(0).Control(4)= "Command2"
Tab(0).Control(4).Enabled= 0 'False
Tab(0).Control(5)= "Command3(0)"
Tab(0).Control(5).Enabled= 0 'False
Tab(0).ControlCount= 6
TabCaption(1) = "数据库备份"
TabPicture(1) = "frmSjhf.frx":308E
Tab(1).ControlEnabled= 0 'False
Tab(1).Control(0)= "Command5"
Tab(1).Control(1)= "Command3(1)"
Tab(1).Control(2)= "Text1"
Tab(1).Control(3)= "Command4"
Tab(1).Control(4)= "Label4"
Tab(1).Control(5)= "Label2"
Tab(1).ControlCount= 6
Begin VB.CommandButton Command5
Caption = "确 定"
Enabled = 0 'False
Height = 435
Left = -73980
TabIndex = 10
Top = 2640
Width = 1035
End
Begin VB.CommandButton Command3
Caption = "取 消"
Height = 435
Index = 1
Left = -71400
TabIndex = 9
Top = 2640
Width = 1035
End
Begin VB.CommandButton Command3
Cancel = -1 'True
Caption = "取 消"
Height = 435
Index = 0
Left = 3600
TabIndex = 8
Top = 2640
Width = 1035
End
Begin VB.CommandButton Command2
Caption = "确 定"
Enabled = 0 'False
Height = 435
Left = 1020
TabIndex = 7
Top = 2640
Width = 1035
End
Begin VB.TextBox Text1
Height = 315
Left = -74100
Locked = -1 'True
TabIndex = 5
Top = 1620
Width = 3735
End
Begin VB.CommandButton Command4
Caption = "浏览..."
Height = 315
Left = -70320
TabIndex = 4
Top = 1620
Width = 915
End
Begin VB.CommandButton Command1
Caption = "浏览..."
Height = 315
Left = 4680
TabIndex = 2
Top = 1620
Width = 915
End
Begin VB.TextBox txtFl
Height = 315
Left = 900
Locked = -1 'True
TabIndex = 1
Top = 1620
Width = 3735
End
Begin VB.Label Label4
Caption = "备份数据库文件,以备以后使用!如果您的数据发生错误时可以从这里恢复!"
Height = 495
Left = -74100
TabIndex = 12
Top = 960
Width = 3735
End
Begin VB.Label Label3
Caption = "当数据库里的数据发生错误时把数据库里的数据恢复到一个比较早的时间!您必须有早些时候的备份文件存在!"
Height = 795
Left = 900
TabIndex = 11
Top = 780
Width = 3735
End
Begin VB.Label Label2
Caption = "另存为:"
Height = 255
Left = -74820
TabIndex = 6
Top = 1680
Width = 855
End
Begin VB.Label Label1
Caption = "打开:"
Height = 255
Left = 360
TabIndex = 3
Top = 1680
Width = 1875
End
End
End
Attribute VB_Name = "frmSjhf"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Dim tmpCnStr As String
Dim FileName As String
Private Declare Function GetShortPathName Lib "kernel32" Alias "GetShortPathNameA" (ByVal lpszLongPath As String, ByVal lpszShortPath As String, ByVal cchBuffer As Long) As Long
Private Sub Command1_Click()
frmMain.CD1.FileName = ""
frmMain.CD1.Filter = "数据文件(*.db)|*.db"
frmMain.CD1.ShowOpen
FileName = ""
If frmMain.CD1.FileName <> "" Then
FileName = frmMain.CD1.FileName
Command2.Enabled = True
txtFl.Text = FileName
End If
End Sub
Private Sub Command2_Click()
On Error GoTo Er
Dim TEMP1 As String * 128
Dim TEMP2 As String * 128
'=============效验数据库文件
Dim SQL As String
GetShortPathName FileName, TEMP1, 128
GetShortPathName DataFile, TEMP2, 128
If TEMP1 = TEMP2 Then
MsgBox "你选择的数据文件就是当前的数据,请另选数据文件!", vbOKOnly + 48
Exit Sub
End If
conStr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & txtFl.Text & ";Persist Security Info=False"
SQL = "SELECT * from 明细表"
ExecSQL SQL
SQL = "SELECT * from 客户表"
ExecSQL SQL
SQL = "SELECT * from 月份表"
ExecSQL SQL
SQL = "SELECT * from 帐本表"
ExecSQL SQL
SQL = "SELECT * from 买会表"
ExecSQL SQL
SQL = "SELECT * from 借款表"
ExecSQL SQL
'断开和数据库的连接
UnloadAll
'覆盖原来的数据库文件
SetAttr DataFile, vbNormal
Kill DataFile
FileCopy FileName, DataFile
MsgBox "数据恢复完成,系统需要重启!", vbOKOnly + vbInformation
'系统重新启动
ShellMe
Er:
If MsgBox("你选择的数据文件不是本系统的数据备份文件!是否继续?", vbYesNo + 16) = vbYes Then
Command1_Click
Else
Unload Me
conStr = tmpCnStr
End If
End Sub
Private Sub Command3_Click(Index As Integer)
Unload Me
End Sub
Private Sub Command4_Click()
Dim ImgId As Long
frmMain.CD1.FileName = ""
frmMain.CD1.Filter = "数据文件(*.db)|*.db"
frmMain.CD1.ShowSave
Dim FileName As String
If frmMain.CD1.FileName <> "" Then
Text1.Text = frmMain.CD1.FileName
Command5.Enabled = True
End If
End Sub
Private Sub Command5_Click()
Dim TEMP1 As String * 128
Dim TEMP2 As String * 128
FileName = Text1
GetShortPathName FileName, TEMP1, 128
GetShortPathName DataFile, TEMP2, 128
If TEMP1 = TEMP2 Then
MsgBox "你选择的数据文件就是当前的数据,请另选数据文件!", vbOKOnly + 48
Exit Sub
End If
UnloadAll
If BackupData(FileName) = True Then
MsgBox "数据备份成功!系统需要重启!"
ShellMe
Else
MsgBox "数据无法备份,请等会再试!", vbOKOnly + 16
End If
End Sub
Private Sub Form_Initialize()
InitCommonControls
End Sub
Private Sub Form_Load()
tmpCnStr = conStr
End Sub
Private Sub txtFl_Change()
If txtFl.Text <> "" Then Command2.Enabled = True
End Sub
Private Sub UnloadAll()
Unload frmAbout
Unload frmCX
Unload frmDel
Unload frmDj
Unload FrmDj2
Unload frmLs
Unload frmML
Unload frmMMXG
Unload Me
Unload frmTj
Unload frmMain
Release
DoEvents
End Sub
Private Sub ShellMe()
FileName = App.Path
If Right(FileName, 1) <> "\" Then FileName = FileName & "\"
FileName = FileName & App.EXEName & ".exe"
Shell FileName, vbNormalFocus
End
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -