📄 main_xstj_yxstj.frm
字号:
VERSION 5.00
Object = "{67397AA1-7FB1-11D0-B148-00A0C922E820}#6.0#0"; "msadodc.ocx"
Object = "{0ECD9B60-23AA-11D0-B351-00A0C9055D8E}#6.0#0"; "MSHFLXGD.OCX"
Begin VB.Form main_xstj_yxstj
BorderStyle = 3 'Fixed Dialog
ClientHeight = 4875
ClientLeft = 45
ClientTop = 1680
ClientWidth = 11430
Icon = "main_xstj_yxstj.frx":0000
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 4875
ScaleWidth = 11430
ShowInTaskbar = 0 'False
StartUpPosition = 1 '所有者中心
Begin VB.TextBox txtMonth
Height = 300
Left = 4140
MaxLength = 2
TabIndex = 11
Top = 150
Width = 2250
End
Begin VB.TextBox txtYear
Height = 300
Left = 930
MaxLength = 4
TabIndex = 9
Top = 165
Width = 2250
End
Begin MSAdodcLib.Adodc Adodc1
Height = 345
Left = -375
Top = 2880
Visible = 0 'False
Width = 2985
_ExtentX = 5265
_ExtentY = 609
ConnectMode = 0
CursorLocation = 3
IsolationLevel = -1
ConnectionTimeout= 15
CommandTimeout = 30
CursorType = 3
LockType = 3
CommandType = 1
CursorOptions = 0
CacheSize = 50
MaxRecords = 0
BOFAction = 0
EOFAction = 0
ConnectStringType= 1
Appearance = 1
BackColor = -2147483643
ForeColor = -2147483640
Orientation = 0
Enabled = -1
Connect = "Provider=SQLOLEDB.1;Persist Security Info=False;User ID=sa;Initial Catalog=db_sell"
OLEDBString = "Provider=SQLOLEDB.1;Persist Security Info=False;User ID=sa;Initial Catalog=db_sell"
OLEDBFile = ""
DataSourceName = ""
OtherAttributes = ""
UserName = ""
Password = ""
RecordSource = $"main_xstj_yxstj.frx":000C
Caption = "Adodc1"
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "宋体"
Size = 9
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
_Version = 393216
End
Begin MSHierarchicalFlexGridLib.MSHFlexGrid MSHFlexGrid1
Height = 3675
Left = 0
TabIndex = 4
Top = 1200
Width = 11430
_ExtentX = 20161
_ExtentY = 6482
_Version = 393216
BackColorFixed = 12648384
SelectionMode = 1
_NumberOfBands = 1
_Band(0).Cols = 2
End
Begin VB.Frame Frame3
Height = 705
Left = 8115
TabIndex = 1
Top = 495
Width = 3315
Begin VB.CommandButton cmdExit
Caption = "退出"
Height = 360
Left = 1665
TabIndex = 2
Top = 210
Width = 1500
End
Begin VB.CommandButton cmdFind
Caption = "统计"
Height = 360
Left = 180
TabIndex = 3
Top = 210
Width = 1500
End
End
Begin VB.Frame Frame1
Height = 705
Left = 0
TabIndex = 0
Top = 495
Width = 8145
Begin VB.OptionButton Option1
Caption = "统计商品销售数量及金额"
Height = 270
Index = 2
Left = 5625
TabIndex = 8
Top = 285
Width = 2835
End
Begin VB.OptionButton Option1
Caption = "仅统计商品销售金额"
Height = 270
Index = 1
Left = 2835
TabIndex = 7
Top = 285
Width = 2700
End
Begin VB.OptionButton Option1
Caption = "仅统计商品销售数量"
Height = 270
Index = 0
Left = 135
TabIndex = 6
Top = 285
Value = -1 'True
Width = 2835
End
End
Begin VB.Label Label2
Caption = "统计月份"
Height = 225
Left = 3375
TabIndex = 10
Top = 195
Width = 735
End
Begin VB.Label Label1
Caption = "统计年份"
Height = 225
Left = 165
TabIndex = 5
Top = 195
Width = 735
End
End
Attribute VB_Name = "main_xstj_yxstj"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Public myIndex As Integer
Private Sub Form_Load()
Me.Caption = text
txtYear = Year(Date)
txtMonth = Month(Date)
cmdFind_Click
End Sub
Private Sub Option1_Click(Index As Integer)
myIndex = Index
End Sub
Private Sub txtMonth_GotFocus()
txtMonth.SelStart = 0
txtMonth.SelLength = Len(txtMonth)
End Sub
Private Sub txtYear_GotFocus()
txtYear.SelStart = 0
txtYear.SelLength = Len(txtYear)
End Sub
Private Sub cmdFind_Click() '查询统计
If IsNumeric(txtYear) = False Then
MsgBox "请输入正确的年份!", , "提示窗口"
txtYear.SetFocus
Exit Sub
End If
If txtYear < 0 Then
MsgBox "年份不能小于0!", , "提示窗口"
txtYear.SetFocus
Exit Sub
End If
If IsNumeric(txtMonth) = False Then
MsgBox "请输入正确的月份!", , "提示窗口"
txtMonth.SetFocus
Exit Sub
End If
If txtMonth > 12 < 0 Then
MsgBox "月份不能大于12或小于0!", , "提示窗口"
txtMonth.SetFocus
Exit Sub
End If
Dim r1 As Integer
Select Case myIndex
Case 0
Adodc1.RecordSource = "select 商品名称,规格,单位,sum(出货数量) as 出货总数 from 出货从表 inner join 出货主表 on 出货从表.出货票号=出货主表.票号" _
& " where year(出货主表.出货日期)='" + txtYear + "' and month(出货主表.出货日期)='" + txtMonth + "'group by 商品名称,规格,单位 order by 出货总数"
Adodc1.Refresh
With MSHFlexGrid1
Set .DataSource = Adodc1
.ColWidth(0) = 200
.ColWidth(1) = 3800
.ColWidth(2) = 2000
.ColWidth(3) = 1200
.ColWidth(4) = 1900
End With
Case 1
Adodc1.RecordSource = "select 商品名称,规格,单位,sum(金额) as 出货总金额 from 出货从表 inner join 出货主表 on 出货从表.出货票号=出货主表.票号" _
& " where year(出货主表.出货日期)='" + txtYear + "' and month(出货主表.出货日期)='" + txtMonth + "'group by 商品名称,规格,单位 order by 出货总金额"
Adodc1.Refresh
r1 = Adodc1.Recordset.RecordCount
With MSHFlexGrid1
Set .DataSource = Adodc1
For i = 1 To r1
.TextMatrix(i, 4) = Format(.TextMatrix(i, 4), "##,##0.00")
Next i
.ColWidth(0) = 200
.ColWidth(1) = 3800
.ColWidth(2) = 2000
.ColWidth(3) = 1200
.ColWidth(4) = 1900
End With
Case 2
Adodc1.RecordSource = "select 商品名称,规格,单位,sum(出货数量) as 出货总数,sum(金额) as 出货总金额 from 出货从表 inner join 出货主表 on 出货从表.出货票号=出货主表.票号" _
& " where year(出货主表.出货日期)='" + txtYear + "' and month(出货主表.出货日期)='" + txtMonth + "'group by 商品名称,规格,单位 order by 出货总数,出货总金额"
Adodc1.Refresh
r1 = Adodc1.Recordset.RecordCount
With MSHFlexGrid1
Set .DataSource = Adodc1
For i = 1 To r1
.TextMatrix(i, 5) = Format(.TextMatrix(i, 5), "##,##0.00")
Next i
.ColWidth(0) = 200
.ColWidth(1) = 3800
.ColWidth(2) = 2000
.ColWidth(3) = 1200
.ColWidth(4) = 1900
.ColWidth(5) = 1900
End With
End Select
End Sub
Private Sub cmdExit_Click()
Unload Me
End Sub
Private Sub txtYear_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyReturn Then txtMonth.SetFocus
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -