?? library.frm
字號:
End
Begin VB.TextBox sname
DataField = "姓名"
DataSource = "stuData"
Height = 285
Left = 3240
Locked = -1 'True
TabIndex = 10
Top = 540
Width = 1215
End
Begin VB.TextBox class
DataField = "班別"
DataSource = "stuData"
Height = 285
Left = 4200
Locked = -1 'True
TabIndex = 9
Top = 1020
Width = 1575
End
Begin VB.TextBox bname
DataField = "書名"
DataSource = "bookData"
Height = 285
Left = 840
Locked = -1 'True
TabIndex = 8
Top = 1500
Width = 3255
End
Begin VB.TextBox author
DataField = "作者"
DataSource = "bookData"
Height = 285
Left = 840
Locked = -1 'True
TabIndex = 7
Top = 1980
Width = 3255
End
Begin VB.TextBox priter
DataField = "出版社"
DataSource = "bookData"
Height = 285
Left = 840
Locked = -1 'True
TabIndex = 6
Top = 2340
Width = 3255
End
Begin VB.TextBox totol
DataField = "總數"
DataSource = "bookData"
Height = 285
Left = 840
Locked = -1 'True
TabIndex = 5
Top = 2700
Width = 735
End
Begin VB.TextBox left
DataField = "在庫數目"
DataSource = "bookData"
Height = 285
Left = 2760
Locked = -1 'True
TabIndex = 4
Top = 2700
Width = 735
End
Begin VB.CommandButton Command1
Caption = "確定"
Enabled = 0 'False
Height = 375
Left = 4800
TabIndex = 3
Top = 2580
Width = 735
End
Begin VB.TextBox sex
DataField = "性別"
DataSource = "stuData"
Height = 285
Left = 3240
Locked = -1 'True
TabIndex = 2
Top = 1020
Width = 375
End
Begin VB.TextBox bo
DataField = "借書數"
DataSource = "stuData"
Height = 285
Left = 5400
Locked = -1 'True
TabIndex = 1
Top = 540
Width = 375
End
Begin VB.Label Label13
Caption = "查詢關鍵字"
Height = 255
Left = -72960
TabIndex = 30
Top = 480
Width = 1215
End
Begin VB.Label Label12
Caption = "查詢方式:"
Height = 255
Left = -74760
TabIndex = 28
Top = 480
Width = 975
End
Begin VB.Label Label1
Caption = "學號"
Height = 255
Left = 240
TabIndex = 21
Top = 540
Width = 495
End
Begin VB.Label Label2
Caption = "書號"
Height = 255
Left = 240
TabIndex = 20
Top = 1020
Width = 495
End
Begin VB.Label Label3
Caption = "姓名"
Height = 255
Left = 2760
TabIndex = 19
Top = 540
Width = 495
End
Begin VB.Label Label4
Caption = "班別"
Height = 255
Left = 3720
TabIndex = 18
Top = 1020
Width = 495
End
Begin VB.Label Label5
Caption = "書名"
Height = 255
Left = 240
TabIndex = 17
Top = 1500
Width = 495
End
Begin VB.Label Label6
Caption = "作者"
Height = 255
Left = 240
TabIndex = 16
Top = 1980
Width = 615
End
Begin VB.Label Label7
Caption = "出版社"
Height = 375
Left = 240
TabIndex = 15
Top = 2340
Width = 615
End
Begin VB.Label Label8
Caption = "總數"
Height = 255
Left = 240
TabIndex = 14
Top = 2700
Width = 495
End
Begin VB.Label Label9
Caption = "在庫數目"
Height = 255
Left = 1920
TabIndex = 13
Top = 2700
Width = 735
End
Begin VB.Label Label10
Caption = "性別"
Height = 255
Left = 2760
TabIndex = 12
Top = 1020
Width = 375
End
Begin VB.Label Label11
Caption = "已借書數"
Height = 255
Left = 4560
TabIndex = 11
Top = 540
Width = 735
End
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Dim condition As String
Dim operate As Byte
Private Sub bnum_Change()
If Len(bnum.Text) = 6 Then
condition = "書號='" & bnum.Text & "'"
bookData.Recordset.FindFirst condition
If operate = 1 Then '要進行的是還書操作
snum.Enabled = True
snum.Clear
condition = "書號='" & bnum.Text & "'"
lendData.Recordset.FindFirst condition
Do While Not lendData.Recordset.NoMatch
snum.AddItem lendData.Recordset.Fields("學號")
lendData.Recordset.FindNext condition
Loop
End If
Else
bookData.Recordset.MoveFirst
End If
Call comfirmdata
End Sub
Private Sub booklist_Click()
bookData.Recordset.MoveFirst
condition = "書號='" & left(booklist.List(booklist.ListIndex), 6) & "'"
bookData.Recordset.FindFirst condition
End Sub
Private Sub Command1_Click()
If operate = 0 Then
condition = "學號='" & snum.Text & "' and 書號='" & bnum.Text & "'"
lendData.Recordset.FindFirst condition
If lendData.Recordset.NoMatch = False Then
MsgBox "讀者已借有該書"
Exit Sub
End If
If stuData.Recordset.Fields("借書數") < 3 Then
stuData.Recordset.Edit
stuData.Recordset.Fields("借書數") = stuData.Recordset.Fields("借書數") + 1
stuData.Recordset.Update
Else
MsgBox "該讀者已經借了三本書"
Exit Sub
End If
If bookData.Recordset.Fields("在庫數目") > 0 Then
bookData.Recordset.Edit
bookData.Recordset.Fields("在庫數目") = bookData.Recordset.Fields("在庫數目") - 1
bookData.Recordset.Update
Else
MsgBox "該書已全部借出"
Exit Sub
End If
lendData.Recordset.AddNew
lendData.Recordset.Fields("學號") = stuData.Recordset.Fields("學號")
lendData.Recordset.Fields("書號") = bookData.Recordset.Fields("書號")
lendData.Recordset.Update
MsgBox "操作成功"
Else
condition = "學號='" & snum.Text & "' and 書號='" & bnum.Text & "'"
lendData.Recordset.FindFirst condition
If lendData.Recordset.NoMatch = True Then
MsgBox "指定的借書記錄不存在"
Exit Sub
End If
stuData.Recordset.Edit
stuData.Recordset.Fields("借書數") = stuData.Recordset.Fields("借書數") - 1
stuData.Recordset.Update
bookData.Recordset.Edit
bookData.Recordset.Fields("在庫數目") = bookData.Recordset.Fields("在庫數目") + 1
bookData.Recordset.Update
condition = "書號='" & bnum.Text & "' and " & "學號='" & snum.Text & "'"
lendData.Recordset.FindFirst condition
lendData.Recordset.Delete
MsgBox "操作成功"
snum.Clear
Call snum_Change
End If
Command1.Enabled = False
End Sub
Private Sub Command2_Click()
Dim table As Recordset
Set table = bookData.Recordset
table.MoveFirst
Do
If InStr(table.Fields(way.Text), keyword.Text) Then
booklist.AddItem table.Fields("書號") & " " & table.Fields("書名")
End If
table.MoveNext
Loop Until table.EOF
End Sub
Private Sub Command3_Click()
booklist.Clear
End Sub
Private Sub Command4_Click()
bookData.Recordset.AddNew
bookData.Recordset.Fields("書號") = " "
bookData.Recordset.Fields("書名") = " "
bookData.Recordset.Update
bookgrid.Refresh
End Sub
Private Sub Command5_Click()
bookData.Recordset.Delete
bookgrid.Refresh
End Sub
Private Sub Command8_Click()
stuData.Recordset.AddNew
stuData.Recordset.Fields("學號") = " "
stuData.Recordset.Fields("姓名") = " "
stuData.Recordset.Update
stugrid.Refresh
End Sub
Private Sub Command9_Click()
stuData.Recordset.Delete
stugrid.Refresh
End Sub
Private Sub Form_Load()
operate = 0
stuData.DatabaseName = App.Path + "\library.mdb"
bookData.DatabaseName = App.Path + "\library.mdb"
lendData.DatabaseName = App.Path + "\library.mdb"
End Sub
Private Sub Option1_Click(Index As Integer)
operate = Index
If Index = 1 Then
snum.Clear
snum.Enabled = False
Else
snum.Enabled = True
End If
End Sub
Private Sub snum_Change()
If Len(snum.Text) = 8 Then
condition = "學號='" & snum.Text & "'"
stuData.Recordset.FindFirst condition
Else
stuData.Recordset.MoveFirst
End If
Call comfirmdata
End Sub
Private Sub snum_Click()
Call snum_Change
End Sub
Public Sub comfirmdata() '確認數據的合法性
If sname.Text <> " " And bname.Text <> " " Then
Command1.Enabled = True
Else
Command1.Enabled = False
End If
End Sub
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -