⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 酒水点菜.frm

📁 本系统主要实现小型酒吧的管理
💻 FRM
📖 第 1 页 / 共 5 页
字号:
         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 + -