Create an application (in C++) that stores Inventory records for a retail store.
The application should have an Inventory class with the following properties:
The application should store Inventory class objects in a collection. Create an application that allows users to input new inventory items to be added to the collection.
orm2.vb[Design]
Form2.vb
Imports System.Text.RegularExpressions
Public Class Form2 'VB class
Dim invNumber As String
Dim description As String
Dim costToInventory As Decimal
Dim RetailPrice As Decimal
Dim OnHold As Integer
Dim i As Integer = 0
Dim strItem As String
Dim flag As Integer = 0
Dim invCollection As New System.Collections.Generic.Dictionary(Of
Integer, Inventory)
Private Sub Form2_Load(sender As Object, e As EventArgs) Handles
MyBase.Load
End Sub
'Add button click
Private Sub btnAdd_Click(sender As Object, e As EventArgs) Handles
btnAdd.Click
'Taking inventory number entered by user
Dim inventroyNumber As String = txtInvNo.Text
'checking whether invNumber is present or not
If (i >= 0) Then
For Each pair As KeyValuePair(Of Integer, Inventory) In
invCollection
'Console.WriteLine(" {0}: {1}", pair.Key, pair.Value.Name)
If pair.Value.invNumber = inventroyNumber Then
'show messagebox
MessageBox.Show("Inventory number already present!!")
flag = 1
Else
flag = 0
End If
Next
End If
'check value of flag
If flag = 0 Then
'creating object of Inventory class
Dim objInv As Inventory = New Inventory()
objInv.costToInventory = txtCosttoStore.Text 'set cost to
store
objInv.description = txtDescription.Text 'set description
objInv.invNumber = inventroyNumber 'set inventroyNumber
objInv.OnHold = txtNoOfItemsOnHold.Text 'set items on hand
objInv.RetailPrice = txtRetailPrice.Text 'set retail price
i = i + 1 'increment value of i
'add items to the collextion
invCollection.Add(i, objInv)
'show messagebox
MsgBox("Record '" & objInv.invNumber & "' added to the
collection.")
End If
End Sub
Private Sub txtCosttoStore_TextChanged(sender As Object, e As
EventArgs) Handles txtCosttoStore.TextChanged
If Not Regex.Match(txtCosttoStore.Text, "^[0-9\.]*$",
RegexOptions.IgnoreCase).Success Then 'Only Letters
MessageBox.Show("Please Enter numeric data Only!") 'Inform
User
txtCosttoStore.Focus()
txtCosttoStore.Clear()
End If
End Sub
'View records button click
Private Sub btnViewRecord_Click(sender As Object, e As EventArgs)
Handles btnViewRecord.Click
Dim flag As Integer = 0
strItem = txtInvlbl.Text.Trim()
txtCosttoStore.Clear()
txtDescription.Clear()
txtNoOfItemsOnHold.Clear()
txtRetailPrice.Clear()
If strItem = "" Then
MessageBox.Show("Please Enter inventory number!") 'Inform
User
Return
End If
For Each pair As KeyValuePair(Of Integer, Inventory) In
invCollection
'Console.WriteLine(" {0}: {1}", pair.Key, pair.Value.Name)
If pair.Value.invNumber = strItem Then
txtCosttoStore.Text = pair.Value.costToInventory
txtDescription.Text = pair.Value.description
txtNoOfItemsOnHold.Text = pair.Value.OnHold
txtRetailPrice.Text = pair.Value.RetailPrice
flag = 1
MessageBox.Show("Inventory number found!!")
Return
End If
Next
If flag = 0 Then
MessageBox.Show("Inventory number not found!!")
End If
End Sub
Private Sub txtRetailPrice_TextChanged(sender As Object, e As
EventArgs) Handles txtRetailPrice.TextChanged
If Not Regex.Match(txtRetailPrice.Text, "^[0-9\.]*$",
RegexOptions.IgnoreCase).Success Then
MessageBox.Show("Please Enter numeric data Only!")
txtRetailPrice.Focus()
txtRetailPrice.Clear()
End If
End Sub
Private Sub txtNoOfItemsOnHold_TextChanged(sender As Object, e
As EventArgs) Handles txtNoOfItemsOnHold.TextChanged
If Not Regex.Match(txtNoOfItemsOnHold.Text, "^[0-9]*$",
RegexOptions.IgnoreCase).Success Then
MessageBox.Show("Please Enter numeric data Only!")
txtNoOfItemsOnHold.Focus()
txtNoOfItemsOnHold.Clear()
End If
End Sub
'Exit button click
Private Sub btnExit_Click(sender As Object, e As EventArgs) Handles
btnExit.Click
Me.Close()
End Sub
End Class
=====================================
Screen 1:Screen when first record is added to
the collection
Screen 2:Screen when record with same inventory number is trying to add into the collection
Get Answers For Free
Most questions answered within 1 hours.