Question
vb.net Form 1: Working with Structures and a Structure Array with LINQs: This form will have three events : Load event and two button click
vb.net
Form 1: Working with Structures and a Structure Array with LINQs:
This form will have three events: Load event and two button click events (queries).
Before you begin working on your code, you need to create a text file and name it Pastries.txt.
Each record is composed of the following field:
Item Id First letter indicates category the items is in: M Muffins, D Doughnuts, S Specialty Items.
Item Description
Cost to Produce
Selling Price
Qty on Hand
Qty Sold to-date this Month
Sample Records:
M001,Lemon Poppy Seed Muffin,.89,2.50,10,38
D101,Glazed Doughnut,.25,1.00,28,120
S203,Bear Claws,.65,2.00,6,42
S205,Apple Fritters,.98,3.00,4,36
This program is to create a UDT (User Defined Type) Structure that will define the layout of the records that are found in the Pastries.txt file.
The structure name should be Pastry.
Each field that exists in the Pastries.txt files records should be included in the Structure.
They should be given meaningful names and appropriate data types should be used.
This program will work with a class level structure array named pastries that needs to be created before the events can work with it.
Load Event:
Populate the String array from the Pastries.txt file using the ReadAllLines method then
Set a size for the structure array, pastries (using ReDim)
Populate the structure array, pastries from the String array using a For loop.
First Button Click Event:
This event must use a LINQ to order the pastry items from the structure array, pastries into alphabetical order based on the Item Description.
The output should include all six fields for all records in the file.
The query results should be displayed in a DataGridView control.
Columns should be given meaningful header text.
Second Button Click Event:
This event must use a LINQ to order the pastry items from the structure array, pastries into descending Selling Price order then Item Description ascending order.
The profit for each pastry must be calculated (selling price - cost to produce).
The output should include the profit along with Item Id, Item Description, and Selling Price.
The query results should be displayed in a DataGridView control.
Columns should be given meaningful header text.
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