📄 frmsrchsysevent.frm
字号:
VERSION 5.00
Begin VB.Form FrmSrchEvent
Caption = "查询日志"
ClientHeight = 5340
ClientLeft = 255
ClientTop = 1335
ClientWidth = 9480
LinkTopic = "Form1"
ScaleHeight = 5340
ScaleWidth = 9480
Begin VB.Data Data1
Caption = "Data1"
Connect = "Access"
DatabaseName = ""
DefaultCursorType= 0 '缺省游标
DefaultType = 2 '使用 ODBC
Exclusive = 0 'False
Height = 285
Left = 3720
Options = 0
ReadOnly = 0 'False
RecordsetType = 1 'Dynaset
RecordSource = ""
Top = 0
Visible = 0 'False
Width = 1140
End
Begin VB.CommandButton CmdAllDelete
Caption = "日志清空"
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 375
Left = 7920
TabIndex = 19
Top = 600
Width = 1215
End
Begin VB.CommandButton CmdCancel
Caption = "取消"
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 375
Left = 7920
TabIndex = 18
Top = 120
Width = 1215
End
Begin VB.CommandButton CmdSingleDelete
Caption = "单个删除"
Enabled = 0 'False
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 375
Left = 6360
TabIndex = 17
Top = 120
Width = 1215
End
Begin VB.CommandButton CmdSomeEvent
Caption = "显示"
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 375
Left = 5040
TabIndex = 16
Top = 600
Width = 1215
End
Begin VB.CommandButton CmdAllEvent
Caption = "全部日志"
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 375
Left = 5040
TabIndex = 15
Top = 120
Width = 1215
End
Begin VB.PictureBox Picture1
BackColor = &H00E0E0E0&
Height = 375
Index = 6
Left = 2880
ScaleHeight = 315
ScaleWidth = 1635
TabIndex = 8
Top = 480
Width = 1695
Begin VB.TextBox TxtDay
BackColor = &H00E0E0E0&
BorderStyle = 0 'None
Height = 255
Index = 1
Left = 1200
MaxLength = 2
TabIndex = 11
Top = 20
Width = 255
End
Begin VB.TextBox TxtYear
BackColor = &H00E0E0E0&
BorderStyle = 0 'None
Height = 255
Index = 1
Left = 40
MaxLength = 4
TabIndex = 10
Top = 20
Width = 435
End
Begin VB.TextBox TxtMonth
BackColor = &H00E0E0E0&
BorderStyle = 0 'None
Height = 255
Index = 1
Left = 720
MaxLength = 2
TabIndex = 9
Top = 20
Width = 255
End
Begin VB.Label Label1
BackColor = &H00E0E0E0&
Caption = "月"
Height = 375
Index = 13
Left = 960
TabIndex = 14
Top = 40
Width = 255
End
Begin VB.Label Label1
BackColor = &H00E0E0E0&
Caption = "年"
Height = 375
Index = 14
Left = 480
TabIndex = 13
Top = 40
Width = 255
End
Begin VB.Label Label1
BackColor = &H00E0E0E0&
Caption = "日"
Height = 375
Index = 15
Left = 1440
TabIndex = 12
Top = 40
Width = 255
End
End
Begin VB.PictureBox Picture1
BackColor = &H00E0E0E0&
Height = 375
Index = 7
Left = 240
ScaleHeight = 315
ScaleWidth = 1635
TabIndex = 1
Top = 480
Width = 1695
Begin VB.TextBox TxtMonth
BackColor = &H00E0E0E0&
BorderStyle = 0 'None
Height = 255
Index = 0
Left = 720
MaxLength = 2
TabIndex = 4
Top = 20
Width = 255
End
Begin VB.TextBox TxtYear
BackColor = &H00E0E0E0&
BorderStyle = 0 'None
Height = 255
Index = 0
Left = 40
MaxLength = 4
TabIndex = 3
Top = 20
Width = 435
End
Begin VB.TextBox TxtDay
BackColor = &H00E0E0E0&
BorderStyle = 0 'None
Height = 255
Index = 0
Left = 1200
MaxLength = 2
TabIndex = 2
Top = 20
Width = 255
End
Begin VB.Label Label1
BackColor = &H00E0E0E0&
Caption = "日"
Height = 375
Index = 16
Left = 1440
TabIndex = 7
Top = 40
Width = 255
End
Begin VB.Label Label1
BackColor = &H00E0E0E0&
Caption = "年"
Height = 375
Index = 17
Left = 480
TabIndex = 6
Top = 40
Width = 255
End
Begin VB.Label Label1
BackColor = &H00E0E0E0&
Caption = "月"
Height = 375
Index = 18
Left = 960
TabIndex = 5
Top = 40
Width = 255
End
End
Begin VB.Line Line1
BorderWidth = 2
X1 = 2400
X2 = 2760
Y1 = 600
Y2 = 600
End
Begin VB.Label Label1
Caption = "输入要查询的开始日期和终止日期"
Height = 375
Index = 0
Left = 240
TabIndex = 0
Top = 240
Width = 3135
End
End
Attribute VB_Name = "FrmSrchEvent"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim CurRecord As String
'************************
'* 功能:获得默认的有效日期,时间
'* 作者:韩国栋
'* 时间:2000-2-12
'************************
Sub ValidDate()
gValidEndDate = Date + 1
TxtYear(0).Text = Year(Date)
TxtMonth(0).Text = Right("00" & Month(Date), 2)
TxtDay(0).Text = Right("00" & Day(Date), 2)
TxtYear(1).Text = Year(gValidEndDate)
TxtMonth(1).Text = Right("00" & Month(gValidEndDate), 2)
TxtDay(1).Text = Right("00" & Day(gValidEndDate), 2)
End Sub
Private Sub CmdAllDelete_Click()
Dim sTmp As String
Dim dEventDate As Date
Data1.Recordset.MoveFirst
While Not Data1.Recordset.EOF
sTmp = Mid$(Data1.Recordset.Fields("操作日期"), 1, 4)
sTmp = sTmp & "-" & Mid$(Data1.Recordset.Fields("操作日期"), 6, 2)
sTmp = sTmp & "-" & Mid$(Data1.Recordset.Fields("操作日期"), 9, 2)
dEventDate = Format(sTmp, "yyyy-mm-dd")
dEventDate = DateAdd("m", DelIntervalMonthConst, dEventDate)
If dEventDate < Date Then
Data1.Recordset.Delete
End If
Data1.Recordset.MoveNext
Wend
Data1.Refresh
End Sub
Private Sub CmdAllEvent_Click()
Dim sSQL As String
sSQL = "select EventContext as 事件描述,EventSDate as 操作日期,ByOperator as 操作人," & _
"Remark as 备注 from eventLog"
Data1.RecordSource = sSQL
Data1.Refresh
End Sub
Private Sub CmdCancel_Click()
Unload Me
End Sub
Private Sub CmdSingleDelete_Click()
Dim sTmp As String
Dim dEventDate As Date
sTmp = Mid$(Data1.Recordset.Fields("操作日期"), 1, 4)
sTmp = sTmp & "-" & Mid$(Data1.Recordset.Fields("操作日期"), 6, 2)
sTmp = sTmp & "-" & Mid$(Data1.Recordset.Fields("操作日期"), 9, 2)
dEventDate = Format(sTmp, "yyyy-mm-dd")
dEventDate = DateAdd("m", DelIntervalMonthConst, dEventDate)
If dEventDate < Date Then
Data1.Recordset.Delete
Data1.Refresh
Else
MsgBox "Sorry,该记录暂时无法删除!", vbInformation + vbOKOnly, "提示"
End If
End Sub
Private Sub CmdSomeEvent_Click()
Dim sSQL, sValidBeginsDate, sValidEndsDate As String
sValidBeginsDate = TxtYear(0).Text & "年" & TxtMonth(0) & "月" & TxtDay(0).Text & "日"
sValidEndsDate = TxtYear(1).Text & "年" & TxtMonth(1) & "月" & TxtDay(1).Text & "日" & "23:59:59"
Data1.DatabaseName = SystemDir & "icdata.mdb"
sSQL = "select EventContext as 事件描述,EventSDate as 操作日期,ByOperator as 操作人," & _
"Remark as 备注 from eventLog where eventsdate<='" & sValidEndsDate & _
"' and eventsdate>='" & sValidBeginsDate & "'"
Data1.RecordSource = sSQL
Data1.Refresh
End Sub
Private Sub DBGrid1_RowColChange(LastRow As Variant, ByVal LastCol As Integer)
On Error GoTo ErrHand:
CurRecord = DBGrid1.Columns(0)
If CurRecord <> "" Then
CmdSingleDelete.Enabled = True
' CmdSomeDelete.Enabled = True
CmdAllDelete.Enabled = True
Else
CmdSingleDelete.Enabled = False
' CmdSomeDelete.Enabled = False
CmdAllDelete.Enabled = False
End If
Exit Sub
ErrHand:
CmdSingleDelete.Enabled = False
' CmdSomeDelete.Enabled = False
CmdAllDelete.Enabled = False
End Sub
Private Sub Form_Load()
Dim sSQL As String
Data1.DatabaseName = SystemDir & "icdata.mdb"
sSQL = "select EventContext as 事件描述,EventSDate as 操作日期,ByOperator as 操作人," & _
"Remark as 备注 from eventLog"
Data1.RecordSource = sSQL
ValidDate
End Sub
Private Sub TxtYear_Change(Index As Integer)
Dim sTmp As String
sTmp = TxtYear(Index).Text
sTmp = "0000" & sTmp
If Mid(sTmp, Len(sTmp), 1) < "0" Or Mid(sTmp, Len(sTmp), 1) > "9" _
Or Mid(sTmp, Len(sTmp) - 1, 1) < "0" Or Mid(sTmp, Len(sTmp) - 1, 1) > "9" _
Or Mid(sTmp, Len(sTmp) - 2, 1) < "0" Or Mid(sTmp, Len(sTmp) - 2, 1) > "9" _
Or Mid(sTmp, Len(sTmp) - 3, 1) < "0" Or Mid(sTmp, Len(sTmp) - 3, 1) > "9" _
Then
MsgBox "日期年(2000以上数字)!", vbInformation + vbOKOnly, "提示"
TxtYear(Index).Text = Left(TxtYear(Index).Text, Len(TxtYear(Index).Text) - 1)
End If
End Sub
Private Sub TxtYear_LostFocus(Index As Integer)
If Val(TxtYear(Index).Text) < 2000 Then
TxtYear(Index).Text = "2000"
MsgBox "日期年(2000以上数字)!", vbInformation + vbOKOnly, "提示"
End If
End Sub
Private Sub TxtMonth_Change(Index As Integer)
Dim sTmp As String
sTmp = TxtMonth(Index).Text
sTmp = "00" & sTmp
If Mid(sTmp, Len(sTmp), 1) < "0" Or Mid(sTmp, Len(sTmp), 1) > "9" _
Or Mid(sTmp, Len(sTmp) - 1, 1) < "0" Or Mid(sTmp, Len(sTmp) - 1, 1) _
> "9" Or Val(sTmp) > 12 Then
MsgBox "日期月(00~12)输入错误!", vbInformation + vbOKOnly, "提示"
TxtMonth(Index).Text = Left(TxtMonth(Index).Text, Len(TxtMonth(Index).Text) - 1)
End If
End Sub
Private Sub TxtMonth_LostFocus(Index As Integer)
TxtMonth(Index).Text = Right("00" & Val(TxtMonth(Index).Text), 2)
End Sub
Private Sub TxtDay_Change(Index As Integer)
Dim sTmp As String
sTmp = TxtDay(Index).Text
sTmp = "00" & sTmp
If Mid(sTmp, Len(sTmp), 1) < "0" Or Mid(sTmp, Len(sTmp), 1) > "9" _
Or Mid(sTmp, Len(sTmp) - 1, 1) < "0" Or Mid(sTmp, Len(sTmp) - 1, 1) _
> "9" Or Val(sTmp) > 31 Then
MsgBox "日期(日00~31)输入错误!", vbInformation + vbOKOnly, "提示"
TxtDay(Index).Text = Left(TxtDay(Index).Text, Len(TxtDay(Index).Text) - 1)
End If
End Sub
Private Sub TxtDay_LostFocus(Index As Integer)
TxtDay(Index).Text = Right("00" & Val(TxtDay(Index).Text), 2)
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -