📄 main_qtgl_mdgl_tq.frm
字号:
Height = 225
Index = 1
Left = 1080
TabIndex = 10
Top = 540
Width = 1215
End
Begin VB.Label Label4
BackStyle = 0 'Transparent
ForeColor = &H00FF0000&
Height = 225
Index = 2
Left = 3405
TabIndex = 9
Top = 255
Width = 1200
End
Begin VB.Label Label4
BackStyle = 0 'Transparent
ForeColor = &H00FF0000&
Height = 225
Index = 3
Left = 3090
TabIndex = 8
Top = 525
Width = 1215
End
Begin VB.Label Label4
BackStyle = 0 'Transparent
ForeColor = &H00FF0000&
Height = 225
Index = 4
Left = 5550
TabIndex = 7
Top = 255
Width = 915
End
Begin VB.Label Label4
BackStyle = 0 'Transparent
ForeColor = &H00FF0000&
Height = 225
Index = 5
Left = 5700
TabIndex = 6
Top = 510
Width = 1995
End
End
Begin VB.Frame Frame3
Height = 465
Left = 8145
TabIndex = 1
Top = 2355
Width = 3150
Begin VB.Label Labyfje
BackStyle = 0 'Transparent
Height = 210
Left = 1155
TabIndex = 45
Top = 195
Width = 1620
End
Begin VB.Label Label1
BackStyle = 0 'Transparent
Caption = "应付金额:"
ForeColor = &H00000000&
Height = 195
Index = 6
Left = 150
TabIndex = 38
Top = 195
Width = 945
End
End
Begin VB.Frame Frame1
Height = 585
Left = 30
TabIndex = 18
Top = 735
Width = 8145
Begin VB.Label labdjh
BackStyle = 0 'Transparent
ForeColor = &H000000FF&
Height = 225
Left = 5925
TabIndex = 23
Top = 240
Width = 1875
End
Begin VB.Label Label5
BackStyle = 0 'Transparent
Caption = "结帐单据号:"
Height = 270
Left = 4770
TabIndex = 22
Top = 255
Width = 1095
End
Begin VB.Label Label4
BackStyle = 0 'Transparent
ForeColor = &H00FF0000&
Height = 225
Index = 6
Left = 645
TabIndex = 21
Top = 225
Width = 1005
End
Begin VB.Label Label3
BackStyle = 0 'Transparent
Caption = "状态:"
Height = 255
Index = 5
Left = 120
TabIndex = 20
Top = 240
Width = 555
End
End
Begin VB.Frame Frame6
Height = 585
Left = 30
TabIndex = 19
Top = 1185
Width = 8145
Begin VB.Label Label8
BackStyle = 0 'Transparent
Caption = "点单日期:"
Height = 225
Left = 4755
TabIndex = 29
Top = 255
Width = 915
End
Begin VB.Label labrq
BackStyle = 0 'Transparent
ForeColor = &H000000FF&
Height = 195
Left = 5685
TabIndex = 28
Top = 240
Width = 1665
End
Begin VB.Label Label7
BackStyle = 0 'Transparent
Caption = "服务员姓名:"
Height = 225
Left = 2010
TabIndex = 27
Top = 255
Width = 1425
End
Begin VB.Label Label6
BackStyle = 0 'Transparent
Caption = "服务员编号:"
Height = 225
Left = 150
TabIndex = 26
Top = 255
Width = 1110
End
Begin VB.Label Labbh
BackStyle = 0 'Transparent
ForeColor = &H00FF0000&
Height = 210
Left = 1200
TabIndex = 25
Top = 240
Width = 735
End
Begin VB.Label Labxm
BackStyle = 0 'Transparent
ForeColor = &H00FF0000&
Height = 210
Left = 3075
TabIndex = 24
Top = 255
Width = 1275
End
End
Begin VB.Frame Frame4
Height = 1245
Left = 8145
TabIndex = 2
Top = 2700
Width = 3150
Begin VB.CommandButton Command4
Caption = "优惠方式结账"
Height = 330
Left = 255
TabIndex = 5
Top = 690
Width = 2670
End
Begin VB.CommandButton Command3
Caption = "免单"
Height = 330
Left = 255
TabIndex = 4
Top = 240
Width = 2670
End
End
Begin VB.Frame Frame5
BackColor = &H80000013&
Height = 900
Left = 8145
TabIndex = 3
Top = 3795
Width = 3150
Begin VB.CommandButton Command6
Caption = "退出特权结账管理"
Height = 330
Left = 285
TabIndex = 62
Top = 330
Width = 2670
End
End
End
Attribute VB_Name = "main_qtgl_mdgl_tq"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim newcnn As New Connection '定义数据库连接
Dim rs1 As New ADODB.Recordset '定义数据集对象
Dim i As Integer '定义整型变量
Dim myval, SQL1, SQL2, SQL3, SQL4 As String '定义字符串变量
Public Sub JZ() '定义结账函数
newcnn.Open "Provider=MSDASQL.1;Persist Security Info=False;User ID=sa;Data Source=CYGLXT"
SQL1 = "update 点单临时表 set 结账日期='" + Trim(rq.text) + "',是否结账='是' where 单据号='" + Trim(labdjh.Caption) + "'"
newcnn.Execute SQL1
SQL2 = "insert 日点单信息表(房台编号,房台类别,商品编号,商品名称,单位,数量,单价,金额,点单日期,结账日期,服务员编号,服务员姓名,状态,单据号,是否结账,备注) select 房台编号,房台类别,商品编号,商品名称,单位,数量,单价,金额,点单日期,结账日期,服务员编号,服务员姓名,状态,单据号,是否结账,备注 from 点单临时表 where 单据号='" + Trim(labdjh.Caption) + "'"
newcnn.Execute SQL2
SQL3 = "delete 点单临时表 where 是否结账='是'and 单据号='" + Trim(labdjh.Caption) + "'"
newcnn.Execute SQL3
SQL4 = "update 房间台号信息表 set 状态='空闲' where 编号='" + Label4(0).Caption + "'"
newcnn.Execute SQL4 'Connection 对象的 Execute 方法,执行指定的查询、SQL 语句、存储过程或特定提供者的文本等内容。
newcnn.Close '关闭连接
End Sub
Private Sub Command1_Click()
End Sub
Private Sub Form_Activate()
rq.text = Now
For i = 0 To 6
Label4(i).Caption = main_qtgl_mdgl.Label4(i).Caption '赋值给label4(i).caption
Next i
Sql = "select * from 点单临时表 where 房台编号='" + Trim(Label4(0).Caption) + "'"
Call FunAdo(Adodc1, Sql)
Adodc1.Refresh
If Adodc1.Recordset.RecordCount > 0 Then
Labbh.Caption = Trim(Adodc1.Recordset.Fields("服务员编号"))
Labxm.Caption = Trim(Adodc1.Recordset.Fields("服务员姓名"))
labdjh.Caption = Trim(Adodc1.Recordset.Fields("单据号"))
labrq.Caption = Trim(Adodc1.Recordset.Fields("点单日期"))
sqlStr = "select 状态 as 状态1,sum(数量)as 数量1,sum(金额)as 金额合计 from 点单临时表 where 房台编号='" + Trim(Label4(0).Caption) + "'group by 状态"
Call FunAdo(Adodc2, sqlStr)
Adodc2.Refresh
If Adodc2.Recordset.RecordCount > 1 Then
Label2(0).Caption = Adodc2.Recordset.Fields(1)
'使用Format函数将数据格式为“0.00”格式
Label2(1).Caption = Format(Adodc2.Recordset.Fields(2), "0.00")
If Adodc2.Recordset.EOF = False Then Adodc2.Recordset.MoveNext
Label2(2).Caption = Adodc2.Recordset.Fields(1)
Label2(3).Caption = Format(Adodc2.Recordset.Fields(2), "0.00")
Else
If Trim(Adodc2.Recordset.Fields("状态1")) = "点单" Then
Label2(0).Caption = Adodc2.Recordset.Fields(1)
Label2(1).Caption = Format(Adodc2.Recordset.Fields(2), "0.00")
Label2(2).Caption = "0"
Label2(3).Caption = "0.00"
Else
Label2(0).Caption = "0"
Label2(1).Caption = "0.00"
Label2(2).Caption = Adodc2.Recordset.Fields(1)
Label2(3).Caption = Format(Adodc2.Recordset.Fields(2), "0.00")
End If
End If
'使用Format函数将数据格式为“0.00”格式
Label2(4).Caption = Val(Label2(0).Caption) + Val(Label2(2).Caption)
Label2(5).Caption = Format(Val(Label2(1).Caption) + Val(Label2(3).Caption), "0.00")
Labyfje.Caption = Format(Val(Label4(4).Caption) + Val(Label2(1).Caption), "0.00") '使用Val函数将字符串转换为数值型
Else
MsgBox ("对不起,此客人未消费,请重新选择!")
main_qtgl_mdgl.Enabled = True
Unload Me
End If
End Sub
Private Sub Form_Load()
Sql = "select * from 点单临时表"
sqlStr = "select * from 点单临时表"
Call FunAdo(Adodc1, Sql)
Call FunAdo(Adodc2, sqlStr)
End Sub
Private Sub Form_Unload(Cancel As Integer)
main_qtgl_mdgl.Enabled = True
End Sub
Private Sub Text1_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyReturn Then Command2.SetFocus '按回车键command2获得焦点
End Sub
Private Sub Text2_KeyDown(Index As Integer, KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyReturn And Index = 0 Then Text2(1).SetFocus
If KeyCode = vbKeyReturn And Index = 1 Then Command5.SetFocus
If KeyCode = vbKeyUp And Index = 1 Then Text2(0).SetFocus
End Sub
Private Sub Command2_Click() '免单
myval = MsgBox("确认免单吗?", vbYesNo)
If myval = vbYes Then
rs1.Open "select * from 日结账表 order by 结账单据号", cnn, adOpenKeyset, adLockOptimistic
rs1.AddNew
rs1.Fields("结账单据号") = labdjh.Caption
rs1.Fields("房台编号") = Label4(0).Caption
rs1.Fields("日期") = Now
rs1.Fields("结款金额") = Val(Labyfje.Caption) '使用Val函数将字符串转换为数值型
rs1.Fields("结款人") = Trim(Labxm.Caption)
rs1.Fields("结款方式") = "免单"
rs1.Fields("结款说明") = "[" & Text1.text & "]"
rs1.Update
rs1.Close
Call JZ '调用函数
MsgBox ("结账完毕!")
Call main_qtgl_mdgl.list_change '调用函数
main_qtgl_mdgl.Enabled = True
Unload Me
End If
End Sub
Private Sub Command3_Click() '免单窗口
Frame10.Visible = True: Frame12.Visible = False
Text1.SetFocus
End Sub
Private Sub Command4_Click() '优惠结账窗口
Frame10.Visible = False: Frame12.Visible = True
Text2(0).SetFocus
End Sub
Private Sub Command5_Click() '优惠结账
myval = MsgBox("确认优惠结账吗?", vbYesNo)
If myval = vbYes Then
rs1.Open "select * from 日结账表 order by 结账单据号", cnn, adOpenKeyset, adLockOptimistic
rs1.AddNew
rs1.Fields("结账单据号") = labdjh.Caption
rs1.Fields("房台编号") = Label4(0).Caption
rs1.Fields("日期") = Now
rs1.Fields("结款金额") = Val(Labyfje.Caption) - Val(Text2(0).text) '使用Val函数将字符串转换为数值型
rs1.Fields("结款人") = Trim(Labxm.Caption)
rs1.Fields("结款方式") = "优惠"
rs1.Fields("结款说明") = "[" & Text2(1).text & "]优惠" & Val(Text2(0).text) & "元"
rs1.Update
rs1.Close
Call JZ '调用函数
MsgBox ("结账完毕!")
Call main_qtgl_mdgl.list_change '调用函数
main_qtgl_mdgl.Enabled = True
Unload Me
End If
End Sub
Private Sub Command6_Click()
main_qtgl_mdgl.Enabled = True
Unload Me
End Sub
Private Sub Command7_Click() '取消
Frame10.Visible = False
End Sub
Private Sub Command8_Click() '取消
Frame12.Visible = False
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -