📄 frmbook.frm
字号:
VERSION 5.00
Begin VB.Form FrmBook
Caption = "图书管理"
ClientHeight = 5160
ClientLeft = 2100
ClientTop = 1845
ClientWidth = 5625
LinkTopic = "Form1"
LockControls = -1 'True
MaxButton = 0 'False
MDIChild = -1 'True
ScaleHeight = 5160
ScaleWidth = 5625
Begin VB.CommandButton cmdCha
Caption = ">|"
Enabled = 0 'False
Height = 255
Index = 3
Left = 4900
TabIndex = 24
Top = 2520
Width = 495
End
Begin VB.CommandButton cmdCha
Caption = ">"
Enabled = 0 'False
Height = 255
Index = 2
Left = 4540
TabIndex = 23
Top = 2520
Width = 375
End
Begin VB.CommandButton cmdCha
Caption = "<"
Enabled = 0 'False
Height = 255
Index = 1
Left = 4080
TabIndex = 22
Top = 2520
Width = 375
End
Begin VB.CommandButton cmdCha
Caption = "|<"
Enabled = 0 'False
Height = 255
Index = 0
Left = 3600
TabIndex = 25
Top = 2520
Width = 495
End
Begin VB.CommandButton CmdExit
Caption = "关 闭"
Height = 375
Left = 3720
TabIndex = 19
Top = 2040
Width = 1575
End
Begin VB.CommandButton CmdFind
Caption = "查 找"
Height = 375
Left = 3720
TabIndex = 20
Top = 1680
Width = 1575
End
Begin VB.CommandButton CmdDel
Caption = "删 除"
Height = 375
Left = 3720
TabIndex = 18
Top = 1320
Width = 1575
End
Begin VB.CommandButton CmdCls
Caption = "清 空"
Height = 375
Left = 3720
TabIndex = 21
Top = 960
Width = 1575
End
Begin VB.CommandButton CmdModify
Caption = "修 改"
Height = 375
Left = 3720
TabIndex = 17
Top = 600
Width = 1575
End
Begin VB.CommandButton CmdAdd
Caption = "增 加"
Height = 375
Left = 3720
TabIndex = 16
Top = 240
Width = 1575
End
Begin VB.TextBox txtMotif
Height = 2055
Left = 1080
MultiLine = -1 'True
TabIndex = 15
Top = 2880
Width = 4095
End
Begin VB.TextBox txtBshelf
Height = 270
Left = 1080
TabIndex = 14
Top = 2480
Width = 2175
End
Begin VB.TextBox txtSort
Height = 270
Left = 1080
TabIndex = 13
Top = 2120
Width = 2175
End
Begin VB.TextBox txtJoin
Height = 270
Left = 1080
TabIndex = 12
Top = 1760
Width = 2175
End
Begin VB.TextBox txtPrice
Height = 270
Left = 1080
TabIndex = 11
Top = 1400
Width = 2175
End
Begin VB.TextBox txtAuthor
Height = 270
Left = 1080
TabIndex = 10
Top = 1040
Width = 2175
End
Begin VB.TextBox txtName
Height = 270
Left = 1080
TabIndex = 9
Top = 680
Width = 2175
End
Begin VB.TextBox txtNum
ForeColor = &H000000FF&
Height = 270
Left = 1080
TabIndex = 8
Top = 305
Width = 2175
End
Begin VB.Label Label8
AutoSize = -1 'True
Caption = "书 架"
Height = 180
Left = 360
TabIndex = 7
Top = 2520
Width = 540
End
Begin VB.Label Label7
AutoSize = -1 'True
Caption = "分 类"
Height = 180
Left = 360
TabIndex = 6
Top = 2160
Width = 540
End
Begin VB.Label Label6
AutoSize = -1 'True
Caption = "加入日期"
Height = 180
Left = 240
TabIndex = 5
Top = 1800
Width = 720
End
Begin VB.Label Label5
AutoSize = -1 'True
Caption = "价 格"
Height = 180
Left = 360
TabIndex = 4
Top = 1440
Width = 540
End
Begin VB.Label Label4
AutoSize = -1 'True
Caption = "说 明"
Height = 180
Left = 360
TabIndex = 3
Top = 3000
Width = 450
End
Begin VB.Label Label3
AutoSize = -1 'True
Caption = "作 者"
Height = 180
Left = 360
TabIndex = 2
Top = 1080
Width = 540
End
Begin VB.Label Label2
AutoSize = -1 'True
Caption = "图书名字"
Height = 180
Left = 240
TabIndex = 1
Top = 720
Width = 720
End
Begin VB.Label Label1
AutoSize = -1 'True
Caption = "图书编号"
Height = 180
Left = 240
TabIndex = 0
Top = 360
Width = 720
End
End
Attribute VB_Name = "FrmBook"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub InBox()
txtNum = DBRct.Fields("bookid").Value
txtName = DBRct.Fields("bookname").Value
If DBRct.Fields("Author").Value <> Empty Then txtAuthor = DBRct.Fields("author").Value
If DBRct.Fields("price").Value <> Empty Then txtPrice = DBRct.Fields("price").Value Else txtG = ""
If DBRct.Fields("joindate").Value <> Empty Then txtJoin = DBRct.Fields("joindate").Value Else txtGre = ""
If DBRct.Fields("sort").Value <> Empty Then txtSort = DBRct.Fields("sort").Value Else txtCla = ""
If DBRct.Fields("bookshelf").Value <> Empty Then txtBshelf = DBRct.Fields("bookshelf").Value Else txtBirth = ""
If DBRct.Fields("motif").Value <> Empty Then txtMotif = DBRct.Fields("motif").Value Else txtJoin = ""
End Sub
Private Sub Command4_Click()
Unload Me
End Sub
Private Sub CmdAdd_Click()
If txtNum = Empty Or txtName = Empty Then MsgBox "数据不完整!", vbInformation, "数据不完整": Exit Sub
Call QueryInfo("select * from books where bookid='" & Choose(txtNum) & "'")
If Not DBRct.EOF Then MsgBox "该书编号已存在!", vbInformation, "出错": Exit Sub
Call ExecuteSQL("insert into books(bookid,bookname,BookShelf,Sort,JoinDate,Author,Price,Motif) values ('" & _
Choose(txtNum) & "','" & Choose(txtName) & "','" & Choose(txtBshelf) & "','" & Choose(txtSort) & "','" & Choose(txtJoin) & "','" & Choose(txtAuthor) & "'," & _
Choose(txtPrice) & ",'" & Choose(txtMotif) & "')")
Call QueryInfo("select * from books where bookid='" & Choose(txtNum) & "'")
If Not DBRct.EOF Then MsgBox "增加信息成功!", vbInformation, "成功" Else MsgBox "数据不符合要求!", vbInformation, "失败"
End Sub
Private Sub cmdCha_Click(Index As Integer)
Select Case Index
Case 0: DBRct.MoveFirst
Case 1: DBRct.MovePrevious: If DBRct.BOF Then DBRct.MoveLast
Case 2: DBRct.MoveNext: If DBRct.EOF Then DBRct.MoveFirst
Case 3: DBRct.MoveLast
End Select
Call InBox
End Sub
Private Sub CmdCls_Click()
txtNum = Empty: txtName = Empty: txtAuthor = Empty
txtPrice = Empty: txtJoin = Empty: txtBshelf = Empty
txtMotif = Empty: txtSort = Empty
End Sub
Private Sub cmdDel_Click()
Call QueryInfo("select * from books where bookid='" & Choose(txtNum) & "'")
If DBRct.EOF Then MsgBox "该书编号不存在!", vbInformation, "出错": Exit Sub
If MsgBox("确认要删除:" & DBRct.Fields("bookname").Value & "吗?", vbInformation + vbYesNo, "删除提示") = vbYes Then
Call ExecuteSQL("delete books where bookid='" & Choose(txtNum) & "'")
DBRct.Delete
DBRct.MoveNext
MsgBox "删除图书成功!", vbInformation, "成功"
End If
cmdCha(0).Enabled = False
cmdCha(1).Enabled = False
cmdCha(2).Enabled = False
cmdCha(3).Enabled = False
End Sub
Private Sub cmdExit_Click()
Unload Me
End Sub
Private Sub CmdFind_Click()
Dim Sql As String
If txtNum <> Empty Then Sql = Sql & "and bookid like '%" & Choose(txtNum) & "%'"
If txtName <> Empty Then Sql = Sql & "and bookname like '%" & Choose(txtName) & "%'"
If txtAuthor <> Empty Then Sql = Sql & "and author like '%" & Choose(txtAuthor) & "%'"
If txtPrice <> Empty Then Sql = Sql & "and price = " & Choose(txtPrice)
If txtJoin <> Empty Then Sql = Sql & "and joindate ='" & Choose(txtJoin) & "'"
If txtSort <> Empty Then Sql = Sql & "and sort ='" & Choose(txtSort) & "'"
If txtBshelf <> Empty Then Sql = Sql & "and bookshelf = '" & Choose(txtBshelf) & "'"
If txtMotif <> Empty Then Sql = Sql & "and motif like '%" & Choose(txtMotif) & "%'"
Call QueryInfo("select * from books where bookid is not null " & Sql)
If DBRct.EOF Then
MsgBox "未查到数据!", vbInformation, "无数据"
blnfind = False
cmdCha(0).Enabled = False
cmdCha(1).Enabled = False
cmdCha(2).Enabled = False
cmdCha(3).Enabled = False
Else: DBRct.MoveFirst: Call InBox
blnfind = True
cmdCha(0).Enabled = True
cmdCha(1).Enabled = True
cmdCha(2).Enabled = True
cmdCha(3).Enabled = True
End If
End Sub
Private Sub CmdModify_Click()
Dim Sql As String
Call QueryInfo("select * from books where bookid='" & Choose(txtNum) & "'")
If DBRct.EOF Then MsgBox "该编号不存在!", vbInformation, "出错": Exit Sub
Sql = "update books set bookid='" & Choose(txtNum) & "'"
If txtName <> Empty Then Sql = Sql & ",bookname='" & Choose(txtName) & "'"
If txtAuthor <> Empty Then Sql = Sql & ",author='" & Choose(txtAuthor) & "'"
If txtPrice <> Empty Then Sql = Sql & ",price = " & Choose(txtPrice)
If txtJoin <> Empty Then Sql = Sql & ",joindate ='" & Choose(txtJoin) & "'"
If txtSort <> Empty Then Sql = Sql & ",sort ='" & Choose(txtSort) & "'"
If txtBshelf <> Empty Then Sql = Sql & ",bookshelf = '" & Choose(txtBshelf) & "'"
If txtMotif <> Empty Then Sql = Sql & ",motif ='" & Choose(txtMotif) & "'"
Sql = Sql & " where bookid='" & Choose(txtNum) & "'"
Call ExecuteSQL(Sql)
MsgBox "修改图书资料成功!", vbInformation, "成功"
End Sub
Private Sub Form_Resize()
If Me.Height <= 500 Or Me.Width <= 1500 Then Exit Sub
Me.Height = 5580
Me.Width = 5745
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -