📄 frmgood.frm
字号:
VERSION 5.00
Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "MSCOMCTL.OCX"
Begin VB.Form frmGood
Caption = "商品管理"
ClientHeight = 4680
ClientLeft = 60
ClientTop = 345
ClientWidth = 7365
Icon = "frmGood.frx":0000
LinkTopic = "Form1"
ScaleHeight = 4680
ScaleWidth = 7365
StartUpPosition = 1 '所有者中心
Begin MSComctlLib.ListView ListView1
Height = 1455
Left = 3720
TabIndex = 0
Top = 1920
Width = 4095
_ExtentX = 7223
_ExtentY = 2566
View = 3
LabelEdit = 1
LabelWrap = -1 'True
HideSelection = -1 'True
FullRowSelect = -1 'True
GridLines = -1 'True
_Version = 393217
ForeColor = -2147483640
BackColor = -2147483643
BorderStyle = 1
Appearance = 1
NumItems = 5
BeginProperty ColumnHeader(1) {BDD1F052-858B-11D1-B16A-00C0F0283628}
Text = "商品编号"
Object.Width = 2540
EndProperty
BeginProperty ColumnHeader(2) {BDD1F052-858B-11D1-B16A-00C0F0283628}
SubItemIndex = 1
Text = "商品名称"
Object.Width = 2540
EndProperty
BeginProperty ColumnHeader(3) {BDD1F052-858B-11D1-B16A-00C0F0283628}
SubItemIndex = 2
Text = "进货价格"
Object.Width = 2540
EndProperty
BeginProperty ColumnHeader(4) {BDD1F052-858B-11D1-B16A-00C0F0283628}
SubItemIndex = 3
Text = "零售价格"
Object.Width = 2540
EndProperty
BeginProperty ColumnHeader(5) {BDD1F052-858B-11D1-B16A-00C0F0283628}
SubItemIndex = 4
Text = "库存数量"
Object.Width = 2540
EndProperty
End
Begin VB.Frame Frame1
Caption = "修改商品资料:"
Height = 3615
Left = 0
TabIndex = 6
Top = 0
Visible = 0 'False
Width = 5655
Begin VB.TextBox Text1
Height = 375
Index = 4
Left = 1560
TabIndex = 16
Top = 2520
Width = 3135
End
Begin VB.TextBox Text1
Height = 375
Index = 3
Left = 1560
TabIndex = 15
Top = 2040
Width = 3135
End
Begin VB.TextBox Text1
Height = 375
Index = 2
Left = 1560
TabIndex = 14
Top = 1560
Width = 3135
End
Begin VB.TextBox Text1
Height = 375
Index = 1
Left = 1560
TabIndex = 13
Top = 1080
Width = 3135
End
Begin VB.TextBox Text1
BackColor = &H80000011&
Height = 375
Index = 0
Left = 1560
Locked = -1 'True
TabIndex = 12
Top = 600
Width = 3135
End
Begin VB.Label Label5
Caption = "库存数量:"
Height = 375
Left = 600
TabIndex = 11
Top = 2640
Width = 1215
End
Begin VB.Label Label4
Caption = "零售价格:"
Height = 255
Left = 600
TabIndex = 10
Top = 2160
Width = 1335
End
Begin VB.Label Label3
Caption = "进货价格:"
Height = 255
Left = 600
TabIndex = 9
Top = 1680
Width = 1095
End
Begin VB.Label Label2
Caption = "商品名称:"
Height = 375
Left = 600
TabIndex = 8
Top = 1200
Width = 975
End
Begin VB.Label Label1
Caption = "商品编号:"
Height = 255
Left = 600
TabIndex = 7
Top = 720
Width = 1095
End
End
Begin VB.PictureBox Picture1
Appearance = 0 'Flat
BorderStyle = 0 'None
ForeColor = &H80000008&
Height = 735
Left = 0
ScaleHeight = 735
ScaleWidth = 7215
TabIndex = 1
Top = 3720
Width = 7215
Begin VB.CommandButton Command6
Caption = "关闭"
Height = 375
Left = 6120
TabIndex = 18
Top = 120
Width = 975
End
Begin VB.CommandButton Command5
Caption = "零售"
Height = 375
Left = 4920
TabIndex = 17
Top = 120
Width = 975
End
Begin VB.CommandButton Command1
Caption = "添加"
Height = 375
Left = 1320
TabIndex = 5
Top = 120
Width = 975
End
Begin VB.CommandButton Command2
Caption = "修改"
Height = 375
Left = 120
TabIndex = 4
Top = 120
Width = 975
End
Begin VB.CommandButton Command3
Caption = "删除"
Height = 375
Left = 2520
TabIndex = 3
Top = 120
Width = 975
End
Begin VB.CommandButton Command4
Caption = "保存"
Enabled = 0 'False
Height = 375
Left = 3720
TabIndex = 2
Top = 120
Width = 975
End
End
End
Attribute VB_Name = "frmGood"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub Command1_Click()
On Error Resume Next
Command1.Enabled = False
Frame1.Visible = True
ListView1.Visible = False
With frmMain.Data3.Recordset
Dim anum As Long, olda As Long, findIt As Boolean
olda = .AbsolutePosition
anum = 0
Do
findIt = False
anum = anum + 1
.MoveFirst
For i = 1 To .RecordCount
If Val(.Fields("商品编号")) = anum Then findIt = True
.MoveNext
Next i
If findIt = False Then Exit Do
Loop
Text1(0).Text = CStr(anum)
For i = 1 To 8 - Len(CStr(anum))
Text1(0).Text = "0" + Text1(0).Text
Next i
.MoveFirst
.Move olda
End With
For i = 1 To 4
Text1(i).Text = ""
Next i
Text1(1).SetFocus
Command2.Caption = "放弃"
End Sub
Private Sub Command2_Click()
On Error Resume Next
If Command2.Caption = "修改" Then
With frmMain.Data3.Recordset
ListView1.Visible = False
Frame1.Visible = True
For i = 0 To 4
Text1(i) = .Fields(i)
Next i
End With
Command2.Caption = "放弃"
Else
ListView1.Visible = True
Frame1.Visible = False
Command2.Caption = "修改"
Command1.Enabled = True
End If
End Sub
Private Sub Command3_Click()
On Error Resume Next
With frmMain.Data5.Recordset
.MoveFirst
For i = 1 To .RecordCount
If .Fields("商品编号") = frmMain.Data3.Recordset.Fields("商品编号") Then
MsgBox "由于当前商品有销售记录,所以不能删除!", vbCritical
Exit Sub
End If
.MoveNext
Next i
If MsgBox("确实要删除当前商品:" + vbCrLf + frmMain.Data3.Recordset.Fields("商品名称") + " 吗?", vbYesNo + vbQuestion) = vbYes Then
frmMain.Data3.Recordset.Delete
LoadList
End If
End With
End Sub
Private Sub Command4_Click()
'保存记录
On Error Resume Next
With frmMain.Data3.Recordset
If Command1.Enabled Then
.Edit
Else
.AddNew
End If
For i = 0 To 4
.Fields(i) = Text1(i)
Next i
.Update
End With
Command2_Click
Command1.Enabled = True
LoadList
frmMain.FlashShangPin
End Sub
Private Sub Command5_Click()
frmSell.Show vbModal, Me
LoadList
End Sub
Private Sub Command6_Click()
Unload Me
End Sub
Private Sub Form_Load()
LoadList
If UserPass < "B" Then
Command1.Enabled = False
Command2.Enabled = False
Command3.Enabled = False
Command4.Enabled = False
End If
End Sub
Private Sub Form_Resize()
On Error Resume Next
ListView1.Move 30, 10, Me.Width - 150, Me.Height - 1200
Picture1.Top = ListView1.Top + ListView1.Height + 100
Picture1.Left = (Me.Width - Picture1.Width) / 2
'Command5.Top ListView1.Top + ListView1.Height + 200
End Sub
Sub LoadList()
'读取数据库到列表中
On Error Resume Next
ListView1.ListItems.Clear
With frmMain.Data3.Recordset
.MoveFirst
For i = 1 To .RecordCount
ListView1.ListItems.Add i, , .Fields("商品编号")
ListView1.ListItems(i).SubItems(1) = .Fields("商品名称")
ListView1.ListItems(i).SubItems(2) = .Fields("进货价格")
ListView1.ListItems(i).SubItems(3) = .Fields("零售价格")
ListView1.ListItems(i).SubItems(4) = .Fields("库存数量")
.MoveNext
Next i
.MoveFirst
End With
End Sub
Private Sub ListView1_ItemClick(ByVal Item As MSComctlLib.ListItem)
On Error Resume Next
With frmMain.Data3.Recordset
.MoveFirst
.Move Item.Index - 1
End With
End Sub
Private Sub Text1_Change(Index As Integer)
Command4.Enabled = True
End Sub
Private Sub Text1_KeyPress(Index As Integer, KeyAscii As Integer)
If Index >= 2 Then
If Chr(KeyAscii) Like "[!0-9.]" And (Not KeyAscii = 8) Then KeyAscii = 0
End If
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -