📄 form5.frm
字号:
Width = 2415
Begin MSComCtl2.DTPicker DTPicker2
Height = 255
Left = 960
TabIndex = 18
Top = 600
Width = 1335
_ExtentX = 2355
_ExtentY = 450
_Version = 393216
Format = 24641537
CurrentDate = 37980
MinDate = 2
End
Begin MSComCtl2.DTPicker DTPicker1
Height = 255
Left = 960
TabIndex = 17
Top = 270
Width = 1335
_ExtentX = 2355
_ExtentY = 450
_Version = 393216
Format = 24641537
CurrentDate = 37980
MinDate = 2
End
Begin VB.ComboBox Combo2
Height = 300
Left = 960
TabIndex = 2
Top = 1320
Width = 1335
End
Begin VB.ComboBox Combo1
Height = 300
ItemData = "Form5.frx":0442
Left = 960
List = "Form5.frx":044C
TabIndex = 1
Text = "支出情况"
Top = 960
Width = 1335
End
Begin VB.Label Label4
AutoSize = -1 'True
Caption = "收/支类型"
Height = 180
Left = 120
TabIndex = 6
Top = 1380
Width = 810
End
Begin VB.Label Label3
AutoSize = -1 'True
Caption = "收/支情况"
Height = 180
Left = 120
TabIndex = 5
Top = 1020
Width = 810
End
Begin VB.Label Label2
AutoSize = -1 'True
Caption = "结束日期"
Height = 180
Left = 120
TabIndex = 4
Top = 630
Width = 720
End
Begin VB.Label Label1
AutoSize = -1 'True
Caption = "开始日期"
Height = 180
Left = 120
TabIndex = 3
Top = 300
Width = 720
End
End
Begin MSAdodcLib.Adodc Adodc1
Height = 330
Left = 720
Top = 8160
Width = 1200
_ExtentX = 2117
_ExtentY = 582
ConnectMode = 0
CursorLocation = 3
IsolationLevel = -1
ConnectionTimeout= 15
CommandTimeout = 30
CursorType = 3
LockType = 3
CommandType = 1
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 = "Form5"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Dim sql As String
Dim he As Currency
Dim rcs As String
Private Sub Check2_Click()
Command4.Enabled = True
If Check2.Value Then
Adodc1.ConnectionString = ado
Adodc1.RecordSource = "Select * From szb"
Adodc1.Refresh
Set DataGrid1.DataSource = Adodc1
DataGrid1.Columns(0).Caption = " 收支时间"
DataGrid1.Columns(0).Width = 1000
DataGrid1.Columns.Remove (1)
DataGrid1.Columns(1).Caption = " 收支金额"
DataGrid1.Columns(1).Width = 1000
DataGrid1.Columns(2).Caption = " 收支类型"
DataGrid1.Columns(2).Width = 1000
DataGrid1.Columns(3).Caption = " 备 注"
DataGrid1.Columns(3).Width = 1800
DataGrid1.Visible = True
'统计结果
If Adodc1.Recordset.BOF Then
Text4.Text = "没有查询到符合条件的记录!"
Else
Text4.Text = "如需查看具体统计结果请先自定义查询条件后再查看!"
End If
End If
rcs = Adodc1.RecordSource
End Sub
Private Sub Check3_Click()
If Check3.Value = 1 Then
Me.Height = 6720
Else
Me.Height = 5895
End If
End Sub
Private Sub Combo1_Click()
If Combo1.Text = "支出情况" Then
'添加支出类型至组合框
Combo2.Clear
Adodc2.ConnectionString = ado
Adodc2.RecordSource = "zclx"
Adodc2.Refresh
While Not Adodc2.Recordset.EOF
Combo2.AddItem Adodc2.Recordset.Fields(0)
Adodc2.Recordset.MoveNext
Wend
Combo2.AddItem "所有类型"
Combo2.Text = Combo2.List(0)
Else
'添加收入类型至组合框
Combo2.Clear
Adodc2.ConnectionString = ado
Adodc2.RecordSource = "sylx"
Adodc2.Refresh
While Not Adodc2.Recordset.EOF
Combo2.AddItem Adodc2.Recordset.Fields(0)
Adodc2.Recordset.MoveNext
Wend
Combo2.AddItem "所有类型"
Combo2.Text = Combo2.List(0)
End If
End Sub
Private Sub Command1_Click()
Unload Me
End Sub
Private Sub Command2_Click()
Check2.Value = False
Command4.Enabled = True
If Check1.Value Then
If Text1.Text = "" And Text2.Text = "" And Text3.Text = "" Then
MsgBox "您至少在高级查找里输入一个查询条件!"
Exit Sub
End If
If (Text2.Text = "" And Text3.Text <> "") Or (Text2.Text <> "" And Text3.Text = "") Then
MsgBox "您必须将金额范围输入完整!"
Exit Sub
End If
If (Not IsNumeric(Text2.Text) And Text2.Text <> "") Or (Not IsNumeric(Text3.Text) And Text3.Text <> "") Then
MsgBox "您只能在金额一栏中输入数字!"
Exit Sub
End If
If Val(Text2.Text) > Val(Text3.Text) Then
MsgBox "最小值金额不能大过最大金额!"
Exit Sub
End If
'***************************************************************************************
If Text1.Text <> "" And Text2.Text = "" And Text3.Text = "" Then
If Combo2.Text = "所有类型" Then
sql = "Select * From szb Where date >=" & DTPicker1.Value - DTPicker1.MinDate + 2 & " and date <=" & DTPicker2.Value - DTPicker2.MinDate + 2 & " And sz='" & Left(Combo1.Text, 1) & "' and bz like '%" & Text1.Text & "%'"
Adodc1.RecordSource = sql
Adodc1.Refresh
rcs = Adodc1.RecordSource '重新排序时记录其数据源
Set DataGrid1.DataSource = Adodc1
DataGrid1.Visible = True
Else
sql = "Select * From szb Where date >=" & DTPicker1.Value - DTPicker1.MinDate + 2 & " and date <=" & DTPicker2.Value - DTPicker2.MinDate + 2 & " And sz='" & Left(Combo1.Text, 1) & "' And lx='" & Combo2.Text & "' and bz like '%" & Text1.Text & "%'"
Adodc1.RecordSource = sql
Adodc1.Refresh
rcs = Adodc1.RecordSource '重新排序时记录其数据源
Set DataGrid1.DataSource = Adodc1
DataGrid1.Visible = True
End If
DataGrid1.Columns(0).Caption = " 收支时间"
DataGrid1.Columns(0).Width = 1000
DataGrid1.Columns.Remove (1)
DataGrid1.Columns(1).Caption = " 收支金额"
DataGrid1.Columns(1).Width = 1000
DataGrid1.Columns(2).Caption = " 收支类型"
DataGrid1.Columns(2).Width = 1000
DataGrid1.Columns(3).Caption = " 备 注"
DataGrid1.Columns(3).Width = 1800
'统计结果
he = 0
If Not Adodc1.Recordset.BOF Then
Adodc1.Recordset.MoveFirst
While Not Adodc1.Recordset.EOF
he = he + Adodc1.Recordset.Fields(2)
Adodc1.Recordset.MoveNext
Wend
End If
If he <> 0 Then
Text4.Text = " 从" & Year(DTPicker1.Value) & "年" & Month(DTPicker1.Value) & "月" & Day(DTPicker1.Value) & "日" _
& "至" & Year(DTPicker2.Value) & "年" & Month(DTPicker2.Value) & "月" & Day(DTPicker2.Value) & "日," _
& "备注中含有“" & Text1.Text & "”关键字的“" & Combo2.Text & "”的发生金额总共为" & he & "元!"
Else
Text4.Text = "没有查询到符合条件的记录!"
End If
Exit Sub
End If
'******************************************************************************************
If Text1.Text = "" And Text2.Text <> "" And Text3.Text <> "" Then
If Combo2.Text = "所有类型" Then
sql = "Select * From szb Where date >=" & DTPicker1.Value - DTPicker1.MinDate + 2 & " and date <=" & DTPicker2.Value - DTPicker2.MinDate + 2 & " And sz='" & Left(Combo1.Text, 1) & "' and mn>=" & Text2.Text & " and mn<=" & Text3.Text
Adodc1.RecordSource = sql
Adodc1.Refresh
rcs = Adodc1.RecordSource '重新排序时记录其数据源
Set DataGrid1.DataSource = Adodc1
DataGrid1.Visible = True
Else
sql = "Select * From szb Where date >=" & DTPicker1.Value - DTPicker1.MinDate + 2 & " and date <=" & DTPicker2.Value - DTPicker2.MinDate + 2 & " And sz='" & Left(Combo1.Text, 1) & "' And lx='" & Combo2.Text & "' and mn>=" & Text2.Text & " and mn<=" & Text3.Text
Adodc1.RecordSource = sql
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -