📄 frmfood.frm
字号:
VERSION 5.00
Object = "{67397AA1-7FB1-11D0-B148-00A0C922E820}#6.0#0"; "MSADODC.OCX"
Object = "{CDE57A40-8B86-11D0-B3C6-00A0C90AEA82}#1.0#0"; "MSDATGRD.OCX"
Begin VB.Form FrmFood
Caption = "菜单管理"
ClientHeight = 5670
ClientLeft = 60
ClientTop = 450
ClientWidth = 7995
LinkTopic = "Form1"
ScaleHeight = 5670
ScaleWidth = 7995
StartUpPosition = 3 '窗口缺省
Begin VB.ComboBox ComboClass
Height = 300
Left = 1320
TabIndex = 6
Text = "Combo1"
Top = 120
Width = 1575
End
Begin VB.CommandButton Cmd_Del
Caption = "删除"
Height = 495
Left = 3840
TabIndex = 4
Top = 4560
Width = 1335
End
Begin MSAdodcLib.Adodc AdoFoodList
Height = 375
Left = 4920
Top = 120
Visible = 0 'False
Width = 2235
_ExtentX = 3942
_ExtentY = 661
ConnectMode = 0
CursorLocation = 3
IsolationLevel = -1
ConnectionTimeout= 15
CommandTimeout = 30
CursorType = 3
LockType = 3
CommandType = 8
CursorOptions = 0
CacheSize = 50
MaxRecords = 0
BOFAction = 0
EOFAction = 0
ConnectStringType= 1
Appearance = 1
BackColor = -2147483643
ForeColor = -2147483640
Orientation = 0
Enabled = -1
Connect = ""
OLEDBString = ""
OLEDBFile = ""
DataSourceName = ""
OtherAttributes = ""
UserName = ""
Password = ""
RecordSource = ""
Caption = "Adodc1"
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "宋体"
Size = 9
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
_Version = 393216
End
Begin MSDataGridLib.DataGrid DataGrid1
Height = 3495
Left = 120
TabIndex = 3
Top = 840
Width = 7215
_ExtentX = 12726
_ExtentY = 6165
_Version = 393216
HeadLines = 1
RowHeight = 15
BeginProperty HeadFont {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "宋体"
Size = 9
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "宋体"
Size = 9
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ColumnCount = 2
BeginProperty Column00
DataField = ""
Caption = ""
BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED}
Type = 0
Format = ""
HaveTrueFalseNull= 0
FirstDayOfWeek = 0
FirstWeekOfYear = 0
LCID = 2052
SubFormatType = 0
EndProperty
EndProperty
BeginProperty Column01
DataField = ""
Caption = ""
BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED}
Type = 0
Format = ""
HaveTrueFalseNull= 0
FirstDayOfWeek = 0
FirstWeekOfYear = 0
LCID = 2052
SubFormatType = 0
EndProperty
EndProperty
SplitCount = 1
BeginProperty Split0
BeginProperty Column00
EndProperty
BeginProperty Column01
EndProperty
EndProperty
End
Begin VB.CommandButton Cmd_Exit
Caption = "退出"
Height = 495
Left = 5400
TabIndex = 2
Top = 4560
Width = 1335
End
Begin VB.CommandButton Cmd_Modi
Caption = "修改"
Height = 495
Left = 2400
TabIndex = 1
Top = 4560
Width = 1335
End
Begin VB.CommandButton Cmd_Add
Caption = "添加"
Height = 495
Left = 840
TabIndex = 0
Top = 4560
Width = 1335
End
Begin VB.Label Label1
Caption = "食品类型"
Height = 375
Left = 120
TabIndex = 5
Top = 120
Width = 975
End
End
Attribute VB_Name = "FrmFood"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim OriClass As String
Private Sub Cmd_Add_Click()
OriClass = ComboClass.Text
With FrmFoodEdit
.Modify = False
.Show 1
End With
Loadtype
Refresh_Food
End Sub
Private Sub Refresh_Food()
'设置ADO控件的数据源
AdoFoodList.ConnectionString = Conn
AdoFoodList.RecordSource = "select * From Food WHERE FoodClass='" + Trim(ComboClass.Text) + "'"
AdoFoodList.Refresh
Set DataGrid1.DataSource = AdoFoodList
With DataGrid1
.Columns(0).Width = 1000 '食品编号
.Columns(1).Width = 1000 '食品分类
.Columns(2).Width = 1000 '食品名称
.Columns(3).Width = 1000 '价格
End With
End Sub
Private Sub Command1_Click()
End Sub
Private Sub Cmd_Del_Click()
If AdoFoodList.Recordset.EOF = True Then
MsgBox "请选择要删除的记录"
Exit Sub
End If
OriClass = ComboClass.Text
If MsgBox("是否删除当前记录", vbYesNo, "请确认") = vbYes Then
SqlStmt = "delete from Food where FoodNo='" + Trim(AdoFoodList.Recordset.Fields(0).Value) + "'"
SQLExt (SqlStmt)
Refresh_Food
End If
Loadtype
End Sub
Private Sub Cmd_Exit_Click()
Unload Me
End Sub
Private Sub Cmd_Modi_Click()
'判断是否选择了要修改的记录
If AdoFoodList.Recordset.EOF = True Then
MsgBox "请选择要修改的记录"
Exit Sub
End If
FrmFoodEdit.Modify = True
If MyFood.GetInfo(Trim(AdoFoodList.Recordset.Fields(0))) = True Then
OriClass = ComboClass.Text
FrmFoodEdit.txtNo = Trim(AdoFoodList.Recordset.Fields(0))
FrmFoodEdit.ComboFoodClass = ComboClass.Text
FrmFoodEdit.txtName = Trim(AdoFoodList.Recordset.Fields(2))
FrmFoodEdit.txtPrice = Trim(AdoFoodList.Recordset.Fields(3))
End If
FrmFoodEdit.Show 1
'刷新显示
Loadtype
Refresh_Food
End Sub
Private Sub Command2_Click()
Unload Me
End Sub
Private Sub ComboClass_Change()
Refresh_Food
End Sub
Private Sub ComboClass_Click()
Refresh_Food
End Sub
Private Sub Form_Load()
Loadtype
Refresh_Food
End Sub
Private Sub Loadtype()
Dim i As Integer
i = 0
MyFood.Loadtype
ComboClass.Clear
i = 0
Do While Arr_FoodClass(i) <> ""
ComboClass.AddItem Arr_FoodClass(i)
i = i + 1
Loop
If OriClass = "" Then
If ComboClass.ListCount > 0 Then
ComboClass.ListIndex = 0
End If
Else
If InCombo(OriClass, ComboClass) = True Then
ComboClass.Text = OriClass
Else
If ComboClass.ListCount > 0 Then
ComboClass.ListIndex = 0
End If
End If
End If
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -