Question

Create an application (in C++) that stores Inventory records for a retail store. The application should...

Create an application (in C++) that stores Inventory records for a retail store.

The application should have an Inventory class with the following properties:

  • InvNumber: A string used to hold an inventory number. Each item in the inventory should have a unique inventory number.
  • Description: A string that holds a brief description of the item.
  • Cost: A decimal value that holds the amount that the retail store paid for the item.
  • Retail: A decimal value that holds the retail price for the item.
  • OnHand: An integer value that holds the number of items on hand. This value cannot be less than 0.

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.

Homework Answers

Answer #1

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

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
Goal:   Manage the inventory of objects sold in an online or brick and mortar store. If...
Goal:   Manage the inventory of objects sold in an online or brick and mortar store. If you can't implement all of the features of Project described in this document, implement what you can. Start by implementing the StockItem class, and its derived classes. Then add in the InventoryManager class later. In each case, the test files must be in separate classes. UML Diagram: Use Violet or other drawing software to draw the UML diagrams of each class that you use...
Create a C# application You are to create a class object called “Employee” which included eight...
Create a C# application You are to create a class object called “Employee” which included eight private variables: firstN lastN dNum wage: holds how much the person makes per hour weekHrsWkd: holds how many total hours the person worked each week. regHrsAmt: initialize to a fixed amount of 40 using constructor. regPay otPay After going over the regular hours, the employee gets 1.5x the wage for each additional hour worked. Methods:  constructor  properties  CalcPay(): Calculate the regular...
--USING C# ONLY-- You will create your own on-line shopping store in the console application. You...
--USING C# ONLY-- You will create your own on-line shopping store in the console application. You can choose different products to sell in your store (at least 8 products). You will create an product inventory text file. The program will display two options at the beginning of the program, Customer and Manager. Customer: If this is a new customer, the program will allow the customer to register with their information and assign a unique ID number to the new customer....
Lists are members of a general category of abstract data types (ADTs) called containers (i.e., objects...
Lists are members of a general category of abstract data types (ADTs) called containers (i.e., objects whose purpose is to hold other objects). A list is a collection of items having the following defining characteristics: Homogeneity: All the items are of the same type. Linearity: Each item has a unique predecessor (except the first) and a unique successor (except the last). Variable Length: The number of items can vary over time. Order: Items may be ordered (i.e., as in a...
Create a simple Java class for a Month object with the following requirements:  This program...
Create a simple Java class for a Month object with the following requirements:  This program will have a header block comment with your name, the course and section, as well as a brief description of what the class does.  All methods will have comments concerning their purpose, their inputs, and their outputs  One integer property: monthNumber (protected to only allow values 1-12). This is a numeric representation of the month (e.g. 1 represents January, 2 represents February,...
In this assignment, you’ll make an inventory system for a store’s items, including produce and books....
In this assignment, you’ll make an inventory system for a store’s items, including produce and books. The starter program is an inventory system for only produce. 1. Include the price of an item by adding to the Item class the protected data member int priceInDollars that stores the price in dollars of an individual item. Write a public function SetPrice with a single int parameter prcInDllrs and returns nothing. SetPrice assigns the value of prcInDllrs to priceInDollars. Modify the AddItemToInventory...
This is C++ Note, for part 2 of this assignment, you DO NOT NEED to use...
This is C++ Note, for part 2 of this assignment, you DO NOT NEED to use arrays or vectors. All changes, calculations, etc should be performed in place ( in the file). You may need one or two structures that temporary hold data needed to be displayed, changed, etc. Part 2: Binary Files Write a program that uses a structure to store the following inventory data in a file: The data can be either read from a text file or...
Cpp Task: Create a class called Mixed. Objects of type Mixed will store and manage rational...
Cpp Task: Create a class called Mixed. Objects of type Mixed will store and manage rational numbers in a mixed number format (integer part and a fraction part). Details and Requirements Your class must allow for storage of rational numbers in a mixed number format. Remember that a mixed number consists of an integer part and a fraction part (like 3 1/2 – “three and one-half”). The Mixed class must allow for both positive and negative mixed number values. A...
in jGRASP INVENTORY CLASS You need to create an Inventory class containing the private data fields,...
in jGRASP INVENTORY CLASS You need to create an Inventory class containing the private data fields, as well as the methods for the Inventory class (object). Be sure your Inventory class defines the private data fields, at least one constructor, accessor and mutator methods, method overloading (to handle the data coming into the Inventory class as either a String and/or int/float), as well as all of the methods (methods to calculate) to manipulate the Inventory class (object). The data fields...
Write the Game class, Java lanuage. A Game instance is described by three instance variables: gameName...
Write the Game class, Java lanuage. A Game instance is described by three instance variables: gameName (a String), numSold (an integer that represents the number of that type of game sold), and priceEach (a double that is the price of each of that type of Game). I only want three instance variables!! The class should have the following methods: A constructor that has two parameter – a String containing the name of the Game and a double containing its price....