📄 frmbooksinfo.frm
字号:
VERSION 5.00
Object = "{5E9E78A0-531B-11CF-91F6-C2863C385E30}#1.0#0"; "MSFLXGRD.OCX"
Begin VB.Form frmBooksInfo
BackColor = &H80000013&
Caption = "书籍列表"
ClientHeight = 7395
ClientLeft = 2580
ClientTop = 3015
ClientWidth = 9735
LinkTopic = "Form1"
ScaleHeight = 7395
ScaleWidth = 9735
Begin VB.Frame Frame1
BackColor = &H80000013&
Caption = "操作"
Height = 735
Left = 1320
TabIndex = 2
Top = 6480
Width = 7815
Begin VB.CommandButton cmdadd
Caption = "添 加"
Default = -1 'True
Height = 375
Left = 360
TabIndex = 7
Top = 240
Width = 1215
End
Begin VB.CommandButton cmdmodify
Caption = "修 改"
Height = 375
Left = 1800
TabIndex = 6
Top = 240
Width = 1215
End
Begin VB.CommandButton cmddel
Caption = "删 除"
Height = 375
Left = 3240
TabIndex = 5
Top = 240
Width = 1215
End
Begin VB.CommandButton cmdqueue
Caption = "查 询"
Height = 375
Left = 4680
TabIndex = 4
Top = 240
Width = 1215
End
Begin VB.CommandButton cmdexit
Cancel = -1 'True
Caption = "退 出"
Height = 375
Left = 6120
TabIndex = 3
Top = 240
Width = 1215
End
End
Begin MSFlexGridLib.MSFlexGrid bookGrid
Height = 5295
Left = 120
TabIndex = 0
Top = 960
Width = 9495
_ExtentX = 16748
_ExtentY = 9340
_Version = 393216
Rows = 1
Cols = 21
FixedCols = 0
BackColor = -2147483639
BackColorBkg = 14737632
GridColor = 14737632
GridColorFixed = 14737632
SelectionMode = 1
AllowUserResizing= 1
End
Begin VB.Label Label1
BackColor = &H80000013&
Caption = " 书 籍 列 表"
BeginProperty Font
Name = "隶书"
Size = 21.75
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 495
Left = 3000
TabIndex = 1
Top = 240
Width = 3615
End
End
Attribute VB_Name = "frmBooksInfo"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
'****************************************************************************
' 作者:林永刚
' 名称:frmBookInfo
' 功能:对图书信息进行添加、修改、删除和查询。
'****************************************************************************
Public Function bookList_update()
Dim rs As New ADODB.Recordset
Dim sql As String
sql = "select * from books" 'books图书信息表
'将图书信息表所有记录显示在frmbookinfo窗体的bookGrid表中
Dim i As Integer
Set rs = ADOSQL(sql)
If Not rs.EOF Then
With bookGrid
.Rows = 1
While Not rs.EOF
.Rows = .Rows + 1
.TextMatrix(.Rows - 1, 0) = rs(0)
.TextMatrix(.Rows - 1, 1) = rs(1)
.TextMatrix(.Rows - 1, 2) = rs(2)
.TextMatrix(.Rows - 1, 3) = rs(3)
.TextMatrix(.Rows - 1, 4) = rs(4)
.TextMatrix(.Rows - 1, 5) = rs(5)
.TextMatrix(.Rows - 1, 6) = rs(6)
.TextMatrix(.Rows - 1, 7) = rs(7)
.TextMatrix(.Rows - 1, 8) = rs(8)
.TextMatrix(.Rows - 1, 9) = rs(9)
.TextMatrix(.Rows - 1, 10) = rs(10)
.TextMatrix(.Rows - 1, 11) = rs(11)
.TextMatrix(.Rows - 1, 12) = rs(12)
.TextMatrix(.Rows - 1, 13) = rs(13)
.TextMatrix(.Rows - 1, 14) = rs(14)
.TextMatrix(.Rows - 1, 15) = rs(15)
.TextMatrix(.Rows - 1, 16) = rs(16)
.TextMatrix(.Rows - 1, 17) = rs(17)
.TextMatrix(.Rows - 1, 18) = rs(18)
rs.MoveNext
Wend
End With
End If
rs.Close
bookGrid.Refresh
End Function
'单击bookGrid时,对一些按钮的Enable设置
Private Sub bookGrid_Click()
If bookGrid.Row > 0 And bookGrid.Rows >= 2 Then
cmdmodify.Enabled = True
cmddel.Enabled = True
Else
cmdmodify.Enabled = False
cmddel.Enabled = False
End If
End Sub
'添加图书信息
Private Sub cmdAdd_Click()
Unload frmAddBook
frmAddBook.Show
End Sub
Private Sub cmddel_Click()
txtbookno = Trim(bookGrid.TextMatrix(bookGrid.Row, 0)) '要准备删除的图书信息的图书编号
del_sql = "delete from books where tsbh = '" & txtbookno & "'" '图书信息表
del_sql2 = "delete from borrow_book where tsbh = '" & txtbookno & "'" '借书信息表
del_sql3 = "delete from return_book where tsbh = '" & txtbookno & "'" '还书信息表
ADOSQL (del_sql)
ADOSQL (del_sql2)
ADOSQL (del_sql3)
MsgBox "删除成功!"
bookGrid.Refresh
End Sub
'退出
Private Sub cmdexit_Click()
Unload Me
End Sub
Private Sub cmdModify_Click()
tShubiaohao = bookGrid.TextMatrix(bookGrid.Row, 0)
frmBookModify.Show
End Sub
Private Sub cmdqueue_Click()
frmQueueBook.Show
End Sub
Private Sub Form_Load()
'初始化bookGrid表
cmdAdd.Enabled = True
cmdmodify.Enabled = False
cmddel.Enabled = False
With bookGrid
.Rows = 1
.TextMatrix(0, 0) = "图书编号"
.TextMatrix(0, 1) = "图书名称"
.TextMatrix(0, 2) = "ISBN"
.TextMatrix(0, 3) = "类别名称"
.TextMatrix(0, 4) = "书架位置"
.TextMatrix(0, 5) = "作者"
.TextMatrix(0, 6) = "译者"
.TextMatrix(0, 7) = "出版社名"
.TextMatrix(0, 8) = "图书页数"
.TextMatrix(0, 9) = "图书价格"
.TextMatrix(0, 10) = "现存量"
.TextMatrix(0, 11) = "库存总量"
.TextMatrix(0, 12) = "借阅次数"
.TextMatrix(0, 13) = "是否注销"
.TextMatrix(0, 14) = "入库日期"
.TextMatrix(0, 15) = "出版日期"
.TextMatrix(0, 16) = "内容简介"
.TextMatrix(0, 17) = "备注"
.TextMatrix(0, 18) = "操作员"
.ColAlignment(0) = 1
.ColWidth(1) = 1500
.ColWidth(4) = 1500
.ColWidth(7) = 1000
.ColWidth(8) = 1500
.ColWidth(9) = 1000
.ColWidth(13) = 100
.ColWidth(14) = 1000
End With
Call bookList_update '把图书信息表的记录载入当前bookGrid表中
End Sub
Private Sub Form_Unload(Cancel As Integer)
frm_main.Show
frm_main.SetFocus
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -