Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Public Class PartsForm
- Public numbers() As String = {"3827", "2871", "8671", "5986"}
- Public price() As Double = {36.74, 3.21, 17.93, 9.21}
- Public description() As String = {"Motor", "Switch", "Wire Harness", "Bearing"}
- Public index As Integer
- Private Sub PartsForm_Load(sender As Object, e As EventArgs) Handles MyBase.Load
- numberTextBox.Text = numbers(0)
- priceTextBox.Text = price(0)
- descriptionTextBox.Text = description(0)
- End Sub
- Private Sub Switch(ByVal add As Boolean, ByVal edit As Boolean, ByVal update As Boolean, ByVal cancel As Boolean)
- If add = True Then
- addButton.Enabled = False
- editButton.Enabled = False
- deleteButton.Enabled = False
- previousButton.Enabled = False
- nextButton.Enabled = False
- updateButton.Enabled = True
- cancelProcessButton.Enabled = True
- numberTextBox.ReadOnly = False
- priceTextBox.ReadOnly = False
- descriptionTextBox.ReadOnly = False
- numberTextBox.Focus()
- numberTextBox.Text = ""
- priceTextBox.Text = ""
- descriptionTextBox.Text = ""
- ElseIf edit = True Then
- addButton.Enabled = False
- editButton.Enabled = False
- deleteButton.Enabled = False
- previousButton.Enabled = False
- nextButton.Enabled = False
- updateButton.Enabled = True
- cancelProcessButton.Enabled = True
- numberTextBox.Text = numbers(0)
- priceTextBox.Text = price(0)
- descriptionTextBox.Text = description(0)
- numberTextBox.ReadOnly = False
- priceTextBox.ReadOnly = False
- descriptionTextBox.ReadOnly = False
- numberTextBox.Focus()
- ElseIf update = True Then
- addButton.Enabled = True
- editButton.Enabled = True
- deleteButton.Enabled = True
- previousButton.Enabled = True
- nextButton.Enabled = True
- updateButton.Enabled = False
- cancelProcessButton.Enabled = False
- numberTextBox.ReadOnly = True
- priceTextBox.ReadOnly = True
- descriptionTextBox.ReadOnly = True
- For i As Integer = 0 To numbers.Length - 1
- numbers(i) = numberTextBox.Text
- Exit Sub
- Next
- For i As Integer = 0 To description.Length - 1
- description(i) = descriptionTextBox.Text
- Next
- For i As Integer = 0 To price.Length - 1
- price(i) = priceTextBox.Text
- Next
- ElseIf cancel = True Then
- addButton.Enabled = True
- editButton.Enabled = True
- deleteButton.Enabled = True
- previousButton.Enabled = True
- nextButton.Enabled = True
- updateButton.Enabled = False
- cancelProcessButton.Enabled = False
- numberTextBox.ReadOnly = True
- priceTextBox.ReadOnly = True
- descriptionTextBox.ReadOnly = True
- numberTextBox.Text = numbers(0)
- priceTextBox.Text = price(0)
- descriptionTextBox.Text = description(0)
- End If
- End Sub
- Private Sub addButton_Click(sender As Object, e As EventArgs) Handles addButton.Click
- Switch(1, 0, 0, 0)
- End Sub
- Private Sub editButton_Click(sender As Object, e As EventArgs) Handles editButton.Click
- Switch(0, 1, 0, 0)
- End Sub
- Private Sub updateButton_Click(sender As Object, e As EventArgs) Handles updateButton.Click
- Switch(0, 0, 1, 0)
- End Sub
- Private Sub cancelProcessButton_Click(sender As Object, e As EventArgs) Handles cancelProcessButton.Click
- Switch(0, 0, 0, 1)
- End Sub
- Private Sub Display(ByVal nextClick As Boolean, ByVal prevClick As Boolean)
- If nextClick = True Then
- index += 1
- If index <= 3 Then
- numberTextBox.Text = numbers(index)
- priceTextBox.Text = price(index)
- descriptionTextBox.Text = description(index)
- End If
- ElseIf index > 3 Then
- index -= 1
- If prevClick = True Then
- numberTextBox.Text = numbers(index)
- priceTextBox.Text = price(index)
- descriptionTextBox.Text = description(index)
- ElseIf index < 3 Then
- index += 1
- End If
- End If
- If prevClick = True Then
- index -= 1
- If index >= 0 Then
- numberTextBox.Text = numbers(index)
- priceTextBox.Text = price(index)
- descriptionTextBox.Text = description(index)
- End If
- ElseIf index < 0 Or index > 3 Then
- End If
- End Sub
- Private Sub nextButton_Click(sender As Object, e As EventArgs) Handles nextButton.Click
- Display(1, 0)
- End Sub
- Private Sub previousButton_Click(sender As Object, e As EventArgs) Handles previousButton.Click
- Display(0, 1)
- End Sub
- End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement