📄 query.frm
字号:
Width = 3735
End
Begin VB.CommandButton cmdFindDay
Caption = "开始查询"
Height = 375
Left = 3240
TabIndex = 19
Top = 840
Width = 1215
End
Begin VB.Label lblTitle
Alignment = 2 'Center
BackStyle = 0 'Transparent
Caption = "Label8"
ForeColor = &H000000FF&
Height = 255
Left = 480
TabIndex = 31
Top = 2400
Width = 3735
End
Begin VB.Label lblEveryDay
Caption = "Label7"
ForeColor = &H00FF0000&
Height = 255
Left = 240
TabIndex = 30
Top = 2160
Width = 3615
End
Begin VB.Label Label1
Caption = "日期: 销售额(元):"
Height = 255
Left = 240
TabIndex = 29
Top = 720
Width = 2655
End
Begin VB.Label Label6
Caption = "至"
Height = 255
Left = 2760
TabIndex = 28
Top = 360
Width = 255
End
Begin VB.Label Label5
Caption = "日期范围:自"
Height = 255
Left = 240
TabIndex = 27
Top = 360
Width = 1095
End
Begin VB.Label lblDay
BackStyle = 0 'Transparent
Caption = "Label5"
ForeColor = &H00FF0000&
Height = 255
Left = 480
TabIndex = 23
Top = 3960
Width = 3855
End
Begin VB.Label Label2
Caption = "客人标识: 消费金额(元):"
Height = 255
Left = 480
TabIndex = 22
Top = 2640
Width = 3855
End
End
Begin VB.Frame Frame1
Caption = "排行内容:"
Height = 975
Left = 360
TabIndex = 10
Top = 600
Width = 4815
Begin VB.OptionButton optWhole
Caption = "全部"
Height = 180
Left = 2160
TabIndex = 15
Top = 240
Width = 735
End
Begin VB.OptionButton optPart
Caption = "选择消费日期范围"
Height = 255
Left = 120
TabIndex = 14
Top = 240
Width = 1815
End
Begin VB.TextBox txtDate1
Height = 270
Left = 360
MaxLength = 10
TabIndex = 13
Top = 510
Width = 1095
End
Begin VB.TextBox txtDate2
Height = 270
Left = 1800
MaxLength = 10
TabIndex = 12
Top = 510
Width = 1095
End
Begin VB.CommandButton cmdOK
Caption = "确定"
Height = 375
Left = 3480
TabIndex = 11
Top = 240
Width = 975
End
Begin VB.Label lblDate1
Caption = "自"
Height = 255
Left = 120
TabIndex = 17
Top = 525
Width = 255
End
Begin VB.Label lblDate2
Caption = "至"
Height = 255
Left = 1560
TabIndex = 16
Top = 525
Width = 255
End
End
Begin VB.ListBox List2
Height = 1500
Left = 2400
TabIndex = 9
Top = 2160
Visible = 0 'False
Width = 1335
End
Begin VB.ListBox List1
Height = 1500
Left = 720
TabIndex = 8
Top = 2160
Visible = 0 'False
Width = 1455
End
Begin VB.Frame Frame2
Caption = "排行方式:"
Height = 615
Left = 360
TabIndex = 1
Top = 6360
Width = 4815
Begin VB.OptionButton optSaleMoney
Caption = "按销售额(含让利部分)"
Height = 255
Left = 1680
TabIndex = 3
Top = 240
Width = 2295
End
Begin VB.OptionButton optSaleCount
Caption = "按销量"
Height = 255
Left = 240
TabIndex = 2
Top = 240
Width = 975
End
End
Begin VB.ListBox lstCompare
Height = 3840
ItemData = "Query.frx":0754
Left = 360
List = "Query.frx":0756
TabIndex = 0
Top = 1920
Width = 4815
End
Begin VB.Timer Timer1
Enabled = 0 'False
Interval = 100
Left = 0
Top = 0
End
Begin VB.Label lblTotal
BackStyle = 0 'Transparent
ForeColor = &H00FF0000&
Height = 495
Left = 360
TabIndex = 7
Top = 5880
Width = 4815
End
Begin VB.Label Label4
BackStyle = 0 'Transparent
Caption = "名次: 品种: 销量(份):销售额(元):"
Height = 255
Left = 360
TabIndex = 6
Top = 1680
Width = 4935
End
Begin VB.Label Label3
AutoSize = -1 'True
BackStyle = 0 'Transparent
Caption = "畅销美食排行榜"
BeginProperty Font
Name = "隶书"
Size = 36
Charset = 134
Weight = 400
Underline = 0 'False
Italic = -1 'True
Strikethrough = 0 'False
EndProperty
ForeColor = &H0000FFFF&
Height = 720
Index = 1
Left = 210
TabIndex = 5
Top = -30
Width = 5160
End
Begin VB.Label Label3
AutoSize = -1 'True
BackStyle = 0 'Transparent
Caption = "畅销美食排行榜"
BeginProperty Font
Name = "隶书"
Size = 36
Charset = 134
Weight = 400
Underline = 0 'False
Italic = -1 'True
Strikethrough = 0 'False
EndProperty
ForeColor = &H000000FF&
Height = 720
Index = 0
Left = 240
TabIndex = 4
Top = 0
Width = 5160
End
End
Attribute VB_Name = "frmQuery"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Dim DB As Database
Dim Rec As Recordset
Dim strDate As String
Dim sngChartHeight As Single
Dim sngChartTop As Single
Private Sub cmdFindDay_Click()
With txtDay1
If Not IsDate(.Text) Then
.Text = "日期无效!"
.SetFocus
.SelStart = 0
.SelLength = Len(.Text)
Exit Sub
End If
End With
With txtDay2
If Not IsDate(.Text) Then
.Text = "日期无效!"
.SetFocus
.SelStart = 0
.SelLength = Len(.Text)
Exit Sub
End If
End With
txtDay1 = Format(txtDay1, "YYYY-MM-DD")
txtDay2 = Format(txtDay2, "YYYY-MM-DD")
lstEveryDay.Clear
lstDay.Clear
lblEveryDay = ""
Dim Rec As Recordset
Dim S As Currency
Set Rec = DB.OpenRecordset("Select Date, Sum(Pay) From Sale Where Date Between #" & txtDay1 & "# And #" & txtDay2 & "# Group By Date", dbOpenSnapshot)
If Rec.RecordCount <> 0 Then
Rec.MoveFirst
Do Until Rec.EOF
lstEveryDay.AddItem Format(Rec.Fields(0), "YYYY-MM-DD") & Space(15 - Len(Format(Rec.Fields(1), "##0.00"))) & Format(Rec.Fields(1), "##0.00")
S = S + Rec.Fields(1)
Rec.MoveNext
Loop
lblEveryDay = "合计:共 " & lstEveryDay.ListCount & " 日,总销售额:" & Format(S, "##0.00") & "元"
lstEveryDay.ListIndex = lstEveryDay.ListCount - 1
End If
End Sub
Private Sub cmdMonthFind_Click()
Dim datFind As Date
Dim strFind As String
strFind = Trim(InputBox("请输入年、月:(格式:YYYY-MM 如:" & Format(Date, "YYYY-MM") & ")", "月销售额查询", Format(Date, "YYYY-MM")))
If strFind = "" Then Exit Sub
If Not IsDate(Left(strFind, 7)) Then
MsgBox "“" & strFind & "”不是一个有效的年月!", vbInformation, "月销售额查询"
Exit Sub
End If
datFind = Format(strFind, "YYYY-MM")
If MsgBox("您要查询的年月是" & Year(datFind) & "年" & Month(datFind) & "月吗?", vbQuestion + vbYesNo, "月销售额查询") = vbNo Then
Exit Sub
End If
Dim Rec As Recordset
Dim S As Currency
Set Rec = DB.OpenRecordset("Select Sum(Pay) From Sale Where Year(Date) = " & Year(datFind) & " And Month(Date) = " & Month(datFind))
If Not IsNull(Rec.Fields(0)) Then
S = Rec.Fields(0)
End If
MsgBox Year(datFind) & "年" & Month(datFind) & "月的销售额是:" & Format(S, "##0.00") & "元。", vbInformation, "月销售额查询"
Rec.Close
Set Rec = Nothing
End Sub
Private Sub cmdOK_Click()
If optPart.Value = True Then
With txtDate1
If Not IsDate(.Text) Then
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -