You are on page 1of 3

Public Class setup Private Sub setup_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load Me.Left = (MainForm.Width - Me.Width) / 2 Me.Top = MainForm.

Height - Me.Height - 50 suppliernum.Text = "" parentnum.Text = "" systempassword.Text = system_password load_listview() End Sub Private Sub Button3_Click(sender As System.Object, e As System.EventArgs) Handles Button3.Click If Button3.FlatAppearance.BorderColor = Color.Red Then Button3.FlatAppearance.BorderColor = Color.Lime Button3.Text = "Prevent Manual Entry" allow_manual_entry = True Else Button3.FlatAppearance.BorderColor = Color.Red Button3.Text = "Allow Manual Entry" allow_manual_entry = False End If configure_mainform_display() End Sub Private Sub Button5_Click(sender As System.Object, e As System.EventArgs) Handles Button5.Click Dim response As Integer = MsgBox("Do You Wish To Exit To The OS?", vbYesNo, "EXIT TO OS") If response = 6 Then Close() End End If End Sub Private Sub ListView1_Click(sender As Object, e As System.EventArgs) Handles ListView1.Click suppliernum.Text = ListView1.SelectedItems(0).SubItems(0).Text parentnum.Text = ListView1.SelectedItems(0).SubItems(1).Text End Sub Private Sub suppliernum_Click(sender As System.Object, e As System.EventArgs) Handles suppliernum.Click entered_text = get_alpha("Enter New Supplier Part Number") If entered_text = "" Then Exit Sub suppliernum.Text = entered_text End Sub Private Sub parentnum_Click(sender As System.Object, e As System.EventArgs) Handles parentnum. Click entered_text = get_alpha("Enter New Parent Part Number") If entered_text = "" Then Exit Sub parentnum.Text = entered_text End Sub Private Sub systempassword_Click(sender As System.Object, e As System.EventArgs) Handles systempassword.Click entered_text = get_alpha("Enter New System Password") If entered_text = "" Then Exit Sub systempassword.Text = entered_text system_password = systempassword.Text save_database() End Sub Private Sub Mod1_Click(sender As System.Object, e As System.EventArgs) Handles Mod1.Click, Mod2. Click, Mod3.Click Dim mybutton As Button = sender Select Case mybutton.Name Case "Mod1" Dim tempstr(1) As String Dim tempnode As ListViewItem Dim new_supplier_num As String = get_alpha("Enter New Supplier Number") Dim new_parent_num As String = get_alpha("Enter New Parent Number") Dim msg As String = "Do You Wish To Save A New Relation?" & vbCrLf & vbCrLf msg = msg & "Supplier Number: " & new_supplier_num & vbCrLf msg = msg & "Parent Number: " & new_parent_num

Dim response As Integer = MsgBox(msg, vbYesNo, "New Relation") If response = 7 Then Exit Sub tempstr(0) = new_supplier_num tempstr(1) = new_parent_num tempnode = New ListViewItem(tempstr) ListView1.Items.Add(tempnode) total_index = total_index + 1 ReDim Preserve partnums(2, total_index) partnums(1, total_index) = new_supplier_num partnums(2, total_index) = new_parent_num save_database() update_database() suppliernum.Text = "" parentnum.Text = "" Case "Mod2" If ListView1.SelectedItems.Count = 0 Then MsgBox("A Supplier Number must be selected to modify", vbOKOnly, "Selection Error") Exit Sub End If Dim old_supplier_num As String = ListView1.SelectedItems(0).SubItems(0).Text Dim old_parent_num As String = ListView1.SelectedItems(0).SubItems(1).Text Dim new_supplier_num As String = get_alpha("Enter Modified Supplier Number") Dim new_parent_num As String = get_alpha("Enter Modified Parent Number") Dim msg As String = "Do You Wish To Change From:" & vbCrLf & vbCrLf msg = msg & "Original Supplier Number: " & old_supplier_num & vbCrLf msg = msg & "Original Parent Number: " & old_parent_num & vbCrLf msg = msg & vbCrLf & "To:" & vbCrLf & vbCrLf msg = msg & "Modified Supplier Number: " & new_supplier_num & vbCrLf msg = msg & "Modified Parent Number: " & new_parent_num Dim response As Integer = MsgBox(msg, vbYesNo, "Modify Relation") If response = 7 Then Exit Sub For j = 1 To total_index If partnums(1, j) = old_supplier_num Then partnums(1, j) = new_supplier_num partnums(2, j) = new_parent_num End If Next save_database() update_database() load_listview() suppliernum.Text = "" parentnum.Text = "" Case "Mod3" If ListView1.SelectedItems.Count = 0 Then MsgBox("A Supplier Number must be selected to delete", vbOKOnly, "Selection Error") Exit Sub End If Dim found_index As Integer = total_index + 1 Dim old_supplier_num As String = ListView1.SelectedItems(0).SubItems(0).Text Dim old_parent_num As String = ListView1.SelectedItems(0).SubItems(1).Text Dim msg As String = "Do You Wish To Delete:" & vbCrLf & vbCrLf msg = msg & "Original Supplier Number: " & old_supplier_num & vbCrLf msg = msg & "Original Parent Number: " & old_parent_num & vbCrLf Dim response As Integer = MsgBox(msg, vbYesNo, "Delete Relation") If response = 7 Then Exit Sub For j = 1 To total_index If partnums(1, j) = old_supplier_num Then found_index = j End If If j >= found_index And j < total_index Then partnums(1, j) = partnums(1, j + 1) partnums(2, j) = partnums(2, j + 1) End If Next total_index = total_index - 1 ReDim Preserve partnums(2, total_index) save_database() update_database() load_listview() suppliernum.Text = ""

parentnum.Text = "" End Select End Sub Private Sub load_listview() Dim tempstr(1) As String Dim tempnode As ListViewItem ' Set columnar mode ListView1.View = View.Details ' Set column header ListView1.Columns.Clear() ListView1.Columns.Add("Supplier #", 138) ListView1.Columns.Add("Parent #", 138) ' Remove previous items ListView1.Items.Clear() For j = 1 To total_index tempstr(0) = partnums(1, j) tempstr(1) = partnums(2, j) tempnode = New ListViewItem(tempstr) ListView1.Items.Add(tempnode) Next End Sub Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click Me.Close() Me.Dispose() End Sub End Class

You might also like