5.4.8 借书业务管理
借书业务管理是系统的常用功能模块,具体实现方法就是如果有借书操作,就在数据库的“Issue”表中添加记录即可。功能实现与图书分类信息管理类似,我们不进行详细讲解,仅给出界面控件设计和代码。
图5-24 借书业务管理子窗体设计1
图5-25 借书业务管理子窗体设计2
代码5-11 借书业务管理功能代码
′****************************************************************************
Dim addnewflag As Boolean
′窗体加载
Private Sub Form_Load()
lblInfo.Left=Me.ScaleLeft
lblInfo.Top=Me.ScaleTop
lblInfo.Width=Screen.Width
sstabIssueInfo.Top=lblInfo.Top+450
sstabIssueInfo.Left=70
sstabIssueInfo.Width=Screen.Width-200
sstabIssueInfo.Height=Screen.Height-2650
DataGrid1.Top=lblInfo.Top+500
DataGrid1.Left=100
DataGrid1.Width=Screen.Width-550
DataGrid1.Height=Screen.Height-3300
DataGrid1.Visible=False
Set DataGrid1.DataSource=rsIssueInfo
DataGrid1.ReBind
Frame2.Left=(Screen.Width-Frame2.Width)/2
If rsIssueInfo.RecordCount=0Then
MsgBox″未查到图书出借信息!″,vbInformation,″借书记录″
Call cmdAddNew_Click
Else
Call display
End If
End Sub
Private Sub cmdBookOpen_Click()
frmBookInfo.Show
frmBookInfo.SetFocus
End Sub
Private Sub cmdMemberOpen_Click()
frmMemberInfo.Show
frmMemberInfo.SetFocus
End Sub
Private Sub cmdFirst_Click()
On Error Resume Next
rsIssueInfo.MoveFirst
Call display
End Sub
Private Sub cmdLast_Click()
On Error Resume Next
rsIssueInfo.MoveLast
Call display
End Sub
Private Sub cmdNext_Click()
On Error Resume Next
rsIssueInfo.MoveNext
If rsIssueInfo.EOF Then
rsIssueInfo.MoveLast
MsgBox″最后一条记录″,vbInformation,″最后一条记录″
Else
Call display
End If
End Sub
Private Sub cmdPrevious_Click()
On Error Resume Next
rsIssueInfo.MovePrevious
If rsIssueInfo.BOF Then
rsIssueInfo.MoveFirst
MsgBox″已是第一条记录″,vbInformation,″已是第一条记录″
Else
Call display
End If
End Sub
′“取消”按钮
Private Sub cmdCancel_Click()
cmdAddNew.Enabled=True
cmdDel.Enabled=True
cmdFirst.Enabled=True
cmdLast.Enabled=True
cmdPrevious.Enabled=True
cmdNext.Enabled=True
cmdCancel.Enabled=False
cmdSave.Caption=″Save″
rsIssueInfo.CancelUpdate
Call display
End Sub
′添加新记录
Private Sub cmdAddNew_Click()
On Error Resume Next
Dim i As Integer
addnewflag=True
cmdAddNew.Enabled=False
cmdSave.Caption=″Issue″
For i=0To rsLibraryId.RecordCount
cmbLibraryId.AddItem rsLibraryId(0)
rsLibraryId.MoveNext
If rsLibraryId.EOF=True Then
rsLibraryId.MoveLast
cmbLibraryId.ListIndex=0
Exit For
End If
Next i
For i=0To rsBookId.RecordCount
cmbBookId.AddItem rsBookId(0)
rsBookId.MoveNext
If rsBookId.EOF=True Then
rsBookId.MoveLast
cmbBookId.ListIndex=0
Exit For
End If
Next i
cmdCancel.Enabled=True
cmdDel.Enabled=False
cmdFirst.Enabled=False
cmdLast.Enabled=False
cmdPrevious.Enabled=False
cmdNext.Enabled=False
rsIssueInfo.AddNew
txtIssueDate.Text=Date$
cmbLibraryId.SetFocus
End Sub
′删除记录
Private Sub cmdDel_click()
On Error Resume Next
If MsgBox(″确认删除么?″,vbOKCancel+vbExclamation,″删除记录″)=vbOK Then
rsIssueInfo.Delete
rsIssueInfo.MoveNext
If rsIssueInfo.EOF Then
rsIssueInfo.MoveLast
MsgBox″最后一条记录″
End If
Call display
End If
End Sub
′保存记录
Private Sub cmdsave_click()
On Error Resume Next
Call assign
rsIssueInfo.Save
MsgBox″保存成功″,vbInformation,″已保存成功″
cmdDel.Enabled=True
cmdFirst.Enabled=True
cmdLast.Enabled=True
cmdPrevious.Enabled=True
cmdNext.Enabled=True
cmdAddNew.Enabled=True
cmdCancel.Enabled=False
cmdSave.Caption=″Save″
Exit Sub
End Sub
′Display函数
Private Sub display()
Dim i As Integer
cmdCancel.Enabled=False
cmbLibraryId.Text=Str(rsIssueInfo(2))&″″
cmbBookId.Text=Str(rsIssueInfo(0))&″″
txtIssueDate.Text=Str(rsIssueInfo(1))&″″
End Sub
′将控件中的数据添加到记录集对应的列
Private Sub assign()
rsIssueInfo(2)=Val(Trim$(cmbLibraryId.Text))
rsIssueInfo(0)=Val(Trim$(cmbBookId.Text))
rsIssueInfo(1)=Trim$(txtIssueDate.Text)
addnewflag=False
End Sub
′选项卡点击使数据表在对应的选项卡中显示
Private Sub sstabIssueInfo_Click(PreviousTab As Integer)
If PreviousTab=0Then
DataGrid1.Visible=True
Else
DataGrid1.Visible=False
End If
End Sub
免责声明:以上内容源自网络,版权归原作者所有,如有侵犯您的原创版权请告知,我们将尽快删除相关内容。