?? frmtgclient.frm
字號:
EndProperty
SplitCount = 1
BeginProperty Split0
BeginProperty Column00
EndProperty
BeginProperty Column01
EndProperty
EndProperty
End
Begin MSDataGridLib.DataGrid DataGrid2
Height = 2415
Index = 1
Left = -74760
TabIndex = 10
Top = 3720
Width = 3975
_ExtentX = 7011
_ExtentY = 4260
_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 = "frmTgClient"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
'rs_client用于最初顯示時的記錄集
Dim rs_client As New ADODB.Recordset
'rs_order 為用于排序時的記錄集
Dim rs_order As New ADODB.Recordset
'rs_tg 為用于統(tǒng)計時的記錄集
Dim rs_tg As New ADODB.Recordset
'sql 為用于最初顯示時的sql語句
Dim sql As String
'sqlod 為用于排序顯示時的sql語句
Dim sqlod As String
'sqltg為用于統(tǒng)計顯示時的sql語句
Dim sqltg As String
Private Sub cmdOrderC_Click()
'排序只是對DataGrid1排序,對于用于統(tǒng)計的DataGrid2不排序
If rs_order.State = adStateOpen Then
rs_order.Close
End If
sqlod = "select * from Client order by " & Combo1(0).Text
rs_order.CursorLocation = adUseClient
rs_order.Open sqlod, conn, adOpenStatic, adLockOptimistic
'設(shè)置DataGrid1的數(shù)據(jù)源
Set DataGrid1(0).DataSource = rs_order
DataGrid1(0).Refresh
sqltg = "select " & Combo1(0).Text & ", count(" & Combo1(0).Text & ") as 數(shù)量統(tǒng)計" & _
" from Client group by " & Combo1(0).Text & " order by " & Combo1(0).Text
If rs_tg.State = adStateOpen Then
rs_tg.Close
End If
rs_tg.CursorLocation = adUseClient
rs_tg.Open sqltg, conn, adOpenStatic, adLockOptimistic
'設(shè)置DataGrid2的數(shù)據(jù)源
Set DataGrid2(0).DataSource = rs_tg
DataGrid2(0).Refresh
End Sub
Private Sub cmdOrderGS_Click()
'排序只是對DataGrid1排序,對于用于統(tǒng)計的DataGrid2不排序
If rs_order.State = adStateOpen Then
rs_order.Close
End If
sqlod = "select * from GongSi order by " & Combo1(1).Text
rs_order.CursorLocation = adUseClient
rs_order.Open sqlod, conn, adOpenStatic, adLockOptimistic
'設(shè)置DataGrid1的數(shù)據(jù)源
Set DataGrid1(1).DataSource = rs_order
DataGrid1(1).Refresh
sqltg = "select " & Combo1(1).Text & ", count(" & Combo1(1).Text & ") as 數(shù)量統(tǒng)計 " & _
" from GongSi group by " & Combo1(1).Text & " order by " & Combo1(1).Text
If rs_tg.State = adStateOpen Then
rs_tg.Close
End If
rs_tg.CursorLocation = adUseClient
rs_tg.Open sqltg, conn, adOpenStatic, adLockOptimistic
'設(shè)置DataGrid2的數(shù)據(jù)源
Set DataGrid2(1).DataSource = rs_tg
DataGrid2(1).Refresh
End Sub
Private Sub Form_Load()
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循環(huán)設(shè)置屬性,以減少代碼
For i = 0 To 1
'設(shè)置網(wǎng)格不可寫
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
Next i
Select Case SSTab1.Tab
'家庭租戶統(tǒng)計選項卡
Case 0
'先設(shè)置DataGrid1的數(shù)據(jù)
sql = "select * from Client order by " & Combo1(0).Text
If rs_client.State = adStateOpen Then
rs_client.Close
End If
rs_client.CursorLocation = adUseClient
rs_client.Open sql, conn, adOpenStatic, adLockOptimistic
'設(shè)置DataGrid1的數(shù)據(jù)源
Set DataGrid1(0).DataSource = rs_client
DataGrid1(0).Refresh
'設(shè)置DataGrid2的統(tǒng)計數(shù)據(jù)
'下面的sql語句已用戶選擇的Combo1(0).text分組,并且統(tǒng)計同一個Combo1(0).text的數(shù)量
sqltg = "select " & Combo1(0).Text & ", count(" & Combo1(0).Text & ") as 數(shù)量統(tǒng)計" & _
" from Client group by " & Combo1(0).Text & " order by " & Combo1(0).Text
If rs_tg.State = adStateOpen Then
rs_tg.Close
End If
rs_tg.CursorLocation = adUseClient
rs_tg.Open sqltg, conn, adOpenStatic, adLockOptimistic
'設(shè)置DataGrid2的數(shù)據(jù)源
Set DataGrid2(0).DataSource = rs_tg
DataGrid2(0).Refresh
Case 1
'先設(shè)置DataGrid1的數(shù)據(jù)
sql = "select * from GongSi order by " & Combo1(1).Text
If rs_client.State = adStateOpen Then
rs_client.Close
End If
rs_client.CursorLocation = adUseClient
rs_client.Open sql, conn, adOpenStatic, adLockOptimistic
'設(shè)置DataGrid1的數(shù)據(jù)源
Set DataGrid1(1).DataSource = rs_client
DataGrid1(1).Refresh
'設(shè)置DataGrid2的統(tǒng)計數(shù)據(jù)
'下面的sql語句已用戶選擇的Combo1(1).text分組,并且統(tǒng)計同一個Combo1(1).text的數(shù)量
sqltg = "select " & Combo1(1).Text & ", count(" & Combo1(1).Text & ") as 數(shù)量統(tǒng)計 " & _
" from GongSi group by " & Combo1(1).Text & " order by " & Combo1(1).Text
If rs_tg.State = adStateOpen Then
rs_tg.Close
End If
rs_tg.CursorLocation = adUseClient
rs_tg.Open sqltg, conn, adOpenStatic, adLockOptimistic
'設(shè)置DataGrid2的數(shù)據(jù)源
Set DataGrid2(1).DataSource = rs_tg
DataGrid2(1).Refresh
End Select
End Sub
Private Sub SSTab1_Click(PreviousTab As Integer)
Select Case SSTab1.Tab
'家庭租戶統(tǒng)計選項卡
Case 0
'先設(shè)置DataGrid1的數(shù)據(jù)
sql = "select * from Client order by " & Combo1(0).Text
If rs_client.State = adStateOpen Then
rs_client.Close
End If
rs_client.CursorLocation = adUseClient
rs_client.Open sql, conn, adOpenStatic, adLockOptimistic
'設(shè)置DataGrid1的數(shù)據(jù)源
Set DataGrid1(0).DataSource = rs_client
DataGrid1(0).Refresh
'設(shè)置DataGrid2的統(tǒng)計數(shù)據(jù)
'下面的sql語句已用戶選擇的Combo1(0).text分組,并且統(tǒng)計同一個Combo1(0).text的數(shù)量
sqltg = "select " & Combo1(0).Text & ", count(" & Combo1(0).Text & ") as 數(shù)量統(tǒng)計" & _
" from Client group by " & Combo1(0).Text & " order by " & Combo1(0).Text
If rs_tg.State = adStateOpen Then
rs_tg.Close
End If
rs_tg.CursorLocation = adUseClient
rs_tg.Open sqltg, conn, adOpenStatic, adLockOptimistic
'設(shè)置DataGrid2的數(shù)據(jù)源
Set DataGrid2(0).DataSource = rs_tg
DataGrid2(0).Refresh
Case 1
'先設(shè)置DataGrid1的數(shù)據(jù)
sql = "select * from GongSi order by " & Combo1(1).Text
If rs_client.State = adStateOpen Then
rs_client.Close
End If
rs_client.CursorLocation = adUseClient
rs_client.Open sql, conn, adOpenStatic, adLockOptimistic
'設(shè)置DataGrid1的數(shù)據(jù)源
Set DataGrid1(1).DataSource = rs_client
DataGrid1(1).Refresh
'設(shè)置DataGrid2的統(tǒng)計數(shù)據(jù)
'下面的sql語句已用戶選擇的Combo1(1).text分組,并且統(tǒng)計同一個Combo1(1).text的數(shù)量
sqltg = "select " & Combo1(1).Text & ", count(" & Combo1(1).Text & ") as 數(shù)量統(tǒng)計 " & _
" from GongSi group by " & Combo1(1).Text & " order by " & Combo1(1).Text
If rs_tg.State = adStateOpen Then
rs_tg.Close
End If
rs_tg.CursorLocation = adUseClient
rs_tg.Open sqltg, conn, adOpenStatic, adLockOptimistic
'設(shè)置DataGrid2的數(shù)據(jù)源
Set DataGrid2(1).DataSource = rs_tg
DataGrid2(1).Refresh
End Select
End Sub
Private Sub Form_Unload(Cancel As Integer)
If rs_client.State = adStateOpen Then
rs_client.Close
End If
If rs_order.State = adStateOpen Then
rs_order.Close
End If
If rs_tg.State = adStateOpen Then
rs_tg.Close
End If
End Sub
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -