📄 frmbackupandrecover.vb
字号:
Imports System.Data.OleDb
Imports System.DateTime
Imports System.Math
Imports System.IO
Imports System.Threading
Public Class frmbackupandrecover
Inherits System.Windows.Forms.Form
Dim MyConnection As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Application.StartupPath & "\shujuku.mdb")
Dim MyCommand As OleDbCommand
Dim MyReader As OleDbDataReader
Private Sub frmbackupandrecover_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
MyConnection.Open()
MyCommand = New OleDbCommand("SELECT * FROM Backup", MyConnection)
MyReader = MyCommand.ExecuteReader()
While MyReader.Read
TxtSourceAddress.Text = MyReader("Source")
TxtDest.Text = MyReader("Dest")
End While
MyConnection.Close()
MyReader.Close()
End Sub
Sub updatePath()
MyConnection.Open()
MyCommand = New OleDbCommand("UPDATE Backup SET Source ='" & TxtSourceAddress.Text & "',Dest = '" & TxtDest.Text & "' ", MyConnection)
Try
MyCommand.ExecuteNonQuery()
Catch c As Exception
MsgBox(c.ToString)
End Try
MyConnection.Close()
MyCommand.Dispose()
End Sub
Private Sub BtnExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnExit.Click
Me.Close()
End Sub
Private Sub bf_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bf.Click
updatePath()
ProgressBar1.Increment(20)
myWait(2500)
ProgressBar1.Increment(20)
Dim filename As String = Date.Now.Hour.ToString + "-" + Date.Now.Minute.ToString + "-" + Date.Now.Second.ToString
Dim direcname = TxtDest.Text
Dim sourcepath As String = TxtSourceAddress.Text
myWait(2500)
ProgressBar1.Increment(20)
myWait(2500)
If Directory.Exists(direcname) = True Then
Else
If Directory.Exists(direcname) = False Then
Directory.CreateDirectory(direcname)
End If
End If
ProgressBar1.Increment(20)
File.Copy(sourcepath, direcname + "\" + filename + ".backup")
myWait(2500)
ProgressBar1.Increment(20)
MsgBox("备份完成!", MsgBoxStyle.OkOnly, "超市管理系统")
End Sub
Sub myWait(ByVal mySeconds As Integer)
Dim myTime As Integer
myTime = 0
While myTime <= mySeconds
myTime = myTime + 50
End While
End Sub
Private Sub Browser_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Browser.Click
Dim objOpenFile As New OpenFileDialog
Dim filePath As String
objOpenFile.Filter = "所有文件 (*.*)|*.*"
If objOpenFile.ShowDialog() = Windows.Forms.DialogResult.OK And objOpenFile.FileName <> "" Then
filePath = objOpenFile.FileName
TxtSourceAddress.Text = filePath
End If
End Sub
Private Sub brown2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles brown2.Click
Dim savefiledialog As New SaveFileDialog
Dim filename As String
savefiledialog.Filter = "所有文件 (*.*)|*.*"
If savefiledialog.ShowDialog() = Windows.Forms.DialogResult.OK And savefiledialog.FileName <> "" Then
filename = savefiledialog.FileName
TxtDest.Text = filename
End If
End Sub
Private Sub hf_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles hf.Click
updatePath()
ProgressBar1.Increment(20)
myWait(2500)
ProgressBar1.Increment(20)
Dim filename As String = Date.Now.Hour.ToString + "-" + Date.Now.Minute.ToString + "-" + Date.Now.Second.ToString
Dim direcname = TextBox2.Text
Dim sourcepath As String = TextBox1.Text
myWait(2500)
ProgressBar1.Increment(20)
myWait(2500)
If Directory.Exists(direcname) = True Then
Else
If Directory.Exists(direcname) = False Then
Directory.CreateDirectory(direcname)
End If
End If
ProgressBar1.Increment(20)
File.Copy(sourcepath, direcname + "\" + "shujuku.mdb")
myWait(2500)
ProgressBar1.Increment(20)
MsgBox("恢复完成!", MsgBoxStyle.OkOnly, "超市管理系统")
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim objOpenFile As New OpenFileDialog
Dim filePath As String
objOpenFile.Filter = "备份文件(*.backup)|"
If objOpenFile.ShowDialog() = Windows.Forms.DialogResult.OK And objOpenFile.FileName <> "" Then
filePath = objOpenFile.FileName
TextBox1.Text = filePath
End If
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
Dim savefiledialog As New SaveFileDialog
Dim filename As String
savefiledialog.Filter = "所有文件 (*.*)|*.*"
If savefiledialog.ShowDialog() = Windows.Forms.DialogResult.OK And savefiledialog.FileName <> "" Then
filename = savefiledialog.FileName
TextBox2.Text = filename
End If
End Sub
End Class
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -