Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please help me Im having trouble getting the second button to work. here is my assignment: here is my code: Public Class frmPastries Structure pastries

Please help me Im having trouble getting the second button to work.

here is my assignment:

image text in transcribedhere is my code:

Public Class frmPastries Structure pastries Dim Id As String Dim Description As String Dim productionCost As String Dim Price As String Dim Qty As String Dim QtySold As String End Structure Dim Pastry() As pastries Private Sub frmPastries_Load(sender As Object, e As EventArgs) Handles MyBase.Load Dim strPastries() As String = IO.File.ReadAllLines("Pastries.txt") ReDim Pastry(strPastries.Count - 1) Dim Line As String Dim Data() As String For i As Integer = 0 To strPastries.Count - 1 lstDisplay.Items.Add(strPastries(i)) Line = strPastries(i) Data = Line.Split(","c) Pastry(i).Id = Data(0) Pastry(i).Description = Data(1) Pastry(i).ProductionCost = Data(2) Pastry(i).Price = Data(3) Pastry(i).Qty = Data(4) Pastry(i).QtySold = Data(5) Next End Sub Private Sub btnOrganize_Click(sender As Object, e As EventArgs) Handles btnOrganize.Click Dim pastryQuery = From pastries In Pastry Order By pastries.Description Ascending Select pastries.Description, pastries.Id, pastries.productionCost, pastries.Price, pastries.Qty, pastries.QtySold dgvDisplay.DataSource = pastryQuery.ToList dgvDisplay.Columns("Id").HeaderText = "Item Id" dgvDisplay.Columns("Description").HeaderText = "Item Description" dgvDisplay.Columns("productionCost").HeaderText = "Cost to Produce" dgvDisplay.Columns("Price").HeaderText = "Selling Price" dgvDisplay.Columns("Qty").HeaderText = "Qty on Hand" dgvDisplay.Columns("QtySold").HeaderText = "Qty Sold to-date this Month" End Sub Private Sub btnProfit_Click(sender As Object, e As EventArgs) Handles btnProfit.Click Dim pastryQuery = From pastries In Pastry Order By pastries.Price Descending, pastries.Description Ascending Select pastries.Id, pastries.Description, pastries.Price, pastries.productionCost Dim Profit As String = (pastries.Price - pastries.productionCost)

comments: error code: reference to a non-shared member requires an object.

comments: pastries.Price is underlined. pastries.productionCost is underlined.

dgvDisplay.DataSource = pastryQuery.ToList dgvDisplay.Columns("Id").HeaderText = "Item Id" dgvDisplay.Columns("Description").HeaderText = "Item Description" dgvDisplay.Columns("Profit").HeaderText = "sellingPrice-productionCost" dgvDisplay.Columns("Price").HeaderText = "Selling Price" End Sub End Class

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) then... 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. 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) then... 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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions