📄 frminput.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 frmInput
BorderStyle = 3 'Fixed Dialog
Caption = "产品入库"
ClientHeight = 6690
ClientLeft = 45
ClientTop = 330
ClientWidth = 9465
LinkTopic = "Form4"
MaxButton = 0 'False
MDIChild = -1 'True
MinButton = 0 'False
ScaleHeight = 6690
ScaleWidth = 9465
ShowInTaskbar = 0 'False
Begin VB.Frame Frame3
Height = 3135
Left = 120
TabIndex = 16
Top = 120
Width = 9255
Begin MSDataGridLib.DataGrid DataGrid1
Height = 2775
Left = 120
TabIndex = 17
Top = 240
Width = 9015
_ExtentX = 15901
_ExtentY = 4895
_Version = 393216
AllowUpdate = 0 'False
Enabled = -1 'True
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
End
Begin VB.Frame Frame2
Height = 855
Left = 120
TabIndex = 9
Top = 5400
Width = 9255
Begin VB.CommandButton cmdClose
Caption = "关闭"
Height = 495
Left = 6840
TabIndex = 13
Top = 240
Width = 1575
End
Begin VB.CommandButton cmdAdd
Caption = "添加入库"
Height = 495
Left = 480
TabIndex = 12
Top = 240
Width = 1575
End
Begin VB.CommandButton cmdUpdate
Caption = "保存"
Height = 495
Left = 2520
TabIndex = 11
Top = 240
Width = 1575
End
Begin VB.CommandButton cmdCancel
Caption = "取消"
Height = 495
Left = 4680
TabIndex = 10
Top = 240
Width = 1575
End
End
Begin VB.Frame Frame1
Caption = "产品入库信息录入"
Height = 1455
Left = 120
TabIndex = 0
Top = 3360
Width = 9255
Begin VB.TextBox txtFields
Height = 495
Index = 5
Left = 7080
TabIndex = 18
Top = 840
Width = 1815
End
Begin VB.TextBox txtFields
Height = 495
Index = 4
Left = 4200
TabIndex = 15
Top = 840
Width = 1935
End
Begin VB.TextBox txtFields
Height = 495
Index = 0
Left = 1200
TabIndex = 4
Top = 240
Width = 1935
End
Begin VB.TextBox txtFields
Height = 495
Index = 1
Left = 4200
TabIndex = 3
Top = 240
Width = 1935
End
Begin VB.TextBox txtFields
Height = 495
Index = 2
Left = 7080
TabIndex = 2
Top = 240
Width = 1815
End
Begin VB.TextBox txtFields
Height = 495
Index = 3
Left = 1200
TabIndex = 1
Top = 840
Width = 1935
End
Begin VB.Label Label6
Caption = "经手人"
Height = 375
Left = 6240
TabIndex = 19
Top = 840
Width = 735
End
Begin VB.Label Label5
Caption = "入库数量"
Height = 375
Left = 6240
TabIndex = 14
Top = 240
Width = 735
End
Begin VB.Label Label4
Caption = "其它"
Height = 375
Left = 3240
TabIndex = 8
Top = 960
Width = 735
End
Begin VB.Label Label3
Caption = "产品描述"
Height = 375
Left = 240
TabIndex = 7
Top = 960
Width = 975
End
Begin VB.Label Label2
Caption = "产品价格"
Height = 375
Left = 3240
TabIndex = 6
Top = 240
Width = 855
End
Begin VB.Label Label1
Caption = "产品名称"
Height = 375
Left = 240
TabIndex = 5
Top = 360
Width = 975
End
End
Begin MSAdodcLib.Adodc Adodc1
Height = 495
Left = 120
Top = 4920
Width = 9255
_ExtentX = 16325
_ExtentY = 873
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 = ""
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
End
Attribute VB_Name = "frmInput"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub cmdAdd_Click()
'如果有错则转入出错处理部分
On Error GoTo AddErr
'添加一条新纪录
Adodc1.Recordset.AddNew
'设置按钮状态
SetButtons False
Exit Sub
AddErr:
'显示出错信息
MsgBox Err.Description
End Sub
Private Sub cmdCancel_Click()
'如果有错则转入出错处理部分
On Error GoTo CancelErr
'取消修改
Adodc1.Recordset.CancelBatch adAffectAll
'设置按钮状态
SetButtons True
'显示操作信息
MsgBox "取消成功!", vbExclamation + vbOKOnly, "产品添加"
Exit Sub
CancelErr:
'显示出错信息
MsgBox Err.Description
End Sub
Private Sub cmdClose_Click()
Unload Me
End Sub
Private Sub cmdUpdate_Click()
On Error GoTo UpdateErr
'条件判断保证输入的合理性
'如果名称文本框为空,则显示提示信息并返回
If Trim(txtFields(0).Text) = "" Then
MsgBox "名称不能为空", vbExclamation + vbOKOnly, "警告"
'设置鼠标焦点
txtFields(0).SetFocus
Exit Sub
End If
'判断价格文本框输入不能为空
If Trim(txtFields(1).Text) = "" Then
MsgBox "价格不能为空", vbExclamation + vbOKOnly, "警告"
'设置鼠标焦点
txtFields(1).SetFocus
Exit Sub
End If
'判断价格文本框输入必须为数字
If Not IsNumeric(Trim(txtFields(1).Text)) Then
MsgBox "价格必须为数字", vbExclamation + vbOKOnly, "警告"
'设置鼠标焦点
txtFields(1).SetFocus
'使文本变为选中状态
'设置选择的起始位置和选择的长度
txtFields(1).SelStart = 0
txtFields(1).SelLength = Len(txtFields(1).Text)
Exit Sub
End If
'判断入库数量文本框输入必须为数字
If Not IsNumeric(Trim(txtFields(2).Text)) Then
MsgBox "入库数量必须为数字", vbExclamation + vbOKOnly, "警告"
'设置鼠标焦点
txtFields(2).SetFocus
'使文本变为选中状态
'设置选择的起始位置和选择的长度
txtFields(2).SelStart = 0
txtFields(2).SelLength = Len(txtFields(2).Text)
Exit Sub
End If
'保存adodc1的记录集的修改
Adodc1.Recordset.UpdateBatch adAffectAll
'保存后,设置按钮状态
SetButtons True
'显示操作信息
MsgBox "保存成功!", vbExclamation + vbOKOnly, "产品添加"
Exit Sub
UpdateErr:
MsgBox Err.Description
End Sub
Private Sub Form_Load()
'设置Adodc1的连接字符串和记录源
Adodc1.ConnectionString = ConnectString
Adodc1.RecordSource = "Select * From product "
'将文本框和Adodc1绑定
Dim i As Integer
For i = 1 To 6
'设置文本框的数据源
Set txtFields(i - 1).DataSource = Adodc1
'设置文本框的数据绑定字段
txtFields(i - 1).DataField = Adodc1.Recordset.Fields(i).Name
Next i
'设置DataGrid1的数据源
Set DataGrid1.DataSource = Adodc1
'设置按钮状态
SetButtons True
End Sub
Private Sub SetButtons(bVal As Boolean)
cmdAdd.Enabled = bVal
cmdUpdate.Enabled = Not bVal
cmdCancel.Enabled = Not bVal
cmdClose.Enabled = bVal
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -