📄 main_xsbb.frm
字号:
Top = 225
Width = 1125
End
Begin VB.CommandButton Command2
Caption = "退出"
Height = 345
Left = 9765
Style = 1 'Graphical
TabIndex = 1
Top = 225
Width = 1125
End
Begin MSComCtl2.DTPicker DTP1
Height = 315
Left = 2340
TabIndex = 4
Top = 210
Width = 1335
_ExtentX = 2355
_ExtentY = 556
_Version = 393216
Format = 100073473
CurrentDate = 37143
End
Begin MSComCtl2.DTPicker DTP2
Height = 315
Left = 5385
TabIndex = 5
Top = 210
Width = 1380
_ExtentX = 2434
_ExtentY = 556
_Version = 393216
Format = 100073473
CurrentDate = 37143
End
Begin MSComCtl2.DTPicker DTM1
Height = 315
Left = 3675
TabIndex = 7
Top = 210
Width = 1350
_ExtentX = 2381
_ExtentY = 556
_Version = 393216
Format = 100073474
CurrentDate = .4375
End
Begin MSComCtl2.DTPicker DTM2
Height = 315
Left = 6750
TabIndex = 8
Top = 210
Width = 1350
_ExtentX = 2381
_ExtentY = 556
_Version = 393216
Format = 100073474
CurrentDate = .4375
End
Begin VB.Label Label2
Caption = "操作员"
Height = 300
Left = 60
TabIndex = 13
Top = 285
Width = 765
End
Begin VB.Label Label1
Caption = "日期从: 到"
Height = 285
Left = 1695
TabIndex = 6
Top = 270
Width = 3660
End
End
End
Attribute VB_Name = "main_xsbb"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub Form_Load()
'自动识别数据库路径
Adodc1.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\DB_KFGL.mdb;Persist Security Info=False"
Adodc1.RecordSource = "select * from tb_tfd"
Adodc1.Refresh
Adodc2.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\DB_KFGL.mdb;Persist Security Info=False"
Adodc2.RecordSource = "select * from tb_tfd"
Adodc2.Refresh
czy.text = Main.StatusBar1.Panels(4).text
DTP1.Value = Date - 1: DTP2.Value = Date + 1
Text1.text = Adodc1.Recordset.RecordCount
End Sub
Private Sub Form_Activate()
D1 = Format(DTP1, "YYYY-MM-DD") '格式化日期
t1 = Format(DTM1, "HH:MM:SS") '格式化时间
D2 = Format(DTP2, "YYYY-MM-DD") '格式化日期
t2 = Format(DTM2, "HH:MM:SS") '格式化时间
'合成“BZ”值,并赋给两个文本框
G1.text = Left(D1, 4) & Right(Left(D1, 7), 2) & Right(D1, 2) & Left(t1, 2) & Left(Right(t1, 5), 2)
G2.text = Left(D2, 4) & Right(Left(D2, 7), 2) & Right(D2, 2) & Left(t2, 2) & Left(Right(t2, 5), 2)
Call Title1 '调用Title1过程
'查询数据表中字段“BZ”在G1和G2值之间的记录
Adodc1.RecordSource = "select * from tb_tfd where tb_tfd.BZ > " + Str(G1.text) + " and tb_tfd.BZ < " + Str(G2.text) + " order by 凭证号码"
Adodc1.Refresh '更新记录
'统计各项费用
Adodc2.RecordSource = "select count(*)as 数量1,sum(应收宿费)as 应收宿费1,sum(杂费)as 杂费1,sum(电话费)as 电话费1 ,sum(会议费)as 会议费1,sum(存车费)as 存车费1,sum(赔偿费)as 赔偿费1,sum(金额总计)as 总计金额1,sum(预收宿费)as 预收宿费1,sum(退还宿费)as 退还宿费1 from tb_tfd where tb_tfd.BZ >" & Val(G1.text) & "AND tb_tfd.bz<" & Val(G2.text)
Adodc2.Refresh
If Adodc2.Recordset.RecordCount > 0 Then '如果记录数大于0
MS2.Cols = 10 '设置MS2的列数为10
MS2.Rows = 1 '设置MS2的行数为一
MS2.TextMatrix(0, 0) = "合计" 'MS2第一个单元个内容为“合计”
For i = 1 To 9
If Adodc2.Recordset.Fields(i) <> "" Then '如果字段内容不为空
MS2.TextMatrix(0, i) = Adodc2.Recordset.Fields(i) '把字段中的内容赋给MS2相应的单元格
Else
MS2.TextMatrix(0, i) = "0" '把“0”赋给MS2的相应单元格
End If
Next i
End If
'设置MSFlexgrid的列宽
MS2.ColWidth(0) = 4500: MS2.ColWidth(1) = 840: MS2.ColWidth(2) = 450
MS2.ColWidth(3) = 650: MS2.ColWidth(4) = 650: MS2.ColWidth(5) = 650
MS2.ColWidth(6) = 650: MS2.ColWidth(7) = 840: MS2.ColWidth(8) = 840
MS2.ColWidth(9) = 840
Adodc1.RecordSource = "select * from tb_tfd where tb_tfd.BZ > " + Str(G1.text) + " and tb_tfd.BZ < " + Str(G2.text) + " order by 凭证号码"
Adodc1.Refresh
Text1.text = Adodc1.Recordset.RecordCount
If Adodc1.Recordset.RecordCount > 0 Then
Do While Adodc1.Recordset.EOF = False
On Error Resume Next
MS1.TextMatrix(MS1.Row, 0) = Adodc1.Recordset.Fields("凭证号码") '把字段“凭证号码”赋给表格
MS1.TextMatrix(MS1.Row, 1) = Adodc1.Recordset.Fields("姓名") '把字段“姓名”内容赋给表格
MS1.TextMatrix(MS1.Row, 2) = Adodc1.Recordset.Fields("房间号") '把字段“房间号”内容赋给表格
MS1.TextMatrix(MS1.Row, 3) = Adodc1.Recordset.Fields("客房价格") '把字段“客房价格”内容赋给表格
MS1.TextMatrix(MS1.Row, 4) = Adodc1.Recordset.Fields("住宿天数") '把字段“住宿天数”内容赋给表格
MS1.TextMatrix(MS1.Row, 5) = Adodc1.Recordset.Fields("折扣或招待") '把字段“折扣或招待”内容赋给表格
MS1.TextMatrix(MS1.Row, 6) = Adodc1.Recordset.Fields("折扣") '把字段“折扣”内容赋给表格
MS1.TextMatrix(MS1.Row, 7) = Adodc1.Recordset.Fields("应收宿费") '把字段“应收”内容赋给表格
MS1.TextMatrix(MS1.Row, 8) = Adodc1.Recordset.Fields("杂费") '把字段“杂费”内容赋给表格
MS1.TextMatrix(MS1.Row, 9) = Adodc1.Recordset.Fields("电话费") '把字段“电话费”内容赋给表格
MS1.TextMatrix(MS1.Row, 10) = Adodc1.Recordset.Fields("会议费") '把字段“会议费”内容赋给表格
MS1.TextMatrix(MS1.Row, 11) = Adodc1.Recordset.Fields("存车费") '把字段“存车费”内容赋给表格
MS1.TextMatrix(MS1.Row, 12) = Adodc1.Recordset.Fields("赔偿费") '把字段“赔偿费”内容赋给表格
MS1.TextMatrix(MS1.Row, 13) = Adodc1.Recordset.Fields("金额总计") '把字段“金额总计”内容赋给表格
MS1.TextMatrix(MS1.Row, 14) = Adodc1.Recordset.Fields("预收宿费") '把字段“预收宿费”内容赋给表格
MS1.TextMatrix(MS1.Row, 15) = Adodc1.Recordset.Fields("退还宿费") '把字段“退还宿费”内容赋给表格
Adodc1.Recordset.MoveNext '记录下移
j = j + 1 '变量累加
MS1.AddItem (j) '添加项
MS1.Row = MS1.Row + 1 '行加一
Loop
End If
End Sub
Private Sub Command1_Click()
If DTP1.Value <= DTP2.Value Then
MS1.Clear
MS2.Clear
MS1.Row = 1
MS1.Col = 0
MS2.Row = 0
MS2.Col = 0
MS1.Rows = MS1.Rows - Val(Text1.text)
Form_Activate
Else
MsgBox "日期不能颠倒", 4, "系统提示"
DTP2.Value = Date
End If
End Sub
Private Sub Command2_Click()
Main.Enabled = True
Unload Me
End Sub
Private Sub Title1()
Dim L As Integer
m = Array(1500, 600, 600, 450, 450, 450, 450, 840, 450, 650, 650, 650, 650, 840, 840, 840)
n = Array("凭证号码", "姓名", "房间号", "房价", "天数", "结款方式", "折扣", "应收宿费", "杂费", "电话费", "会议费", "存车费", "赔偿费", "实收金额", "预收宿费", "退还宿费")
For L = 0 To 15
MS1.ColWidth(L) = m(L)
MS1.TextMatrix(0, L) = n(L)
Next L
End Sub
Private Sub Form_Unload(Cancel As Integer)
Main.Show
Main.Enabled = True
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -