?? dlgdatabaserestore.frm
字號:
Unload Me
Exit Sub
ERROR_EXIT:
m_tagErrInfo.strErrDate = Format(Now, "yyyy-mm-dd hh:mm:ss")
m_tagErrInfo.strErrFile = "dlgDatabaseRestore"
m_tagErrInfo.strErrFunc = "cmdOk_Click"
m_tagErrInfo.nErrNum = Err.Number
m_tagErrInfo.strErrDesc = Error(Err.Number)
If Err.Number <> 0 Then Err.Clear
modErrorInfo.WriteErrLog m_tagErrInfo
cmdOk.Enabled = False
End Sub
'***********************************
' 用戶單擊選中操作
Private Sub ctlXPFlexGrid_EventNonnEditCellClick(ByVal Row As Long, ByVal Col As Long)
On Error GoTo ERROR_EXIT
Dim color As Long
Dim strShortFileName As String, strPath As String
cmdOk.Enabled = False
cmdDelete.Enabled = False
'恢復原來的選中行的顏色
If m_lSelRow > 0 And m_lSelRow <= ctlXPFlexGrid.FilledRowCount Then
If m_lSelRow Mod 2 = 0 Then
ctlXPFlexGrid.SetRowBackColor m_lSelRow, ctlXPFlexGrid.EvenRowBkColor
Else
ctlXPFlexGrid.SetRowBackColor m_lSelRow, ctlXPFlexGrid.OddRowBkColor
End If
m_lSelRow = 0
End If
lblPath.Caption = ""
txtFileName.Text = ""
'設置新選中行的顏色
If Row > 0 And Row <= ctlXPFlexGrid.FilledRowCount Then
m_lSelRow = Row
ctlXPFlexGrid.SetRowBackColor Row, &HC0FFC0
'分解并設置完整文件名中的路徑和文件名
If Not FilterFileName(ctlXPFlexGrid.Cell(m_lSelRow, 1), strPath, strShortFileName) Then GoTo ERROR_EXIT
lblPath.Caption = strPath
txtFileName.Text = strShortFileName
If Trim(lblPath.Caption) = "" Or Trim(txtFileName.Text) = "" Then GoTo ERROR_EXIT
cmdOk.Enabled = True
cmdDelete.Enabled = True
End If
Exit Sub
ERROR_EXIT:
m_tagErrInfo.strErrDate = Format(Now, "yyyy-mm-dd hh:mm:ss")
m_tagErrInfo.strErrFile = "dlgDatabaseRestore"
m_tagErrInfo.strErrFunc = "ctlXPFlexGrid_EventNonnEditCellClick"
m_tagErrInfo.nErrNum = Err.Number
m_tagErrInfo.strErrDesc = Error(Err.Number)
If Err.Number <> 0 Then Err.Clear
modErrorInfo.WriteErrLog m_tagErrInfo
cmdOk.Enabled = False
End Sub
'*******************************************************
'初始化 ctlXPFlexGrid 控件各個列的標題
Private Function InitXPFlexGridControl() As Boolean
On Error GoTo ERROR_EXIT
Dim fReadOnly As Boolean
Dim i As Long
fReadOnly = ctlXPFlexGrid.ReadOnly
ctlXPFlexGrid.ReadOnly = False
ctlXPFlexGrid.RemoveAllRow
'設置 ctlXPFlexGrid 控件的的標題
ctlXPFlexGrid.ColHeadTxts = m_strColumnHeads
ctlXPFlexGrid.ReadOnly = fReadOnly
InitXPFlexGridControl = True
Exit Function
ERROR_EXIT:
m_tagErrInfo.strErrDate = Format(Now, "yyyy-mm-dd hh:mm:ss")
m_tagErrInfo.strErrFile = "dlgBaseCity"
m_tagErrInfo.strErrFunc = "InitXPFlexGridControl"
m_tagErrInfo.nErrNum = Err.Number
m_tagErrInfo.strErrDesc = Error(Err.Number) & "初始化 ctlXPFlexGrid 控件各個列的標題失敗。"
If Err.Number <> 0 Then Err.Clear
modErrorInfo.WriteErrLog m_tagErrInfo
ctlXPFlexGrid.ReadOnly = True
InitXPFlexGridControl = False
End Function
'*******************************************************
'顯示數據庫中已有的備份文件信息
Private Function OpenDB() As Boolean
On Error GoTo ERROR_EXIT
Dim rs As New ADODB.Recordset
Dim cmd As New ADODB.Command
Dim i As Long
Dim strRow As String
'查詢數據庫主表
cmd.ActiveConnection = dbMyDB
cmd.CommandText = " SELECT * FROM T_DATABASE_BACKUP WHERE bc_flag = 0 AND bc_SrcdbName = '" _
& g_MyUserDB.strUserDatabase & "'"
rs.CursorLocation = adUseClient
rs.Open cmd, , adOpenStatic, adLockReadOnly
'文件名 , 備份時間 , 完全/增量備份 , 用戶名 , id
ctlXPFlexGrid.ReadOnly = False
ctlXPFlexGrid.Visible = False
ctlXPFlexGrid.RemoveAllRow
If rs.State <> adStateOpen Then GoTo ERROR_EXIT
If Not rs.EOF And rs.RecordCount > 0 Then
rs.MoveFirst
For i = 0 To rs.RecordCount - 1
strRow = Trim(rs!bc_filename) & vbTab
strRow = strRow & Format(rs!bc_BackupTime, "yyyy-mm-dd") & vbTab
If CLng(rs!bc_full) = 0 Then
strRow = strRow & "完全" & vbTab
Else
strRow = strRow & "增量" & vbTab
End If
strRow = strRow & Trim(rs!bc_UserName)
ctlXPFlexGrid.AddRow strRow
rs.MoveNext
Next
End If
ctlXPFlexGrid.ReadOnly = True
ctlXPFlexGrid.Visible = True
'CheckFileNameExist = 0
ERROR_EXIST:
If rs.State = adStateOpen Then rs.Close
Set rs = Nothing
Set cmd = Nothing
OpenDB = True
Exit Function
ERROR_EXIT:
m_tagErrInfo.strErrDate = Format(Now, "yyyy-mm-dd hh:mm:ss")
m_tagErrInfo.strErrFile = "dlgDatabaseBackup"
m_tagErrInfo.strErrFunc = "CheckFileNameExist"
m_tagErrInfo.nErrNum = Err.Number
m_tagErrInfo.strErrDesc = Error(Err.Number)
If Err.Number <> 0 Then Err.Clear
modErrorInfo.WriteErrLog m_tagErrInfo
ctlXPFlexGrid.ReadOnly = True
ctlXPFlexGrid.Visible = True
If rs.State = adStateOpen Then rs.Close
Set rs = Nothing
Set cmd = Nothing
OpenDB = False
End Function
Private Sub txtFileName_Change()
On Error Resume Next
If Trim(txtFileName.Text) <> "" Then
cmdOk.Enabled = True
Else
cmdOk.Enabled = False
End If
End Sub
'*******************************************************
'將完整文件名分解為路徑名和短文件名
Private Function FilterFileName(ByVal strFullName As String, _
ByRef strPath As String, _
ByRef strFile As String) As Boolean
On Error GoTo ERROR_EXIT
Dim strShortFileName As String
Dim nPos As Long
If Trim(strFullName) = "" Then GoTo ERROR_EXIT
strShortFileName = strFullName
nPos = InStr(strShortFileName, "\")
While nPos > 0
strShortFileName = Right(strShortFileName, Len(strShortFileName) - nPos)
nPos = InStr(strShortFileName, "\")
Wend
strPath = Left(strFullName, Len(strFullName) - Len(strShortFileName))
strFile = strShortFileName
FilterFileName = True
Exit Function
ERROR_EXIT:
m_tagErrInfo.strErrDate = Format(Now, "yyyy-mm-dd hh:mm:ss")
m_tagErrInfo.strErrFile = "dlgDatabaseBackup"
m_tagErrInfo.strErrFunc = "CheckFileNameExist"
m_tagErrInfo.nErrNum = Err.Number
m_tagErrInfo.strErrDesc = Error(Err.Number)
If Err.Number <> 0 Then Err.Clear
modErrorInfo.WriteErrLog m_tagErrInfo
FilterFileName = False
End Function
Private Sub cmdQuit_Click()
Unload Me
End Sub
'***********************************
' 刪除備份文件操作
Private Sub cmdDelete_Click()
On Error GoTo ERROR_EXIT
If m_lSelRow < 1 Or m_lSelRow > ctlXPFlexGrid.FilledRowCount Then GoTo ERROR_EXIT
If vbYes <> MsgBox("刪除的文件將無法恢復,請確認是否刪除!", vbYesNo Or vbExclamation, "警告") Then Exit Sub
DeleteBackupFile ctlXPFlexGrid.Cell(m_lSelRow, 1)
txtFileName.Text = ""
cmdDelete.Enabled = False
If Not OpenDB Then GoTo ERROR_EXIT
Exit Sub
ERROR_EXIT:
m_tagErrInfo.strErrDate = Format(Now, "yyyy-mm-dd hh:mm:ss")
m_tagErrInfo.strErrFile = "dlgDatabaseBackup"
m_tagErrInfo.strErrFunc = "CheckFileNameExist"
m_tagErrInfo.nErrNum = Err.Number
m_tagErrInfo.strErrDesc = Error(Err.Number)
If Err.Number <> 0 Then Err.Clear
modErrorInfo.WriteErrLog m_tagErrInfo
txtFileName.Text = ""
cmdDelete.Enabled = False
End Sub
Private Sub txtFileName_GotFocus()
txtFileName.BackColor = &H80000018
End Sub
Private Sub txtFileName_LostFocus()
txtFileName.BackColor = &H80000005
End Sub
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -