📄 frmsbydraw.frm
字号:
VERSION 5.00
Object = "{67397AA1-7FB1-11D0-B148-00A0C922E820}#6.0#0"; "MSADODC.OCX"
Object = "{CDE57A40-8B86-11D0-B3C6-00A0C90AEA82}#1.0#0"; "MSDATGRD.OCX"
Begin VB.Form FrmSByDraw
Caption = "领用统计"
ClientHeight = 6960
ClientLeft = 60
ClientTop = 345
ClientWidth = 6255
LinkTopic = "Form1"
ScaleHeight = 6960
ScaleWidth = 6255
StartUpPosition = 2 '屏幕中心
Begin VB.Frame Frame1
Height = 1215
Left = 120
TabIndex = 2
Top = 0
Width = 6015
Begin VB.CommandButton Cmd_Sts
Caption = "统 计"
Height = 495
Left = 4440
TabIndex = 9
Top = 360
Width = 1335
End
Begin VB.ComboBox cob_By
Height = 300
Left = 1200
Style = 2 'Dropdown List
TabIndex = 7
Top = 240
Width = 1355
End
Begin VB.TextBox txtSDate
Height = 300
Left = 1200
TabIndex = 4
Top = 690
Width = 1335
End
Begin VB.TextBox txtEDate
Height = 300
Left = 2880
TabIndex = 3
Top = 690
Width = 1335
End
Begin VB.Label Label6
AutoSize = -1 'True
Caption = "统计方式"
Height = 180
Left = 240
TabIndex = 8
Top = 300
Width = 720
End
Begin VB.Label Label4
AutoSize = -1 'True
Caption = "日期范围"
Height = 195
Left = 240
TabIndex = 6
Top = 750
Width = 720
End
Begin VB.Label Label5
AutoSize = -1 'True
Caption = "-"
Height = 195
Left = 2640
TabIndex = 5
Top = 750
Width = 180
End
End
Begin MSAdodcLib.Adodc Adodc1
Height = 375
Left = 0
Top = 6120
Visible = 0 'False
Width = 1575
_ExtentX = 2778
_ExtentY = 661
ConnectMode = 0
CursorLocation = 3
IsolationLevel = -1
ConnectionTimeout= 15
CommandTimeout = 30
CursorType = 3
LockType = 3
CommandType = 8
CursorOptions = 0
CacheSize = 50
MaxRecords = 0
BOFAction = 0
EOFAction = 0
ConnectStringType= 1
Appearance = 1
BackColor = -2147483643
ForeColor = -2147483640
Orientation = 0
Enabled = -1
Connect = ""
OLEDBString = ""
OLEDBFile = ""
DataSourceName = ""
OtherAttributes = ""
UserName = ""
Password = ""
RecordSource = ""
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 VB.CommandButton Cmd_Back
Caption = "返 回"
Height = 495
Left = 2460
TabIndex = 1
Top = 6360
Width = 1335
End
Begin MSDataGridLib.DataGrid DataGrid1
Height = 4815
Left = 120
TabIndex = 0
Top = 1320
Width = 6015
_ExtentX = 10610
_ExtentY = 8493
_Version = 393216
AllowUpdate = 0 'False
HeadLines = 1
RowHeight = 15
RowDividerStyle = 6
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
Attribute VB_Name = "FrmSByDraw"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub Cmd_Back_Click()
Unload Me
End Sub
Private Sub DataRefresh()
Dim StrSearch As String
Dim StrGroup As String
Dim TmpSource As String
Dim TmpS1 As String
StrSearch = ""
'判断日期是否正确
If Not IsDate(Trim(txtSDate)) Or Not IsDate(Trim(txtEDate)) Then
MsgBox "请输入正确的日期"
Exit Sub
End If
'读取时间范围
If Len(Trim(txtSDate)) = 0 Then
If Len(Trim(txtEDate)) > 0 Then
StrSearch = " And CreateDate<=#" + Trim(txtEDate) + "#"
End If
Else
StrSearch = " And CreateDate>=#" + Trim(txtSDate) + "#"
If Len(Trim(txtEDate)) > 0 Then
StrSearch = StrSearch + " And CreateDate<=#" + Trim(txtEDate) + "#"
End If
End If
'按统计方式设置查询语句和Group By语句
If cob_By.ListIndex = 0 Then ' 按一级分类统计
TmpS1 = "Select t.TypeName AS 一级分类名称," _
+ "IIF(SUM(v.OAmount) IS NULL,0,SUM(v.OAmount)) AS 领用总数量" _
+ " From Types t Left Join"
TmpSource = TmpS1 + "(Select * From v_Draw Where 1=1 " + StrSearch _
+ " ) v On t.TypeId=v.t1Id Group By t.TypeName"
ElseIf cob_By.ListIndex = 1 Then ' 按二级分类统计
TmpS1 = "Select t.t1Name AS 一级分类名称,t.t2Name AS 二级分类名称," _
+ "IIF(SUM(v.OAmount) IS NULL,0,SUM(v.OAmount)) AS 领用总数量" _
+ " From v_Types t Left Join"
TmpSource = TmpS1 + " (Select * From v_Draw Where 1=1 " + StrSearch _
+ ")v On t.t2Id=v.t2Id Group By t.t1Name,t.t2Name"
ElseIf cob_By.ListIndex = 2 Then ' 按办公用品统计
TmpS1 = "Select s.t1Name AS 一级分类名称,s.t2Name AS 二级分类名称,s.OName AS 办公用品名称," _
+ "IIF(SUM(v.OAmount) IS NULL,0,SUM(v.OAmount)) AS 领用总数量" _
+ " From v_Store s Left Join"
TmpSource = TmpS1 + " (Select * From v_Draw Where 1=1 " + StrSearch _
+ ") v On s.OId=v.OId Group By s.t1Name,s.t2Name,s.OName"
Else ' 按部门统计
TmpSource = "Select d.DepName AS 部门名称,v.t1Name AS 一级分类名称,v.t2Name AS 二级分类名称," _
+ "IIF(SUM(v.OAmount) IS NULL,0,SUM(v.OAmount)) AS 领用总数量" _
+ " From Department d Left Join v_Draw v On d.DepId=v.DepId " _
+ " WHERE 1=1 " + StrSearch + " Group By d.DepName,v.t1Name,v.t2Name"
End If
Adodc1.ConnectionString = Conn
Adodc1.RecordSource = TmpSource
' MsgBox TmpSource
Adodc1.Refresh
Set DataGrid1.DataSource = Adodc1
DataGrid1.Columns(0).Width = 1600
DataGrid1.Columns(1).Width = 1200
End Sub
Private Sub Cmd_Sts_Click()
DataRefresh
End Sub
Private Sub Form_Load()
cob_By.AddItem "按一级分类", 0
cob_By.AddItem "按二级分类", 1
cob_By.AddItem "按办公用品", 2
cob_By.AddItem "按 部 门", 3
cob_By.ListIndex = 0
txtSDate = Date
txtEDate = Date
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -