Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Public Class Form1
- 'Dec Arrays
- Dim ArrProductName(4) As String
- Dim ArrProductPrice(4) As Integer
- Dim ArrProductQuntity(4) As Integer
- Dim ArrProductID(4) As Integer
- 'Declaring a variable to hold a value that will be used to calculate toltal price
- Dim intValues As Integer = 0
- 'Dec Counters
- Dim intNCounter As Integer = -1
- Dim intPCounter As Integer = -1
- Dim intQCounter As Integer = -1
- Dim intIDCounter As Integer = -1
- 'Declare variables
- Dim intAmountET As Integer
- Dim intSalesTax As Integer
- Dim intAmountIT As Integer
- Dim intChangeDue As Integer
- Dim intChange As Integer
- Const VAT As Decimal = CDec((14 / 100))
- Dim intChnage As Integer
- 'Function for Clearing of fields GroupBox 2
- Private Sub ClearControls()
- txtItemN.Clear()
- txtItemP.Clear()
- txtItemQ.Clear()
- txtItemID.Clear()
- txtItemN.Focus()
- End Sub
- Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
- TabControl1.TabPages(1).Enabled = False
- TabControl1.TabPages(2).Enabled = False
- TabControl1.TabPages(3).Enabled = False
- TabControl1.TabPages(4).Enabled = False
- End Sub
- Private Sub btnLogin_Click(sender As Object, e As EventArgs) Handles btnLogin.Click
- Dim UserName As String
- Dim Password As String
- UserName = CStr(txtUser.Text)
- Password = CStr(txtPass.Text)
- If UserName = "E" And Password = "E" Then
- MessageBox.Show("Login Successful")
- TabControl1.SelectedTab = TabPage2
- TabControl1.TabPages(1).Enabled = True
- TabControl1.TabPages(2).Enabled = True
- TabControl1.TabPages(3).Enabled = True
- TabControl1.TabPages(4).Enabled = True
- txtUser.Clear()
- txtPass.Clear()
- GroupBox1.Enabled = False
- Else
- MessageBox.Show("Login Unsuccessful")
- txtUser.Clear()
- txtPass.Clear()
- txtUser.Focus()
- Exit Sub
- End If
- End Sub
- Private Sub btnClose_Click(sender As Object, e As EventArgs) Handles btnClose.Click
- Dim intResponse As Integer
- intResponse = MessageBox.Show("Are You Aure You Want To Exit?", "Exit Application", MessageBoxButtons.YesNo, MessageBoxIcon.Question)
- If intResponse = DialogResult.Yes Then
- Me.Close()
- End If
- End Sub
- Private Sub btnGen_Click(sender As Object, e As EventArgs) Handles btnGen.Click
- Dim Random As New Random
- Dim ID As Integer
- ID = Random.Next(1000, 9666 + 123)
- txtItemID.Text = ID.ToString()
- End Sub
- Private Sub btnClearC_Click(sender As Object, e As EventArgs) Handles btnClearC.Click
- ClearControls()
- End Sub
- Private Sub btnAdd_Click(sender As Object, e As EventArgs) Handles btnAdd.Click
- 'Adding Product Names to ArrProductName
- If IsNumeric(txtItemN.Text) = True Or IsNothing(txtItemN.Text) = True Then
- MessageBox.Show("Please enter a Item Name!", "Entry Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
- Else
- If intNCounter = 4 Then
- MessageBox.Show("Stock MAXXED", "We are FULL!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
- ClearControls() 'clears fields inside groupbox 2 so it looks nice
- GroupBox2.Enabled = False 'disables groupbox 2 so no further enteries can be made
- Else
- intNCounter = intNCounter + 1
- ArrProductName(intNCounter) = txtItemN.Text
- End If
- End If
- 'Adding Product Price to ArrProductPrice
- If IsNumeric(txtItemP.Text) = False Or IsNothing(txtItemP.Text) = True Then
- MessageBox.Show("Please enter a Valid Price!", "Entry Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
- Else
- If intPCounter = 4 Then
- 'MessageBox.Show("Stock MAXXED", "We are FULL!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
- Else
- intPCounter = intPCounter + 1
- ArrProductPrice(intPCounter) = CInt(txtItemP.Text)
- End If
- End If
- 'Adding Product Quantity to ArrProductQuantity
- If IsNumeric(txtItemQ.Text) = False Or IsNothing(txtItemQ.Text) = True Then
- MessageBox.Show("Please enter a Valid Quantity!", "Entry Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
- Else
- If intQCounter = 4 Then
- 'MessageBox.Show("Stock MAXXED", "We are FULL!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
- Else
- intQCounter = intQCounter + 1
- ArrProductQuntity(intQCounter) = CInt(txtItemQ.Text)
- End If
- End If
- 'Adding Product ID to ArrProductID
- If IsNumeric(txtItemID.Text) = False Or IsNothing(txtItemID.Text) = True Then
- MessageBox.Show("Please enter a Valid Product ID!", "Entry Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
- Else
- If intIDCounter = 4 Then
- 'MessageBox.Show("Stock MAXXED", "We are FULL!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
- Else
- intIDCounter = intIDCounter + 1
- ArrProductID(intIDCounter) = CInt(txtItemID.Text)
- End If
- End If
- End Sub
- Private Sub btnViewP_Click(sender As Object, e As EventArgs) Handles btnViewP.Click
- 'Add details captured to ListBox = lstProducts
- lstProducts.Items.Clear()
- lstProducts.Items.Add("Product Name: " & vbTab & "Product ID: ")
- lstProducts.Items.Add("---------------------------------------")
- For index As Integer = 0 To 4
- lstProducts.Items.Add(ArrProductName(index).ToString() & vbTab & ArrProductID(index).ToString())
- Next
- End Sub
- Private Sub btnViewAP_Click(sender As Object, e As EventArgs) Handles btnViewAP.Click
- 'Add details captured to ListBox = lstAllProducts
- lstAllProducts.Items.Clear()
- lstAllProducts.Items.Add("Product Name: " & vbTab & "Product Price: " & vbTab & "Product Quantity: " & vbTab & "Product ID: ")
- lstAllProducts.Items.Add("--------------------------------------------------------------------------------------------------------------")
- For index As Integer = 0 To 4
- lstAllProducts.Items.Add(ArrProductName(index).ToString() & vbTab & vbTab & "R" & ArrProductPrice(index).ToString() & vbTab & vbTab & ArrProductQuntity(index) & vbTab & vbTab & ArrProductID(index))
- Next
- End Sub
- Private Sub btnViewP2_Click(sender As Object, e As EventArgs) Handles btnViewP2.Click
- lstProStock.Items.Clear()
- lstProStock.Items.Add("Product Name: " & vbTab & "Product ID: ")
- lstProStock.Items.Add("-----------------------------------------")
- For index As Integer = 0 To 4
- lstProStock.Items.Add(vbTab & ArrProductName(index).ToString() & vbTab & ArrProductID(index).ToString())
- Next
- End Sub
- Private Sub lstProStock_SelectedIndexChanged(sender As Object, e As EventArgs) Handles lstProStock.SelectedIndexChanged
- If lstProStock.SelectedIndex = 2 Then
- txtPrice.Text = ArrProductPrice(0).ToString()
- ElseIf lstProStock.SelectedIndex = 3 Then
- txtPrice.Text = ArrProductPrice(1).ToString()
- ElseIf lstProStock.SelectedIndex = 4 Then
- txtPrice.Text = ArrProductPrice(2).ToString()
- ElseIf lstProStock.SelectedIndex = 5 Then
- txtPrice.Text = ArrProductPrice(3).ToString()
- ElseIf lstProStock.SelectedIndex = 6 Then
- txtPrice.Text = ArrProductPrice(4).ToString()
- End If
- End Sub
- Private Sub btnAddP_Click(sender As Object, e As EventArgs) Handles btnAddP.Click
- 'Adding selected items from lstProStock to lstReciept
- If lstProStock.SelectedIndex = 2 Then
- lstReciept.Items.Add(ArrProductName(0).ToString() & vbTab & "R" & ArrProductPrice(0).ToString() & vbTab & ArrProductID(0))
- lstCompleteR.Items.Add(ArrProductName(0).ToString() & vbTab & "R" & ArrProductPrice(0).ToString() & vbTab & ArrProductID(0)) 'Adds selected item to lstCompleteR
- intValues = intValues + CInt(txtPrice.Text) 'this line is going to hold values from the text box being added to lstReciept, also ganna work out total
- ElseIf lstProStock.SelectedIndex = 3 Then
- lstReciept.Items.Add(ArrProductName(1).ToString() & vbTab & "R" & ArrProductPrice(1).ToString() & vbTab & ArrProductID(1))
- lstCompleteR.Items.Add(ArrProductName(1).ToString() & vbTab & "R" & ArrProductPrice(1).ToString() & vbTab & ArrProductID(1)) 'Adds selected item to lstCompleteR
- intValues = intValues + CInt(txtPrice.Text) 'this line is going to hold values from the text box being added to lstReciept, also ganna work out total
- ElseIf lstProStock.SelectedIndex = 4 Then
- lstReciept.Items.Add(ArrProductName(2).ToString() & vbTab & "R" & ArrProductPrice(2).ToString() & vbTab & ArrProductID(2))
- lstCompleteR.Items.Add(ArrProductName(2).ToString() & vbTab & "R" & ArrProductPrice(2).ToString() & vbTab & ArrProductID(2)) 'Adds selected item to lstCompleteR
- intValues = intValues + CInt(txtPrice.Text) 'this line is going to hold values from the text box being added to lstReciept, also ganna work out total
- ElseIf lstProStock.SelectedIndex = 5 Then
- lstReciept.Items.Add(ArrProductName(3).ToString() & vbTab & "R" & ArrProductPrice(3).ToString() & vbTab & ArrProductID(3))
- lstCompleteR.Items.Add(ArrProductName(3).ToString() & vbTab & "R" & ArrProductPrice(3).ToString() & vbTab & ArrProductID(3)) 'Adds selected item to lstCompleteR
- intValues = intValues + CInt(txtPrice.Text) 'this line is going to hold values from the text box being added to lstReciept, also ganna work out total
- ElseIf lstProStock.SelectedIndex = 6 Then
- lstReciept.Items.Add(ArrProductName(4).ToString() & vbTab & "R" & ArrProductPrice(4).ToString() & vbTab & ArrProductID(4))
- lstCompleteR.Items.Add(ArrProductName(4).ToString() & vbTab & "R" & ArrProductPrice(4).ToString() & vbTab & ArrProductID(4)) 'Adds selected item to lstCompleteR
- intValues = intValues + CInt(txtPrice.Text) 'this line is going to hold values from the text box being added to lstReciept, also ganna work out total
- End If
- End Sub
- Private Sub btnCalc_Click(sender As Object, e As EventArgs) Handles btnCalc.Click
- 'Calcs
- intAmountET = intValues
- intSalesTax = CInt(CDec(intValues * VAT))
- intAmountIT = intAmountET + intSalesTax
- 'Display
- lblAmountET.Text = intAmountET.ToString("C2")
- lblVAT.Text = intSalesTax.ToString("C2")
- lblAmountIT.Text = intAmountIT.ToString("C2")
- End Sub
- Private Sub btnChange_Click(sender As Object, e As EventArgs) Handles btnChange.Click
- 'defensive stuff
- If IsNumeric(txtPayment.Text) = False Or IsNothing(txtPayment.Text) = True Then
- MessageBox.Show("Please Enter A Numeric Value", "Entery Error")
- Exit Sub
- Else
- intChange = CInt(txtPayment.Text)
- End If
- intChangeDue = intAmountIT - intChnage
- lblChange.Text = intChangeDue.ToString("C2")
- End Sub
- End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement