?? 酒水點菜.frm
字號:
Name = "隸書"
Size = 42
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H0000FF00&
Height = 855
Left = 4050
TabIndex = 0
Top = 0
Width = 3375
End
End
Attribute VB_Name = "酒水點菜"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Const N As Integer = 7
Private Sub save_record()
Dim dd As Integer
old = Data2.Recordset.Fields(10).Value
Data2.Recordset.Edit
Data2.Recordset.Fields(10).Value = old + Val(消費金額.Caption)
s = Data2.Recordset.Fields(10).Value
If s < 1000 Then
Data2.Recordset.Fields(11).Value = s
Else
Data2.Recordset.Fields(11).Value = 1000 + Int((s - 1000) * 1.2)
End If
t = Data2.Recordset.Fields(11).Value
If Data2.Recordset.Fields(11).Value >= 2000 Then
Data2.Recordset.Fields(12).Value = "金卡"
ElseIf Data2.Recordset.Fields(11).Value >= 1000 Then
Data2.Recordset.Fields(12).Value = "銀卡"
End If
Data2.UpdateRecord
'在酒水庫存中減去數量
For i = 0 To N
If 品名(i).Text <> "" Then
With Data1.Recordset
.FindFirst "品名=" & "'" & 品名(i).Text & "'"
.Edit
old_ = .Fields(2).Value
.Fields(2).Value = old_ - Val(數量(i).Text)
End With
End If
Data1.UpdateRecord
Next
'進行消費記錄
With Data3.Recordset
.AddNew
.Fields(0).Value = Val(Text5.Text)
.Fields(1).Value = CDate(Text3.Text)
.Fields(2).Value = Val(Text4.Text)
.Fields(3).Value = Val(Text1.Text)
For j = 0 To N
If 品名(j) <> "" Then
.Fields(4).Value = .Fields(4).Value & 品名(j).Text & " "
dd = dd + Val(數量(j).Text)
End If
Next
.Fields(5).Value = dd
.Fields(6).Value = Val(消費金額.Caption)
.Fields(7).Value = t
End With
Data3.UpdateRecord
End Sub
Private Sub Command1_Click()
If Text1.Text = "" Then Exit Sub
save_record
Text1.Text = ""
Text2.Text = ""
Text4.Text = ""
Text5.Text = ""
品名(0).Enabled = False
單價(0).Enabled = False
數量(0).Enabled = False
備注(0).Enabled = False
合計(0).Enabled = False
For i = 1 To N
品名(i).Visible = False
單價(i).Visible = False
數量(i).Visible = False
合計(i).Visible = False
備注(i).Visible = False
Next i
End Sub
Private Sub Command1_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then Command1_Click
End Sub
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = 112 Then
幫助對話框.Show 1
Else
If KeyCode = vbKeyEscape Then
Unload Me
End If
End If
End Sub
Private Sub Form_Load()
Data1.DatabaseName = App.Path & "\酒吧管理數據庫.mdb"
Data2.DatabaseName = App.Path & "\酒吧管理數據庫.mdb"
Data3.DatabaseName = App.Path & "\酒吧管理數據庫.mdb"
Text3.Text = Now()
End Sub
Private Sub Text1_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
Text3.SetFocus
SendKeys "{home}+{end}"
ElseIf (KeyAscii < 48 Or KeyAscii > 57) And KeyAscii <> 8 Then
MsgBox "請輸入數字", vbCritical
KeyAscii = 0
End If
End Sub
Private Sub Text2_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
Text5.SetFocus
SendKeys "{home}+{end}"
ElseIf (KeyAscii < 48 Or KeyAscii > 57) And KeyAscii <> 8 Then
MsgBox "請輸入數字", vbCritical
KeyAscii = 0
End If
End Sub
Private Sub Text3_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
Text4.SetFocus
SendKeys "{home}+{end}"
End If
End Sub
Private Sub Text4_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
Text2.SetFocus
SendKeys "{home}+{end}"
ElseIf (KeyAscii < 48 Or KeyAscii > 57) And KeyAscii <> 8 Then
MsgBox "請輸入數字", vbCritical
KeyAscii = 0
End If
End Sub
Private Sub Text5_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
strip = Val(Text5.Text)
Data2.Recordset.FindFirst "卡號=" & strip
If Data2.Recordset.NoMatch Then
MsgBox "該會員不存在,請重新輸入", vbCritical
Else
品名(0).Enabled = True
單價(0).Enabled = True
數量(0).Enabled = True
備注(0).Enabled = True
品名(0).SetFocus
SendKeys "{home}+{end}"
End If
ElseIf (KeyAscii < 48 Or KeyAscii > 57) And KeyAscii <> 8 Then
MsgBox "請輸入數字", vbCritical
KeyAscii = 0
End If
End Sub
Private Sub 備注_GotFocus(Index As Integer)
If Index = N Then Exit Sub
品名(Index + 1).Visible = True
單價(Index + 1).Visible = True
數量(Index + 1).Visible = True
合計(Index + 1).Visible = True
備注(Index + 1).Visible = True
End Sub
Private Sub 備注_KeyDown(Index As Integer, KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyLeft And 備注(Index).SelStart = 0 Then 數量(Index).SetFocus
If KeyCode = vbKeyRight And Index < N And 備注(Index).SelStart = Len(備注(Index).Text) Then
If 品名(Index + 1).Visible = True Then
品名(Index + 1).SetFocus
Else
品名(Index + 1).Visible = True
品名(Index + 1).SetFocus
End If
End If
If KeyCode = vbKeyUp And Index > 0 Then 備注(Index - 1).SetFocus
If KeyCode = vbKeyDown And Index < N = True Then 備注(Index + 1).SetFocus
End Sub
Private Sub 備注_KeyPress(Index As Integer, KeyAscii As Integer)
If KeyAscii = 13 And Index < N Then 品名(Index + 1).SetFocus
End Sub
Private Sub 單價_Change(Index As Integer)
合計(Index).Text = Val(單價(Index).Text) * Val(數量(Index).Text)
End Sub
Private Sub 單價_KeyDown(Index As Integer, KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyLeft And 單價(Index).SelStart = 0 Then 品名(Index).SetFocus
If KeyCode = vbKeyRight And 單價(Index).SelStart = Len(單價(Index).Text) Then 數量(Index).SetFocus
If KeyCode = vbKeyUp And Index > 0 Then 單價(Index - 1).SetFocus
If KeyCode = vbKeyDown And 單價(Index + 1).Visible = True And Index < N Then 單價(Index + 1).SetFocus
End Sub
Private Sub 單價_KeyPress(Index As Integer, KeyAscii As Integer)
If KeyAscii = 13 Then
數量(Index).SetFocus
數量(Index).Text = 1
SendKeys "{home}+{end}"
ElseIf (KeyAscii < 48 Or KeyAscii > 57) And KeyAscii <> 8 Then
MsgBox "請輸入數字", vbCritical
KeyAscii = 0
End If
End Sub
Private Sub 合計_Change(Index As Integer)
Sum = Val(合計(0).Text) + Val(合計(1).Text) + Val(合計(2).Text) + Val(合計(3).Text) + Val(合計(4).Text) + Val(合計(5).Text)
If Data2.Recordset.Fields(12).Value = "金卡" Or Sum > 2000 Then
消費金額.Caption = Int(Sum * 0.8)
ElseIf Data2.Recordset.Fields(12).Value = "銀卡" Or Sum >= 1000 Then
消費金額.Caption = Int(Sum * 0.88)
Else
消費金額.Caption = Int(Sum)
End If
End Sub
Private Sub 品名_Click(Index As Integer, Area As Integer)
Dim strd As String
strd = 品名(Index).Text
Data1.Recordset.FindFirst "品名=" & "'" & strd & "'"
單價(Index).Text = Data1.Recordset.Fields(1).Value
End Sub
Private Sub 品名_KeyDown(Index As Integer, KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyLeft And Index > 0 And 品名(Index).SelStart = 0 Then 備注(Index - 1).SetFocus
If KeyCode = vbKeyRight And 品名(Index).SelStart = Len(品名(Index).Text) Then 單價(Index).SetFocus
End Sub
Private Sub 品名_KeyPress(Index As Integer, KeyAscii As Integer)
If KeyAscii = 13 Then
單價(Index).SetFocus
SendKeys "{home}+{end}"
End If
End Sub
Private Sub 品名_LostFocus(Index As Integer)
Dim strd As String
strd = 品名(Index).Text
strm = Data1.Recordset.Bookmark
If strd = "" Then
單價(Index) = ""
數量(Index) = ""
Exit Sub
End If
For i = 0 To Index - 1
If strd = 品名(i).Text Then
MsgBox "已經要了這個酒水了,請另選其他", vbCritical
品名(Index).SetFocus
品名(Index).Text = ""
單價(Index) = ""
數量(Index) = ""
Exit Sub
End If
Next
Data1.Recordset.FindFirst "品名=" & "'" & strd & "'"
If Data1.Recordset.NoMatch Then
Data1.Recordset.Bookmark = strm
MsgBox "你所要求的酒水不還沒進貨,請另選其他!", vbCritical
品名(Index).SetFocus
Else
單價(Index).Text = Data1.Recordset.Fields(1).Value
End If
End Sub
Private Sub 數量_Change(Index As Integer)
合計(Index).Text = Val(單價(Index).Text) * Val(數量(Index).Text)
End Sub
Private Sub 數量_KeyDown(Index As Integer, KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyLeft And 數量(Index).SelStart = 0 Then 單價(Index).SetFocus
If KeyCode = vbKeyRight And 數量(Index).SelStart = Len(數量(Index).Text) Then 備注(Index).SetFocus
If KeyCode = vbKeyUp And Index > 0 Then 數量(Index - 1).SetFocus
If KeyCode = vbKeyDown And 數量(Index + 1).Visible = True And Index < N Then 數量(Index + 1).SetFocus
End Sub
Private Sub 數量_KeyPress(Index As Integer, KeyAscii As Integer)
If KeyAscii = 13 Then
備注(Index).SetFocus
SendKeys "{home}+{end}"
ElseIf (KeyAscii < 48 Or KeyAscii > 57) And KeyAscii <> 8 Then
MsgBox "請輸入數字", vbCritical
KeyAscii = 0
End If
End Sub
Private Sub 數量_LostFocus(Index As Integer)
s = Data1.Recordset.Fields(2).Value
If s = 0 Then
MsgBox "已經沒有了,請換一樣吧", vbCritical
品名(Index).SetFocus
SendKeys "{home}+{end}"
Else
If Val(數量(Index).Text) > s Then
MsgBox "只有" & s & "瓶了,請要少一點好嗎?", vbCritical
數量(Index).SetFocus
SendKeys "{home}+{end}"
End If
End If
End Sub
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -