Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Create and use an Inventory Item class In this exercise, you ll add a class to an Inventory Maintenance application and then add code to
Create and use an Inventory Item class
In this exercise, youll add a class to an Inventory Maintenance application and then add code to the two forms that use this class.
Open the project and add an InvItem class
Extract the provided start project W Exercise Start.zip Then, review the existing code for both of the forms so you get an idea of how this application should work.
Add a class named InvItem to this project, and add the properties, method, and constructors that are shown in the table below.
Property Description
ItemNo Gets or sets an int that contains the items number.
Description Gets or sets a string that contains the items description.
Price Gets or sets a decimal that contains the items price.
Method Description
GetDisplayText Returns a string that contains the items number, description, and price formatted like this:
Agapanthus $The item number and description are separated by four spaces.
Constructor Description
Creates an InvItem object with default values.
itemNo Creates an InvItem object with the specified values.
description, price
CIS W W Exercise Classes, Structures, and Records Page of
Add code to implement the New Item form
Display the code for the New Item form, and declare a class variable named invItem of type InvItem with an initial value of null.
Add a public method named GetNewItem that displays the form as a dialog box and returns an InvItem object.
Add code to the btnSaveClick event handler that creates a new InvItem object and closes the form if the data is valid.
Add code to implement the Inventory Maintenance form
Display the code for the Inventory Maintenance form, and declare a class variable named invItems of type List with an initial value of null.
Add a statement to the frmInvMaintLoad event handler that uses the GetItems method of the InvItemDB class to load the items list.
Add code to the FillItemListBox method that adds the items in the list to the Items list box. Use the GetDisplayText method of the InvItem class to format the item data.
Add code to the btnAddClick event handler that creates a new instance of the New Item form and executes the GetNewItem method of that form. If the InvItem object thats returned by this method is not null, this event handler should add the new item to the list, call the SaveItems method of the InvItemDB class to save the list, and then refresh the Items list box. Test the application to be sure this event handler works.
Add code to the btnDeleteClick event handler that removes the selected item from the list, calls the SaveItems method of the
InvItemDB class to save the list, and refreshes the Items list box. Be sure to confirm the delete operation. Then, test the application to be sure this event handler works.
CreCIS W W Exercise Classes, St ructures, and Records
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started