📄 main_jbxx_spinf.frm
字号:
VERSION 5.00
Begin VB.Form main_jbxx_spinf
Caption = "商品信息"
ClientHeight = 3360
ClientLeft = 60
ClientTop = 345
ClientWidth = 6900
Icon = "main_jbxx_spinf.frx":0000
LinkTopic = "Form1"
MaxButton = 0 'False
ScaleHeight = 3360
ScaleWidth = 6900
StartUpPosition = 1 '所有者中心
Begin VB.CommandButton CmdEnd
Caption = "返回"
Height = 390
Left = 3630
TabIndex = 18
Top = 2835
Width = 1935
End
Begin VB.CommandButton CmdSave
Caption = "保存"
Height = 390
Left = 1560
TabIndex = 15
Top = 2835
Width = 1935
End
Begin VB.Frame Frame2
Height = 2700
Left = 60
TabIndex = 0
Top = 45
Width = 6735
Begin VB.TextBox Text1
Height = 330
Index = 0
Left = 1110
Locked = -1 'True
TabIndex = 16
Top = 285
Width = 1485
End
Begin VB.TextBox Text1
Height = 330
Index = 5
Left = 1110
TabIndex = 7
Top = 1695
Width = 2730
End
Begin VB.TextBox Text1
Height = 330
Index = 3
Left = 1110
TabIndex = 6
Top = 1230
Width = 2730
End
Begin VB.TextBox Text1
Height = 330
Index = 1
Left = 1110
TabIndex = 5
Top = 765
Width = 2730
End
Begin VB.TextBox Text1
Height = 330
Index = 6
Left = 4890
TabIndex = 4
Top = 1695
Width = 1710
End
Begin VB.TextBox Text1
Height = 330
Index = 4
Left = 4875
TabIndex = 3
Top = 1230
Width = 1710
End
Begin VB.TextBox Text1
Height = 330
Index = 2
Left = 4890
TabIndex = 2
Top = 765
Width = 1710
End
Begin VB.TextBox Text1
Height = 330
Index = 7
Left = 1095
TabIndex = 1
Top = 2160
Width = 5505
End
Begin VB.Label Label1
BackStyle = 0 'Transparent
Caption = "商品编号:"
ForeColor = &H00000000&
Height = 315
Index = 6
Left = 135
TabIndex = 17
Top = 375
Width = 1065
End
Begin VB.Label Label1
BackStyle = 0 'Transparent
Caption = "单 价:"
ForeColor = &H00000000&
Height = 315
Index = 5
Left = 3975
TabIndex = 14
Top = 1770
Width = 1065
End
Begin VB.Label Label1
BackStyle = 0 'Transparent
Caption = "单 位:"
ForeColor = &H00000000&
Height = 315
Index = 4
Left = 150
TabIndex = 13
Top = 1755
Width = 1065
End
Begin VB.Label Label1
BackStyle = 0 'Transparent
Caption = "产 地:"
ForeColor = &H00000000&
Height = 315
Index = 3
Left = 3975
TabIndex = 12
Top = 1320
Width = 1065
End
Begin VB.Label Label1
BackStyle = 0 'Transparent
Caption = "规 格:"
ForeColor = &H00000000&
Height = 315
Index = 2
Left = 150
TabIndex = 11
Top = 1320
Width = 1065
End
Begin VB.Label Label1
BackStyle = 0 'Transparent
Caption = "简 称:"
ForeColor = &H00000000&
Height = 315
Index = 1
Left = 3975
TabIndex = 10
Top = 855
Width = 1065
End
Begin VB.Label Label1
BackStyle = 0 'Transparent
Caption = "商品名称:"
ForeColor = &H00000000&
Height = 315
Index = 0
Left = 150
TabIndex = 9
Top = 840
Width = 1065
End
Begin VB.Label Label1
BackStyle = 0 'Transparent
Caption = "库存数量:"
ForeColor = &H00000000&
Height = 315
Index = 7
Left = 150
TabIndex = 8
Top = 2220
Width = 1065
End
End
End
Attribute VB_Name = "main_jbxx_spinf"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim i As Integer '定义整型变量
Dim rs1 As New ADODB.Recordset '定义数据集对象
Private Sub Form_Activate()
Text1(1).SetFocus
End Sub
Private Sub Text1_KeyDown(Index As Integer, KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyReturn And Index < 7 Then Text1(Index + 1).SetFocus '回车获得焦点
If KeyCode = vbKeyReturn And Index = 7 Then CmdSave.SetFocus
If KeyCode = vbKeyUp And Index > 1 Then Text1(Index - 1).SetFocus
End Sub
Private Sub CmdSave_Click()
Dim a As String
rs1.Open "select * from 商品信息表 where 商品编号='" & Text1(0).Text & "'order by 商品编号", Cnn, adOpenKeyset, adLockOptimistic
If rs1.RecordCount > 0 Then
a = MsgBox("您确实要修改这条数据吗?", vbYesNo)
If a = vbYes Then
For i = 1 To 7
If Text1(1).Text <> "" Then rs1.Fields(i) = Trim(Text1(i).Text)
Next i
rs1.Update
main_jbxx_spll.Adodc1.Refresh
End If
Else
If Text1(1).Text <> "" And Text1(2).Text <> "" Then
'添加商品信息
rs1.AddNew
For i = 0 To 6
rs1.Fields(i) = Trim(Text1(i).Text)
Next i
rs1.Fields(7) = Val(Text1(7).Text)
'更新数据库
rs1.Update
main_jbxx_spll.Adodc1.Refresh
Else
MsgBox "请填写完整的信息"
End If
End If
'关闭数据集对象
rs1.Close
Unload Me
End Sub
Private Sub Form_Unload(Cancel As Integer)
frm_main.Enabled = True
End Sub
Private Sub CmdEnd_Click()
Unload Me
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -