图书借出代码如下:
Private Sub Command1_Click()
If Text1.Text = "" Or Text2.Text = "" Or Text3.Text = "" Or Text4.Text = "" Or Text9.Text = "" Then
MsgBox "输入的借书信息不完全!", , "提示信息"
Else
rs.Open "select sum(借书数量) from dzjstb where 读者编号='" + Text1.Text + "'", cnn, adOpenKeyset, adLockOptimistic
Adodc3.RecordSource = "select * from sz"
Adodc3.Refresh
If rs.Fields(0) + Val(Text9.Text) > Adodc3.Recordset.Fields(0) Then
MsgBox "您的借书量已满!!", vbOKOnly, "提示"
rs.Close
Exit Sub
Else
Adodc2.RecordSource = "select * from books where 条码号='" + Text3.Text + "'"
Adodc2.Refresh
If Adodc2.Recordset.RecordCount > 0 Then
cnn.Execute ("insert into dzjstb values('" & Text1 & "','" & Text2 & "','" & Text3 & "','" & Text4 & "'," & Text5.Text & ",'" & Text6 & "','" & Text7 & "','" & Text8 & "','" & Text9 & "','" & Text10 & "','" & DTPicker1 & "','" & DTPicker2 & "','借')")
x = Val(Adodc2.Recordset.Fields("复本数")) - Val(Text9.Text)
y = Val(Adodc2.Recordset.Fields("借书数量")) + Val(Text9.Text)
hs1 = "update books set 复本数='" & x & "',借书数量='" & y & "'where 条码号='" & Text3.Text & "'"
cnn.Execute (hs1)
Else
End If
End If
MsgBox "借出完毕!", vbOKOnly, "提示"
Set rs = Nothing
End If
End Sub
5.3.3 读者还书管理
窗体界面设计如下:
图书归还代码如下:
Private Sub Command1_Click()
Dim hs, js, i As String
Dim hs1, sz1 As String
Dim x, y, z As Integer
If Text1.Text = "" Or Text2.Text = "" Then
MsgBox "请输入读者编号和条码号", , "提示信息"
Text2.SetFocus
Else
i = MsgBox("确认归还该图书吗!", vbYesNo + vbOKOnly, "提示")
If i = vbYes Then
Set rs = cnn.Execute("insert into hsstb values('" & Text1 & "','" & Text2 & "','" & Text3 & "'," & Text5.Text & ",'" & Text6 & "','" & Text7 & "','" & Text8 & "','" & DTPicker1 & "','" & DTPicker2 & "','" & Text9 & "','" & DTPicker3 & "','" & Text10 & "')")
Adodc1.Refresh
Adodc3.RecordSource = "select * from books where 条码号='" & Text1.Text & "'"
Adodc3.Refresh
If Adodc3.Recordset.RecordCount > 0 Then
Adodc2.RecordSource = "select * from dzjstb where 条码号='" & Text1.Text & "' and 读者编号='" + Text2.Text + "'"
Adodc2.Refresh
If Adodc2.Recordset.RecordCount > 0 Then
x = Val(Adodc3.Recordset.Fields("复本数")) + Val(Adodc2.Recordset.Fields("借书数量"))
y = Val(Adodc3.Recordset.Fields("借书数量")) - Val(Adodc2.Recordset.Fields("借书数量"))
hs1 = "update books set 复本数='" & x & "',借书数量='" & y & "'where 条码号='" & Text1.Text & "'"
cnn.Execute (hs1)
Else
End If
End If
js = "update dzjstb set 借='还',借书数量='0' where 条码号='" & Text1.Text & "'"
cnn.Execute (js)
Adodc2.Refresh
MsgBox "还书成功!", vbOKOnly, "提示"
Else
On Error Resume Next
rs.CancelUpdate
End If
End If
End Sub
上一页 [1] [2] [3] [4] [5] [6] [7] [8] 下一页