VB图书管理系统源代码 第3页
Handles btnUpdate.Click
'将在窗体中对数据的更改保存到数据库中
Try
Me.UpdateDataSet()
Catch eUpdate As System.Exception
System.Windows.Forms.MessageBox.Show(eUpdate.Message)
End Try
Me.objLib读者信息_PositionChanged()
End Sub
Public Sub UpdateDataSet()
Dim objDataSetChanges As 图书馆管理.Lib读者信息 = _
New 图书馆管理.Lib读者信息
'创建一个新数据集来保存对主数据集所做的更改
Me.BindingContext(objLib读者信息, "读者信息").EndCurrentEdit()
'停止当前的任何编辑
objDataSetChanges = CType(objLib读者信息.GetChanges, 图书馆管理.Lib读者信息)
If (Not (objDataSetChanges) Is Nothing) Then
Try
Me.UpdateDataSource(objDataSetChanges)
'调用UpdateDataSource函数将更改合并到数据集中
objLib读者信息.Merge(objDataSetChanges)
objLib读者信息.AcceptChanges()
Catch eUpdate As System.Exception
Throw eUpdate
End Try
End If
End Sub
Public Sub UpdateDataSource(ByVal ChangedRows As 图书馆管理.Lib读者信息)
'打开数据连接,使用OleDbDataAdapter的Update方法更新数据库
Try
If (Not (ChangedRows) Is Nothing) Then
Me.OleDbConnection1.Open()
Me.OleDbDataAdapter1.Update(ChangedRows)
End If
Catch updateException As System.Exception
Throw updateException
Finally
Me.OleDbConnection1.Close()
End Try
End Sub
Private Sub btnNavFirst_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnNavFirst.Click
Me.BindingContext(objLib读者信息, "读者信息").Position = 0
Me.objLib读者信息_PositionChanged()
End Sub
Private Sub btnCancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCancel.Click
Me.BindingContext(objLib读者信息, "读者信息").CancelCurrentEdit()
Me.objLib读者信息_PositionChanged()
End Sub
Private Sub btnDelete_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDelete.Click
If (Me.BindingContext(objLib读者信息, "读者信息").Count > 0) Then
Me.BindingContext(objLib读者信息, "读者信息").RemoveAt _
(Me.BindingContext(objLib读者信息, "读者信息").Position)
End If
Me.objLib读者信息_PositionChanged()
End Sub
Private Sub btnLast_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLast.Click
Me.BindingContext(objLib读者信息, "读者信息").Position = _
(Me.BindingContext(objLib读者信息, "读者信息").Count - 1)
Me.objLib读者信息_PositionChanged()
End Sub
Private Sub btnNavPrev_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnNavPrev.Click
Me.BindingContext(objLib读者信息, "读者信息").Position = _
(Me.BindingContext(objLib读者信息, "读者信息").Position - 1)
Me.objLib读者信息_PositionChanged()
End Sub
Private Sub btnNavNext_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnNavNext.Click
Me.BindingContext(objLib读者信息, "读者信息").Position = _
(Me.BindingContext(objLib读者信息, "读者信息").Position + 1)
Me.objLib读者信息_PositionChanged()
End Sub
Private Sub btnCancelAll_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCancelAll.Click
Me.objLib读者信息.RejectChanges()
End Sub
End Class
**鉴于“读者信息”,“管理者信息”,“出版社信息”,“书籍信息”,“借阅信息”模块除连接数据源不同外,设计思路步骤均相同,此处省略“管理者信息”,“出版社信息”,“书籍信息”,“借阅信息”四个模块的代码。
附:综合查询窗体设计代码如下:
Public Class 综合查询
Inherits System.Windows.Forms.Form
#Region " Windows 窗体设计器生成的代码 "
‘此处省略窗体设计代码
#End Region
Sub QueryData(ByVal SqlString As String, ByVal OrderString As String)
QueryString = SqlString
If OrderString <> "" Then
QueryString = SqlString + " ORDER BY " + OrderString
End If
End Sub
Public Sub LoadDataSet()
Dim objDataSetTemp As 图书馆管理.Lib综合查询
objDataSetTemp = New 图书馆管理.Lib综合查询
Try
Me.FillDataSet(objDataSetTemp)
Catch eFillDataSet As System.Exception
Throw eFillDataSet
End Try
Try
objLib综合查询.Clear()
objLib综合查询.Merge(objDataSetTemp)
Catch eLoadMerge As System.Exception
Throw eLoadMerge
End Try
End Sub
Public Sub FillDataSet(ByVal dataSet As 图书馆管理.Lib综合查询)
dataSet.EnforceConstraints = False
Try
If Me.OleDbConnection1.State <> ConnectionState.Closed Then
Me.OleDbConnection1.Close()
End If
Me.OleDbConnection1.Open()
Me.OleDbDataAdapter1.Fill(dataSet)
Me.OleDbDataAdapter2.Fill(dataSet)
Me.OleDbDataAdapter3.Fill(dataSet)
Me.OleDbDataAdapter4.Fill(dataSet)
Me.OleDbDataAdapter5.Fill(dataSet)
Catch fillException As System.Exception
Throw fillException
Finally
dataSet.EnforceConstraints = True
Me.OleDbConnection1.Close()
End Try
End Sub
Dim DataType(100) As String
'该数组用来存储字段的数据类型
上一页 [1] [2] [3] [4] [5] [6] [7] [8] 下一页
VB图书管理系统源代码 第3页下载如图片无法显示或论文不完整,请联系qq752018766