Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Imports System.IO 'import the input and output features
- Public Class DueDates 'due dates form
- Dim lineCount As Integer 'The full amount of records in the file
- Dim rowIndex As Integer 'The currently selected row of the datagrid
- Private Sub fillGrid() 'fills the datagrud
- Dim encryption As New clsEncryption 'instantiate the encryption class
- Dim validation As New clsValidation 'instantiate the validation class
- Dim record1 As String 'record for individual borrowings
- Dim fields1() As String 'fields in the record
- Dim record2 As String 'record for borrowing data
- Dim fields2() As String 'fields in the record
- Dim validated As Boolean = True 'is data validated
- Dim searchID As String 'ID being searched for
- Dim searchBorrowingID As String 'borrowingID being searched for
- lineCount = 0
- If validation.presenceCheck(txt_customerID.Text) = True And txt_customerID.Text <> "CustomerID" Then 'validation
- searchID = txt_customerID.Text
- Else
- validated = False 'validation not met
- End If
- If validated = True Then 'if validation met
- Dim sr1 As New StreamReader("individualBorrowings.txt") 'stream reader of individual borrowings
- While sr1.Peek() >= 0 'check every indvidual borrowing for ones with the correct customerID to get a borrowing ID
- record1 = encryption.decrypt(sr1.ReadLine) 'decrypt record from file
- fields1 = record1.Split(",") 'fields in record
- If fields1(1) = searchID Then 'if the search ID is the record ID
- searchBorrowingID = fields1(0) 'store the borrowingID
- Dim sr2 As New StreamReader("borrowingData.txt") 'Stream reader of the borrowingData file
- While sr2.Peek() >= 0 'display the details of the borrowingID
- record2 = encryption.decrypt(sr2.ReadLine) 'decrypt record
- fields2 = record2.Split(",") 'split record into fields
- If fields2(0) = searchBorrowingID Then 'if the borrowingID is found
- Dim index = dgv_dueDates.Rows.Add 'the next row to add to
- dgv_dueDates.Rows(index).SetValues(fields2) 'set the row
- lineCount = lineCount + 1 'increment the linecount to show all rows that have been stored
- End If
- End While
- sr2.Close() 'close the stream reader
- End If
- End While
- sr1.Close() 'close the stream writer
- dgv_dueDates.RowHeadersVisible = False 'Removes the symbols by the rows
- dgv_dueDates.ClearSelection() 'Removes the blue selection box
- dgv_dueDates.Rows(lineCount - 1).Selected = True 'select the final record in the datagrid
- rowIndex = lineCount - 1
- Else
- MsgBox("Must meet validation requirements") 'notify user
- End If
- txt_customerID.Text = "CustomerID" 'reset text boxes
- End Sub
- Private Sub DueDates_Load(sender As Object, e As EventArgs) Handles MyBase.Load
- Me.CenterToScreen() 'centre form to screen
- Dim startupPath As String 'stores the location the program is running
- startupPath = Application.StartupPath
- pbx_logo.ImageLocation = startupPath & "\PennardLibraryLogo.png" 'set image locations
- pbx_back.ImageLocation = startupPath & "\Arrow.png"
- If levelOfAccess = 3 Then
- Me.BackColor = Color.FromArgb(247, 220, 143) 'For admins use yellow
- End If
- If levelOfAccess = 2 Then
- Me.BackColor = Color.FromArgb(140, 227, 245) 'For librarians use a blue background instead of the standard green
- End If
- If levelOfAccess = 1 Then
- Me.BackColor = Color.FromArgb(163, 255, 166) 'For customers use standard green
- End If
- End Sub
- Private Sub pbx_back_Click(sender As Object, e As EventArgs) Handles pbx_back.Click
- Dim MainMenu As New MainMenu 'instantiate the main menu form
- MainMenu.Show() 'show the new form
- Me.Close() 'close the current form
- End Sub
- Private Sub pbx_back_MouseHover(sender As Object, e As EventArgs) Handles pbx_back.MouseHover
- Dim startupPath As String 'stores the location the program is running
- startupPath = Application.StartupPath
- pbx_back.ImageLocation = startupPath & "\ArrowRollover.png" 'rollover image
- End Sub
- Private Sub pbx_back_MouseLeave(sender As Object, e As EventArgs) Handles pbx_back.MouseLeave
- Dim startupPath As String 'stores the location the program is running
- startupPath = Application.StartupPath
- pbx_back.ImageLocation = startupPath & "\Arrow.png" 'rollover image
- End Sub
- Private Sub btn_view_Click(sender As Object, e As EventArgs) Handles btn_view.Click
- fillGrid() 'fill the data grid
- End Sub
- Private Sub txt_customerID_MouseClick(sender As Object, e As MouseEventArgs) Handles txt_customerID.MouseClick
- If txt_customerID.Text = "CustomerID" Then 'if the text is the starting text
- txt_customerID.Text = "" 'clear the textbox
- End If
- End Sub
- Private Sub btn_first_Click(sender As Object, e As EventArgs) Handles btn_first.Click
- dgv_dueDates.ClearSelection()
- dgv_dueDates.Rows(0).Selected = True 'gp back to the first record
- rowIndex = 0
- End Sub
- Private Sub btn_previous_Click(sender As Object, e As EventArgs) Handles btn_previous.Click
- dgv_dueDates.ClearSelection()
- If rowIndex = 0 Then
- MsgBox("You are already looking at the first record")
- Else
- rowIndex = rowIndex - 1
- dgv_dueDates.Rows(rowIndex).Selected = True 'go one record back unless you are at the fist one already
- End If
- End Sub
- Private Sub btn_next_Click(sender As Object, e As EventArgs) Handles btn_next.Click
- dgv_dueDates.ClearSelection()
- If rowIndex = lineCount - 1 Then
- MsgBox("You are already looking at the last record")
- Else
- rowIndex = rowIndex + 1
- dgv_dueDates.Rows(rowIndex).Selected = True 'go on record forwards unless you are at the last one already
- End If
- End Sub
- Private Sub btn_last_Click(sender As Object, e As EventArgs) Handles btn_last.Click
- dgv_dueDates.ClearSelection()
- dgv_dueDates.Rows(lineCount - 1).Selected = True 'go to the last record stored
- rowIndex = lineCount - 1
- End Sub
- End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement