📄 form16.frm
字号:
_Version = 393216
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 MSDataGridLib.DataGrid DataGrid2
Height = 1815
Index = 1
Left = 240
TabIndex = 20
Top = 3600
Width = 3495
_ExtentX = 6165
_ExtentY = 3201
_Version = 393216
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
End
End
Attribute VB_Name = "frmD3"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
'rs_fee用于最初显示时的记录集
Dim rs_fee As New ADODB.Recordset
'rs_order 为用于排序时的记录集
Dim rs_order As New ADODB.Recordset
'rs_tg 为用于统计时的记录集
Dim rs_tg As New ADODB.Recordset
'sql 为用于最初显示时的sql语句
Dim sql As String
'sqlod 为用于排序显示时的sql语句
Dim sqlod As String
'sqltg为用于统计显示时的sql语句
Dim sqltg As String
Dim MsgText As String
Private Sub cmdOrderWY_Click()
'排序只是对DataGrid1排序,对于用于统计的DataGrid2不排序
If rs_order.State = adStateOpen Then
rs_order.Close
End If
sqlod = "select * from wysf order by " & Combo1(0).Text
rs_order.CursorLocation = adUseClient
Set rs_order = ExecuteSQL(sqlod, MsgText)
'设置DataGrid1的数据源
Set DataGrid1(0).DataSource = rs_order
DataGrid1(0).Refresh
End Sub
Private Sub cmdOrderYB_Click()
'排序只是对DataGrid1排序,对于用于统计的DataGrid2不排序
If rs_order.State = adStateOpen Then
rs_order.Close
End If
sqlod = "select * from ybsf order by " & Combo1(2).Text
rs_order.CursorLocation = adUseClient
Set rs_order = ExecuteSQL(sqlod, MsgText)
'设置DataGrid1的数据源
Set DataGrid1(1).DataSource = rs_order
DataGrid1(1).Refresh
End Sub
Private Sub cmdTgWY_Click()
'统计只是在DataGrid2上显示统计,对于DataGrid1的数据改动
If rs_tg.State = adStateOpen Then
rs_tg.Close
End If
sqltg = "select " & Combo1(1).Text & ", sum( 已交金额 ) as 已交金额统计," & _
"sum(应收总额) as 应收总额统计, sum(欠费金额) as 欠费金额统计 from wysf " & _
"group by " & Combo1(1).Text & " order by " & Combo1(1).Text & ", sum( 已交金额 ) "
rs_tg.CursorLocation = adUseClient
Set rs_tg = ExecuteSQL(sqltg, MsgText)
'设置DataGrid2的数据源
Set DataGrid2(0).DataSource = rs_tg
DataGrid2(0).Refresh
End Sub
Private Sub cmdTgYB_Click()
'统计只是在DataGrid2上显示统计,对于DataGrid1的数据改动
If rs_tg.State = adStateOpen Then
rs_tg.Close
End If
sqltg = "select " & Combo1(3).Text & ", sum( 已交金额 ) as 已交金额统计," & _
"sum(应收总额) as 应收总额统计, sum(欠费金额) as 欠费金额统计 from ybsf " & _
"group by " & Combo1(3).Text & " order by " & Combo1(3).Text & ", sum( 已交金额 ) "
rs_tg.CursorLocation = adUseClient
Set rs_tg = ExecuteSQL(sqltg, MsgText)
'设置DataGrid2的数据源
Set DataGrid2(1).DataSource = rs_tg
DataGrid2(1).Refresh
End Sub
Private Sub Form_Load()
frmD3.Width = 9015
frmD3.Height = 6780
Dim x0 As Long
Dim y0 As Long
'让窗体居中
x0 = Screen.Width
y0 = Screen.Height
x0 = (x0 - Me.Width) / 2
y0 = (y0 - Me.Height) / 2
Me.Move x0, y0
'使用for循环设置属性,以减少代码
For i = 0 To 1
'设置网格不可写
DataGrid1(i).AllowAddNew = False
DataGrid1(i).AllowDelete = False
DataGrid1(i).AllowUpdate = False
DataGrid2(i).AllowAddNew = False
DataGrid2(i).AllowDelete = False
DataGrid2(i).AllowUpdate = False
Combo1(i).ListIndex = 0
Combo1(i + 2).ListIndex = 0
Next i
Select Case SSTab1.Tab
'物业收费统计选项卡
Case 0
'先设置DataGrid1的数据
sql = "select * from wysf order by " & Combo1(0).Text
If rs_fee.State = adStateOpen Then
rs_fee.Close
End If
rs_fee.CursorLocation = adUseClient
Set rs_fee = ExecuteSQL(sql, MsgText)
'设置DataGrid1的数据源
Set DataGrid1(0).DataSource = rs_fee
DataGrid1(0).Refresh
'设置DataGrid2的统计数据
'下面的sql语句已用户选择的Combo1(1).text分组,并且统计同一个Combo1(1).text的费用总额
sqltg = "select " & Combo1(1).Text & ", sum( 已交金额 ) as 已交金额统计," & _
"sum(应收总额) as 应收总额统计, sum(欠费金额) as 欠费金额统计 from wysf " & _
"group by " & Combo1(1).Text & " order by " & Combo1(1).Text & ", sum( 已交金额 ) "
If rs_tg.State = adStateOpen Then
rs_tg.Close
End If
rs_tg.CursorLocation = adUseClient
Set rs_tg = ExecuteSQL(sqltg, MsgText)
'设置DataGrid2的数据源
Set DataGrid2(0).DataSource = rs_tg
DataGrid2(0).Refresh
Case 1
'先设置DataGrid1的数据
sql = "select * from ybsf order by " & Combo1(2).Text
If rs_fee.State = adStateOpen Then
rs_fee.Close
End If
rs_fee.CursorLocation = adUseClient
Set rs_fee = ExecuteSQL(sql, MsgText)
'设置DataGrid1的数据源
Set DataGrid1(1).DataSource = rs_fee
DataGrid1(1).Refresh
'设置DataGrid2的统计数据
'下面的sql语句已用户选择的Combo1(3).text分组,并且统计同一个Combo1(3).text的费用总额
sqltg = "select " & Combo1(3).Text & ", sum( 已交金额 ) as 已交金额统计," & _
"sum(应收总额) as 应收总额统计, sum(欠费金额) as 欠费金额统计 from ybsf " & _
"group by " & Combo1(3).Text & " order by " & Combo1(3).Text & ", sum( 已交金额 ) "
If rs_tg.State = adStateOpen Then
rs_tg.Close
End If
rs_tg.CursorLocation = adUseClient
Set rs_tg = ExecuteSQL(sqltg, MsgText)
'设置DataGrid2的数据源
Set DataGrid2(1).DataSource = rs_tg
DataGrid2(1).Refresh
End Select
End Sub
Private Sub SSTab1_Click(PreviousTab As Integer)
Select Case SSTab1.Tab
'物业收费统计选项卡
Case 0
'如果点击的是该选项卡本身,则不作处理
If PreviousTab = 0 Then
Exit Sub
End If
'先设置DataGrid1的数据
sql = "select * from wysf order by " & Combo1(0).Text
If rs_fee.State = adStateOpen Then
rs_fee.Close
End If
rs_fee.CursorLocation = adUseClient
Set rs_fee = ExecuteSQL(sql, MsgText)
'设置DataGrid1的数据源
Set DataGrid1(0).DataSource = rs_fee
DataGrid1(0).Refresh
'设置DataGrid2的统计数据
'下面的sql语句已用户选择的Combo1(1).text分组,并且统计同一个Combo1(1).text的费用总额
sqltg = "select " & Combo1(1).Text & ", sum( 已交金额 ) as 已交金额统计," & _
"sum(应收总额) as 应收总额统计, sum(欠费金额) as 欠费金额统计 from wysf " & _
"group by " & Combo1(1).Text & " order by " & Combo1(1).Text & ", sum( 已交金额 ) "
If rs_tg.State = adStateOpen Then
rs_tg.Close
End If
rs_tg.CursorLocation = adUseClient
Set rs_tg = ExecuteSQL(sqltg, MsgText)
'设置DataGrid2的数据源
Set DataGrid2(0).DataSource = rs_tg
DataGrid2(0).Refresh
Case 1
'如果点击的是该选项卡本身,则不作处理
If PreviousTab = 1 Then
Exit Sub
End If
'先设置DataGrid1的数据
sql = "select * from ybsf order by " & Combo1(2).Text
If rs_fee.State = adStateOpen Then
rs_fee.Close
End If
rs_fee.CursorLocation = adUseClient
Set rs_fee = ExecuteSQL(sql, MsgText)
'设置DataGrid1的数据源
Set DataGrid1(1).DataSource = rs_fee
DataGrid1(1).Refresh
'设置DataGrid2的统计数据
'下面的sql语句已用户选择的Combo1(3).text分组,并且统计同一个Combo1(3).text的费用总额
sqltg = "select " & Combo1(3).Text & ", sum( 已交金额 ) as 已交金额统计," & _
"sum(应收总额) as 应收总额统计, sum(欠费金额) as 欠费金额统计 from ybsf " & _
"group by " & Combo1(3).Text & " order by " & Combo1(3).Text & ", sum( 已交金额 ) "
If rs_tg.State = adStateOpen Then
rs_tg.Close
End If
rs_tg.CursorLocation = adUseClient
Set rs_tg = ExecuteSQL(sqltg, MsgText)
'设置DataGrid2的数据源
Set DataGrid2(1).DataSource = rs_tg
DataGrid2(1).Refresh
End Select
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -