📄 新菜添加.frm
字号:
VERSION 5.00
Begin VB.Form frmaddmenu
BackColor = &H00C0E0FF&
Caption = "新菜添加"
ClientHeight = 5775
ClientLeft = 2955
ClientTop = 2145
ClientWidth = 8115
LinkTopic = "Form4"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 5775
ScaleWidth = 8115
Begin VB.TextBox Text3
BackColor = &H80000009&
ForeColor = &H0000C000&
Height = 375
Left = 1560
TabIndex = 13
Top = 3840
Width = 1335
End
Begin VB.CommandButton Command2
BackColor = &H00C0E0FF&
Caption = "退出"
Height = 375
Left = 4320
TabIndex = 12
Top = 4920
Width = 855
End
Begin VB.CommandButton Command1
BackColor = &H00C0E0FF&
Caption = "添加"
Height = 375
Left = 2520
TabIndex = 11
Top = 4920
Width = 855
End
Begin VB.TextBox Text5
BackColor = &H80000009&
ForeColor = &H0000C000&
Height = 1695
Left = 4680
MultiLine = -1 'True
ScrollBars = 2 'Vertical
TabIndex = 4
Top = 2400
Width = 2895
End
Begin VB.TextBox Text4
BackColor = &H80000009&
ForeColor = &H0000C000&
Height = 375
Left = 4680
TabIndex = 3
Top = 1440
Width = 1335
End
Begin VB.TextBox Text2
BackColor = &H80000009&
ForeColor = &H0000C000&
Height = 375
Left = 1560
TabIndex = 2
Top = 2760
Width = 1335
End
Begin VB.TextBox Text1
BackColor = &H80000009&
Enabled = 0 'False
ForeColor = &H0000C000&
Height = 375
Left = 1560
TabIndex = 1
Top = 1920
Width = 1335
End
Begin VB.ComboBox Combo1
BackColor = &H80000009&
ForeColor = &H0000C000&
Height = 300
ItemData = "新菜添加.frx":0000
Left = 1560
List = "新菜添加.frx":0016
TabIndex = 0
Text = "类别"
Top = 1080
Width = 975
End
Begin VB.Label Label6
BackColor = &H00C0E0FF&
Caption = "类别"
Height = 255
Left = 480
TabIndex = 10
Top = 1200
Width = 495
End
Begin VB.Label Label5
BackColor = &H00C0E0FF&
Caption = "备注"
Height = 255
Left = 3600
TabIndex = 9
Top = 3360
Width = 495
End
Begin VB.Label Label4
BackColor = &H00C0E0FF&
Caption = "成本"
Height = 255
Left = 3600
TabIndex = 8
Top = 1440
Width = 495
End
Begin VB.Label Label3
BackColor = &H00C0E0FF&
Caption = "单价"
Height = 255
Left = 480
TabIndex = 7
Top = 3840
Width = 495
End
Begin VB.Label Label2
BackColor = &H00C0E0FF&
Caption = "菜名"
Height = 255
Left = 480
TabIndex = 6
Top = 2880
Width = 495
End
Begin VB.Label Label1
BackColor = &H00C0E0FF&
Caption = "编号"
Height = 255
Left = 480
TabIndex = 5
Top = 2040
Width = 495
End
End
Attribute VB_Name = "frmaddmenu"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim number As Long
Public Sub Combo1_Click()
If Combo1.Text = "类别" Then
Exit Sub
End If
cptable.MoveFirst
Do While Not cptable.EOF
If cptable.Fields(3) = Combo1.Text Then
number = cptable.Fields(0)
End If
cptable.MoveNext
Loop
number = number + 1
Text1.Text = number
Text2.Text = ""
Text3.Text = ""
Text4.Text = ""
Text5.Text = ""
End Sub
Private Sub Command1_Click()
If Text2.Text = "" Or Text3.Text = "" Or Text4.Text = "" Or Text5.Text = "" Then
MsgBox "请将新菜信息添加完整!"
Exit Sub
End If
If Combo1.Text = "类别" Then
MsgBox "你还未选择新菜的类别!"
Exit Sub
End If
cptable.MoveFirst
Do While Not cptable.EOF
If cptable.Fields(0) = number - 1 Then
cptable.AddNew
cptable.Fields(0) = CLng(Text1.Text)
cptable.Fields(1) = Text2.Text
cptable.Fields(2) = CLng(Text3.Text)
cptable.Fields(3) = Combo1.Text
cptable.Fields(4) = CLng(Text4.Text)
cptable.Fields(5) = "1"
cptable.Fields(8) = Text5.Text
cptable.Fields(9) = Text2.Text + ".jpg"
cptable.Update
MsgBox "新菜已成功添加!"
Call Combo1_Click
Text2.SetFocus
Exit Sub
End If
cptable.MoveNext
Loop
End Sub
Private Sub Command2_Click()
Unload Me
End Sub
Private Sub Form_Load()
Form1.Enabled = False
dcpath = "c:\点菜系统.mdb"
Set dcdb = OpenDatabase(dcpath)
Set cptable = dcdb.OpenRecordset("菜谱表", dbOpenTable)
End Sub
Private Sub Form_Unload(Cancel As Integer)
Form1.Enabled = True
dcdb.Close
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -