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

📄 main_xtgl.frm

📁 从网络上下载的VB的人事档案管理系统,经过修改.加入了些功能.希望对大家有帮助
💻 FRM
字号:
VERSION 5.00
Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "MSCOMCTL.OCX"
Object = "{248DD890-BB45-11CF-9ABC-0080C7E7B78D}#1.0#0"; "MSWINSCK.OCX"
Begin VB.Form main_xtgl 
   BorderStyle     =   1  'Fixed Single
   Caption         =   "数据库备份与恢复"
   ClientHeight    =   4965
   ClientLeft      =   45
   ClientTop       =   330
   ClientWidth     =   8655
   Icon            =   "main_xtgl.frx":0000
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MinButton       =   0   'False
   ScaleHeight     =   4965
   ScaleWidth      =   8655
   StartUpPosition =   1  '所有者中心
   Begin VB.Frame Frame2 
      Caption         =   "请选择数据库路径"
      Height          =   3540
      Left            =   4545
      TabIndex        =   6
      Top             =   480
      Width           =   4065
      Begin VB.DriveListBox Drive1 
         Height          =   300
         Left            =   150
         TabIndex        =   9
         Top             =   255
         Width           =   3750
      End
      Begin VB.DirListBox Dir1 
         Height          =   720
         Left            =   150
         TabIndex        =   8
         Top             =   630
         Width           =   3750
      End
      Begin VB.FileListBox File1 
         Height          =   2070
         Left            =   150
         Pattern         =   "*.BAK"
         TabIndex        =   7
         Top             =   1380
         Width           =   3750
      End
   End
   Begin VB.Frame Frame1 
      Caption         =   "备份卡列表"
      Height          =   3540
      Left            =   45
      TabIndex        =   4
      Top             =   480
      Width           =   4350
      Begin MSWinsockLib.Winsock Winsock1 
         Left            =   270
         Top             =   2985
         _ExtentX        =   741
         _ExtentY        =   741
         _Version        =   393216
      End
      Begin MSComctlLib.ListView ListView1 
         Height          =   3180
         Left            =   120
         TabIndex        =   5
         Top             =   240
         Width           =   4050
         _ExtentX        =   7144
         _ExtentY        =   5609
         Sorted          =   -1  'True
         LabelWrap       =   0   'False
         HideSelection   =   -1  'True
         HoverSelection  =   -1  'True
         _Version        =   393217
         Icons           =   "ImageList1"
         SmallIcons      =   "ImageList1"
         ForeColor       =   -2147483640
         BackColor       =   -2147483643
         BorderStyle     =   1
         Appearance      =   1
         NumItems        =   1
         BeginProperty ColumnHeader(1) {BDD1F052-858B-11D1-B16A-00C0F0283628} 
            Object.Width           =   2540
         EndProperty
      End
   End
   Begin VB.OptionButton Option2 
      Caption         =   "数据恢复"
      Height          =   300
      Left            =   6360
      TabIndex        =   3
      Top             =   90
      Width           =   1740
   End
   Begin VB.OptionButton Option1 
      Caption         =   "数据备份"
      Height          =   300
      Left            =   4605
      TabIndex        =   2
      Top             =   90
      Width           =   1740
   End
   Begin VB.CommandButton CmdEnd 
      Caption         =   "退出"
      Height          =   420
      Left            =   4350
      TabIndex        =   1
      Top             =   4455
      Width           =   1830
   End
   Begin VB.CommandButton CmdBackup 
      Caption         =   "数据备份或数据恢复"
      Height          =   420
      Left            =   2520
      TabIndex        =   0
      Top             =   4455
      Width           =   1830
   End
   Begin MSComctlLib.ImageList ImageList1 
      Left            =   -135
      Top             =   1560
      _ExtentX        =   1005
      _ExtentY        =   1005
      BackColor       =   -2147483643
      ImageWidth      =   32
      ImageHeight     =   32
      MaskColor       =   12632256
      _Version        =   393216
      BeginProperty Images {2C247F25-8591-11D1-B16A-00C0F0283628} 
         NumListImages   =   2
         BeginProperty ListImage1 {2C247F27-8591-11D1-B16A-00C0F0283628} 
            Picture         =   "main_xtgl.frx":000C
            Key             =   ""
         EndProperty
         BeginProperty ListImage2 {2C247F27-8591-11D1-B16A-00C0F0283628} 
            Picture         =   "main_xtgl.frx":08E8
            Key             =   ""
         EndProperty
      EndProperty
   End
   Begin VB.Label Label2 
      BackStyle       =   0  'Transparent
      Caption         =   "请选择数据备份或数据恢复选项"
      ForeColor       =   &H000000FF&
      Height          =   300
      Left            =   75
      TabIndex        =   11
      Top             =   120
      Width           =   2580
   End
   Begin VB.Label Label1 
      BackStyle       =   0  'Transparent
      ForeColor       =   &H000000FF&
      Height          =   375
      Left            =   60
      TabIndex        =   10
      Top             =   4050
      Width           =   8025
   End
End
Attribute VB_Name = "main_xtgl"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim StrCnn As New Connection     '定义连接
Dim itmX As ListItem     '定义一个ListItem对象
Dim key, list, sql As String     '定义字符串变量
Private Sub Form_Load()
 Option1.Value = True     '设置Option1的值为真
 Dir1_Change
End Sub
Private Sub Dir1_Change()
 File1.Path = Dir1.Path
 '添加数据备份卡到列表中
 ListView1.ListItems.Clear
 If File1.ListCount <> 0 Then
  a = 0     '给变量a设置初值
  Do While File1.ListIndex < File1.ListCount - 1
    File1.ListIndex = a     '赋值给变量a
    key = File1.FileName
    Set itmX = ListView1.ListItems.Add(, , key, 1)
    a = a + 1
  Loop
 End If
 File1_Click
End Sub
Private Sub Drive1_Change()
 Dir1.Path = Drive1.Drive
End Sub
Private Sub File1_Click()
 Label1.Caption = Dir1.Path & "\" & File1.FileName     '获得路径
End Sub
Private Sub ListView1_Click()
 Label1.Caption = Dir1.Path & "\" & ListView1.SelectedItem     '获得路径
End Sub
Private Sub CmdBackup_Click()
 Dim S
 If Option1.Value = True Then
 '备份数据库
   S = Dir1.Path & "\" & Date & ".BAK"
   If Label1.Caption = S Then
    MsgBox "数据备份卡已存在!"
   Else
    StrCnn.Open "Provider=SQLOLEDB.1;Persist Security Info=False;User ID=sa"
    '备份SQL Server数据库
    sql = "backup DATABASE RSDAGLXT TO disk='" & S & "'"
    StrCnn.Execute (sql)     '执行SQL语句
    StrCnn.Close
    MsgBox "数据库备份成功!"
    key = Date & ".BAK"
    Set itmX = ListView1.ListItems.Add(, , key, 1)
   End If
 End If
 If Option2.Value = True Then
'恢复指定路径下的数据库
  If File1.ListCount <> 0 Then
   If Label1.Caption <> "" Then
    StrCnn.Open "Provider=SQLOLEDB.1;Persist Security Info=False;User ID=sa;Initial Catalog=master;Data Source=" & Winsock1.LocalHostName
    '数据恢复语句
    sql = "RESTORE DATABASE RSDAGLXT from disk='" & Label1.Caption

    StrCnn.Execute (sql)     '执行SQL语句
    StrCnn.Close
    MsgBox "数据库恢复成功!"
   Else
    MsgBox "请选择要恢复的数据备份卡!"
   End If
  Else
   MsgBox "请选择要恢复的数据备份卡!"
  End If
 End If
End Sub
Private Sub CmdEnd_Click()
  Unload Me
  frm_main.Enabled = True
End Sub

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -