Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Code in c# . please keep in mind that I am a complete beginner. Review the code Open the InventoryMaintenance project You may need to
Code in c# please keep in mind that I am a complete beginner.
Review the code
Open the InventoryMaintenance project
You may need to set the property of the txt file to "Content" and "Copy Always" or "Copy if newer" in the file's properties window
Display the code for the InvItemList class and note that it contains a readonly property named DisplayText.
Display the code for the Inventory Maintenance form and review the code that loads the items in the combo box and the code that executes when the selected item in the combo box is changed.
Run the application and view the items in the combo box. Notice that nothing happens when you change the selected item. Exit the application.
Add code that sorts and filters the inventory items
Find the FillItemListBox method in the Inventory Maintenance form. It starts by storing the selected value of the combo box in a variable named filter and declaring a local collection of InvItem objects named filteredItems.
Code an ifelse statement that uses LINQ to query the classlevel collection named invItems based on the value of the filter variable. The LINQ queries should also order the inventory items by Description. Assign the result of each LINQ query to the filteredItems collection. Note: You can use methodbased queries or query expressions here.
Update the foreach statement so it loops through the local filteredItems collection rather than the classlevel invItems collection.
Test the application to be sure it displays the items in alphabetical order and filters the items by price when the selected item in the combo box changes.
Add the following new item to the inventory: ItemNo: Description: Creeping Phlox Price: Notice that the new item is sorted so it appears alphabetically in the display. Use the combo box to show items whose price is between $ and $ and see that the new item is displayed. When youre done, exit the application.
Open the InventoryItems.txt file and see that the items arent in alphabetical order, and that the item you just added is the last item in the file
Add code that uses LINQ to find the inventory item to delete
Run the application, select the item you added and click Delete. Note that the confirmation message identifies the wrong item for deletion. Click Cancel and exit the application.
Display the btnDeleteClick event handler in the Inventory Maintenance form and comment out the line of code that uses the selected index value of the ListView control to get the selected InvItem object from the invItems collection.
Add code that uses that selected index value to retrieve the display text of the selected item from the Items collection of the ListView control.
Use a LINQ query to get the selected InvItem object from the InvItems collection. The LINQ query should select the item whose DisplayText property is equal to the display text value you just retrieved. Note: To do this, you need to use the First or FirstOrDefault method. Because of that, you should code this as a methodbased query.
Run the application and try to delete the item you added in step This time, the confirm message should present the correct inventory item. Click OK to delete the item and exit the application STUDENT: FillItemListBox Must have Correct Coding and Edit Code for btnDeleteClick according to directions above. I also have picture of code I put provided but the code is incomplete and not functioning at all. Please help me fix the code to function correctly.
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