1,216
社区成员
发帖
与我相关
我的任务
分享
Private Sub Command1_Click()
Command2.Enabled = True
If Text1.Text = "" Or Text10.Text = "" Then
MsgBox "资料名字或借者名字不能为空", , "提示"
Exit Sub
Else
Text2.DataField = "编号"
Text3.DataField = "价格"
Text5.DataField = "名字"
Text6.DataField = "出版社"
Text7.DataField = "借书日期"
Text9.DataField = "限还日期"
Text11.DataField = "名字"
Text12.DataField = "总量"
Text13.DataField = "已借数量"
Text8.Text = Date
Data1.Recordset.MoveFirst
Data2.Recordset.MoveFirst
Data1.Recordset.FindFirst " 名字='" & Text1.Text & "'" '图书名字段为”名字“,借者名字段也为"名字"
Data2.Recordset.FindFirst " 已借图书='" & Text1.Text & "' And 名字='" & Text10.Text & "'"
End If
If Data2.Recordset.NoMatch Then
Text2.Text = ""
Text3.Text = ""
Text5.Text = ""
Text7.Text = ""
Text6.Text = ""
Text8.Text = ""
Text9.Text = ""
Text11.Text = ""
Text12.Text = ""
Text13.Text = ""
MsgBox "数据库中没有这本图书!", vbOKOnly + vbExclamation, "警告"
Command2.Enabled = False
End If
End Sub
Private Sub Command2_Click()
a = MsgBox("你确定还此书吗?", vbYesNo + vbQuestion, "提示")
If a = vbYes Then
Data2.Recordset.Delete
Text12.Text = Str(Val(Text12.Text) + 1)
Text13.Text = Str(Val(Text13.Text) - 1)
Data1.Recordset.Edit
Text2.Text = ""
Text3.Text = ""
Text5.Text = ""
Text7.Text = ""
Text6.Text = ""
Text8.Text = ""
Text9.Text = ""
Text11.Text = ""
Text12.Text = ""
Text13.Text = ""
Text1.Text = ""
Text10.Text = ""
Command2.Enabled = False
End If
End Sub
Private Sub Command7_Click()
Me.Hide
End Sub
Private Sub Form_Activate()
Text2.Text = ""
Text3.Text = ""
Text5.Text = ""
Text7.Text = ""
Text6.Text = ""
Text8.Text = ""
Text9.Text = ""
Text11.Text = ""
Text12.Text = ""
Text13.Text = ""
Text1.Text = ""
Text10.Text = ""
' Data1.Recordset.Update
' Data2.Recordset.Update
End Sub
Private Sub Form_Load()
Command2.Enabled = False
'Text13.Visible = False
'Text12.Visible = False
Data2.Visible = False
Data1.Visible = False
If Right(App.Path, 1) = "\" Then
Data1.DatabaseName = App.Path + "数据库.mdb"
Else
Data1.DatabaseName = App.Path + "\数据库.mdb"
End If
If Right(App.Path, 1) = "\" Then
Data2.DatabaseName = App.Path + "数据库.mdb"
Else
Data2.DatabaseName = App.Path + "\数据库.mdb"
End If
Data1.RecordSource = "图书信息"
Data2.RecordSource = "借者信息"
Data1.Refresh
Data2.Refresh
End Sub