Create a project to keep track of concert ticket sales by your club. Ticket prices are based on the seating location. Use an array to hold the price of each type of seats.
Do not allow the user to receive an exception for subscript out-of-range.
Your program should calculate the total tickets sold for each section for each member of the club (at least 10 members). The club member’s name and the number of tickets sold for each section should be in a text file (Use the order as shown in the table below.
If a member did not sell any tickets for that section use 0 as the entry), The program
should read this text file and then create an array with the information, (Use the Split Method).
The program should create a Two- dimensional array of the results (The original array plus the total tickets sold and total income for each member (2 more columns) Display the Ticket price schedule. Display the final array in a list box. The last line should have the totals.
Use a LINQ query (Must have Option Infer at top) to find the members with the top five Sales Display this on a Summary form
Use Good Programming Practices: Such an appropriate splash screen, an about box, and menus. Make sure that you use comments throughout the code
Type of seating Price per seat
Orchestra 40.00
Mezzanine 27.50
General I 15.00
Balcony 10.00
What I have tried:
I tries the following code but the question says to get the array through text-file and also LINQ query. If you read the question you'll get it.
Public Class MainForm
Friend PriceDecimal() As Decimal = {40D, 27.5D, 15D, 10D}
Friend SectionString() As String = {"Orchestra", "Mezzanine", "General", "Balcony"}
Friend NumberInteger As Integer
Friend TotalTicketsInteger(3) As Integer
Private Sub AboutToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AboutToolStripMenuItem.Click
AboutBox1.ShowDialog()
End Sub
Private Sub ExitToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ExitToolStripMenuItem.Click
Me.Close()
End Sub
Private Sub ClearToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ClearToolStripMenuItem.Click
NumberTextBox.Clear()
PurchaseInfoLabel.Text = ""
AmountDueTextBox.Clear()
With SelectionListBox
.SelectedIndex = -1
.Focus()
End With
End Sub
Private Sub DisplayPricesToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DisplayPricesToolStripMenuItem.Click
For i = 0 To 3
PriceScheduleForm.PriceScheduleListBox.Items.Add(SectionString(i) & " " & PriceDecimal(i).ToString("C"))
Next
PriceScheduleForm.ShowDialog()
End Sub
Private Sub PrintSummaryToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PrintSummaryToolStripMenuItem.Click
PrintPreviewDialog1.Document = PrintDocument1
PrintPreviewDialog1.ShowDialog()
End Sub
Private Sub PrintDocument1_PrintPage(ByVal sender As System.Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles PrintDocument1.PrintPage
Dim PrintFont As New Font("Arial", 12)
Dim LineHeightSingle As Single = PrintFont.GetHeight + 2
Dim HorizontalPrintLocationSingle As Single = 250
Dim VerticalPrintLocationSingle As Single = e.MarginBounds.Top
Dim ColumnEndSingle As Single
Dim ColumnXSingle As Single
Dim FontSizeF As New SizeF
Dim FormattedOutputString As String
Dim SalesAmountDecimal(3) As Decimal
Dim TotalSalesDecimal As Decimal
Using HeadingFont As New Font("Arial", 16, FontStyle.Bold)
e.Graphics.DrawString("Summary of Ticket Sales", HeadingFont, Brushes.Black, HorizontalPrintLocationSingle, VerticalPrintLocationSingle)
VerticalPrintLocationSingle += LineHeightSingle * 2
End Using
e.Graphics.DrawString("Section", PrintFont, Brushes.Black, HorizontalPrintLocationSingle, VerticalPrintLocationSingle)
HorizontalPrintLocationSingle += 100
e.Graphics.DrawString("# Tickets", PrintFont, Brushes.Black, HorizontalPrintLocationSingle, VerticalPrintLocationSingle)
HorizontalPrintLocationSingle += 100
e.Graphics.DrawString("Ticket Price", PrintFont, Brushes.Black, HorizontalPrintLocationSingle, VerticalPrintLocationSingle)
HorizontalPrintLocationSingle += 100
e.Graphics.DrawString("Sales Amount", PrintFont, Brushes.Black, HorizontalPrintLocationSingle, VerticalPrintLocationSingle)
HorizontalPrintLocationSingle += 100
VerticalPrintLocationSingle += LineHeightSingle
For IndexInteger = 0 To 3
HorizontalPrintLocationSingle = 250
e.Graphics.DrawString(Me.SelectionListBox.Items(IndexInteger).ToString, PrintFont, Brushes.Black, HorizontalPrintLocationSingle, VerticalPrintLocationSingle)
HorizontalPrintLocationSingle += 100
ColumnEndSingle = 400
FormattedOutputString = TotalTicketsInteger(IndexInteger).ToString
FontSizeF = e.Graphics.MeasureString(FormattedOutputString, PrintFont)
ColumnXSingle = ColumnEndSingle - FontSizeF.Width
e.Graphics.DrawString(FormattedOutputString, PrintFont, Brushes.Black, ColumnXSingle, VerticalPrintLocationSingle)
HorizontalPrintLocationSingle += 100
e.Graphics.DrawString(FormatCurrency(PriceDecimal(IndexInteger), 2), PrintFont, Brushes.Black, HorizontalPrintLocationSingle, VerticalPrintLocationSingle)
HorizontalPrintLocationSingle += 100
SalesAmountDecimal(IndexInteger) = TotalTicketsInteger(IndexInteger) * PriceDecimal(IndexInteger)
TotalSalesDecimal += SalesAmountDecimal(IndexInteger)
e.Graphics.DrawString(FormatCurrency(SalesAmountDecimal(IndexInteger), 2), PrintFont, Brushes.Black, HorizontalPrintLocationSingle, VerticalPrintLocationSingle)
VerticalPrintLocationSingle += LineHeightSingle
Next
HorizontalPrintLocationSingle = 500
VerticalPrintLocationSingle += LineHeightSingle * 2
e.Graphics.DrawString("Total Sales: " & FormatCurrency(TotalSalesDecimal, 2), PrintFont, Brushes.Black, HorizontalPrintLocationSingle, VerticalPrintLocationSingle)
End Sub
Private Sub PurchaseTicketsToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PurchaseTicketsToolStripMenuItem.Click
Dim SelectionString As String
Dim SelectedPriceDecimal As Decimal
Try
NumberInteger = Integer.Parse(NumberTextBox.Text)
Try
SelectionString = SelectionListBox.SelectedItem
SelectedPriceDecimal = PriceDecimal(SelectionListBox.Items.IndexOf(SelectionString))
TotalTicketsInteger(SelectionListBox.Items.IndexOf(SelectionString)) += NumberInteger
PurchaseInfoLabel.Text = "Purchased " & NumberInteger & " ticket(s) at " & FormatCurrency(SelectedPriceDecimal, 2) & " per ticket"
AmountDueTextBox.Text = FormatCurrency((NumberInteger * SelectedPriceDecimal), 2)
Catch SectionException As FormatException
MessageBox.Show("You must first select a seating section.", "Missing Data", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
SelectionListBox.Focus()
End Try
Catch NumberException As FormatException
MessageBox.Show("Enter desired number of tickets.", "Missing Data", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
With NumberTextBox
.Focus()
.SelectAll()
End With
End Try
End Sub
Private Sub frmTicketSales_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
For i = 0 To 3
SelectionListBox.Items.Add(SectionString(i))
Next
End Sub
End Class