📄 frmygxs.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"
Object = "{86CF1D34-0C5F-11D2-A9FC-0000F8754DA1}#2.0#0"; "MSCOMCT2.OCX"
Begin VB.Form frmygxs
Caption = "员工销售查询"
ClientHeight = 8070
ClientLeft = 60
ClientTop = 345
ClientWidth = 9780
LinkTopic = "Form1"
ScaleHeight = 8070
ScaleWidth = 9780
StartUpPosition = 2 '屏幕中心
WindowState = 2 'Maximized
Begin VB.Frame Frame3
Caption = "销售汇总"
Height = 1095
Left = 480
TabIndex = 9
Top = 6960
Width = 10935
Begin MSAdodcLib.Adodc Adodcsalefz
Height = 330
Left = 3240
Top = 240
Visible = 0 'False
Width = 1560
_ExtentX = 2752
_ExtentY = 582
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 MSDataGridLib.DataGrid DataGrid2
Bindings = "frmygxs.frx":0000
Height = 735
Left = 120
TabIndex = 10
Top = 240
Width = 10695
_ExtentX = 18865
_ExtentY = 1296
_Version = 393216
HeadLines = 1
RowHeight = 15
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
Begin VB.Frame Frame2
Caption = "销售明细"
Height = 5655
Left = 480
TabIndex = 7
Top = 1200
Width = 10935
Begin MSAdodcLib.Adodc Adodcygsale
Height = 495
Left = 960
Top = 4080
Visible = 0 'False
Width = 2280
_ExtentX = 4022
_ExtentY = 873
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 MSDataGridLib.DataGrid DataGrid1
Bindings = "frmygxs.frx":001A
Height = 5295
Left = 120
TabIndex = 8
Top = 240
Width = 10695
_ExtentX = 18865
_ExtentY = 9340
_Version = 393216
HeadLines = 1
RowHeight = 15
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
Begin VB.Frame Frame1
Caption = "查询操作"
Height = 975
Left = 480
TabIndex = 0
Top = 120
Width = 10935
Begin VB.CommandButton Command2
Caption = "退出"
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 495
Left = 9000
TabIndex = 6
Top = 240
Width = 1335
End
Begin VB.CommandButton Command1
Caption = "查询"
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 495
Left = 6960
TabIndex = 5
Top = 240
Width = 1455
End
Begin MSComCtl2.DTPicker DTPickertj
Height = 255
Left = 4320
TabIndex = 4
Top = 360
Width = 1815
_ExtentX = 3201
_ExtentY = 450
_Version = 393216
Format = 21233665
CurrentDate = 38521
End
Begin VB.ComboBox Combo1
Height = 300
Left = 1560
TabIndex = 2
Text = "Combo1"
Top = 360
Width = 1335
End
Begin VB.Label Label2
Caption = "选择月份:"
Height = 255
Left = 3360
TabIndex = 3
Top = 360
Width = 975
End
Begin VB.Label Label1
Caption = "选择员工:"
Height = 255
Left = 360
TabIndex = 1
Top = 360
Width = 975
End
End
End
Attribute VB_Name = "frmygxs"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
'Download by http://www.codefans.net
Private Sub Command1_Click()
Dim sqlYGSale As String
Dim sqlsalefz As String
Dim startdate As String
Dim enddate As String
startdate = Year(DTPickertj.Value) & "/" & Month(DTPickertj.Value) & "/01" & " 00:00:01"
enddate = Year(DTPickertj.Value) & "/" & Month(DTPickertj.Value) & "/" & monthdays() & " 23:59:59"
Adodcygsale.ConnectionString = ConnStr
'销售表.销售编号,销售表.商品编号,销售表.销售方式,销售表.售价,销售表.数量,销售表.结账方式,销售表.数额,销售表.员工编号,销售表.日期,销售表.备注
'销售表.员工编号=员工表.员工编号 and 商品表.商品编号=销售表.商品编号 and 客户表.用户编号=销售表.用户编号 and 员工表.姓名='" & Trim(Combo1.Text) & "'
sqlYGSale = "select * from 销售表"
sqlYGSale = sqlYGSale & " where 销售表.员工编号='" & ygid(Trim(Combo1.Text)) & "' and 销售表.日期 Between #" & startdate & "# and #" & enddate & "#"
Adodcygsale.CommandType = adCmdText
Adodcygsale.RecordSource = sqlYGSale
Adodcygsale.Refresh
'求汇总数据
sqlsalefz = "select 销售表.员工编号,员工表.姓名 as 员工姓名,sum(销售表.数量) as 销售总量 from 销售表,员工表 "
sqlsalefz = sqlsalefz & " where 员工表.员工编号=销售表.员工编号 and 销售表.员工编号='" & ygid(Trim(Combo1.Text)) & "' and 销售表.日期 Between #" & startdate & "# and #" & enddate & "#" & "group by 销售表.员工编号,员工表.姓名"
Adodcsalefz.ConnectionString = ConnStr
Adodcsalefz.CommandType = adCmdText
Adodcsalefz.RecordSource = sqlsalefz
Adodcsalefz.Refresh
End Sub
Private Sub Command2_Click()
Unload Me
Set frmygxs = Nothing
End Sub
Private Sub Form_Load()
Call loadYG(Combo1)
DTPickertj.Value = Now()
Call Command1_Click
End Sub
Private Sub loadYG(combo As ComboBox) '加载员工名称的过程
On Error GoTo errorhandle
Dim rsyg As ADODB.Recordset
Dim sqlyg As String
sqlyg = "select 姓名 from 员工表"
Set rsyg = ExeSQL(sqlyg)
combo.Clear
Do While Not rsyg.EOF
combo.AddItem (rsyg.Fields(0))
rsyg.MoveNext
Loop
combo.ListIndex = 0
rsyg.Close
Set rsyg = Nothing
Exit Sub
errorhandle:
If Err.Number = 380 Then
Resume Next
End If
End Sub
Public Function monthdays() As String '计算该月的天数
Select Case Month(DTPickertj.Value)
Case 1
monthdays = 31
Case 2
Dim yeartj As Integer
yeartj = Year(DTPickertj.Value)
If yeartj Mod 4 = 0 And yeartj Mod 100 <> 4 Or yeartj Mod 400 = 0 Then
monthdays = 29
Else
monthdays = 28
End If
Case 3
monthdays = 31
Case 4
monthdays = 30
Case 5
monthdays = 31
Case 6
monthdays = 30
Case 7
monthdays = 31
Case 8
monthdays = 31
Case 9
monthdays = 30
Case 10
monthdays = 31
Case 11
monthdays = 30
Case 12
monthdays = 31
End Select
End Function
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -