MSFlexGrid1.Text = \出入库\ If rs_sum.EOF = False Then rs_sum.MoveFirst
Do While Not rs_sum.EOF
MSFlexGrid1.Row = MSFlexGrid1.Row + 1 MSFlexGrid1.Col = 0
MSFlexGrid1.Text = rs_sum.Fields(0) MSFlexGrid1.Col = 1
If CDbl(rs_sum.Fields(1)) < 0 Then
MSFlexGrid1.Text = Replace(rs_sum.Fields(1), \ MSFlexGrid1.Col = 2
MSFlexGrid1.Text = \出库\ Else
MSFlexGrid1.Text = rs_sum.Fields(1) MSFlexGrid1.Col = 2
MSFlexGrid1.Text = \入库\ End If
addup = addup + CDbl(rs_sum.Fields(1)) rs_sum.MoveNext Loop
MSFlexGrid1.Row = MSFlexGrid1.Row + 1 MSFlexGrid1.Col = 0
MSFlexGrid1.Text = \总计)\ MSFlexGrid1.Col = 1
MSFlexGrid1.Text = addup End If
rs_sum.Close
Case \ '按客户汇总 Label1.Caption = \按客户汇总\
sql = \客户名,sum(金额) as 总金额 from 货物明细 group by 客户名 order by sum(金额)\
rs_sum.CursorLocation = adUseClient
rs_sum.Open sql, conn, adOpenKeyset, adLockPessimistic addup = 0
MSFlexGrid1.Rows = rs_sum.RecordCount + 2 MSFlexGrid1.Cols = 3 MSFlexGrid1.Row = 0 MSFlexGrid1.Col = 0
MSFlexGrid1.Text = \客户名\ MSFlexGrid1.Col = 1
MSFlexGrid1.Text = \总金额\ MSFlexGrid1.Col = 2
MSFlexGrid1.Text = \出入库\ If rs_sum.EOF = False Then
61
rs_sum.MoveFirst
Do While Not rs_sum.EOF
MSFlexGrid1.Row = MSFlexGrid1.Row + 1 MSFlexGrid1.Col = 0
MSFlexGrid1.Text = rs_sum.Fields(0) MSFlexGrid1.Col = 1
If CDbl(rs_sum.Fields(1)) < 0 Then
MSFlexGrid1.Text = Replace(rs_sum.Fields(1), \ MSFlexGrid1.Col = 2
MSFlexGrid1.Text = \出库\ Else
MSFlexGrid1.Text = rs_sum.Fields(1) MSFlexGrid1.Col = 2
MSFlexGrid1.Text = \入库\ End If
addup = addup + CDbl(rs_sum.Fields(1)) rs_sum.MoveNext Loop
MSFlexGrid1.Row = MSFlexGrid1.Row + 1 MSFlexGrid1.Col = 0
MSFlexGrid1.Text = \总计)\ MSFlexGrid1.Col = 1
MSFlexGrid1.Text = addup End If
rs_sum.Close
Case \ '按货物+日期汇总 Label1.Caption = \按货物+日期汇总\
sql = \货源地,日期,sum(金额) as 总金额 from 货物明细 \ \货源地,日期 order by sum(金额)\ rs_sum.CursorLocation = adUseClient
rs_sum.Open sql, conn, adOpenKeyset, adLockPessimistic addup = 0
MSFlexGrid1.MergeCells = flexMergeRestrictRows MSFlexGrid1.MergeCol(0) = True
MSFlexGrid1.Rows = rs_sum.RecordCount + 2 MSFlexGrid1.Rows = rs_sum.RecordCount + 2 MSFlexGrid1.Cols = 4 MSFlexGrid1.Row = 0 MSFlexGrid1.Col = 0
MSFlexGrid1.Text = \货源地\ MSFlexGrid1.Col = 1
MSFlexGrid1.Text = \日期\ MSFlexGrid1.Col = 2
MSFlexGrid1.Text = \总金额\
62
MSFlexGrid1.Col = 3
MSFlexGrid1.Text = \出入库\ If rs_sum.EOF = False Then rs_sum.MoveFirst
Do While Not rs_sum.EOF
MSFlexGrid1.Row = MSFlexGrid1.Row + 1 MSFlexGrid1.Col = 0
MSFlexGrid1.Text = rs_sum.Fields(0) MSFlexGrid1.Col = 1
MSFlexGrid1.Text = rs_sum.Fields(1) MSFlexGrid1.Col = 2
If CDbl(rs_sum.Fields(2)) < 0 Then
MSFlexGrid1.Text = Replace(rs_sum.Fields(2), \ MSFlexGrid1.Col = 3
MSFlexGrid1.Text = \出库\ Else
MSFlexGrid1.Text = rs_sum.Fields(2) MSFlexGrid1.Col = 3
MSFlexGrid1.Text = \入库\ End If
addup = addup + CDbl(rs_sum.Fields(2)) rs_sum.MoveNext Loop
MSFlexGrid1.Row = MSFlexGrid1.Row + 1 MSFlexGrid1.Col = 0
MSFlexGrid1.Text = \总计)\ MSFlexGrid1.Col = 2
MSFlexGrid1.Text = addup End If
rs_sum.Close
Case \ '按日期+客户汇总 Label1.Caption = \按客户+日期汇总\
sql = \客户名,日期,sum(金额) as 总金额 from 货物明细 \ \客户名,日期 order by sum(金额)\ rs_sum.CursorLocation = adUseClient
rs_sum.Open sql, conn, adOpenKeyset, adLockPessimistic addup = 0
MSFlexGrid1.MergeCells = flexMergeRestrictRows MSFlexGrid1.MergeCol(0) = True
MSFlexGrid1.Rows = rs_sum.RecordCount + 2 MSFlexGrid1.Rows = rs_sum.RecordCount + 2 MSFlexGrid1.Cols = 4 MSFlexGrid1.Row = 0 MSFlexGrid1.Col = 0
63
MSFlexGrid1.Text = \客户名\ MSFlexGrid1.Col = 1
MSFlexGrid1.Text = \日期\ MSFlexGrid1.Col = 2
MSFlexGrid1.Text = \总金额\ MSFlexGrid1.Col = 3
MSFlexGrid1.Text = \出入库\ If rs_sum.EOF = False Then rs_sum.MoveFirst
Do While Not rs_sum.EOF
MSFlexGrid1.Row = MSFlexGrid1.Row + 1 MSFlexGrid1.Col = 0
MSFlexGrid1.Text = rs_sum.Fields(0) MSFlexGrid1.Col = 1
MSFlexGrid1.Text = rs_sum.Fields(1) MSFlexGrid1.Col = 2
If CDbl(rs_sum.Fields(2)) < 0 Then
MSFlexGrid1.Text = Replace(rs_sum.Fields(2), \ MSFlexGrid1.Col = 3
MSFlexGrid1.Text = \出库\ Else
MSFlexGrid1.Text = rs_sum.Fields(2) MSFlexGrid1.Col = 3
MSFlexGrid1.Text = \入库\ End If
addup = addup + CDbl(rs_sum.Fields(2)) rs_sum.MoveNext Loop
MSFlexGrid1.Row = MSFlexGrid1.Row + 1 MSFlexGrid1.Col = 0
MSFlexGrid1.Text = \总计)\ MSFlexGrid1.Col = 2
MSFlexGrid1.Text = addup End If
rs_sum.Close End Select End Sub
12.4.10
Option Explicit
Public bolAuthority As String '保存用户权限(是否为超级用户)Public conn As New ADODB.Connection '标记连接对象 Public userID As String '标记当前用户ID Public userpow As String '标记用户权限
64
Public find As Boolean '标记查询 Public sqlfind As String '查询语句 Public rs_data1 As New ADODB.Recordset Public findok As Boolean
Public hz_menu As String '标记汇总种类 Public frmdata As Boolean
Public Sub ScreenCenter(fm As Form) '>>置窗体于屏幕中心 Dim mt!, ml! With fm
mt = (Screen.Height - .Height) * 0.5 ml = (Screen.Width - .Width) * 0.5 .Move ml, mt End With End Sub
65
VB实例源码
![](/skin/haowen/images/icon_star.png)
![](/skin/haowen/images/icon_star.png)
![](/skin/haowen/images/icon_star.png)
![](/skin/haowen/images/icon_star.png)