📄 frmreturn.frm
字号:
VERSION 5.00
Begin VB.Form frmReturn
BorderStyle = 3 'Fixed Dialog
Caption = "还书"
ClientHeight = 5025
ClientLeft = 2760
ClientTop = 3750
ClientWidth = 5325
BeginProperty Font
Name = "Tahoma"
Size = 8.25
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 5025
ScaleWidth = 5325
ShowInTaskbar = 0 'False
StartUpPosition = 2 '屏幕中心
Begin VB.TextBox Text2
Height = 285
Left = 1800
Locked = -1 'True
TabIndex = 19
Top = 2040
Width = 3375
End
Begin VB.TextBox txtFines
Height = 285
Left = 1800
TabIndex = 16
Top = 2400
Width = 3015
End
Begin VB.CommandButton Command4
BeginProperty Font
Name = "MS Sans Serif"
Size = 8.25
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 315
Left = 4920
Picture = "frmReturn.frx":0000
Style = 1 'Graphical
TabIndex = 15
ToolTipText = "Use calculator."
Top = 2400
Width = 315
End
Begin VB.TextBox Text1
BackColor = &H00F4FEFF&
Height = 285
Left = 1800
Locked = -1 'True
TabIndex = 13
Top = 1680
Width = 3375
End
Begin VB.TextBox Text4
BackColor = &H80000018&
Height = 285
Left = 1800
Locked = -1 'True
TabIndex = 12
Top = 1320
Width = 3015
End
Begin VB.CommandButton cmdCode
BeginProperty Font
Name = "MS Sans Serif"
Size = 8.25
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 315
Left = 4920
Style = 1 'Graphical
TabIndex = 11
ToolTipText = "Browse record."
Top = 1320
Width = 315
End
Begin VB.Frame Frame1
Caption = "信息"
Height = 1215
Left = 240
TabIndex = 4
Top = 2880
Width = 4935
Begin VB.Label Label4
Caption = "借书日期:"
Height = 255
Left = 120
TabIndex = 10
Top = 360
Width = 1215
End
Begin VB.Label Label5
Caption = "超期天数:"
Height = 255
Left = 120
TabIndex = 9
Top = 600
Width = 2295
End
Begin VB.Label Label6
Caption = "应交罚款:"
Height = 255
Left = 120
TabIndex = 8
Top = 840
Width = 2655
End
Begin VB.Label lblDate
Caption = "请先选择一本书"
Height = 255
Left = 3120
TabIndex = 7
Top = 360
Width = 1455
End
Begin VB.Label lblLate
Caption = "请先选择一本书"
Height = 255
Left = 3120
TabIndex = 6
Top = 600
Width = 1455
End
Begin VB.Label lblFines
Caption = "请先选择一本书"
Height = 255
Left = 3120
TabIndex = 5
Top = 840
Width = 1695
End
End
Begin VB.CommandButton cmdReturn
Caption = "还书"
Default = -1 'True
Height = 375
Left = 240
TabIndex = 2
Top = 4440
Width = 1455
End
Begin VB.CommandButton cmdCancel
Cancel = -1 'True
Caption = "取消"
Height = 375
Left = 3600
TabIndex = 1
Top = 4440
Width = 1455
End
Begin VB.CommandButton cmdReset
Caption = "重置"
Height = 375
Left = 1920
TabIndex = 0
Top = 4440
Width = 1455
End
Begin VB.Label Label7
Caption = "还书日期:"
Height = 255
Left = 240
TabIndex = 18
Top = 2040
Width = 1215
End
Begin VB.Label Label3
Caption = "超期罚款:"
Height = 255
Left = 240
TabIndex = 17
Top = 2400
Width = 1215
End
Begin VB.Label Label1
Caption = "学生编号:"
Height = 255
Left = 240
TabIndex = 14
Top = 1680
Width = 1335
End
Begin VB.Line Line3
BorderColor = &H80000014&
Index = 0
X1 = 120
X2 = 5280
Y1 = 1080
Y2 = 1080
End
Begin VB.Label Label2
Caption = "图书编号:"
Height = 255
Index = 0
Left = 240
TabIndex = 3
Top = 1320
Width = 1575
End
Begin VB.Image Image1
Height = 480
Left = 120
Stretch = -1 'True
Top = 240
Width = 480
End
Begin VB.Line Line4
BorderColor = &H80000010&
BorderWidth = 2
Index = 0
X1 = 120
X2 = 5280
Y1 = 1080
Y2 = 1080
End
Begin VB.Line Line3
BorderColor = &H80000014&
Index = 1
X1 = 240
X2 = 5160
Y1 = 4320
Y2 = 4320
End
Begin VB.Line Line4
BorderColor = &H80000010&
BorderWidth = 2
Index = 1
X1 = 240
X2 = 5160
Y1 = 4320
Y2 = 4320
End
End
Attribute VB_Name = "frmReturn"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
'----------------------------------------------------------------------
'Books Return Form
'This form is used to return books that have been taken from the library
'and recorded in the database via the issue form.
'More details in cmdCode_Click and cmdReturn_Click procedures.
'-----------------------------------------------------------------------
Public MaxDays As Integer
Public FineAmnt As Currency
Private Sub cmdCancel_Click()
Unload Me
End Sub
Private Sub cmdReset_Click()
lblLate.Caption = "请选择一本图书"
lblFines.Caption = "请选择一本图书"
lblDate.Caption = "请选择一本图书"
txtFines.Text = ""
txtFines.Locked = True
Text1.Text = ""
Text4.Text = ""
Text2.Text = FormatDateTime$(Date, vbLongDate)
End Sub
Private Sub cmdReturn_Click()
Dim RS As ADODB.RecordSet
'What it does here is pretty easy. The return information is recorded
'in two places. One in the Book Table where the book Borrowed is set to
'False, and in the Transaction Table where the amount payed and book
'returned is stored with the date the book is returned.
If Text4.Text = "" Then Text4.SetFocus
On Error GoTo hell
Set RS = New ADODB.RecordSet
With RS
CN.BeginTrans 'Begin a new transaction
.Open "Select [是否出借] from tblBooks where [图书编号]='" & Text4.Text & "'", CN, adOpenDynamic, adLockOptimistic
.MoveFirst
.Fields(0) = False
.Update
.Close
.Open "Select [罚款],[是否归还] From tblTrans where [图书编号]='" & Text4.Text & "'" & "And [是否归还] = False", CN, adOpenDynamic, adLockOptimistic
.MoveFirst
.Fields("罚款") = CCur(txtFines.Text)
.Fields("是否归还") = True
.Update
.Close
CN.CommitTrans 'If no error was raised then record info
End With
Set RS = Nothing
'Show MsgBox if another book needs returning
If MsgBox("这本书" & Text4.Text & " 已经归还 " & Text1.Text & vbNewLine & vbNewLine & "您是否要创建一条归还图书记录?", vbInformation + vbYesNo) = vbYes Then
cmdReset_Click
Else
Unload Me
End If
Exit Sub
hell:
Handler Err
On Error Resume Next 'If an error was raised then rollback
CN.RollbackTrans 'any transaction so GIGO does not take place
'in the future.
End Sub
Private Sub cmdCode_Click()
Dim RS As ADODB.RecordSet, i As Integer
'The first part of this event procedure will open the frmSelectDg form
'and expect an input from the user. This will ease the selection part
'from the users point-of-view and validation part from the devolopers
'point-of-view.
On Error Resume Next
With frmSelectDg
'First show the box
.CommandText = "SELECT tblTrans.[图书编号], tblTrans.[学生编号], tblBooks.图书标题, [姓名] & ' ' & [性别] & ' ' & [专业] AS 借书人, tblTrans.[借书日期] FROM tblMembers INNER JOIN (tblBooks INNER JOIN tblTrans ON tblBooks.[图书编号] = tblTrans.[图书编号]) ON tblMembers.[学生编号] = tblTrans.[学生编号] Where (((tblTrans.是否归还) = False)) ORDER BY tblTrans.[图书编号];"
.DataGrid1.Caption = "借书信息"
.Show vbModal
'Now display the data
If .OKPressed Then
Text4.Text = .rRS1
Text1.Text = .rRS2
txtFines.Locked = False
Else
'If the user did not enter anything then skip the second
'part of the procedure to skip errors that may arise because
'there will be no data (in text4 and text1) and as such
'null errors or record not found errors.
Exit Sub
End If
End With
'The second part will calculate the number of days a book was taken out
'of the library and print it in the txtFines text box.
Set RS = New ADODB.RecordSet
RS.Open "Select * from tblTrans Where [图书编号] ='" & Text4.Text & "'", CN, adOpenDynamic, adLockOptimistic
lblDate.Caption = CDate(RS(2)) 'Just for validation
'Store the difference of the current date and the date returned
'in a variable. It the variable is negative it means that the
'book returned is within the time limit and Fines=i*FineAmnt
'must be 0. So transform i into 0
i = Date - CDate(lblDate.Caption)
If i < 0 Then i = 0
If MaxDays < i Then lblLate.Caption = i - MaxDays Else lblLate.Caption = "0"
'Print fines due in a label and a text box
lblFines.Caption = CStr(FormatCurrency$(FineAmnt * lblLate))
'Also, use an editable text box so the correct amount a member
'is payed is recorded. Sometimes the member may pay money not
'exactly as required (payable $15 from $15.25 total fines)
txtFines.Text = lblFines.Caption
Set RS = Nothing
'So, practically all the librarian did was just select a book id through
'a GUI friendly interface and everything will be done by the system
End Sub
Private Sub Command4_Click()
On Error GoTo hell
Shell "calc.exe", vbNormalFocus
Exit Sub
hell:
MsgBox "The operating system cannot find the system calculator." & vbNewLine & "Please check whether it is properly installed or not", vbCritical, "File not found"
End Sub
Private Sub Form_Load()
Me.Icon = frmMain.ImgList32.ListImages(8).Picture
Image1.Picture = Me.Icon
cmdReset_Click
cmdCode.Picture = frmMain.ImgList16.ListImages(1).Picture
End Sub
Private Sub Text4_Keypress(Keyascii As Integer)
cmdCode_Click
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -