📄 chanpin.frm
字号:
VERSION 5.00
Object = "{5E9E78A0-531B-11CF-91F6-C2863C385E30}#1.0#0"; "MSFLXGRD.OCX"
Begin VB.Form Form3
BorderStyle = 3 'Fixed Dialog
Caption = "产品列表"
ClientHeight = 4920
ClientLeft = 45
ClientTop = 330
ClientWidth = 7470
LinkTopic = "Form3"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 4920
ScaleWidth = 7470
ShowInTaskbar = 0 'False
StartUpPosition = 3 '窗口缺省
Begin VB.Frame Frame2
Height = 735
Left = 120
TabIndex = 10
Top = 4080
Width = 7215
Begin VB.CommandButton Command1
Caption = "增 加"
Height = 375
Left = 480
TabIndex = 15
Top = 240
Width = 975
End
Begin VB.CommandButton Command2
Caption = "保 存"
Height = 375
Left = 1800
TabIndex = 14
Top = 240
Width = 975
End
Begin VB.CommandButton Command3
Caption = "修 改"
Height = 375
Left = 3120
TabIndex = 13
Top = 240
Width = 975
End
Begin VB.CommandButton Command4
Caption = "删 除"
Height = 375
Left = 4440
TabIndex = 12
Top = 240
Width = 975
End
Begin VB.CommandButton Command5
Caption = "退 出"
Height = 375
Left = 5760
TabIndex = 11
Top = 240
Width = 975
End
End
Begin VB.Data Data1
Caption = "Data1"
Connect = "Access"
DatabaseName = ""
DefaultCursorType= 0 '缺省游标
DefaultType = 2 '使用 ODBC
Exclusive = 0 'False
Height = 345
Left = 5760
Options = 0
ReadOnly = 0 'False
RecordsetType = 1 'Dynaset
RecordSource = ""
Top = 480
Visible = 0 'False
Width = 1140
End
Begin VB.Data Data2
Caption = "Data2"
Connect = "Access"
DatabaseName = ""
DefaultCursorType= 0 '缺省游标
DefaultType = 2 '使用 ODBC
Exclusive = 0 'False
Height = 345
Left = 5760
Options = 0
ReadOnly = 0 'False
RecordsetType = 1 'Dynaset
RecordSource = ""
Top = 120
Visible = 0 'False
Width = 1140
End
Begin VB.Frame Frame1
Caption = "编缉区"
ForeColor = &H00FF0000&
Height = 1335
Left = 120
TabIndex = 0
Top = 2640
Width = 7215
Begin VB.TextBox Text4
Height = 270
Left = 5760
TabIndex = 17
Text = "Text4"
Top = 840
Width = 975
End
Begin VB.TextBox Text3
Height = 270
Left = 3960
TabIndex = 8
Text = "Text3"
Top = 840
Width = 975
End
Begin VB.TextBox Text1
Height = 270
Left = 3960
TabIndex = 3
Text = "Text1"
Top = 360
Width = 2775
End
Begin VB.ComboBox Combo1
Height = 300
Left = 1080
Sorted = -1 'True
TabIndex = 2
Top = 345
Width = 1935
End
Begin VB.TextBox Text2
Height = 270
Left = 1080
TabIndex = 1
Text = "Text2"
Top = 840
Width = 1935
End
Begin VB.Label Label5
Caption = "库存"
ForeColor = &H00008000&
Height = 255
Left = 5160
TabIndex = 16
Top = 848
Width = 495
End
Begin VB.Label Label4
Caption = "单位"
ForeColor = &H000000FF&
Height = 255
Left = 3360
TabIndex = 7
Top = 848
Width = 495
End
Begin VB.Label Label1
AutoSize = -1 'True
Caption = "产品"
ForeColor = &H000000FF&
Height = 180
Left = 3360
TabIndex = 6
Top = 405
Width = 360
End
Begin VB.Label Label2
AutoSize = -1 'True
Caption = "品牌"
ForeColor = &H000000FF&
Height = 180
Left = 480
TabIndex = 5
Top = 405
Width = 360
End
Begin VB.Label Label3
Caption = "规格"
ForeColor = &H000000FF&
Height = 255
Left = 480
TabIndex = 4
Top = 848
Width = 495
End
End
Begin MSFlexGridLib.MSFlexGrid MSFlexGrid1
Bindings = "ChanPin.frx":0000
Height = 2535
Left = 120
TabIndex = 9
Top = 0
Width = 7215
_ExtentX = 12726
_ExtentY = 4471
_Version = 393216
FixedCols = 0
BackColor = 8421376
ForeColor = 65535
BackColorBkg = 12632256
GridColor = 65535
TextStyleFixed = 1
AllowUserResizing= 1
End
End
Attribute VB_Name = "Form3"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Public rec As Integer
Public BZ As Integer
Private Sub Combo1_Click()
Text1.SetFocus
Text2.SetFocus
Text3.SetFocus
Text4.SetFocus
End Sub
Private Sub Command1_Click()
Text1.Enabled = True
Text2.Enabled = True
Text3.Enabled = True
Text4.Enabled = True
Combo1.Enabled = True
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
Text4.Text = 0
Command2.Enabled = True
BZ = 1
Text1.SetFocus
Text2.SetFocus
Text3.SetFocus
Text4.SetFocus
End Sub
Private Sub Command2_Click()
If BZ = 1 Then
If Text1.Text = "" Or Text2.Text = "" Or Text3.Text = "" Then
MsgBox "关键不能为空", 0 + 16
Exit Sub
End If
If Combo1.Text = "" Then
MsgBox "品牌不能为空", 0 + 16
Exit Sub
End If
Data1.Recordset.FindFirst "产品=" + "'" + Text1.Text + "'"
Data1.Recordset.FindFirst "规格=" + "'" + Text2.Text + "'"
Data1.Recordset.FindFirst "单位=" + "'" + Text3.Text + "'"
Data1.Recordset.FindFirst "数量=" + "" + Text4.Text + ""
With Data1.Recordset
.AddNew
.Update
.Bookmark = .LastModified
.Edit
.Fields("品牌") = Combo1.Text
.Fields("产品") = Text1.Text
.Fields("规格") = Text2.Text
.Fields("单位") = Text3.Text
.Fields("数量") = Text4.Text
.Update
End With
End If
If BZ = 2 Then
If Text1.Text = "" Or Text2.Text = "" Or Text3.Text = "" Then
MsgBox "关健不能为空", 0 + 16
Exit Sub
End If
If Combo1.Text = "" Then
MsgBox "品牌不能为空", 0 + 16
Exit Sub
End If
Data1.Recordset.FindFirst "产品=" + "'" + Text1.Text + "'"
Data1.Recordset.FindFirst "规格=" + "'" + Text2.Text + "'"
Data1.Recordset.FindFirst "单位=" + "'" + Text3.Text + "'"
Data1.Recordset.FindFirst "数量=" + "" + Text4.Text + ""
With Data1.Recordset
.AbsolutePosition = rec
.Edit
.Fields("品牌") = Combo1.Text
.Fields("产品") = Text1.Text
.Fields("规格") = Text2.Text
.Fields("单位") = Text3.Text
.Fields("数量") = Text4.Text
.Update
End With
End If
Data1.Refresh
Text1.Enabled = False
Command2.Enabled = False
Command1.SetFocus
End Sub
Private Sub Command3_Click()
Data1.Recordset.AbsolutePosition = rec
Combo1.Text = Data1.Recordset.Fields("品牌")
Text1.Text = Data1.Recordset.Fields("产品")
Text2.Text = Data1.Recordset.Fields("规格")
Text3.Text = Data1.Recordset.Fields("单位")
Text4.Text = Data1.Recordset.Fields("数量")
Text1.Enabled = True
Text2.Enabled = True
Text3.Enabled = True
Text4.Enabled = True
Combo1.Enabled = True
Command2.Enabled = True
BZ = 2
End Sub
Private Sub Command4_Click()
Dim msg As Long
msg = MsgBox("是否确认删除?", 1 + 32)
If msg = 1 Then
Data1.Recordset.AbsolutePosition = rec
Data1.Recordset.Delete
Data1.Refresh
Else
Exit Sub
End If
End Sub
Private Sub Command5_Click()
Unload Me
End Sub
Private Sub Data1_Reposition()
If Data1.Recordset.RecordCount > 0 Then
Command3.Enabled = True
Command4.Enabled = True
Else
Command3.Enabled = False
Command4.Enabled = False
End If
End Sub
Private Sub Form_Activate()
Data1.DatabaseName = App.Path + "\odb.dll"
Data1.RecordSource = "kucun"
Data1.Refresh
Data2.DatabaseName = App.Path + "\odb.dll"
Data2.RecordSource = "paizi"
Data2.Refresh
If Data2.Recordset.RecordCount = 0 Then
MsgBox "请先建立品牌档案!", 0 + 64
Unload Me
Exit Sub
End If
While Data2.Recordset.EOF = False
Combo1.AddItem Data2.Recordset.Fields("品牌")
Data2.Recordset.MoveNext
Wend
Combo1.Text = Combo1.List(0)
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
Text4.Text = 0
Text1.Enabled = False
Text2.Enabled = False
Text3.Enabled = False
Text4.Enabled = False
Combo1.Enabled = False
Command2.Enabled = False
Command4.Enabled = False
End Sub
Private Sub MSFlexGrid1_Click()
rec = MSFlexGrid1.Row - 1
Command4.Enabled = True
End Sub
Private Sub Text1_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
Command2.SetFocus
End If
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -