📄 frmbuyst.frm
字号:
_ExtentX = 11033
_ExtentY = 2566
_Version = 393216
AllowUpdate = 0 'False
HeadLines = 1
RowHeight = 15
BeginProperty HeadFont {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "MS Sans Serif"
Size = 8.25
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "MS Sans Serif"
Size = 8.25
Charset = 0
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 VB.Label Label4
Caption = "进货总金额:"
Height = 375
Left = -73200
TabIndex = 9
Top = 4080
Width = 1095
End
Begin VB.Label Label3
Caption = "进货总金额:"
Height = 375
Left = -73560
TabIndex = 7
Top = 4200
Width = 1095
End
Begin VB.Label Label2
Caption = "进货总金额:"
Height = 375
Left = -73920
TabIndex = 5
Top = 4200
Width = 1095
End
Begin VB.Label Label1
Caption = "进货总金额:"
Height = 375
Left = 1080
TabIndex = 2
Top = 4200
Width = 1095
End
End
End
Attribute VB_Name = "frmbuyst"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub Form_activate()
'让窗体居中
Call MakeCenter(Me)
Dim inty As Integer '当前年份
Dim intm As Integer '当前月份
Dim intd As Integer '当前日期
inty = Year(Date)
intm = Month(Date)
intd = Day(Date)
Dim sqlbuy As String
Dim sqlfctotal As String '各厂商进货总金额
Dim sqltotal As String '总进货金额
Dim rs_check As New ADODB.Recordset
Dim rs_fctotal As New ADODB.Recordset
Dim rs_total As New ADODB.Recordset
rs_check.CursorLocation = adUseClient '设置游标方式
rs_fctotal.CursorLocation = adUseClient
rs_total.CursorLocation = adUseClient
Adodc1.ConnectionString = connStr
Set DataGrid1.DataSource = Adodc1
Adodc2.ConnectionString = connStr
Set DataGrid2.DataSource = Adodc2
Adodc3.ConnectionString = connStr
Set DataGrid3.DataSource = Adodc3
Adodc4.ConnectionString = connStr
Set DataGrid4.DataSource = Adodc4
Adodc5.ConnectionString = connStr
Set DataGrid5.DataSource = Adodc5
Adodc6.ConnectionString = connStr
Set DataGrid6.DataSource = Adodc6
Adodc7.ConnectionString = connStr
Set DataGrid7.DataSource = Adodc7
Adodc8.ConnectionString = connStr
Set DataGrid8.DataSource = Adodc8
Select Case SSTabbuy.Tab
Case 0 '今日进货选项卡
SSTabbuy.TabEnabled(0) = True '设为可用
SSTabbuy.TabEnabled(1) = False '设为不可用
SSTabbuy.TabEnabled(2) = False
SSTabbuy.TabEnabled(3) = False
'下面的sql语句从goods表中选择进货日期为当前系统时间的记录的所有项,
'并且把结果按生产厂商,总金额的降序排列
sqlbuy = "select * from goods where 进货年 =" & inty _
& " and 进货月=" & intm & " and 进货日=" & intd & " order by" _
& " 生产厂商,总金额 desc"
'打开游标
rs_check.Open sqlbuy, conn, adOpenKeyset, adLockPessimistic
Adodc1.RecordSource = sqlbuy '修改Adodc1的RecordSource属性
Adodc1.Refresh '刷新Adodc1的属性
DataGrid1.ReBind '重新绑定DataGrid1
'如果所查询结果集为空,则重新设置Adodc2和重新绑定DataGrid2,使其也为空
If rs_check.EOF = True Then
Adodc2.RecordSource = sqlbuy
Adodc2.Refresh
DataGrid2.ReBind
Text1.Text = 0
MsgBox "您今日没有进货!", vbOKOnly + vbInformation, "注意"
rs_check.Close
Exit Sub
End If
'下面的sql语句从goods表中选择进货日期为当前日期的记录集的"生产厂商"和"总金额",
'并对结果以生产厂商为对象进行分组,对分组后的总金额进行求和统计
sqlfctotal = "select 生产厂商,sum(总金额) as 各厂商进货总金额 " _
& " from goods where 进货年 =" & inty & "and 进货月=" & intm _
& " and 进货日=" & intd & " group by 生产厂商 "
rs_fctotal.Open sqlfctotal, conn, adOpenKeyset, adLockPessimistic
Adodc2.RecordSource = sqlfctotal
Adodc2.Refresh
DataGrid2.ReBind
rs_fctotal.Close
sqltotal = "select sum(总金额) as 进货总金额 from goods where " _
& " 进货年 =" & inty & "and 进货月=" & intm & "and 进货日=" & intd
rs_total.Open sqltotal, conn, adOpenKeyset, adLockPessimistic
Text1.Text = rs_total.Fields(0)
rs_total.Close
rs_check.Close
Case 1
SSTabbuy.TabEnabled(0) = False
SSTabbuy.TabEnabled(1) = True
SSTabbuy.TabEnabled(2) = False
SSTabbuy.TabEnabled(3) = False
sqlbuy = "select * from goods where 进货年 =" & inty _
& "and 进货月=" & intm & " order by 生产厂商,总金额 desc"
rs_check.Open sqlbuy, conn, adOpenKeyset, adLockPessimistic
Adodc3.RecordSource = sqlbuy
Adodc3.Refresh
DataGrid3.ReBind
If rs_check.EOF = True Then
Adodc4.RecordSource = sqlbuy
Adodc4.Refresh
DataGrid4.ReBind
Text2.Text = 0
MsgBox "您本月没有进货!", vbOKOnly + vbInformation, "注意"
rs_check.Close
Exit Sub
End If
rs_check.Close
sqlfctotal = "select 生产厂商,sum(总金额) as 各厂商进货总金额 " _
& "from goods where 进货年 =" & inty & "and 进货月=" & intm _
& " group by 生产厂商 "
rs_fctotal.Open sqlfctotal, conn, adOpenKeyset, adLockPessimistic
Adodc4.RecordSource = sqlfctotal
Adodc4.Refresh
DataGrid4.ReBind
rs_fctotal.Close
sqltotal = "select sum(总金额) as 进货总金额 from goods where " _
& " 进货年 =" & inty & "and 进货月=" & intm
rs_total.Open sqltotal, conn, adOpenKeyset, adLockPessimistic
Text2.Text = rs_total.Fields(0)
rs_total.Close
Case 2
SSTabbuy.TabEnabled(0) = False
SSTabbuy.TabEnabled(1) = False
SSTabbuy.TabEnabled(2) = True
SSTabbuy.TabEnabled(3) = False
Dim s As Integer '用于判断当前月为本季度的第几个月
s = intm Mod 3
If s = 0 Then s = 3 '如果能整除3,则说明当前月为本季度的第3个月
sqlbuy = "select * from goods where 进货年 =" & inty _
& " and 进货月 between " & (intm - s) & " and " & (intm + 1) _
& " order by 生产厂商,总金额 desc"
rs_check.Open sqlbuy, conn, adOpenKeyset, adLockPessimistic
Adodc5.RecordSource = sqlbuy
Adodc5.Refresh
DataGrid5.ReBind
If rs_check.EOF = True Then
Adodc6.RecordSource = sqlbuy
Adodc6.Refresh
DataGrid6.ReBind
MsgBox "您本季度没有进货!", vbOKOnly + vbInformation, "注意"
rs_check.Close
Exit Sub
End If
rs_check.Close
sqlfctotal = "select 生产厂商,sum(总金额) as 各厂商进货总金额 " _
& "from goods where 进货年 =" & inty & "and 进货月 between " _
& (intm - s) & " and " & intm & " group by 生产厂商 "
rs_fctotal.Open sqlfctotal, conn, adOpenKeyset, adLockPessimistic
Adodc6.RecordSource = sqlfctotal
Adodc6.Refresh
DataGrid6.ReBind
rs_fctotal.Close
sqltotal = "select sum(总金额) as 进货总金额 from goods where 进货年 =" _
& inty & "and 进货月 between " & (intm - s) & " and " & intm
rs_total.Open sqltotal, conn, adOpenKeyset, adLockPessimistic
Text3.Text = rs_total.Fields(0)
rs_total.Close
Case 3
SSTabbuy.TabEnabled(0) = False
SSTabbuy.TabEnabled(1) = False
SSTabbuy.TabEnabled(2) = False
SSTabbuy.TabEnabled(3) = True
sqlbuy = "select * from goods where 进货年 =" & inty _
& " order by 生产厂商,总金额 desc"
rs_check.Open sqlbuy, conn, adOpenKeyset, adLockPessimistic
Adodc7.RecordSource = sqlbuy
Adodc7.Refresh
DataGrid7.ReBind
If rs_check.EOF = True Then
Adodc8.RecordSource = sqlbuy
Adodc8.Refresh
DataGrid8.ReBind
Text3.Text = 0
MsgBox "您本年度没有进货!", vbOKOnly + vbInformation, "注意"
rs_check.Close
Exit Sub
End If
rs_check.Close
sqlfctotal = "select 生产厂商,sum(总金额) as 各厂商进货总金额 " _
& "from goods where 进货年 =" & inty & " group by 生产厂商 "
rs_fctotal.Open sqlfctotal, conn, adOpenKeyset, adLockPessimistic
Adodc8.RecordSource = sqlfctotal
Adodc8.Refresh
DataGrid8.ReBind
rs_fctotal.Close
sqltotal = "select sum(总金额) as 进货总金额 from goods where " _
& "进货年 =" & inty
rs_total.Open sqltotal, conn, adOpenKeyset, adLockPessimistic
Text4.Text = rs_total.Fields(0)
rs_total.Close
End Select
End Sub
Private Sub Form_Load()
'Adodc1.ConnectionString=
' Set Adodc1.ConnectionString = conn.ConnectionString
' Set Adodc2.ConnectionString = conn.ConnectionString
' Set Adodc3.ConnectionString = conn.ConnectionString
' Set Adodc4.ConnectionString = conn.ConnectionString
' Set Adodc5.ConnectionString = conn.ConnectionString
' Set Adodc6.ConnectionString = conn.ConnectionString
' Set Adodc7.ConnectionString = conn.ConnectionString
' Set Adodc8.ConnectionString = conn.ConnectionString
End Sub
Private Sub Form_Unload(Cancel As Integer)
Unload Me
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -