📄 main_jcxx_tswzsz.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 main_jcxx_tswzsz
BorderStyle = 1 'Fixed Single
Caption = "基础信息管理-【图书存放位置】"
ClientHeight = 3690
ClientLeft = 45
ClientTop = 330
ClientWidth = 6600
Icon = "main_jcxx_tswzsz.frx":0000
LinkTopic = "Form1"
LockControls = -1 'True
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 3690
ScaleWidth = 6600
StartUpPosition = 1 '所有者中心
Begin MSDataGridLib.DataGrid DataGrid1
Bindings = "main_jcxx_tswzsz.frx":0CCA
Height = 1395
Left = 105
TabIndex = 11
Top = 1545
Width = 6420
_ExtentX = 11324
_ExtentY = 2461
_Version = 393216
BackColor = 12713963
HeadLines = 1
RowHeight = 15
FormatLocked = -1 'True
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
ColumnWidth = 2580.095
EndProperty
BeginProperty Column01
ColumnWidth = 2745.071
EndProperty
EndProperty
End
Begin MSAdodcLib.Adodc Adodc1
Height = 390
Left = 1470
Top = 2295
Visible = 0 'False
Width = 2325
_ExtentX = 4101
_ExtentY = 688
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 = "Adodc1"
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
Begin VB.Frame Frame1
Caption = "图书存放位置信息"
Height = 1455
Left = 90
TabIndex = 0
Top = 0
Width = 6435
Begin VB.TextBox Text2
BackColor = &H00FFFFFF&
Enabled = 0 'False
Height = 285
Left = 2295
TabIndex = 2
Top = 930
Width = 3735
End
Begin VB.TextBox Text1
BackColor = &H00FFFFFF&
Enabled = 0 'False
Height = 285
Left = 2295
Locked = -1 'True
TabIndex = 1
Top = 405
Width = 3720
End
Begin VB.Image Image1
Height = 735
Left = 495
Picture = "main_jcxx_tswzsz.frx":0CDF
Stretch = -1 'True
Top = 435
Width = 570
End
Begin VB.Label Label1
BackStyle = 0 'Transparent
Caption = "位置编号: 存放位置:"
ForeColor = &H000000FF&
Height = 885
Left = 1350
TabIndex = 3
Top = 465
Width = 990
End
End
Begin VB.Frame Frame2
Height = 675
Left = 105
TabIndex = 4
Top = 2970
Width = 4875
Begin VB.CommandButton CmdAdd
Caption = "添加"
Height = 360
Left = 75
TabIndex = 8
Top = 210
Width = 1095
End
Begin VB.CommandButton CmdDelete
Caption = "删除"
Height = 360
Left = 2475
TabIndex = 7
Top = 210
Width = 1095
End
Begin VB.CommandButton CmdSave
Caption = "保存"
Enabled = 0 'False
Height = 360
Left = 1260
TabIndex = 6
Top = 210
Width = 1095
End
Begin VB.CommandButton CmdEsc
Caption = "取消"
Enabled = 0 'False
Height = 360
Left = 3675
TabIndex = 5
Top = 210
Width = 1095
End
End
Begin VB.Frame Frame3
Height = 675
Left = 4950
TabIndex = 9
Top = 2970
Width = 1575
Begin VB.CommandButton CmdExit
Caption = "退出"
Height = 360
Left = 240
TabIndex = 10
Top = 210
Width = 1095
End
End
End
Attribute VB_Name = "main_jcxx_tswzsz"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim rs1 As New ADODB.Recordset '声明数据集对象
Private Sub Form_Load()
'自动识别路径
Adodc1.ConnectionString = "DSN=NBooks"
Adodc1.RecordSource = "select * from tswzb"
Adodc1.Refresh
End Sub
Private Sub Text1_GotFocus() '获得焦点时,Text1颜色变化
text1.BackColor = &HFFFF00
End Sub
Private Sub Text1_LostFocus() '失去焦点时,Text1颜色变化
text1.BackColor = &HFFFFFF
End Sub
Private Sub Text1_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyReturn Then Text2.SetFocus '按回车键Text2获得焦点
End Sub
Private Sub Text2_GotFocus()
Text2.BackColor = &HFFFF00 '设置Text2颜色
End Sub
Private Sub Text2_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then CmdSave.SetFocus '按回车键CmdSave获得焦点
End Sub
Private Sub Text2_LostFocus()
Text2.BackColor = &HFFFFFF '设置Text2颜色
End Sub
Private Sub CmdAdd_Click() '添加操作
'自动创建位置编号
rs1.Open "select * from tswzb order by 位置编号", Cnn, adOpenKeyset, adLockOptimistic
If rs1.RecordCount > 0 Then
If Not rs1.EOF Then rs1.MoveLast
If rs1.Fields("位置编号") <> "" Then
text1.text = "P" & Format(Right(rs1.Fields("位置编号"), 5) + 1, "00000")
'Format 函数返回 Variant (String),其中含有一个表达式,它是根据格式表达式中的指令来格式化的。
'Right 函数返回 Variant (String),其中包含从字符串右边取出的指定数量的字符。
End If
Else
text1.text = "P00001"
End If
rs1.Close
text1.Enabled = True
Text2.Enabled = True
Text2.SetFocus
'设置控件状态
CmdAdd.Enabled = False
CmdDelete.Enabled = False
CmdSave.Enabled = True
CmdEsc.Enabled = True
End Sub
Private Sub CmdSave_Click() '保存图书存放位置信息
rs1.Open "select * from tswzb where 位置编号='" & Trim(text1.text) & "'order by 位置编号", Cnn, adOpenKeyset, adLockOptimistic
'Trim 函数返回 Variant (String),其中包含指定字符串的拷贝,没有前导和尾随空白 (Trim)。
If Text2.text = "" Then
MsgBox "请输入存放位置!", , "图书综合管理系统"
Text2.SetFocus
Exit Sub
End If
'添加图书存放位置信息
Adodc1.Recordset.AddNew
Adodc1.Recordset.Fields("位置编号") = text1.text
Adodc1.Recordset.Fields("存放位置") = Text2.text
'更新数据库
Adodc1.Recordset.Update
'清空文本框中的数据
text1.text = ""
Text2.text = ""
'设置控件有效或无效
text1.Enabled = False
Text2.Enabled = False
CmdSave.Enabled = False
CmdEsc.Enabled = False
CmdAdd.Enabled = True
CmdDelete.Enabled = True
rs1.Close
End Sub
Private Sub CmdDelete_Click() '删除图书存放位置信息
On Error Resume Next
If MsgBox("确认删除该信息?", 4, "图书综合管理系统") = vbYes Then
Adodc1.Recordset.Delete
Adodc1.Recordset.Update
End If
End Sub
Private Sub CmdEsc_Click() '取消操作
'设置控件状态
text1.text = ""
Text2.text = ""
text1.Enabled = False
Text2.Enabled = False
CmdSave.Enabled = False
CmdEsc.Enabled = False
CmdAdd.Enabled = True
CmdDelete.Enabled = True
End Sub
Private Sub Form_Unload(Cancel As Integer)
frm_main.Enabled = True
End Sub
Private Sub CmdExit_Click() '退出
Unload Me
frm_main.Enabled = True
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -