Sei sulla pagina 1di 64

SOURCE CODE OF THE FORMS

SPLASH FORM
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Timer1.Tick
ProgressBar1.Value += 2
If ProgressBar1.Value <= 30 Then
Label2.Text = "Initializing....."
ElseIf ProgressBar1.Value <= 50 Then
Label2.Text = "Loading components....."
ElseIf ProgressBar1.Value <= 70 Then
Label2.Text = "Integrating Database...."
ElseIf ProgressBar1.Value <= 100 Then
Label2.Text = "Please wait......"
End If
If ProgressBar1.Value = 100 Then
Timer1.Dispose()
Me.Visible = False
Dim f As New Login()
f.Show()
End If
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
End Sub
Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As
System.EventArgs)
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs)
End Sub

Private Sub Button1_Click_1(ByVal sender As System.Object, ByVal e As


System.EventArgs)
End Sub
Private Sub TextBox1_TextChanged_1(ByVal sender As System.Object, ByVal e As
System.EventArgs)
End Sub
End Class

LOGIN FORM
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button3.Click
Dispose()
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button2.Click
TextBox2.Text = ""
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim main As New Main()
If TextBox2.Text = "aa" Then
MessageBox.Show("Login Successful!")
Dim login As New Login()
login.Close()
main.Show()
Else
MessageBox.Show("Login Failed Plaese Try Again!")
End If
End Sub
Private Sub Login_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
End Sub
End Class

MAIN FORM
Public Class Main
Inherits System.Windows.Forms.Form
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim s As Integer
Dim p As Integer
s = InputBox("Enter Accession No")
If s <> 0 Then
Dim cm As CurrencyManager = CType(BindingContext _
(objBookDetails, "BookIssue"), CurrencyManager)
Dim dv As DataView = CType(cm.List, DataView)
p = dv.Find(s)
End If
If p >= -1 Then
Me.BindingContext(objBookDetails, "Book Details").Position = p
Me.objBookDetails_PositionChanged()
End If
End Sub
Private Sub BookRecords_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Try
'Attempt to load the dataset.
Me.LoadDataSet()
Dim cm As CurrencyManager = CType(BindingContext _
(objBookDetails, "Book Details"), CurrencyManager)
Dim dv As DataView = CType(cm.List, DataView)
dv.Sort = "AccessionNo"
Button1.Enabled = True
Catch eLoad As System.Exception
'Add your error handling code here.
'Display error message, if any.
System.Windows.Forms.MessageBox.Show(eLoad.Message)

End Try
Me.objBookDetails_PositionChanged()
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button3.Click
Dim frm1 As New Form1()
frm1.Show()
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button2.Click
Dispose()
End Sub
End Class

BOOK ISSUE
Public Class BookIss
Inherits System.Windows.Forms.Form
Private Sub btnCancel_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnCancel.Click
Me.BindingContext(objBookIssue, "BookIssue").CancelCurrentEdit()
Me.objBookIssue_PositionChanged()
End Sub
Private Sub btnDelete_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnDelete.Click
If (Me.BindingContext(objBookIssue, "BookIssue").Count > 0) Then
Me.BindingContext(objBookIssue,
"BookIssue").RemoveAt(Me.BindingContext(objBookIssue, "BookIssue").Position)
Me.objBookIssue_PositionChanged()
End If
End Sub
Private Sub btnAdd_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnAdd.Click
Try
'Clear out the current edits
Me.BindingContext(objBookIssue, "BookIssue").EndCurrentEdit()
Me.BindingContext(objBookIssue, "BookIssue").AddNew()
Catch eEndEdit As System.Exception
System.Windows.Forms.MessageBox.Show(eEndEdit.Message)
End Try
Me.objBookIssue_PositionChanged()
End Sub
Private Sub btnUpdate_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnUpdate.Click
Try
'Attempt to update the datasource.
Me.UpdateDataSet()
Catch eUpdate As System.Exception

'Add your error handling code here.


'Display error message, if any.
System.Windows.Forms.MessageBox.Show(eUpdate.Message)
End Try
Me.objBookIssue_PositionChanged()
End Sub
Private Sub btnLoad_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnLoad.Click
Try
'Attempt to load the dataset.
Me.LoadDataSet()
Catch eLoad As System.Exception
'Add your error handling code here.
'Display error message, if any.
System.Windows.Forms.MessageBox.Show(eLoad.Message)
End Try
Me.objBookIssue_PositionChanged()
End Sub
Private Sub btnNavFirst_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnNavFirst.Click
Me.BindingContext(objBookIssue, "BookIssue").Position = 0
Me.objBookIssue_PositionChanged()
End Sub
Private Sub btnLast_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnLast.Click
Me.BindingContext(objBookIssue, "BookIssue").Position =
(Me.objBookIssue.Tables("BookIssue").Rows.Count - 1)
Me.objBookIssue_PositionChanged()
End Sub
Private Sub btnNavPrev_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnNavPrev.Click
Me.BindingContext(objBookIssue, "BookIssue").Position =
(Me.BindingContext(objBookIssue, "BookIssue").Position - 1)

Me.objBookIssue_PositionChanged()
End Sub
Private Sub btnNavNext_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnNavNext.Click
Me.BindingContext(objBookIssue, "BookIssue").Position =
(Me.BindingContext(objBookIssue, "BookIssue").Position + 1)
Me.objBookIssue_PositionChanged()
End Sub
Private Sub objBookIssue_PositionChanged()
Me.lblNavLocation.Text = (((Me.BindingContext(objBookIssue,
"BookIssue").Position + 1).ToString + " of ") _
+ Me.BindingContext(objBookIssue, "BookIssue").Count.ToString)
End Sub
Private Sub btnCancelAll_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnCancelAll.Click
Me.objBookIssue.RejectChanges()
End Sub
Public Sub UpdateDataSet()
'Create a new dataset to hold the changes that have been made to the main dataset.
Dim objDataSetChanges As Library_Management_System.BookIssue = New
Library_Management_System.BookIssue()
'Stop any current edits.
Me.BindingContext(objBookIssue, "BookIssue").EndCurrentEdit()
'Get the changes that have been made to the main dataset.
objDataSetChanges = CType(objBookIssue.GetChanges,
Library_Management_System.BookIssue)
'Check to see if any changes have been made.
If (Not (objDataSetChanges) Is Nothing) Then
Try
'There are changes that need to be made, so attempt to update the datasource by
'calling the update method and passing the dataset and any parameters.
Me.UpdateDataSource(objDataSetChanges)

objBookIssue.Merge(objDataSetChanges)
objBookIssue.AcceptChanges()
Catch eUpdate As System.Exception
'Add your error handling code here.
Throw eUpdate
End Try
'Add your code to check the returned dataset for any errors that may have been
'pushed into the row object's error.
End If
End Sub
Public Sub LoadDataSet()
'Create a new dataset to hold the records returned from the call to FillDataSet.
'A temporary dataset is used because filling the existing dataset would
'require the databindings to be rebound.
Dim objDataSetTemp As Library_Management_System.BookIssue
objDataSetTemp = New Library_Management_System.BookIssue()
Try
'Attempt to fill the temporary dataset.
Me.FillDataSet(objDataSetTemp)
Catch eFillDataSet As System.Exception
'Add your error handling code here.
Throw eFillDataSet
End Try
Try
'Empty the old records from the dataset.
objBookIssue.Clear()
'Merge the records into the main dataset.
objBookIssue.Merge(objDataSetTemp)
Catch eLoadMerge As System.Exception
'Add your error handling code here.
Throw eLoadMerge
End Try

End Sub
Public Sub UpdateDataSource(ByVal ChangedRows As
Library_Management_System.BookIssue)
Try
'The data source only needs to be updated if there are changes pending.
If (Not (ChangedRows) Is Nothing) Then
'Open the connection.
Me.OleDbConnection1.Open()
'Attempt to update the data source.
OleDbDataAdapter1.Update(ChangedRows)
End If
Catch updateException As System.Exception
'Add your error handling code here.
Throw updateException
Finally
'Close the connection whether or not the exception was thrown.
Me.OleDbConnection1.Close()
End Try
End Sub
Public Sub FillDataSet(ByVal dataSet As Library_Management_System.BookIssue)
'Turn off constraint checking before the dataset is filled.
'This allows the adapters to fill the dataset without concern
'for dependencies between the tables.
dataSet.EnforceConstraints = False
Try
'Open the connection.
Me.OleDbConnection1.Open()
'Attempt to fill the dataset through the OleDbDataAdapter1.
Me.OleDbDataAdapter1.Fill(dataSet)
Catch fillException As System.Exception
'Add your error handling code here.
Throw fillException

Finally
'Turn constraint checking back on.
dataSet.EnforceConstraints = True
'Close the connection whether or not the exception was thrown.
Me.OleDbConnection1.Close()
End Try
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim s As Integer
Dim p As Integer
s = InputBox("Enter Accession No")
If s <> 0 Then
Dim cm As CurrencyManager = CType(BindingContext _
(objBookIssue, "BookIssue"), CurrencyManager)
Dim dv As DataView = CType(cm.List, DataView)
p = dv.Find(s)
If p >= -1 Then
Me.BindingContext(objBookIssue, "BookIssue").Position = p
Me.objBookIssue_PositionChanged()
End If
End If
If p = -1 Then
MsgBox("Record not found")
End If
End Sub
Private Sub BookIss_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Try
'Attempt to load the dataset.
Me.LoadDataSet()
Dim cm As CurrencyManager = CType(BindingContext _

(objBookIssue, "BookIssue"), CurrencyManager)


Dim dv As DataView = CType(cm.List, DataView)
dv.Sort = "AccessionNo"
Button1.Enabled = True
Catch eLoad As System.Exception
'Add your error handling code here.
'Display error message, if any.
System.Windows.Forms.MessageBox.Show(eLoad.Message)
End Try
Me.objBookIssue_PositionChanged()
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button2.Click
Dispose()
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button3.Click
Dim frm2 As New Form2()
frm2.Show()
End Sub
End Class
Public Class BookReturns
Inherits System.Windows.Forms.Form
Private Sub btnCancel_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnCancel.Click
Me.BindingContext(objBookReturn, "BookReturn").CancelCurrentEdit()
Me.objBookReturn_PositionChanged()
End Sub
Private Sub btnDelete_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnDelete.Click
If (Me.BindingContext(objBookReturn, "BookReturn").Count > 0) Then

Me.BindingContext(objBookReturn,
"BookReturn").RemoveAt(Me.BindingContext(objBookReturn, "BookReturn").Position)
Me.objBookReturn_PositionChanged()
End If
End Sub
Private Sub btnAdd_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnAdd.Click
Try
'Clear out the current edits
Me.BindingContext(objBookReturn, "BookReturn").EndCurrentEdit()
Me.BindingContext(objBookReturn, "BookReturn").AddNew()
Catch eEndEdit As System.Exception
System.Windows.Forms.MessageBox.Show(eEndEdit.Message)
End Try
Me.objBookReturn_PositionChanged()
End Sub
Private Sub btnUpdate_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnUpdate.Click
Try
'Attempt to update the datasource.
Me.UpdateDataSet()
Catch eUpdate As System.Exception
'Add your error handling code here.
'Display error message, if any.
System.Windows.Forms.MessageBox.Show(eUpdate.Message)
End Try
Me.objBookReturn_PositionChanged()
End Sub
Private Sub btnLoad_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnLoad.Click
Try

'Attempt to load the dataset.


Me.LoadDataSet()
Catch eLoad As System.Exception
'Add your error handling code here.
'Display error message, if any.
System.Windows.Forms.MessageBox.Show(eLoad.Message)
End Try
Me.objBookReturn_PositionChanged()
End Sub
Private Sub btnNavFirst_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnNavFirst.Click
Me.BindingContext(objBookReturn, "BookReturn").Position = 0
Me.objBookReturn_PositionChanged()
End Sub
Private Sub btnLast_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnLast.Click
Me.BindingContext(objBookReturn, "BookReturn").Position =
(Me.objBookReturn.Tables("BookReturn").Rows.Count - 1)
Me.objBookReturn_PositionChanged()
End Sub
Private Sub btnNavPrev_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnNavPrev.Click
Me.BindingContext(objBookReturn, "BookReturn").Position =
(Me.BindingContext(objBookReturn, "BookReturn").Position - 1)
Me.objBookReturn_PositionChanged()
End Sub
Private Sub btnNavNext_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnNavNext.Click
Me.BindingContext(objBookReturn, "BookReturn").Position =
(Me.BindingContext(objBookReturn, "BookReturn").Position + 1)

Me.objBookReturn_PositionChanged()
End Sub
Private Sub objBookReturn_PositionChanged()
Me.lblNavLocation.Text = (((Me.BindingContext(objBookReturn,
"BookReturn").Position + 1).ToString + " of ") _
+ Me.BindingContext(objBookReturn, "BookReturn").Count.ToString)
End Sub
Private Sub btnCancelAll_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnCancelAll.Click
Me.objBookReturn.RejectChanges()
End Sub
Public Sub UpdateDataSet()
'Create a new dataset to hold the changes that have been made to the main dataset.
Dim objDataSetChanges As Library_Management_System.BookReturn = New
Library_Management_System.BookReturn()
'Stop any current edits.
Me.BindingContext(objBookReturn, "BookReturn").EndCurrentEdit()
'Get the changes that have been made to the main dataset.
objDataSetChanges = CType(objBookReturn.GetChanges,
Library_Management_System.BookReturn)
'Check to see if any changes have been made.
If (Not (objDataSetChanges) Is Nothing) Then
Try
'There are changes that need to be made, so attempt to update the datasource by
'calling the update method and passing the dataset and any parameters.
Me.UpdateDataSource(objDataSetChanges)
objBookReturn.Merge(objDataSetChanges)
objBookReturn.AcceptChanges()
Catch eUpdate As System.Exception
'Add your error handling code here.
Throw eUpdate
End Try

'Add your code to check the returned dataset for any errors that may have been
'pushed into the row object's error.
End If
End Sub
Public Sub LoadDataSet()
'Create a new dataset to hold the records returned from the call to FillDataSet.
'A temporary dataset is used because filling the existing dataset would
'require the databindings to be rebound.
Dim objDataSetTemp As Library_Management_System.BookReturn
objDataSetTemp = New Library_Management_System.BookReturn()
Try
'Attempt to fill the temporary dataset.
Me.FillDataSet(objDataSetTemp)
Catch eFillDataSet As System.Exception
'Add your error handling code here.
Throw eFillDataSet
End Try
Try
'Empty the old records from the dataset.
objBookReturn.Clear()
'Merge the records into the main dataset.
objBookReturn.Merge(objDataSetTemp)
Catch eLoadMerge As System.Exception
'Add your error handling code here.
Throw eLoadMerge
End Try
End Sub
Public Sub UpdateDataSource(ByVal ChangedRows As
Library_Management_System.BookReturn)
Try
'The data source only needs to be updated if there are changes pending.

If (Not (ChangedRows) Is Nothing) Then


'Open the connection.
Me.OleDbConnection1.Open()
'Attempt to update the data source.
OleDbDataAdapter1.Update(ChangedRows)
End If
Catch updateException As System.Exception
'Add your error handling code here.
Throw updateException
Finally
'Close the connection whether or not the exception was thrown.
Me.OleDbConnection1.Close()
End Try
End Sub
Public Sub FillDataSet(ByVal dataSet As Library_Management_System.BookReturn)
'Turn off constraint checking before the dataset is filled.
'This allows the adapters to fill the dataset without concern
'for dependencies between the tables.
dataSet.EnforceConstraints = False
Try
'Open the connection.
Me.OleDbConnection1.Open()
'Attempt to fill the dataset through the OleDbDataAdapter1.
Me.OleDbDataAdapter1.Fill(dataSet)
Catch fillException As System.Exception
'Add your error handling code here.
Throw fillException
Finally
'Turn constraint checking back on.
dataSet.EnforceConstraints = True
'Close the connection whether or not the exception was thrown.
Me.OleDbConnection1.Close()
End Try

End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dispose()
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button3.Click
Dim s As Integer
Dim p As Integer
s = InputBox("Enter Accession No")
If s <> 0 Then
Dim cm As CurrencyManager = CType(BindingContext _
(objBookReturn, "BookReturn"), CurrencyManager)
Dim dv As DataView = CType(cm.List, DataView)
p = dv.Find(s)
If p >= -1 Then
Me.BindingContext(objBookReturn, "BookReturn").Position = p
Me.objBookReturn_PositionChanged()
End If
End If
If p = -1 Then
MsgBox("Record not found")
End If
End Sub
Private Sub BookReturns_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Try
'Attempt to load the dataset.
Me.LoadDataSet()
Dim cm As CurrencyManager = CType(BindingContext _
(objBookReturn, "BookReturn"), CurrencyManager)
Dim dv As DataView = CType(cm.List, DataView)
dv.Sort = "ID"

Button1.Enabled = True
Catch eLoad As System.Exception
'Add your error handling code here.
'Display error message, if any.
System.Windows.Forms.MessageBox.Show(eLoad.Message)
End Try
Me.objBookReturn_PositionChanged()
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button2.Click
Dim frm5 As New Form5()
frm5.Show()
End Sub
End Class

ORDERS OF BOOK
Public Class Orderss
Inherits System.Windows.Forms.Form
Private Sub btnCancel_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnCancel.Click
Me.BindingContext(objOrders, "Orders").CancelCurrentEdit()
Me.objOrders_PositionChanged()
End Sub
Private Sub btnDelete_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnDelete.Click
If (Me.BindingContext(objOrders, "Orders").Count > 0) Then
Me.BindingContext(objOrders,
"Orders").RemoveAt(Me.BindingContext(objOrders, "Orders").Position)
Me.objOrders_PositionChanged()
End If
End Sub
Private Sub btnAdd_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnAdd.Click
Try
'Clear out the current edits
Me.BindingContext(objOrders, "Orders").EndCurrentEdit()
Me.BindingContext(objOrders, "Orders").AddNew()
Catch eEndEdit As System.Exception
System.Windows.Forms.MessageBox.Show(eEndEdit.Message)
End Try
Me.objOrders_PositionChanged()
End Sub
Private Sub btnUpdate_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnUpdate.Click
Try
'Attempt to update the datasource.
Me.UpdateDataSet()
Catch eUpdate As System.Exception

'Add your error handling code here.


'Display error message, if any.
System.Windows.Forms.MessageBox.Show(eUpdate.Message)
End Try
Me.objOrders_PositionChanged()
End Sub
Private Sub btnLoad_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnLoad.Click
Try
'Attempt to load the dataset.
Me.LoadDataSet()
Catch eLoad As System.Exception
'Add your error handling code here.
'Display error message, if any.
System.Windows.Forms.MessageBox.Show(eLoad.Message)
End Try
Me.objOrders_PositionChanged()
End Sub
Private Sub btnNavFirst_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnNavFirst.Click
Me.BindingContext(objOrders, "Orders").Position = 0
Me.objOrders_PositionChanged()
End Sub
Private Sub btnLast_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnLast.Click
Me.BindingContext(objOrders, "Orders").Position =
(Me.objOrders.Tables("Orders").Rows.Count - 1)
Me.objOrders_PositionChanged()
End Sub
Private Sub btnNavPrev_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnNavPrev.Click
Me.BindingContext(objOrders, "Orders").Position =
(Me.BindingContext(objOrders, "Orders").Position - 1)

Me.objOrders_PositionChanged()
End Sub
Private Sub btnNavNext_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnNavNext.Click
Me.BindingContext(objOrders, "Orders").Position =
(Me.BindingContext(objOrders, "Orders").Position + 1)
Me.objOrders_PositionChanged()
End Sub
Private Sub objOrders_PositionChanged()
Me.lblNavLocation.Text = (((Me.BindingContext(objOrders, "Orders").Position +
1).ToString + " of ") _
+ Me.BindingContext(objOrders, "Orders").Count.ToString)
End Sub
Private Sub btnCancelAll_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnCancelAll.Click
Me.objOrders.RejectChanges()
End Sub
Public Sub UpdateDataSet()
'Create a new dataset to hold the changes that have been made to the main dataset.
Dim objDataSetChanges As Library_Management_System.Orders = New
Library_Management_System.Orders()
'Stop any current edits.
Me.BindingContext(objOrders, "Orders").EndCurrentEdit()
'Get the changes that have been made to the main dataset.
objDataSetChanges = CType(objOrders.GetChanges,
Library_Management_System.Orders)
'Check to see if any changes have been made.
If (Not (objDataSetChanges) Is Nothing) Then
Try
'There are changes that need to be made, so attempt to update the datasource by
'calling the update method and passing the dataset and any parameters.
Me.UpdateDataSource(objDataSetChanges)
objOrders.Merge(objDataSetChanges)

objOrders.AcceptChanges()
Catch eUpdate As System.Exception
'Add your error handling code here.
Throw eUpdate
End Try
'Add your code to check the returned dataset for any errors that may have been
'pushed into the row object's error.
End If
End Sub
Public Sub LoadDataSet()
'Create a new dataset to hold the records returned from the call to FillDataSet.
'A temporary dataset is used because filling the existing dataset would
'require the databindings to be rebound.
Dim objDataSetTemp As Library_Management_System.Orders
objDataSetTemp = New Library_Management_System.Orders()
Try
'Attempt to fill the temporary dataset.
Me.FillDataSet(objDataSetTemp)
Catch eFillDataSet As System.Exception
'Add your error handling code here.
Throw eFillDataSet
End Try
Try
'Empty the old records from the dataset.
objOrders.Clear()
'Merge the records into the main dataset.
objOrders.Merge(objDataSetTemp)
Catch eLoadMerge As System.Exception
'Add your error handling code here.
Throw eLoadMerge
End Try
End Sub

Public Sub UpdateDataSource(ByVal ChangedRows As


Library_Management_System.Orders)
Try
'The data source only needs to be updated if there are changes pending.
If (Not (ChangedRows) Is Nothing) Then
'Open the connection.
Me.OleDbConnection1.Open()
'Attempt to update the data source.
OleDbDataAdapter1.Update(ChangedRows)
End If
Catch updateException As System.Exception
'Add your error handling code here.
Throw updateException
Finally
'Close the connection whether or not the exception was thrown.
Me.OleDbConnection1.Close()
End Try
End Sub
Public Sub FillDataSet(ByVal dataSet As Library_Management_System.Orders)
'Turn off constraint checking before the dataset is filled.
'This allows the adapters to fill the dataset without concern
'for dependencies between the tables.
dataSet.EnforceConstraints = False
Try
'Open the connection.
Me.OleDbConnection1.Open()
'Attempt to fill the dataset through the OleDbDataAdapter1.
Me.OleDbDataAdapter1.Fill(dataSet)
Catch fillException As System.Exception
'Add your error handling code here.
Throw fillException
Finally
'Turn constraint checking back on.

dataSet.EnforceConstraints = True
'Close the connection whether or not the exception was thrown.
Me.OleDbConnection1.Close()
End Try
End Sub
Private Sub Orderss_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Label1.Text = Now.Date
Try
'Attempt to load the dataset.
Me.LoadDataSet()
Dim cm As CurrencyManager = CType(BindingContext _
(objOrders, "Orders"), CurrencyManager)
Dim dv As DataView = CType(cm.List, DataView)
dv.Sort = "OrderNo"
Button1.Enabled = True
Catch eLoad As System.Exception
'Add your error handling code here.
'Display error message, if any.
System.Windows.Forms.MessageBox.Show(eLoad.Message)
End Try
Me.objOrders_PositionChanged()
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dispose()
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button3.Click
Dim s As Integer
Dim p As Integer

s = InputBox("Enter Order No")


If s <> 0 Then
Dim cm As CurrencyManager = CType(BindingContext _
(objOrders, "Orders"), CurrencyManager)
Dim dv As DataView = CType(cm.List, DataView)
p = dv.Find(s)
If p >= -1 Then
Me.BindingContext(objOrders, "Orders").Position = p
Me.objOrders_PositionChanged()
End If
End If
If p = -1 Then
MsgBox("Record not found")
End If
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button2.Click
Dim frm3 As New Form3()
frm3.Show()
End Sub
End Class

NEWSPAPER
Public Class Newspapaer
Inherits System.Windows.Forms.Form
Private Sub btnCancel_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnCancel.Click
Me.BindingContext(objNewspaper, "Newspaper").CancelCurrentEdit()
Me.objNewspaper_PositionChanged()
End Sub
Private Sub btnDelete_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnDelete.Click
If (Me.BindingContext(objNewspaper, "Newspaper").Count > 0) Then
Me.BindingContext(objNewspaper,
"Newspaper").RemoveAt(Me.BindingContext(objNewspaper, "Newspaper").Position)
Me.objNewspaper_PositionChanged()
End If
End Sub
Private Sub btnAdd_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnAdd.Click
Try
'Clear out the current edits
Me.BindingContext(objNewspaper, "Newspaper").EndCurrentEdit()
Me.BindingContext(objNewspaper, "Newspaper").AddNew()
Catch eEndEdit As System.Exception
System.Windows.Forms.MessageBox.Show(eEndEdit.Message)
End Try
Me.objNewspaper_PositionChanged()
End Sub
Private Sub btnUpdate_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnUpdate.Click
Try
'Attempt to update the datasource.
Me.UpdateDataSet()
Catch eUpdate As System.Exception

'Add your error handling code here.


'Display error message, if any.
System.Windows.Forms.MessageBox.Show(eUpdate.Message)
End Try
Me.objNewspaper_PositionChanged()
End Sub
Private Sub btnLoad_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnLoad.Click
Try
'Attempt to load the dataset.
Me.LoadDataSet()
Catch eLoad As System.Exception
'Add your error handling code here.
'Display error message, if any.
System.Windows.Forms.MessageBox.Show(eLoad.Message)
End Try
Me.objNewspaper_PositionChanged()
End Sub
Private Sub btnNavFirst_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnNavFirst.Click
Me.BindingContext(objNewspaper, "Newspaper").Position = 0
Me.objNewspaper_PositionChanged()
End Sub
Private Sub btnLast_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnLast.Click
Me.BindingContext(objNewspaper, "Newspaper").Position =
(Me.objNewspaper.Tables("Newspaper").Rows.Count - 1)
Me.objNewspaper_PositionChanged()
End Sub
Private Sub btnNavPrev_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnNavPrev.Click
Me.BindingContext(objNewspaper, "Newspaper").Position =
(Me.BindingContext(objNewspaper, "Newspaper").Position - 1)

Me.objNewspaper_PositionChanged()
End Sub
Private Sub btnNavNext_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnNavNext.Click
Me.BindingContext(objNewspaper, "Newspaper").Position =
(Me.BindingContext(objNewspaper, "Newspaper").Position + 1)
Me.objNewspaper_PositionChanged()
End Sub
Private Sub objNewspaper_PositionChanged()
Me.lblNavLocation.Text = (((Me.BindingContext(objNewspaper,
"Newspaper").Position + 1).ToString + " of ") _
+ Me.BindingContext(objNewspaper, "Newspaper").Count.ToString)
End Sub
Private Sub btnCancelAll_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnCancelAll.Click
Me.objNewspaper.RejectChanges()
End Sub
Public Sub UpdateDataSet()
'Create a new dataset to hold the changes that have been made to the main dataset.
Dim objDataSetChanges As Library_Management_System.Newspaper = New
Library_Management_System.Newspaper()
'Stop any current edits.
Me.BindingContext(objNewspaper, "Newspaper").EndCurrentEdit()
'Get the changes that have been made to the main dataset.
objDataSetChanges = CType(objNewspaper.GetChanges,
Library_Management_System.Newspaper)
'Check to see if any changes have been made.
If (Not (objDataSetChanges) Is Nothing) Then
Try
'There are changes that need to be made, so attempt to update the datasource by
'calling the update method and passing the dataset and any parameters.
Me.UpdateDataSource(objDataSetChanges)
objNewspaper.Merge(objDataSetChanges)

objNewspaper.AcceptChanges()
Catch eUpdate As System.Exception
'Add your error handling code here.
Throw eUpdate
End Try
'Add your code to check the returned dataset for any errors that may have been
'pushed into the row object's error.
End If
End Sub
Public Sub LoadDataSet()
'Create a new dataset to hold the records returned from the call to FillDataSet.
'A temporary dataset is used because filling the existing dataset would
'require the databindings to be rebound.
Dim objDataSetTemp As Library_Management_System.Newspaper
objDataSetTemp = New Library_Management_System.Newspaper()
Try
'Attempt to fill the temporary dataset.
Me.FillDataSet(objDataSetTemp)
Catch eFillDataSet As System.Exception
'Add your error handling code here.
Throw eFillDataSet
End Try
Try
'Empty the old records from the dataset.
objNewspaper.Clear()
'Merge the records into the main dataset.
objNewspaper.Merge(objDataSetTemp)
Catch eLoadMerge As System.Exception
'Add your error handling code here.
Throw eLoadMerge
End Try
End Sub

Public Sub UpdateDataSource(ByVal ChangedRows As


Library_Management_System.Newspaper)
Try
'The data source only needs to be updated if there are changes pending.
If (Not (ChangedRows) Is Nothing) Then
'Open the connection.
Me.OleDbConnection1.Open()
'Attempt to update the data source.
OleDbDataAdapter1.Update(ChangedRows)
End If
Catch updateException As System.Exception
'Add your error handling code here.
Throw updateException
Finally
'Close the connection whether or not the exception was thrown.
Me.OleDbConnection1.Close()
End Try
End Sub
Public Sub FillDataSet(ByVal dataSet As Library_Management_System.Newspaper)
'Turn off constraint checking before the dataset is filled.
'This allows the adapters to fill the dataset without concern
'for dependencies between the tables.
dataSet.EnforceConstraints = False
Try
'Open the connection.
Me.OleDbConnection1.Open()
'Attempt to fill the dataset through the OleDbDataAdapter1.
Me.OleDbDataAdapter1.Fill(dataSet)
Catch fillException As System.Exception
'Add your error handling code here.
Throw fillException
Finally
'Turn constraint checking back on.

dataSet.EnforceConstraints = True
'Close the connection whether or not the exception was thrown.
Me.OleDbConnection1.Close()
End Try
End Sub
Private Sub Newspapaer_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Label1.Text = Now.Date
Try
'Attempt to load the dataset.
Me.LoadDataSet()
Dim cm As CurrencyManager = CType(BindingContext _
(objNewspaper, "Newspaper"), CurrencyManager)
Dim dv As DataView = CType(cm.List, DataView)
dv.Sort = "ID"
Button1.Enabled = True
Catch eLoad As System.Exception
'Add your error handling code here.
'Display error message, if any.
System.Windows.Forms.MessageBox.Show(eLoad.Message)
End Try
Me.objNewspaper_PositionChanged()
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dispose()
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button3.Click
Dim s As Integer
Dim p As Integer
s = InputBox("Enter Newspaper Name")
If s <> 0 Then

Dim cm As CurrencyManager = CType(BindingContext _


(objNewspaper, "Newspaper"), CurrencyManager)
Dim dv As DataView = CType(cm.List, DataView)
p = dv.Find(s)
If p >= -1 Then
Me.BindingContext(objNewspaper, "Newspaper").Position = p
Me.objNewspaper_PositionChanged()
End If
End If
If p = -1 Then
MsgBox("Record not found")
End If
End Sub
End Class

MAGAZINE
Public Class Magzines
Inherits System.Windows.Forms.Form
Private Sub btnCancel_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnCancel.Click
Me.BindingContext(objMagzine, "Magzine").CancelCurrentEdit()
Me.objMagzine_PositionChanged()
End Sub
Private Sub btnDelete_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnDelete.Click
If (Me.BindingContext(objMagzine, "Magzine").Count > 0) Then
Me.BindingContext(objMagzine,
"Magzine").RemoveAt(Me.BindingContext(objMagzine, "Magzine").Position)
Me.objMagzine_PositionChanged()
End If
End Sub
Private Sub btnAdd_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnAdd.Click
Try
'Clear out the current edits
Me.BindingContext(objMagzine, "Magzine").EndCurrentEdit()
Me.BindingContext(objMagzine, "Magzine").AddNew()
Catch eEndEdit As System.Exception
System.Windows.Forms.MessageBox.Show(eEndEdit.Message)
End Try
Me.objMagzine_PositionChanged()
End Sub
Private Sub btnUpdate_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnUpdate.Click
Try
'Attempt to update the datasource.
Me.UpdateDataSet()
Catch eUpdate As System.Exception

'Add your error handling code here.


'Display error message, if any.
System.Windows.Forms.MessageBox.Show(eUpdate.Message)
End Try
Me.objMagzine_PositionChanged()
End Sub
Private Sub btnLoad_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnLoad.Click
Try
'Attempt to load the dataset.
Me.LoadDataSet()
Catch eLoad As System.Exception
'Add your error handling code here.
'Display error message, if any.
System.Windows.Forms.MessageBox.Show(eLoad.Message)
End Try
Me.objMagzine_PositionChanged()
End Sub
Private Sub btnNavFirst_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnNavFirst.Click
Me.BindingContext(objMagzine, "Magzine").Position = 0
Me.objMagzine_PositionChanged()
End Sub
Private Sub btnLast_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnLast.Click
Me.BindingContext(objMagzine, "Magzine").Position =
(Me.objMagzine.Tables("Magzine").Rows.Count - 1)
Me.objMagzine_PositionChanged()
End Sub
Private Sub btnNavPrev_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnNavPrev.Click
Me.BindingContext(objMagzine, "Magzine").Position =
(Me.BindingContext(objMagzine, "Magzine").Position - 1)

Me.objMagzine_PositionChanged()
End Sub
Private Sub btnNavNext_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnNavNext.Click
Me.BindingContext(objMagzine, "Magzine").Position =
(Me.BindingContext(objMagzine, "Magzine").Position + 1)
Me.objMagzine_PositionChanged()
End Sub
Private Sub objMagzine_PositionChanged()
Me.lblNavLocation.Text = (((Me.BindingContext(objMagzine, "Magzine").Position
+ 1).ToString + " of ") _
+ Me.BindingContext(objMagzine, "Magzine").Count.ToString)
End Sub
Private Sub btnCancelAll_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnCancelAll.Click
Me.objMagzine.RejectChanges()
End Sub
Public Sub UpdateDataSet()
'Create a new dataset to hold the changes that have been made to the main dataset.
Dim objDataSetChanges As Library_Management_System.Magzine = New
Library_Management_System.Magzine()
'Stop any current edits.
Me.BindingContext(objMagzine, "Magzine").EndCurrentEdit()
'Get the changes that have been made to the main dataset.
objDataSetChanges = CType(objMagzine.GetChanges,
Library_Management_System.Magzine)
'Check to see if any changes have been made.
If (Not (objDataSetChanges) Is Nothing) Then
Try
'There are changes that need to be made, so attempt to update the datasource by
'calling the update method and passing the dataset and any parameters.
Me.UpdateDataSource(objDataSetChanges)
objMagzine.Merge(objDataSetChanges)

objMagzine.AcceptChanges()
Catch eUpdate As System.Exception
'Add your error handling code here.
Throw eUpdate
End Try
'Add your code to check the returned dataset for any errors that may have been
'pushed into the row object's error.
End If
End Sub
Public Sub LoadDataSet()
'Create a new dataset to hold the records returned from the call to FillDataSet.
'A temporary dataset is used because filling the existing dataset would
'require the databindings to be rebound.
Dim objDataSetTemp As Library_Management_System.Magzine
objDataSetTemp = New Library_Management_System.Magzine()
Try
'Attempt to fill the temporary dataset.
Me.FillDataSet(objDataSetTemp)
Catch eFillDataSet As System.Exception
'Add your error handling code here.
Throw eFillDataSet
End Try
Try
'Empty the old records from the dataset.
objMagzine.Clear()
'Merge the records into the main dataset.
objMagzine.Merge(objDataSetTemp)
Catch eLoadMerge As System.Exception
'Add your error handling code here.
Throw eLoadMerge
End Try
End Sub

Public Sub UpdateDataSource(ByVal ChangedRows As


Library_Management_System.Magzine)
Try
'The data source only needs to be updated if there are changes pending.
If (Not (ChangedRows) Is Nothing) Then
'Open the connection.
Me.OleDbConnection1.Open()
'Attempt to update the data source.
OleDbDataAdapter1.Update(ChangedRows)
End If
Catch updateException As System.Exception
'Add your error handling code here.
Throw updateException
Finally
'Close the connection whether or not the exception was thrown.
Me.OleDbConnection1.Close()
End Try
End Sub
Public Sub FillDataSet(ByVal dataSet As Library_Management_System.Magzine)
'Turn off constraint checking before the dataset is filled.
'This allows the adapters to fill the dataset without concern
'for dependencies between the tables.
dataSet.EnforceConstraints = False
Try
'Open the connection.
Me.OleDbConnection1.Open()
'Attempt to fill the dataset through the OleDbDataAdapter1.
Me.OleDbDataAdapter1.Fill(dataSet)
Catch fillException As System.Exception
'Add your error handling code here.
Throw fillException
Finally
'Turn constraint checking back on.

dataSet.EnforceConstraints = True
'Close the connection whether or not the exception was thrown.
Me.OleDbConnection1.Close()
End Try
End Sub
Private Sub Magzines_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Try
'Attempt to load the dataset.
Me.LoadDataSet()
Dim cm As CurrencyManager = CType(BindingContext _
(objMagzine, "Magzine"), CurrencyManager)
Dim dv As DataView = CType(cm.List, DataView)
dv.Sort = "MagzineName"
Button1.Enabled = True
Catch eLoad As System.Exception
'Add your error handling code here.
'Display error message, if any.
System.Windows.Forms.MessageBox.Show(eLoad.Message)
End Try
Me.objMagzine_PositionChanged()
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim s As Integer
Dim p As Integer
s = InputBox("Enter Magzine Name")
If s <> 0 Then
Dim cm As CurrencyManager = CType(BindingContext _
(objMagzine, "Magzine"), CurrencyManager)
Dim dv As DataView = CType(cm.List, DataView)
p = dv.Find(s)
If p >= -1 Then

Me.BindingContext(objMagzine, "Magzine").Position = p
Me.objMagzine_PositionChanged()
End If
End If
If p = -1 Then
MsgBox("Record not found")
End If
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button2.Click
Dispose()
End Sub
End Class

MATERIALS
Public Class Materialss
Inherits System.Windows.Forms.Form
Private Sub btnCancel_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnCancel.Click
Me.BindingContext(objMaterials, "Material").CancelCurrentEdit()
Me.objMaterials_PositionChanged()
End Sub
Private Sub btnDelete_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnDelete.Click
If (Me.BindingContext(objMaterials, "Material").Count > 0) Then
Me.BindingContext(objMaterials,
"Material").RemoveAt(Me.BindingContext(objMaterials, "Material").Position)
Me.objMaterials_PositionChanged()
End If
End Sub
Private Sub btnAdd_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnAdd.Click
Try
'Clear out the current edits
Me.BindingContext(objMaterials, "Material").EndCurrentEdit()
Me.BindingContext(objMaterials, "Material").AddNew()
Catch eEndEdit As System.Exception
System.Windows.Forms.MessageBox.Show(eEndEdit.Message)
End Try
Me.objMaterials_PositionChanged()
End Sub
Private Sub btnUpdate_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnUpdate.Click
Try
'Attempt to update the datasource.
Me.UpdateDataSet()
Catch eUpdate As System.Exception

'Add your error handling code here.


'Display error message, if any.
System.Windows.Forms.MessageBox.Show(eUpdate.Message)
End Try
Me.objMaterials_PositionChanged()
End Sub
Private Sub btnLoad_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnLoad.Click
Try
'Attempt to load the dataset.
Me.LoadDataSet()
Catch eLoad As System.Exception
'Add your error handling code here.
'Display error message, if any.
System.Windows.Forms.MessageBox.Show(eLoad.Message)
End Try
Me.objMaterials_PositionChanged()
End Sub
Private Sub btnNavFirst_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnNavFirst.Click
Me.BindingContext(objMaterials, "Material").Position = 0
Me.objMaterials_PositionChanged()
End Sub
Private Sub btnLast_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnLast.Click
Me.BindingContext(objMaterials, "Material").Position =
(Me.objMaterials.Tables("Material").Rows.Count - 1)
Me.objMaterials_PositionChanged()
End Sub
Private Sub btnNavPrev_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnNavPrev.Click
Me.BindingContext(objMaterials, "Material").Position =
(Me.BindingContext(objMaterials, "Material").Position - 1)

Me.objMaterials_PositionChanged()
End Sub
Private Sub btnNavNext_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnNavNext.Click
Me.BindingContext(objMaterials, "Material").Position =
(Me.BindingContext(objMaterials, "Material").Position + 1)
Me.objMaterials_PositionChanged()
End Sub
Private Sub objMaterials_PositionChanged()
Me.lblNavLocation.Text = (((Me.BindingContext(objMaterials, "Material").Position
+ 1).ToString + " of ") _
+ Me.BindingContext(objMaterials, "Material").Count.ToString)
End Sub
Private Sub btnCancelAll_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnCancelAll.Click
Me.objMaterials.RejectChanges()
End Sub
Public Sub UpdateDataSet()
'Create a new dataset to hold the changes that have been made to the main dataset.
Dim objDataSetChanges As Library_Management_System.Materials = New
Library_Management_System.Materials()
'Stop any current edits.
Me.BindingContext(objMaterials, "Material").EndCurrentEdit()
'Get the changes that have been made to the main dataset.
objDataSetChanges = CType(objMaterials.GetChanges,
Library_Management_System.Materials)
'Check to see if any changes have been made.
If (Not (objDataSetChanges) Is Nothing) Then
Try
'There are changes that need to be made, so attempt to update the datasource by
'calling the update method and passing the dataset and any parameters.
Me.UpdateDataSource(objDataSetChanges)

objMaterials.Merge(objDataSetChanges)
objMaterials.AcceptChanges()
Catch eUpdate As System.Exception
'Add your error handling code here.
Throw eUpdate
End Try
'Add your code to check the returned dataset for any errors that may have been
'pushed into the row object's error.
End If
End Sub
Public Sub LoadDataSet()
'Create a new dataset to hold the records returned from the call to FillDataSet.
'A temporary dataset is used because filling the existing dataset would
'require the databindings to be rebound.
Dim objDataSetTemp As Library_Management_System.Materials
objDataSetTemp = New Library_Management_System.Materials()
Try
'Attempt to fill the temporary dataset.
Me.FillDataSet(objDataSetTemp)
Catch eFillDataSet As System.Exception
'Add your error handling code here.
Throw eFillDataSet
End Try
Try
'Empty the old records from the dataset.
objMaterials.Clear()
'Merge the records into the main dataset.
objMaterials.Merge(objDataSetTemp)
Catch eLoadMerge As System.Exception
'Add your error handling code here.
Throw eLoadMerge
End Try

End Sub
Public Sub UpdateDataSource(ByVal ChangedRows As
Library_Management_System.Materials)
Try
'The data source only needs to be updated if there are changes pending.
If (Not (ChangedRows) Is Nothing) Then
'Open the connection.
Me.OleDbConnection1.Open()
'Attempt to update the data source.
OleDbDataAdapter1.Update(ChangedRows)
End If
Catch updateException As System.Exception
'Add your error handling code here.
Throw updateException
Finally
'Close the connection whether or not the exception was thrown.
Me.OleDbConnection1.Close()
End Try
End Sub
Public Sub FillDataSet(ByVal dataSet As Library_Management_System.Materials)
'Turn off constraint checking before the dataset is filled.
'This allows the adapters to fill the dataset without concern
'for dependencies between the tables.
dataSet.EnforceConstraints = False
Try
'Open the connection.
Me.OleDbConnection1.Open()
'Attempt to fill the dataset through the OleDbDataAdapter1.
Me.OleDbDataAdapter1.Fill(dataSet)
Catch fillException As System.Exception
'Add your error handling code here.
Throw fillException
Finally

'Turn constraint checking back on.


dataSet.EnforceConstraints = True
'Close the connection whether or not the exception was thrown.
Me.OleDbConnection1.Close()
End Try
End Sub
Private Sub Materialss_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Try
'Attempt to load the dataset.
Me.LoadDataSet()
Dim cm As CurrencyManager = CType(BindingContext _
(objMaterials, "Material"), CurrencyManager)
Dim dv As DataView = CType(cm.List, DataView)
dv.Sort = "MaterialName"
Button1.Enabled = True
Catch eLoad As System.Exception
'Add your error handling code here.
'Display error message, if any.
System.Windows.Forms.MessageBox.Show(eLoad.Message)
End Try
Me.objMaterials_PositionChanged()
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button2.Click
Dispose()
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim s As Integer
Dim p As Integer
s = InputBox("Enter Material Name")
If s <> 0 Then

Dim cm As CurrencyManager = CType(BindingContext _


(objMaterials, "Material"), CurrencyManager)
Dim dv As DataView = CType(cm.List, DataView)
p = dv.Find(s)
If p >= -1 Then
Me.BindingContext(objMaterials, "Materials").Position = p
Me.objMaterials_PositionChanged()
End If
End If
If p = -1 Then
MsgBox("Record not found")
End If
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button3.Click
Dim frm4 As New form4()
frm4.show()
End Sub
End Class

MEMBERS
Public Class MemberRecords
Inherits System.Windows.Forms.Form
Private Sub btnCancel_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnCancel.Click
Me.BindingContext(objMembers, "Members").CancelCurrentEdit()
Me.objMembers_PositionChanged()
End Sub
Private Sub btnDelete_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnDelete.Click
If (Me.BindingContext(objMembers, "Members").Count > 0) Then
Me.BindingContext(objMembers,
"Members").RemoveAt(Me.BindingContext(objMembers, "Members").Position)
Me.objMembers_PositionChanged()
End If
End Sub
Private Sub btnAdd_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnAdd.Click
Try
'Clear out the current edits
Me.BindingContext(objMembers, "Members").EndCurrentEdit()
Me.BindingContext(objMembers, "Members").AddNew()
Catch eEndEdit As System.Exception
System.Windows.Forms.MessageBox.Show(eEndEdit.Message)
End Try
Me.objMembers_PositionChanged()
End Sub
Private Sub btnUpdate_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnUpdate.Click
Try
'Attempt to update the datasource.
Me.UpdateDataSet()
Catch eUpdate As System.Exception

'Add your error handling code here.


'Display error message, if any.
System.Windows.Forms.MessageBox.Show(eUpdate.Message)
End Try
Me.objMembers_PositionChanged()
End Sub
Private Sub btnLoad_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnLoad.Click
Try
'Attempt to load the dataset.
Me.LoadDataSet()
Catch eLoad As System.Exception
'Add your error handling code here.
'Display error message, if any.
System.Windows.Forms.MessageBox.Show(eLoad.Message)
End Try
Me.objMembers_PositionChanged()
End Sub
Private Sub btnNavFirst_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnNavFirst.Click
Me.BindingContext(objMembers, "Members").Position = 0
Me.objMembers_PositionChanged()
End Sub
Private Sub btnLast_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnLast.Click
Me.BindingContext(objMembers, "Members").Position =
(Me.objMembers.Tables("Members").Rows.Count - 1)
Me.objMembers_PositionChanged()
End Sub
Private Sub btnNavPrev_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnNavPrev.Click
Me.BindingContext(objMembers, "Members").Position =
(Me.BindingContext(objMembers, "Members").Position - 1)

Me.objMembers_PositionChanged()
End Sub
Private Sub btnNavNext_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnNavNext.Click
Me.BindingContext(objMembers, "Members").Position =
(Me.BindingContext(objMembers, "Members").Position + 1)
Me.objMembers_PositionChanged()
End Sub
Private Sub objMembers_PositionChanged()
Me.lblNavLocation.Text = (((Me.BindingContext(objMembers,
"Members").Position + 1).ToString + " of ") _
+ Me.BindingContext(objMembers, "Members").Count.ToString)
End Sub
Private Sub btnCancelAll_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnCancelAll.Click
Me.objMembers.RejectChanges()
End Sub
Public Sub UpdateDataSet()
'Create a new dataset to hold the changes that have been made to the main dataset.
Dim objDataSetChanges As Library_Management_System.Members = New
Library_Management_System.Members()
'Stop any current edits.
Me.BindingContext(objMembers, "Members").EndCurrentEdit()
'Get the changes that have been made to the main dataset.
objDataSetChanges = CType(objMembers.GetChanges,
Library_Management_System.Members)
'Check to see if any changes have been made.
If (Not (objDataSetChanges) Is Nothing) Then
Try
'There are changes that need to be made, so attempt to update the datasource by
'calling the update method and passing the dataset and any parameters.
Me.UpdateDataSource(objDataSetChanges)
objMembers.Merge(objDataSetChanges)

objMembers.AcceptChanges()
Catch eUpdate As System.Exception
'Add your error handling code here.
Throw eUpdate
End Try
'Add your code to check the returned dataset for any errors that may have been
'pushed into the row object's error.
End If
End Sub
Public Sub LoadDataSet()
'Create a new dataset to hold the records returned from the call to FillDataSet.
'A temporary dataset is used because filling the existing dataset would
'require the databindings to be rebound.
Dim objDataSetTemp As Library_Management_System.Members
objDataSetTemp = New Library_Management_System.Members()
Try
'Attempt to fill the temporary dataset.
Me.FillDataSet(objDataSetTemp)
Catch eFillDataSet As System.Exception
'Add your error handling code here.
Throw eFillDataSet
End Try
Try
'Empty the old records from the dataset.
objMembers.Clear()
'Merge the records into the main dataset.
objMembers.Merge(objDataSetTemp)
Catch eLoadMerge As System.Exception
'Add your error handling code here.
Throw eLoadMerge
End Try
End Sub

Public Sub UpdateDataSource(ByVal ChangedRows As


Library_Management_System.Members)
Try
'The data source only needs to be updated if there are changes pending.
If (Not (ChangedRows) Is Nothing) Then
'Open the connection.
Me.OleDbConnection1.Open()
'Attempt to update the data source.
OleDbDataAdapter1.Update(ChangedRows)
End If
Catch updateException As System.Exception
'Add your error handling code here.
Throw updateException
Finally
'Close the connection whether or not the exception was thrown.
Me.OleDbConnection1.Close()
End Try
End Sub
Public Sub FillDataSet(ByVal dataSet As Library_Management_System.Members)
'Turn off constraint checking before the dataset is filled.
'This allows the adapters to fill the dataset without concern
'for dependencies between the tables.
dataSet.EnforceConstraints = False
Try
'Open the connection.
Me.OleDbConnection1.Open()
'Attempt to fill the dataset through the OleDbDataAdapter1.
Me.OleDbDataAdapter1.Fill(dataSet)
Catch fillException As System.Exception
'Add your error handling code here.
Throw fillException
Finally
'Turn constraint checking back on.

dataSet.EnforceConstraints = True
'Close the connection whether or not the exception was thrown.
Me.OleDbConnection1.Close()
End Try
End Sub
Private Sub editName_TextChanged(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles editName.TextChanged
End Sub
Private Sub lblName_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles lblName.Click
End Sub
Private Sub editPhone2_TextChanged(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles editPhone2.TextChanged
End Sub
Private Sub editPhone1_TextChanged(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles editPhone1.TextChanged
End Sub
Private Sub lblPhone2_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles lblPhone2.Click
End Sub
Private Sub lblPhone1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles lblPhone1.Click
End Sub
Private Sub MemberRecords_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Try
'Attempt to load the dataset.
Me.LoadDataSet()
Dim cm As CurrencyManager = CType(BindingContext _
(objMembers, "Members"), CurrencyManager)
Dim dv As DataView = CType(cm.List, DataView)
dv.Sort = "MemeberID"
Button1.Enabled = True

Catch eLoad As System.Exception


'Add your error handling code here.
'Display error message, if any.
System.Windows.Forms.MessageBox.Show(eLoad.Message)
End Try
Me.objMembers_PositionChanged()
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim s As Integer
Dim p As Integer
s = InputBox("Enter MemberID")
If s <> 0 Then
Dim cm As CurrencyManager = CType(BindingContext _
(objMembers, "Members"), CurrencyManager)
Dim dv As DataView = CType(cm.List, DataView)
p = dv.Find(s)
If p >= -1 Then
Me.BindingContext(objMembers, "Members").Position = p
Me.objMembers_PositionChanged()
End If
End If
If p = -1 Then
MsgBox("Record not found")
End If
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button2.Click
Dispose()
End Sub
End Class

VENDORS
Public Class Vendors
Inherits System.Windows.Forms.Form
Private Sub btnCancel_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnCancel.Click
Me.BindingContext(objVendor, "Vendor").CancelCurrentEdit()
Me.objVendor_PositionChanged()
End Sub
Private Sub btnDelete_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnDelete.Click
If (Me.BindingContext(objVendor, "Vendor").Count > 0) Then
Me.BindingContext(objVendor,
"Vendor").RemoveAt(Me.BindingContext(objVendor, "Vendor").Position)
Me.objVendor_PositionChanged()
End If
End Sub
Private Sub btnAdd_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnAdd.Click
Try
'Clear out the current edits
Me.BindingContext(objVendor, "Vendor").EndCurrentEdit()
Me.BindingContext(objVendor, "Vendor").AddNew()
Catch eEndEdit As System.Exception
System.Windows.Forms.MessageBox.Show(eEndEdit.Message)
End Try
Me.objVendor_PositionChanged()
End Sub
Private Sub btnUpdate_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnUpdate.Click
Try
'Attempt to update the datasource.
Me.UpdateDataSet()
Catch eUpdate As System.Exception

'Add your error handling code here.


'Display error message, if any.
System.Windows.Forms.MessageBox.Show(eUpdate.Message)
End Try
Me.objVendor_PositionChanged()
End Sub
Private Sub btnLoad_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnLoad.Click
Try
'Attempt to load the dataset.
Me.LoadDataSet()
Catch eLoad As System.Exception
'Add your error handling code here.
'Display error message, if any.
System.Windows.Forms.MessageBox.Show(eLoad.Message)
End Try
Me.objVendor_PositionChanged()
End Sub
Private Sub btnNavFirst_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnNavFirst.Click
Me.BindingContext(objVendor, "Vendor").Position = 0
Me.objVendor_PositionChanged()
End Sub
Private Sub btnLast_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnLast.Click
Me.BindingContext(objVendor, "Vendor").Position =
(Me.objVendor.Tables("Vendor").Rows.Count - 1)
Me.objVendor_PositionChanged()
End Sub
Private Sub btnNavPrev_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnNavPrev.Click
Me.BindingContext(objVendor, "Vendor").Position =
(Me.BindingContext(objVendor, "Vendor").Position - 1)

Me.objVendor_PositionChanged()
End Sub
Private Sub btnNavNext_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnNavNext.Click
Me.BindingContext(objVendor, "Vendor").Position =
(Me.BindingContext(objVendor, "Vendor").Position + 1)
Me.objVendor_PositionChanged()
End Sub
Private Sub objVendor_PositionChanged()
Me.lblNavLocation.Text = (((Me.BindingContext(objVendor, "Vendor").Position +
1).ToString + " of ") _
+ Me.BindingContext(objVendor, "Vendor").Count.ToString)
End Sub
Private Sub btnCancelAll_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnCancelAll.Click
Me.objVendor.RejectChanges()
End Sub
Public Sub UpdateDataSet()
'Create a new dataset to hold the changes that have been made to the main dataset.
Dim objDataSetChanges As Library_Management_System.Vendor = New
Library_Management_System.Vendor()
'Stop any current edits.
Me.BindingContext(objVendor, "Vendor").EndCurrentEdit()
'Get the changes that have been made to the main dataset.
objDataSetChanges = CType(objVendor.GetChanges,
Library_Management_System.Vendor)
'Check to see if any changes have been made.
If (Not (objDataSetChanges) Is Nothing) Then
Try
'There are changes that need to be made, so attempt to update the datasource by
'calling the update method and passing the dataset and any parameters.
Me.UpdateDataSource(objDataSetChanges)
objVendor.Merge(objDataSetChanges)

objVendor.AcceptChanges()
Catch eUpdate As System.Exception
'Add your error handling code here.
Throw eUpdate
End Try
'Add your code to check the returned dataset for any errors that may have been
'pushed into the row object's error.
End If
End Sub
Public Sub LoadDataSet()
'Create a new dataset to hold the records returned from the call to FillDataSet.
'A temporary dataset is used because filling the existing dataset would
'require the databindings to be rebound.
Dim objDataSetTemp As Library_Management_System.Vendor
objDataSetTemp = New Library_Management_System.Vendor()
Try
'Attempt to fill the temporary dataset.
Me.FillDataSet(objDataSetTemp)
Catch eFillDataSet As System.Exception
'Add your error handling code here.
Throw eFillDataSet
End Try
Try
'Empty the old records from the dataset.
objVendor.Clear()
'Merge the records into the main dataset.
objVendor.Merge(objDataSetTemp)
Catch eLoadMerge As System.Exception
'Add your error handling code here.
Throw eLoadMerge
End Try
End Sub

Public Sub UpdateDataSource(ByVal ChangedRows As


Library_Management_System.Vendor)
Try
'The data source only needs to be updated if there are changes pending.
If (Not (ChangedRows) Is Nothing) Then
'Open the connection.
Me.OleDbConnection1.Open()
'Attempt to update the data source.
OleDbDataAdapter1.Update(ChangedRows)
End If
Catch updateException As System.Exception
'Add your error handling code here.
Throw updateException
Finally
'Close the connection whether or not the exception was thrown.
Me.OleDbConnection1.Close()
End Try
End Sub
Public Sub FillDataSet(ByVal dataSet As Library_Management_System.Vendor)
'Turn off constraint checking before the dataset is filled.
'This allows the adapters to fill the dataset without concern
'for dependencies between the tables.
dataSet.EnforceConstraints = False
Try
'Open the connection.
Me.OleDbConnection1.Open()
'Attempt to fill the dataset through the OleDbDataAdapter1.
Me.OleDbDataAdapter1.Fill(dataSet)
Catch fillException As System.Exception
'Add your error handling code here.
Throw fillException
Finally
'Turn constraint checking back on.

dataSet.EnforceConstraints = True
'Close the connection whether or not the exception was thrown.
Me.OleDbConnection1.Close()
End Try
End Sub
Private Sub editAddress_TextChanged(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles editAddress.TextChanged
End Sub
Private Sub lblAddress_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles lblAddress.Click
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dispose()
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button3.Click
Dim s As Integer
Dim p As Integer
s = InputBox("Enter Vendor Code")
If s <> 0 Then
Dim cm As CurrencyManager = CType(BindingContext _
(objVendor, "Vendor"), CurrencyManager)
Dim dv As DataView = CType(cm.List, DataView)
p = dv.Find(s)
If p >= -1 Then
Me.BindingContext(objVendor, "Vendor").Position = p
Me.objVendor_PositionChanged()
End If
End If
If p = -1 Then
MsgBox("Record not found")
End If

End Sub
Private Sub Vendors_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Try
'Attempt to load the dataset.
Me.LoadDataSet()
Dim cm As CurrencyManager = CType(BindingContext _
(objVendor, "Vendor"), CurrencyManager)
Dim dv As DataView = CType(cm.List, DataView)
dv.Sort = "ID"
Button1.Enabled = True
Catch eLoad As System.Exception
'Add your error handling code here.
'Display error message, if any.
System.Windows.Forms.MessageBox.Show(eLoad.Message)
End Try
Me.objVendor_PositionChanged()
End Sub
End Class

ABOUT SOFTWARE
Public Class About
Inherits System.Windows.Forms.Form
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dispose()
End Sub
Private Sub About_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
End Sub
End Class

ABOUT VB.NET
Public Class About_Net
Inherits System.Windows.Forms.Form
Private Sub About_Net_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
End Sub
End Class

UTILITY
Public Class Calender
Inherits System.Windows.Forms.Form
Private Sub Calender_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
End Sub
End Class

Potrebbero piacerti anche