Sie sind auf Seite 1von 13

LOGIN FORM

Imports System.Data.OleDb

Public Class LoginForm1


Dim read As String
Dim datafile As String
Dim connstring As String
Dim myconnection As OleDbConnection = New OleDbConnection

Private Sub OK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)


Handles OK.Click
If UsernameTextBox.Text = Nothing Or PasswordTextBox.Text = Nothing Then
MsgBox("Enter Valid Credentials", MsgBoxStyle.Exclamation)

End If

read = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source ="

datafile = "D:\Finals
Thesis\DiazCollegeLibrarySystem\DiazCollegeLibrarySystem\LibraryRecords.accdb"

connstring = read & datafile

myconnection.ConnectionString = connstring

Dim cmd As OleDbCommand = New OleDbCommand("select * from [UserRegister] where


[UserName] = '" & UsernameTextBox.Text & "' and [Password] = '" & PasswordTextBox.Text &
"'", myconnection)
myconnection.Open()

Dim dr As OleDbDataReader = cmd.ExecuteReader

Dim userconfrm As Boolean = False

While dr.Read
userconfrm = True
End While

If userconfrm = True Then


Form2.Show()
Me.Hide()
Else
MsgBox("login error")
End If
myconnection.Close()
End Sub

Private Sub Cancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)


Handles Cancel.Click
Me.Close()
End Sub

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


System.Windows.Forms.LinkLabelLinkClickedEventArgs) Handles LinkLabel1.LinkClicked
Form1.Show()
Me.Hide()
End Sub
End Class

USER REGISTRATION FORM


Imports System.Data.OleDb

Public Class Form1

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs)


Handles MyBase.Load

End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)


Handles Button2.Click
LoginForm1.Show()
Me.Hide()
End Sub

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


System.Windows.Forms.LinkLabelLinkClickedEventArgs) Handles LinkLabel1.LinkClicked
LoginForm1.Show()
Me.Hide()
End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)


Handles Button1.Click
If TextBox1.Text = "" Or TextBox2.Text = "" Or TextBox3.Text = "" Or
ComboBox1.Text = "" Or ComboBox2.Text = "" Then
MsgBox("plz fill the info")
Else
Try
Dim conn As New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data
Source=D:\Finals
Thesis\DiazCollegeLibrarySystem\DiazCollegeLibrarySystem\LibraryRecords.accdb;")
Dim insert As String = "Insert into UserRegister values('" &
TextBox1.Text & "','" & TextBox2.Text & "','" & TextBox3.Text & "','" & ComboBox1.Text &
"','" & ComboBox2.Text & "');"
Dim cmd As New OleDbCommand(insert, conn)
conn.Open()
cmd.ExecuteNonQuery()
MsgBox("create success")
Me.Close()
LoginForm1.Show()
Catch ex As Exception
MsgBox("error")
End Try
End If
End Sub
End Class
MAIN MENU FORM
Public Class Form2

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


System.EventArgs) Handles ExitToolStripMenuItem.Click
If MsgBox("Confirm if you wish to exit?", MsgBoxStyle.YesNo, Title:="Confirm") =
vbYes Then

Application.Exit()
Else

End If

End Sub

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


As System.EventArgs) Handles ViewUsersToolStripMenuItem.Click
Form3.Show()
Me.Enabled = False
End Sub

Private Sub UpdateBookInventoryToolStripMenuItem_Click(ByVal sender As System.Object,


ByVal e As System.EventArgs) Handles UpdateBookInventoryToolStripMenuItem.Click
Form4.Show()
Me.Enabled = False
End Sub

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


As System.EventArgs) Handles BorrowABookToolStripMenuItem.Click
Form8.Show()
Me.Enabled = False
End Sub

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


As System.EventArgs) Handles ReturnABookToolStripMenuItem.Click
Form6.Show()
Me.Enabled = False
End Sub

Private Sub RegisterABorrowerToolStripMenuItem_Click(ByVal sender As System.Object,


ByVal e As System.EventArgs) Handles RegisterABorrowerToolStripMenuItem.Click
Form7.Show()
Me.Enabled = False
End Sub

End Class

USER INFORMATION FORM


Imports System.Data.OleDb

Public Class Form3

Dim con As New OleDbConnection


Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles Button1.Click
Form2.Enabled = True
Form2.Show()
Me.Hide()
End Sub

Private Sub Form3_Load(ByVal sender As System.Object, ByVal e As System.EventArgs)


Handles MyBase.Load
con.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source =D:\Finals
Thesis\DiazCollegeLibrarySystem\DiazCollegeLibrarySystem\LibraryRecords.accdb"
con.Open()

Dim dt As New DataTable


Dim ds As New DataSet
ds.Tables.Add(dt)
Dim da As New OleDbDataAdapter

da = New OleDbDataAdapter("Select * from UserRegister", con)


da.Fill(dt)

DataGridView1.DataSource = dt.DefaultView

con.Close()

End Sub

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


System.EventArgs) Handles TextBox1.TextChanged
Dim dt As New DataTable
Dim ds As New DataSet
Dim dtview As New DataView
Dim bs As New BindingSource
ds.Tables.Add(dt)
Dim da As New OleDbDataAdapter

con.Open()

da = New OleDbDataAdapter("Select * from UserRegister", con)


da.Fill(dt)

con.Close()

dtview = ds.Tables(0).DefaultView
bs.DataSource = dtview
bs.Filter = "UserName LIKE'" & TextBox1.Text & "*' or Password LIKE'" &
TextBox1.Text & "*' or FullName LIKE'" & TextBox1.Text & "*' or Gender LIKE'" &
TextBox1.Text & "*' or Position LIKE'" & TextBox1.Text & "*'"
DataGridView1.DataSource = bs
con.Close()
End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)


Handles Button2.Click
Dim dt As New DataTable
Dim ds As New DataSet
ds.Tables.Add(dt)
Dim da As New OleDbDataAdapter

con.Open()

da = New OleDbDataAdapter("Select * from UserRegister", con)


da.Fill(dt)
If MsgBox("Are you sure?", MsgBoxStyle.YesNo, Title:="Confirm") = vbYes Then

dt.Rows(0).BeginEdit()
dt.Rows(0).Delete()
dt.Rows(0).EndEdit()

Dim cb As New OleDbCommandBuilder(da)

da.Update(dt)

DataGridView1.DataSource = dt.DefaultView

con.Close()

Else

End If

End Sub
End Class

INVENTORY UPDATE FORM


Imports System.Drawing.Printing

Public Class Form4

Private Sub Form4_Load(ByVal sender As System.Object, ByVal e As System.EventArgs)


Handles MyBase.Load
'TODO: This line of code loads data into the 'LibraryRecordsDataSet.Books' table.
You can move, or remove it, as needed.
Me.BooksTableAdapter.Fill(Me.LibraryRecordsDataSet.Books)

End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)


Handles Button1.Click
Form2.Enabled = True
Form2.Show()
Me.Hide()
End Sub

Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)


Handles Button3.Click

Me.Validate()
Me.BooksBindingSource.EndEdit()
Me.BooksTableAdapter.Update(Me.LibraryRecordsDataSet)
End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)


Handles Button2.Click

Me.BooksBindingSource.AddNew()

End Sub

Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)


Handles Button4.Click
If MsgBox("Are you sure?", MsgBoxStyle.YesNo, Title:="Confirm") = vbYes Then

Me.BooksBindingSource.RemoveCurrent()
Me.Validate()
Me.BooksBindingSource.EndEdit()
Me.BooksTableAdapter.Update(Me.LibraryRecordsDataSet)

Else

End If

End Sub

Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)


Handles Button5.Click
TextBox1.Clear()
TextBox2.Clear()
TextBox3.Clear()
TextBox4.Clear()
TextBox5.Clear()
TextBox6.Clear()
TextBox7.Clear()
TextBox8.Clear()
End Sub

Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)


Handles Button6.Click
PrntDoc.DefaultPageSettings.Landscape = True
PrntPrevDiag.Document = PrntDoc
PrntPrevDiag.ShowDialog()
End Sub

Dim mRow As Integer = 0


Dim newpage As Boolean = True

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


System.Drawing.Printing.PrintPageEventArgs) Handles PrntDoc.PrintPage

With DGV1

Dim fmt As StringFormat = New StringFormat(StringFormatFlags.LineLimit)

fmt.LineAlignment = StringAlignment.Center

fmt.Trimming = StringTrimming.EllipsisCharacter
Dim y As Single = e.MarginBounds.Top

Do While mRow < .RowCount

Dim row As DataGridViewRow = .Rows(mRow)

Dim x As Single = e.MarginBounds.Left

Dim h As Single = 0

For Each cell As DataGridViewCell In row.Cells

Dim rc As RectangleF = New RectangleF(x, y, cell.Size.Width,


cell.Size.Height)

e.Graphics.DrawRectangle(Pens.Black, rc.Left, rc.Top, rc.Width,


rc.Height)

If (newpage) Then

e.Graphics.DrawString(DGV1.Columns(cell.ColumnIndex).HeaderText,
.Font, Brushes.Black, rc, fmt)

Else

e.Graphics.DrawString(DGV1.Rows(cell.RowIndex).Cells(cell.ColumnIndex).FormattedValue.ToS
tring(), .Font, Brushes.Black, rc, fmt)

End If

x += rc.Width

h = Math.Max(h, rc.Height)

Next

newpage = False

y += h

mRow += 1

If y + h > e.MarginBounds.Bottom Then

e.HasMorePages = True

mRow -= 1

newpage = True

Exit Sub

End If

Loop

mRow = 0
End With

End Sub

End Class

BORROWER REGISTRATION FORM


Public Class Form7

Private Sub Form7_Load(ByVal sender As System.Object, ByVal e As System.EventArgs)


Handles MyBase.Load
'TODO: This line of code loads data into the
'LibraryRecordsDataSet.BorrowerRegister' table. You can move, or remove it, as needed.
Me.BorrowerRegisterTableAdapter.Fill(Me.LibraryRecordsDataSet.BorrowerRegister)

End Sub

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


System.EventArgs) Handles Button5.Click
TextBox1.Clear()
TextBox2.Clear()
TextBox3.Clear()
TextBox4.Clear()
TextBox7.Clear()
TextBox8.Clear()
TextBox5.Clear()
TextBox6.Clear()
End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)


Handles Button1.Click
Form2.Enabled = True
Form2.Show()
Me.Hide()
End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)


Handles Button2.Click

Me.BorrowerRegisterBindingSource.AddNew()

End Sub

Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)


Handles Button3.Click

Me.Validate()
Me.BorrowerRegisterBindingSource.EndEdit()
Me.BorrowerRegisterTableAdapter.Update(Me.LibraryRecordsDataSet)

End Sub

Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)


Handles Button4.Click
Me.BorrowerRegisterBindingSource.RemoveCurrent()

End Sub
End Class

BOOK BORROWING FORM


Imports System.Data.OleDb
Public Class Form8

Dim con As New OleDbConnection

Private Sub Form8_Load(ByVal sender As System.Object, ByVal e As System.EventArgs)


Handles MyBase.Load
'TODO: This line of code loads data into the 'LibraryRecordsDataSet.Books' table.
You can move, or remove it, as needed.
Me.BooksTableAdapter.Fill(Me.LibraryRecordsDataSet.Books)
'TODO: This line of code loads data into the
'LibraryRecordsDataSet.BorrowedBooks' table. You can move, or remove it, as needed.
Me.BorrowedBooksTableAdapter.Fill(Me.LibraryRecordsDataSet.BorrowedBooks)

Me.BorrowedBooksBindingSource.AddNew()

con.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source =D:\Finals


Thesis\DiazCollegeLibrarySystem\DiazCollegeLibrarySystem\LibraryRecords.accdb"
con.Open()

Dim ta As New DataTable


Dim d As New DataSet
d.Tables.Add(ta)
Dim ad As New OleDbDataAdapter

ad = New OleDbDataAdapter("Select * from BorrowerRegister", con)

ad.Fill(ta)

DataGridView2.DataSource = ta.DefaultView

con.Close()

Timer1.Start()
TextBox13.Text = Date.Now
TextBox15.Text = Date.Now.AddDays(1)

End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)


Handles Button1.Click
Form2.Enabled = True
Form2.Show()
Me.Hide()
End Sub

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


System.EventArgs) Handles TextBox1.TextChanged

Me.BooksBindingSource.Filter = " BookNumber LIKE'" & TextBox1.Text & "*' or


BookTitle LIKE'" & TextBox1.Text & "*' or Subject LIKE'" & TextBox1.Text & "*' or Author
LIKE'" & TextBox1.Text & "*' or Publisher LIKE'" & TextBox1.Text & "*'or DatePublished
LIKE'" & TextBox1.Text & "*'or Edition LIKE'" & TextBox1.Text & "*'or Copies LIKE'" &
TextBox1.Text & "*'or ShelfLocation LIKE'" & TextBox1.Text & "*'"

End Sub

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


System.EventArgs) Handles TextBox2.TextChanged

Dim ta As New DataTable


Dim d As New DataSet
Dim dv As New DataView
Dim b As New BindingSource
d.Tables.Add(ta)
Dim ad As New OleDbDataAdapter

con.Open()

ad = New OleDbDataAdapter("Select * from BorrowerRegister", con)


ad.Fill(ta)

con.Close()

dv = d.Tables(0).DefaultView
b.DataSource = dv
b.Filter = " BorrowerID LIKE'" & TextBox2.Text & "*' or FullName LIKE'" &
TextBox2.Text & "*' or Gender LIKE'" & TextBox2.Text & "*' or Department LIKE'" &
TextBox2.Text & "*' or [Course/Position] LIKE'" & TextBox2.Text & "*'or [Grade/Year]
LIKE'" & TextBox2.Text & "*'"
DataGridView2.DataSource = b
con.Close()

End Sub

Private Sub DataGridView1_CellClick(ByVal sender As Object, ByVal e As


System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView1.CellClick

Dim index As Integer


index = e.RowIndex
Dim selectedrow As DataGridViewRow
selectedrow = DataGridView1.Rows(index)
TextBox3.Text = selectedrow.Cells(0).Value.ToString
TextBox4.Text = selectedrow.Cells(1).Value.ToString
TextBox5.Text = selectedrow.Cells(2).Value.ToString
TextBox6.Text = selectedrow.Cells(3).Value.ToString
TextBox7.Text = selectedrow.Cells(4).Value.ToString
TextBox8.Text = selectedrow.Cells(5).Value.ToString
TextBox9.Text = selectedrow.Cells(6).Value.ToString
TextBox10.Text = selectedrow.Cells(7).Value.ToString
TextBox14.Text = selectedrow.Cells(8).Value.ToString
End Sub

Private Sub DataGridView2_CellClick(ByVal sender As Object, ByVal e As


System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView2.CellClick

Dim index As Integer


index = e.RowIndex
Dim selectedrow As DataGridViewRow
selectedrow = DataGridView2.Rows(index)
TextBox11.Text = selectedrow.Cells(0).Value.ToString
TextBox12.Text = selectedrow.Cells(1).Value.ToString
End Sub

Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs)


Handles Timer1.Tick
Timer1.Start()
TextBox13.Text = Date.Now
TextBox15.Text = Date.Now.AddDays(1)
End Sub

Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)


Me.BorrowedBooksBindingSource.RemoveCurrent()

End Sub

Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)


Handles Button3.Click
If MsgBox("Are you sure?", MsgBoxStyle.YesNo, Title:="Confirm") = vbYes Then

Me.Validate()
Me.BorrowedBooksBindingSource.EndEdit()
Me.BorrowedBooksTableAdapter.Update(Me.LibraryRecordsDataSet)

Me.BorrowedBooksBindingSource.AddNew()

Me.BooksBindingSource.RemoveCurrent()

Me.Validate()
Me.BooksBindingSource.EndEdit()
Me.BooksTableAdapter.Update(Me.LibraryRecordsDataSet)

End If
End Sub

Private Sub DataGridView1_DataError(ByVal sender As Object, ByVal e As


System.Windows.Forms.DataGridViewDataErrorEventArgs) Handles DataGridView1.DataError
e.Cancel = True
End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)


Handles Button2.Click
Me.BooksTableAdapter.Fill(Me.LibraryRecordsDataSet.Books)
End Sub
End Class
RETURN BOOKS FORM
Public Class Form6

Private Sub Form6_Load(ByVal sender As System.Object, ByVal e As System.EventArgs)


Handles MyBase.Load
'TODO: This line of code loads data into the 'LibraryRecordsDataSet.Books' table.
You can move, or remove it, as needed.
Me.BooksTableAdapter.Fill(Me.LibraryRecordsDataSet.Books)
'TODO: This line of code loads data into the
'LibraryRecordsDataSet.BorrowedBooks' table. You can move, or remove it, as needed.
Me.BorrowedBooksTableAdapter.Fill(Me.LibraryRecordsDataSet.BorrowedBooks)

Me.BooksBindingSource.AddNew()

End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)


Handles Button2.Click
Form2.Enabled = True
Form2.Show()
Me.Hide()
End Sub

Private Sub DGV1_CellClick(ByVal sender As Object, ByVal e As


System.Windows.Forms.DataGridViewCellEventArgs) Handles DGV1.CellClick
Dim index As Integer
index = e.RowIndex
Dim selectedrow As DataGridViewRow
selectedrow = DGV1.Rows(index)
TextBox3.Text = selectedrow.Cells(0).Value.ToString
TextBox4.Text = selectedrow.Cells(3).Value.ToString
TextBox5.Text = selectedrow.Cells(6).Value.ToString
TextBox6.Text = selectedrow.Cells(7).Value.ToString
TextBox7.Text = selectedrow.Cells(8).Value.ToString
TextBox8.Text = selectedrow.Cells(9).Value.ToString
TextBox9.Text = selectedrow.Cells(10).Value.ToString
TextBox10.Text = selectedrow.Cells(11).Value.ToString
TextBox11.Text = selectedrow.Cells(3).Value.ToString
TextBox12.Text = selectedrow.Cells(4).Value.ToString
TextBox13.Text = selectedrow.Cells(5).Value.ToString
TextBox17.Text = selectedrow.Cells(12).Value.ToString

End Sub

Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)


Handles Button4.Click
Me.Validate()
Me.BooksBindingSource.EndEdit()
Me.BooksTableAdapter.Update(Me.LibraryRecordsDataSet)

Me.BooksBindingSource.AddNew()

Me.BorrowedBooksBindingSource.RemoveCurrent()
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles Button1.Click
TextBox14.Text = Date.Now

Dim date1 As Date


Dim date2 As Date
Dim difference As TimeSpan
date1 = Convert.ToDateTime(TextBox13.Text)
date2 = Convert.ToDateTime(TextBox14.Text)
difference = date2.Subtract(date1)
TextBox15.Text = FormatNumber(difference.TotalHours, 0)

Dim fine As Integer


Dim addfine As Integer
Dim d As Integer
Dim due As Integer

due = 24
d = Val(TextBox15.Text) \ 24
fine = 5
addfine = 1
If TextBox15.Text <= due Then
TextBox16.Text = 0
End If
If TextBox15.Text > due Then
TextBox16.Text = fine + addfine

End If

End Sub

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


System.EventArgs) Handles TextBox1.TextChanged
Me.BorrowedBooksBindingSource.Filter = " BorrowerInfo LIKE'" & TextBox1.Text &
"*'"
End Sub
End Class

Das könnte Ihnen auch gefallen