📄 form7.frm
字号:
VERSION 5.00
Begin VB.Form Form7
Caption = "客房商品资料维护"
ClientHeight = 3255
ClientLeft = 60
ClientTop = 450
ClientWidth = 6330
LinkTopic = "Form7"
ScaleHeight = 3255
ScaleWidth = 6330
StartUpPosition = 1 '所有者中心
Begin VB.CommandButton Command1
Caption = "添加"
Height = 375
Left = 2640
TabIndex = 6
Top = 2640
Width = 1215
End
Begin VB.CommandButton Command2
Caption = "退出"
Height = 375
Left = 4320
TabIndex = 5
Top = 2640
Width = 975
End
Begin VB.Frame Frame1
Caption = "请输入要添加的物品"
Height = 1335
Left = 2520
TabIndex = 3
Top = 960
Width = 2895
Begin VB.TextBox Text2
Height = 375
Left = 960
TabIndex = 7
Top = 840
Width = 1695
End
Begin VB.TextBox Text1
Height = 375
Left = 240
TabIndex = 4
Top = 240
Width = 2535
End
Begin VB.Label Label2
Caption = "单价"
Height = 255
Left = 360
TabIndex = 8
Top = 960
Width = 495
End
End
Begin VB.ListBox List1
Height = 3120
Left = 0
TabIndex = 2
Top = 0
Width = 1455
End
Begin VB.Frame Frame2
Caption = "删除操作"
Height = 615
Left = 1800
TabIndex = 0
Top = 0
Width = 4455
Begin VB.Label Label1
BackStyle = 0 'Transparent
Caption = "在左侧的列表中双击选定的物品名称进行删除操作!"
Height = 975
Left = 0
TabIndex = 1
Top = 240
Width = 4455
End
End
End
Attribute VB_Name = "Form7"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
'FIXIT: 使用 Option Explicit 可以避免隐式创建 Variant 类型的变量 FixIT90210ae-R383-H1984
Dim Yume As String
Private Sub Command1_Click()
If Trim(Text1.Text) = "" Then
MsgBox "对不起,名称必须输入? ", vbInformation, "Hello!"
Text1.SetFocus
Exit Sub
End If
'开始保存内容
Dim db As Database
Dim EF As Recordset
Set db = OpenDatabase(ConData, False, False, Constr)
Set EF = db.OpenRecordset("Select * from wp", dbOpenDynaset)
'==================1
'FIXIT: 用 "Trim$" 函数替换 "Trim" 函数 FixIT90210ae-R9757-R1B8ZE
If Trim(Text1.Text) <> "" Then
EF.AddNew
EF("名称") = Text1.Text
EF("单价") = Text2.Text
EF.Update
End If
'-----------------2
'-----------------
EF.Close
db.Close
Yume = "Select * from wp"
List1.Clear
SearchIt
MsgBox "物品已经录入 ", vbInformation
Text1.Text = ""
Text1.SetFocus
End Sub
Private Sub Command2_Click()
Unload Me
End Sub
Private Sub Form_Load()
Yume = "Select * from wp"
SearchIt
End Sub
Private Sub SearchIt()
'检索数据
Dim db As Database
Dim EF As Recordset
Set db = OpenDatabase(ConData, False, False, Constr)
Set EF = db.OpenRecordset(Yume, dbOpenDynaset)
'列出记录
If Not (EF.BOF And EF.EOF) Then
Do While Not EF.EOF
List1.AddItem EF("名称")
EF.MoveNext
Loop
End If
'添加合计
EF.Close
db.Close
End Sub
Private Sub List1_DblClick()
Yume = "Select * from wp where 名称='" & List1.Text & "'"
If MsgBox("您确认要删除本条记录吗(Y/N)? ", vbInformation + vbYesNo) = vbYes Then dIt
End Sub
Private Sub dIt()
'检索数据
Dim db As Database
Dim EF As Recordset
Set db = OpenDatabase(ConData, False, False, Constr)
Set EF = db.OpenRecordset(Yume, dbOpenDynaset)
'列出记录
If Not (EF.BOF And EF.EOF) Then
Do While Not EF.EOF
EF.Delete
EF.MoveNext
Loop
End If
'添加合计
EF.Close
db.Close
List1.Clear
Yume = "Select * from wp"
SearchIt
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -