📄 editbook.frm
字号:
Left = 4605
List = "EditBook.frx":2AC2
TabIndex = 1
Text = "Combo1"
Top = 705
Width = 1335
End
Begin VB.Label Label2
AutoSize = -1 'True
BackStyle = 0 'Transparent
Caption = "基本信息"
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H00008000&
Height = 210
Left = 555
TabIndex = 17
Top = 390
Width = 840
End
Begin VB.Label Label1
AutoSize = -1 'True
BackStyle = 0 'Transparent
Caption = "信息编号"
ForeColor = &H000000FF&
Height = 180
Index = 0
Left = 405
TabIndex = 10
Top = 780
Width = 720
End
Begin VB.Label Label1
AutoSize = -1 'True
BackStyle = 0 'Transparent
Caption = "名 称"
ForeColor = &H00800000&
Height = 180
Index = 1
Left = 600
TabIndex = 9
Top = 1185
Width = 540
End
Begin VB.Label Label1
AutoSize = -1 'True
BackStyle = 0 'Transparent
Caption = "值"
ForeColor = &H00800000&
Height = 180
Index = 2
Left = 600
TabIndex = 8
Top = 2025
Width = 180
End
Begin VB.Label Label1
AutoSize = -1 'True
BackStyle = 0 'Transparent
Caption = "类 别"
ForeColor = &H00008000&
Height = 180
Index = 3
Left = 3930
TabIndex = 7
Top = 765
Width = 540
End
Begin VB.Label Label1
AutoSize = -1 'True
BackStyle = 0 'Transparent
Caption = "描 述"
ForeColor = &H00800000&
Height = 180
Index = 4
Left = 600
TabIndex = 6
Top = 1605
Width = 540
End
Begin VB.Image Image1
Height = 480
Left = 75
Picture = "EditBook.frx":2AC4
Top = 195
Width = 480
End
End
End
Attribute VB_Name = "EditBook"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim db As Database
Dim rst As Recordset
Dim Rec As Integer
Dim StrFlag As String
Dim NumFlag As Boolean
Dim db1 As Database
Dim rst1 As Recordset
Private Sub cmdOkCancel_Click(Index As Integer)
Select Case Index
Case 0
If StrFlag = "修改" Then
rst.Edit
WriteIn
rst.Update
Disp
Picture2.Visible = False
Picture1.Visible = True
SetTxt (False)
ElseIf StrFlag = "删除" Then
rst.Delete
rst.MovePrevious
If rst.BOF Then rst.MoveNext
Disp
Picture2.Visible = False
Picture1.Visible = True
End If
Case 1
Disp
Picture2.Visible = False
Picture1.Visible = True
SetTxt (False)
End Select
End Sub
Private Sub Command1_Click()
Unload Me
End Sub
Private Sub Form_Load()
Set db = Workspaces(0).OpenDatabase(App.Path & "\Database\Data.mdb", False)
Set rst = db.OpenRecordset("Book", dbOpenTable)
rst.Index = "信息编号"
Set db1 = Workspaces(0).OpenDatabase(App.Path & "\Database\Data.mdb", False)
Set rst1 = db1.OpenRecordset("Type", dbOpenTable)
Rec = rst.RecordCount
If Rec = 0 Then
Toolbar1.Enabled = False
SetTxt (False)
End If
SetTxt (False)
rst.MoveFirst
Disp
TypeAdd
Picture1.Visible = True
Picture2.Visible = False
NumFlag = False
End Sub
Private Sub Disp()
txtBookNum = rst.Fields("信息编号") & vbNullString
txtBookName = rst.Fields("名称") & vbNullString
txtCost = rst.Fields("值") & Empty
txtBookChu = rst.Fields("描述") & vbNullString
Combo1.Text = rst.Fields("类别") & vbNullString
End Sub
Private Sub Kong()
txtBookNum = ""
txtBookName = ""
txtbookcost = ""
txtBookChu = ""
Combo1.Text = ""
End Sub
Private Sub SetTxt(Bool As Boolean)
txtBookNum.Enabled = Bool
txtCost.Enabled = Bool
txtBookName.Enabled = Bool
txtBookChu.Enabled = Bool
Combo1.Enabled = Bool
End Sub
Private Sub Form_Unload(Cancel As Integer)
rst.Close
rst1.Close
db1.Close
db.Close
End Sub
Private Sub Toolbar1_ButtonClick(ByVal Button As MSComctlLib.Button)
Select Case Button.Index
Case 1
rst.MoveFirst
Disp
Case 2
rst.MovePrevious
If rst.BOF Then
rst.MoveNext
Exit Sub
End If
Disp
Case 3
rst.MoveNext
If rst.EOF Then
rst.MovePrevious
Exit Sub
End If
Disp
Case 4
rst.MoveLast
Disp
Case 6
StrFlag = "修改"
SetTxt (True)
labFlag.Caption = "保存记录"
Picture1.Visible = False
Picture2.Visible = True
Case 7
StrFlag = "删除"
labFlag.Caption = "删除记录"
Picture1.Visible = False
Picture2.Visible = True
Case 8
SearchNum.Show (1)
If SearchFlag = True Then
rst.Seek "=", BookBianHao
If rst.NoMatch Then
MsgBox "没有此信息编号!", 0 + 48, "查找失败"
Exit Sub
End If
Disp
SearchFlag = False
End If
End Select
End Sub
Private Sub WriteIn()
rst.Fields("信息编号") = txtBookNum
rst.Fields("名称") = txtBookName
rst.Fields("值") = Val(txtCost)
rst.Fields("描述") = txtBookChu
rst.Fields("类别") = Combo1.Text
End Sub
Private Sub TypeAdd()
rst1.MoveLast
rst1.MoveFirst
For i = 1 To rst1.RecordCount
Combo1.AddItem rst1.Fields("类别")
rst1.MoveNext
If rst1.EOF Then Exit Sub
Next
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -