Question: Programming in Visual Basic 2010 Chapter 12 Modify the Very Very Boards project from Chapter 5 to seperate the user interface from the business logic.

Programming in Visual Basic 2010 Chapter 12

Modify the Very Very Boards project from Chapter 5 to seperate the user interface from the business logic. Create a class for each shirt sale with properties for order number, quantity, and size. Use boolean properites for monogram and pocket and a method to calculate the price. Maintain shared read-only properties for the summary information. Display the summary information and the About Box on forms, rather than message boxes. Optional extra: Use visual inheritance for the forms.

Very Very Boards Chapter 5

Modify your case study project from chapter 4 to add a menu and a function procedure. Refer to chapter 4 for project specifications. Write a function procedure to calculate and return the price of shirts; display the About box in a message box. Allow the user to change the font size and font color of the label that displays the company slogan. Include keyboard shortcuts for the menu commands.

Menu: File Sale Display Help

Summary Add to Order Font About

Exit Clear this item Color

Order Complete Slogan

Logo

The slogan logo: Make up a slogan for the company, such as "We're Number One" or "The Best in Boards." The logo should be a graphic ; ou can use an icon, any graphic you have available, or a graphic you create yourself with a draw or paint program. The slogan and logo menu choices must toggle and display a check mark when selected. Fore example, when the slogan is displayed, the slogan menu command is checked. If the user selects the slogan command again, hide the slogan and uncheck the menu command. The slogan and logo commands operate independently; that is, the user may select either, both, or neither item. When the project begins, the slogan and logo must both be displayed and their menu commands appear checked.

Chapter 4

Very Very Boards does a big business in shirts, especially for groups and teams. They need a project that will calculate the price for individual orders, as well as a summary for all orders. The store employee will enter the orders in an order form that has text boxes for customer name and order number. To specify the shirts, use a text box for the quantitiy, radio buttons to select the size(small, medium, large, xlarge, and xxl), and check boxes to specify a monogram and/or a pocket. Display the shirt price for the current order and the order totoal in ReadOnly text boxes or labels. Include buttons to add a shirt to an order, clear the current item, complete the order, and display the summary of all orders. Don not allow the summary to display if the current order is not complete. Also, disable the text boxes for customer name and order number after an order is started; enable them again whn the user clicks on the button to begin a new order. Confirm the operation before clearing the current order. When the user add shirts to an order, validate the quantity, which must be greater than zero. If the entry does not pass the validation, do not perform any calculations but display a message box and allow the user to correct the value. Determine the price of the shirts from the radio buttons and check boxes for the monogram and pockets. Multiply the quantity by the price to determince the extended price, and add to the order total and summary total. Use constants for shirt prices. Display the order summary in a message box. Include the number of shirts, the number of orders, and the dollar total of the orders.

Prices for shirts:

Small, Medium, and Large $10

XLarge $11

XXLarge $12

Monogram $2

Pocket $1

Very Very Boards project starts at the begining of the book here is the code I was going to modify which is from chapter 6:

Form1.vb

Public Class Form1 'declare module level constants Const smlMedLg As Decimal = 10D Const exLarge As Decimal = 11D Const xxLarge As Decimal = 12D Const monogram As Decimal = 2D Const pocket As Decimal = 1D 'declare variables for summary Friend qtyShirts, numOrders As Integer Friend total, totalAllOrders As Decimal

Private Sub addItemButton_Click(sender As Object, e As EventArgs) Handles addItemButton.Click 'add shirt to order

Dim oneShirt, shirtPrice As Decimal Dim qtyInteger As Integer Dim MessageString As String

'convert quantity Try qtyInteger = Integer.Parse(quantityTextBox.Text)

'only except a value > 0

If qtyInteger > 0 Then If smallRadioButton.Checked Or mediumRadioButton.Checked Or largeRadioButton.Checked Or xLargeRadioButton.Checked Or xxlRadioButton.Checked Then

custNameTextBox.Enabled = False orderNumTextBox.Enabled = False completeButton.Enabled = True summaryButton.Enabled = True

'Determine the price of the shirt If smallRadioButton.Checked Or mediumRadioButton.Checked Or largeRadioButton.Checked Then oneShirt = smlMedLg ElseIf xLargeRadioButton.Checked Then oneShirt = exLarge Else oneShirt = xxLarge End If If monogramCheckBox.Checked = True Then oneShirt = monogram + oneShirt End If If pocketCheckBox.Checked = True Then oneShirt = pocket + oneShirt End If

'Calculate totals to display on the form shirtPrice = oneShirt * qtyInteger total += shirtPrice

'Calculate totals for the summary qtyShirts += qtyInteger totalAllOrders += shirtPrice

'Display the shirt price and total for this customer shirtPriceTextBox.Text = shirtPrice.ToString("C") orderTotalTextBox.Text = total.ToString("C") Else MessageString = "Please select a shirt size." MessageBox.Show(MessageString, "Selection Required", MessageBoxButtons.OK, MessageBoxIcon.Error) End If Else MessageString = "Please enter a number greater than zero." MessageBox.Show(MessageString, "Input Quantity", MessageBoxButtons.OK, MessageBoxIcon.Error) With quantityTextBox .Focus() .SelectAll() End With End If Catch QuantityException As FormatException MessageString = "Please enter the number of shirts." MessageBox.Show(MessageString, "Input Needed", MessageBoxButtons.OK, MessageBoxIcon.Error) With quantityTextBox .Focus() .SelectAll() End With Catch AnyException As Exception MessageBox.Show("Error: " & AnyException.Message) End Try

End Sub

Private Sub clearButton_Click(sender As Object, e As EventArgs) Handles clearButton.Click 'clear the appropriate fields shirtPriceTextBox.Clear() orderNumTextBox.Clear() orderTotalTextBox.Clear() monogramCheckBox.Checked = False pocketCheckBox.Checked = False smallRadioButton.Checked = False mediumRadioButton.Checked = False largeRadioButton.Checked = False xLargeRadioButton.Checked = False xxlRadioButton.Checked = False With quantityTextBox .Clear() .Focus() End With qtyShirts = 0 totalAllOrders = 0 numOrders = 0 End Sub

Private Sub completeButton_Click(sender As Object, e As EventArgs) Handles completeButton.Click 'Clear this customer and begin a new order Dim replyDialogResult As DialogResult Dim messageString As String

MessageString = "Do you wish to complete this order?" ReplyDialogResult = MessageBox.Show(MessageString, "Confirmation Required", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) If ReplyDialogResult = DialogResult.Yes Then custNameTextBox.Clear() orderNumTextBox.Clear() quantityTextBox.Clear() shirtPriceTextBox.Clear() orderTotalTextBox.Clear() smallRadioButton.Checked = False mediumRadioButton.Checked = False largeRadioButton.Checked = False xLargeRadioButton.Checked = False xxlRadioButton.Checked = False monogramCheckBox.Checked = False pocketCheckBox.Checked = False

total = 0 numOrders += 1

custNameTextBox.Enabled = True orderNumTextBox.Enabled = True completeButton.Enabled = False summaryButton.Enabled = True custNameTextBox.Focus() End If End Sub

Private Sub summaryButton_Click(sender As Object, e As EventArgs) Handles summaryButton.Click 'calculates summary and shows summary form Dim MessageString As String

If total > 0 Then MessageString = "The current order is not included in the summary." MessageBox.Show(MessageString, "Please complete the order!", MessageBoxButtons.OK, MessageBoxIcon.Information) Else MessageString = "Total Shirts Ordered: " & qtyShirts.ToString("N") & Environment.NewLine & "Number of Orders: " & numOrders.ToString("N") & Environment.NewLine & "Total of All Orders: " & totalAllOrders.ToString("C") Summary.ShowDialog() End If End Sub

Private Sub printButton_Click(sender As Object, e As EventArgs) Handles printButton.Click 'Print the form

PrintForm1.PrintAction = Printing.PrintAction.PrintToPreview PrintForm1.Print() End Sub

Private Sub exitButton_Click(sender As Object, e As EventArgs) Handles exitButton.Click 'exit the program

Me.Close()

End Sub

Private Sub SummaryToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles SummaryToolStripMenuItem.Click 'calculates summary and shows summary form Dim MessageString As String

If total > 0 Then MessageString = "The current order is not included in the summary." MessageBox.Show(MessageString, "Please complete the order!", MessageBoxButtons.OK, MessageBoxIcon.Information) Else MessageString = "Total Shirts Ordered: " & qtyShirts.ToString("N") & Environment.NewLine & "Number of Orders: " & numOrders.ToString("N") & Environment.NewLine & "Total of All Orders: " & totalAllOrders.ToString("C") Summary.ShowDialog() End If

End Sub

Private Sub ExitToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles ExitToolStripMenuItem.Click 'exit the program

Me.Close()

End Sub

Private Sub AddItemToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles AddItemToolStripMenuItem.Click 'add shirt to order

Dim oneShirt, shirtPrice As Decimal Dim qtyInteger As Integer Dim MessageString As String

'convert quantity Try qtyInteger = Integer.Parse(quantityTextBox.Text)

'only except a value > 0

If qtyInteger > 0 Then If smallRadioButton.Checked Or mediumRadioButton.Checked Or largeRadioButton.Checked Or xLargeRadioButton.Checked Or xxlRadioButton.Checked Then

custNameTextBox.Enabled = False orderNumTextBox.Enabled = False completeButton.Enabled = True summaryButton.Enabled = True

'Determine the price of the shirt If smallRadioButton.Checked Or mediumRadioButton.Checked Or largeRadioButton.Checked Then oneShirt = smlMedLg ElseIf xLargeRadioButton.Checked Then oneShirt = exLarge Else oneShirt = xxLarge End If If monogramCheckBox.Checked = True Then oneShirt = monogram + oneShirt End If If pocketCheckBox.Checked = True Then oneShirt = pocket + oneShirt End If

'Calculate totals to display on the form shirtPrice = oneShirt * qtyInteger total += shirtPrice

'Calculate totals for the summary qtyShirts += qtyInteger totalAllOrders += shirtPrice

'Display the shirt price and total for this customer shirtPriceTextBox.Text = shirtPrice.ToString("C") orderTotalTextBox.Text = total.ToString("C") Else MessageString = "Please select a shirt size." MessageBox.Show(MessageString, "Selection Required", MessageBoxButtons.OK, MessageBoxIcon.Error) End If Else MessageString = "Please enter a number greater than zero." MessageBox.Show(MessageString, "Input Quantity", MessageBoxButtons.OK, MessageBoxIcon.Error) With quantityTextBox .Focus() .SelectAll() End With End If Catch QuantityException As FormatException MessageString = "Please enter the number of shirts." MessageBox.Show(MessageString, "Input Needed", MessageBoxButtons.OK, MessageBoxIcon.Error) With quantityTextBox .Focus() .SelectAll() End With Catch AnyException As Exception MessageBox.Show("Error: " & AnyException.Message) End Try End Sub

Private Sub ClearItemToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles ClearItemToolStripMenuItem.Click 'clear the appropriate fields shirtPriceTextBox.Clear() orderNumTextBox.Clear() orderTotalTextBox.Clear() monogramCheckBox.Checked = False pocketCheckBox.Checked = False smallRadioButton.Checked = False mediumRadioButton.Checked = False largeRadioButton.Checked = False xLargeRadioButton.Checked = False xxlRadioButton.Checked = False With quantityTextBox .Clear() .Focus() End With qtyShirts = 0 totalAllOrders = 0 numOrders = 0 End Sub

Private Sub OrderCompleteToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles OrderCompleteToolStripMenuItem.Click 'Clear this customer and begin a new order Dim replyDialogResult As DialogResult Dim messageString As String

messageString = "Do you wish to complete this order?" replyDialogResult = MessageBox.Show(messageString, "Confirmation Required", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) If replyDialogResult = DialogResult.Yes Then custNameTextBox.Clear() orderNumTextBox.Clear() quantityTextBox.Clear() shirtPriceTextBox.Clear() orderTotalTextBox.Clear() smallRadioButton.Checked = False mediumRadioButton.Checked = False largeRadioButton.Checked = False xLargeRadioButton.Checked = False xxlRadioButton.Checked = False monogramCheckBox.Checked = False pocketCheckBox.Checked = False

total = 0 numOrders += 1

custNameTextBox.Enabled = True orderNumTextBox.Enabled = True completeButton.Enabled = False summaryButton.Enabled = True custNameTextBox.Focus() End If End Sub

Private Sub FontToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles FontToolStripMenuItem.Click Dim fntDialog As New FontDialog

With fntDialog .Font = sloganLabel.Font .ShowDialog() sloganLabel.Font = .Font End With End Sub

Private Sub ColorToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles ColorToolStripMenuItem.Click Dim colorDialog As New ColorDialog

With colorDialog .ShowDialog() sloganLabel.ForeColor = .Color End With End Sub

Private Sub SloganToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles SloganToolStripMenuItem.Click 'toggles slogan on and off

If SloganToolStripMenuItem.Checked Then sloganLabel.Visible = True Else sloganLabel.Visible = False End If

End Sub

Private Sub LogoToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles LogoToolStripMenuItem.Click 'toggles logo on and off

If LogoToolStripMenuItem.Checked Then logoPictureBox.Visible = True Else logoPictureBox.Visible = False End If End Sub

Private Sub AboutToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles AboutToolStripMenuItem.Click 'the about menu options shows the name of the program and the name of the programmer

AboutBox1.ShowDialog()

End Sub

Summary.vb

Public Class Summary

Private Sub Summary_Load(ByVal sender As System.Object, ByVal e As EventArgs) Handles MyBase.Activated

totalShirtsOrderedLabel.Text = Form1.qtyShirts.ToString() numOrdersLabel.Text = Form1.numOrders.ToString() totalAllOrdersLabel.Text = Form1.totalAllOrders.ToString("C")

End Sub

Private Sub summaryOKButton_Click(sender As Object, e As EventArgs) Handles summaryOKButton.Click 'closes summary form and returns to main form

Me.Close()

End Sub

End Class

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!