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

📄 frmlogman.frm

📁 vb与access数据库的操作实例
💻 FRM
字号:
VERSION 5.00
Object = "{67397AA1-7FB1-11D0-B148-00A0C922E820}#6.0#0"; "MSADODC.OCX"
Object = "{CDE57A40-8B86-11D0-B3C6-00A0C90AEA82}#1.0#0"; "MSDATGRD.OCX"
Object = "{86CF1D34-0C5F-11D2-A9FC-0000F8754DA1}#2.0#0"; "MSCOMCT2.OCX"
Begin VB.Form FrmLogMan 
   BorderStyle     =   1  'Fixed Single
   Caption         =   "系统日志管理"
   ClientHeight    =   7605
   ClientLeft      =   45
   ClientTop       =   330
   ClientWidth     =   10575
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MinButton       =   0   'False
   ScaleHeight     =   7605
   ScaleWidth      =   10575
   StartUpPosition =   2  '屏幕中心
   Begin VB.Frame Frame1 
      Height          =   855
      Left            =   0
      TabIndex        =   4
      Top             =   120
      Width           =   10575
      Begin MSComCtl2.DTPicker DtCheckDate 
         Height          =   300
         Left            =   4800
         TabIndex        =   10
         Top             =   300
         Width           =   1575
         _ExtentX        =   2778
         _ExtentY        =   529
         _Version        =   393216
         Format          =   23789569
         CurrentDate     =   38235
      End
      Begin VB.ComboBox ComboUser 
         Height          =   300
         ItemData        =   "FrmLogMan.frx":0000
         Left            =   8520
         List            =   "FrmLogMan.frx":0002
         Style           =   2  'Dropdown List
         TabIndex        =   6
         Top             =   300
         Width           =   1575
      End
      Begin VB.ComboBox ComboType 
         Height          =   300
         ItemData        =   "FrmLogMan.frx":0004
         Left            =   1440
         List            =   "FrmLogMan.frx":0006
         Style           =   2  'Dropdown List
         TabIndex        =   5
         Top             =   300
         Width           =   1575
      End
      Begin VB.Label Label3 
         AutoSize        =   -1  'True
         BackStyle       =   0  'Transparent
         Caption         =   "选择用户"
         Height          =   180
         Left            =   7440
         TabIndex        =   9
         Top             =   360
         Width           =   720
      End
      Begin VB.Label Label2 
         AutoSize        =   -1  'True
         BackStyle       =   0  'Transparent
         Caption         =   "选择日期"
         Height          =   180
         Left            =   3840
         TabIndex        =   8
         Top             =   360
         Width           =   720
      End
      Begin VB.Label Label7 
         AutoSize        =   -1  'True
         BackStyle       =   0  'Transparent
         Caption         =   "事件类别"
         Height          =   180
         Left            =   360
         TabIndex        =   7
         Top             =   360
         Width           =   720
      End
   End
   Begin VB.CommandButton Cmd_DelbyId 
      Caption         =   "单个删除"
      Height          =   400
      Left            =   2992
      MouseIcon       =   "FrmLogMan.frx":0008
      MousePointer    =   99  'Custom
      Style           =   1  'Graphical
      TabIndex        =   2
      Top             =   6840
      Width           =   1300
   End
   Begin VB.CommandButton Cmd_DelbyDate 
      Caption         =   "全天删除"
      Height          =   400
      Left            =   4637
      MouseIcon       =   "FrmLogMan.frx":0312
      MousePointer    =   99  'Custom
      Style           =   1  'Graphical
      TabIndex        =   1
      Top             =   6840
      Width           =   1300
   End
   Begin VB.CommandButton Cmd_Back 
      Cancel          =   -1  'True
      Caption         =   "返 回"
      Height          =   400
      Left            =   6282
      MouseIcon       =   "FrmLogMan.frx":061C
      MousePointer    =   99  'Custom
      Style           =   1  'Graphical
      TabIndex        =   0
      Top             =   6840
      Width           =   1300
   End
   Begin MSDataGridLib.DataGrid DataGrid1 
      Height          =   5415
      Left            =   0
      TabIndex        =   3
      Top             =   1080
      Width           =   10575
      _ExtentX        =   18653
      _ExtentY        =   9551
      _Version        =   393216
      AllowUpdate     =   0   'False
      AllowArrows     =   -1  'True
      HeadLines       =   1
      RowHeight       =   15
      BeginProperty HeadFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "宋体"
         Size            =   9
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "宋体"
         Size            =   9
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ColumnCount     =   2
      BeginProperty Column00 
         DataField       =   ""
         Caption         =   ""
         BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
            Type            =   0
            Format          =   ""
            HaveTrueFalseNull=   0
            FirstDayOfWeek  =   0
            FirstWeekOfYear =   0
            LCID            =   2052
            SubFormatType   =   0
         EndProperty
      EndProperty
      BeginProperty Column01 
         DataField       =   ""
         Caption         =   ""
         BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
            Type            =   0
            Format          =   ""
            HaveTrueFalseNull=   0
            FirstDayOfWeek  =   0
            FirstWeekOfYear =   0
            LCID            =   2052
            SubFormatType   =   0
         EndProperty
      EndProperty
      SplitCount      =   1
      BeginProperty Split0 
         BeginProperty Column00 
         EndProperty
         BeginProperty Column01 
         EndProperty
      EndProperty
   End
   Begin MSAdodcLib.Adodc Adodc1 
      Height          =   375
      Left            =   0
      Top             =   6600
      Visible         =   0   'False
      Width           =   1815
      _ExtentX        =   3201
      _ExtentY        =   661
      ConnectMode     =   0
      CursorLocation  =   3
      IsolationLevel  =   -1
      ConnectionTimeout=   15
      CommandTimeout  =   30
      CursorType      =   3
      LockType        =   3
      CommandType     =   8
      CursorOptions   =   0
      CacheSize       =   50
      MaxRecords      =   0
      BOFAction       =   0
      EOFAction       =   0
      ConnectStringType=   1
      Appearance      =   1
      BackColor       =   -2147483643
      ForeColor       =   -2147483640
      Orientation     =   0
      Enabled         =   -1
      Connect         =   ""
      OLEDBString     =   ""
      OLEDBFile       =   ""
      DataSourceName  =   ""
      OtherAttributes =   ""
      UserName        =   ""
      Password        =   ""
      RecordSource    =   ""
      Caption         =   "Adodc1"
      BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "宋体"
         Size            =   9
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      _Version        =   393216
   End
End
Attribute VB_Name = "FrmLogMan"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub Refresh_Log()
  Dim TmpSource As String
  TmpSource = "SELECT LogId As 编号, LogDate As 日期, LogTime As 时间, UserName As 操作用户," _
        + "LogType As 事件类型, Title As 标题, Body As 内容 FROM SysLog " _
        + " WHERE LogDate=#" + Trim(Format(DtCheckDate.Value, "yyyy-mm-dd")) + "#"
  
  If ComboType.ListIndex > 0 Then
    TmpSource = TmpSource + " And LogType='" + Trim(ComboType.Text) + "'"
  End If
  
  If ComboUser.ListIndex > 0 Then
    TmpSource = TmpSource + " And UserName='" + Trim(ComboUser) + "'"
  End If
  
  TmpSource = TmpSource + " ORDER BY LogId"
  Adodc1.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" _
          + App.Path + "\人事.mdb;Persist Security Info=False"
  Adodc1.RecordSource = TmpSource
  Adodc1.Refresh
  Set DataGrid1.DataSource = Adodc1
  DataGrid1.Columns(0).Width = 600
  DataGrid1.Columns(1).Width = 1200
  DataGrid1.Columns(2).Width = 1200
  DataGrid1.Columns(3).Width = 1200
  DataGrid1.Columns(4).Width = 1000
  DataGrid1.Columns(5).Width = 2000
  DataGrid1.Columns(6).Width = 3000
End Sub

Private Sub Cmd_Back_Click()
  Unload Me
End Sub

Private Sub Cmd_DelbyDate_Click()
  If MsgBox("是否删除当前的全天日志记录", vbYesNo, "请确认") = vbYes Then
    MyLog.DeleteByDate (Format(DtCheckDate.Value, "yyyy-mm-dd"))
  End If
  
  Refresh_Log
End Sub

Private Sub Cmd_DelbyId_Click()
  If Adodc1.Recordset.EOF = True Then
    MsgBox "请选择要删除的日志"
    Exit Sub
  End If
  
  If MsgBox("是否删除当前日志记录", vbYesNo, "请确认") = vbYes Then
    MyLog.DeleteById (Adodc1.Recordset.Fields(0))
  End If
  
  Refresh_Log
End Sub

Private Sub ComboType_Click()
  Refresh_Log
End Sub

Private Sub ComboUser_Click()
  Refresh_Log
End Sub

Private Sub DtCheckDate_Change()
  Refresh_Log
End Sub

Private Sub Form_Load()
  DtCheckDate.Value = Format(Now, "yyyy-mm-dd")      '设置为当天日期
  
  '加载事件类型
  ComboType.AddItem "全部", 0
  ComboType.AddItem "插入", 1
  ComboType.AddItem "修改", 2
  ComboType.AddItem "删除", 3
  '加载用户名
  MyUser.LoadUsers
  ComboUser.AddItem "全部"
  i = 0
  Do While Arr_User(i) <> ""
    ComboUser.AddItem Arr_User(i)
    i = i + 1
  Loop
  ComboUser.ListIndex = 0
  ComboType.ListIndex = 0
  
  Refresh_Log
End Sub

⌨️ 快捷键说明

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