HELP: Simple POS system in VB .NET

Please support our VB.NET advertiser: $4.95 a Month - ASP.NET Web Hosting – Click Here!
Reply

Join Date: Oct 2007
Posts: 2
Reputation: nitewolfgtr is an unknown quantity at this point 
Solved Threads: 0
nitewolfgtr nitewolfgtr is offline Offline
Newbie Poster

HELP: Simple POS system in VB .NET

 
0
  #1
Oct 13th, 2007
I have a assignment from school that I'm having trouble with. I need the program to beable to do... Can someone help me with what I'm doing wrong?

* Input an order ( NumberOfPizzas and NumberOfCokes)
* Compute the OrderAmount = (NumberOfPizzas * decPIZZAPRICE + NumberOfCokes * decCOKEPRICE)
* Compute SalesTax = OrderAmount * decSALESTAXRATE
* Compute AmountDue = OrderAmount + SalesTax
* Display OrderAmount, SalesTax, AmountDue
* Input AmountPaid
* Compute Change = AmountPaid - AmountDue
* Displays Change
* Allows the user to view all the orders placed and a summary of sales for the day (Cokes and Pizzas, total number and $$ amount, and average sale at a minimum.)



Requirements:
Order class
numberOfPizzas
numberOfCokes

methods
InputOrder
GetAmountDue
GetChangedue

DailySummary
private Orders() as Order
numberOfCokes
numberOfPizzas
totalOfCokes
totalOfPizzas

methods
StoreOrder
GetOrder


Figure 1. Mid-Term UML Class diagram

1. Implement the UML class diagram in figure 1 (25 pts)(Note that you can use an arraylist of Order objects in your DailySummary class to make things simpler)
2. (25 pts) Create an order class and instantiate it for each order placed. The order class should have the following methods (at a minimum, you may decide you need more):
* inputOrder (numberOfPizzas, numberOfCokes)
* getAmountDue (which might use private methods to compute orderAmount & salesTax)
* getChangeDue

3. (25 pts) Create a DailySummary class that stores each order and calculates summary information for the day. Store each order object created in an attribute of the DailySummary class. (hint: use a private arraylist in the DailySummary Class to store your orders. Create accessor methods to store and retrieve order info. Create class variables and methods as needed to retrieve order summary data.

4. Design a form (or forms) with the necessary text boxes and buttons to perform the task.

5. Provide some means by which a user can view a summary of the days orders (which will access your DailySummary class)
6. Use a multi-line textbox for all output. Use appropriate formatting for output. Your output should be very similar to (though not necessarily identical):


4 Pizzas @ 8.99: $35.96
5 Cokes @ .99: $4.95
Order Amount: $40.91
Sales Tax: $2.66
Amount Due: $43.57
Amount Paid: $50.00
Change Due: $6.43

My code...

Order Class
  1. Public Class Order
  2.  
  3. 'Constant variables
  4. Public Const PIZZA_PRICE As Double = 8.99
  5. Public Const COKE_PRICE As Double = 0.99
  6. Public Const SALES_TAX_RATE As Double = 0.065
  7.  
  8. Private numberOfPizzas As Double
  9. Private numberOfCokes As Double
  10. Private amountPaid As Double
  11. Private amountDue As Double
  12. Private changeDue As Double
  13.  
  14. Private theDailySummary As DailySummary
  15.  
  16.  
  17.  
  18. Public Sub New(ByVal aNumberOfPizzas As Double, ByVal aNumberOfCokes As Double, ByVal anAmountPaid As Double)
  19. SetNumberOfPizzas(aNumberOfPizzas)
  20. SetNumberOfCokes(aNumberOfCokes)
  21. SetAmountPaid(anAmountPaid)
  22. OrderAmount()
  23. SalesTax()
  24. SetAmountDue()
  25. SetChangeDue()
  26. End Sub
  27.  
  28. Public Overrides Function ToString() As String
  29. Return numberOfPizzas & " Pizzas @ " & FormatCurrency(PIZZA_PRICE) & ": " & (numberOfPizzas * PIZZA_PRICE) & vbNewLine & _
  30. numberOfCokes & " Cokes @ " & FormatCurrency(COKE_PRICE) & ": " & (numberOfCokes * COKE_PRICE) & vbNewLine & _
  31. " Order Amount: " & FormatCurrency(OrderAmount()) & vbNewLine & _
  32. " Sales Tax: " & FormatCurrency(SalesTax()) & vbNewLine & _
  33. " Amount Due: " & FormatCurrency(amountDue) & vbNewLine & _
  34. " Amount Paid: " & FormatCurrency(amountPaid) & vbNewLine & _
  35. " Change Due: " & FormatCurrency(changeDue)
  36. End Function
  37.  
  38. Public Function OrderAmount() As Double
  39. Dim aOrderAmount As Double
  40. aOrderAmount = (numberOfPizzas * PIZZA_PRICE + numberOfCokes * COKE_PRICE)
  41. Return aOrderAmount
  42. End Function
  43.  
  44. Public Function SalesTax() As Double
  45. Dim aSalesTax As Double
  46. aSalesTax = (OrderAmount() * SALES_TAX_RATE)
  47. Return aSalesTax
  48. End Function
  49.  
  50. Public Function GetAmountDue() As Double
  51. Return amountDue
  52. End Function
  53.  
  54. Public Sub SetAmountDue()
  55. amountDue = OrderAmount() + SalesTax()
  56. End Sub
  57.  
  58. Public Function GetChangeDue() As Double
  59. Return changeDue
  60. End Function
  61.  
  62. Public Sub SetChangeDue()
  63. changeDue = amountPaid - amountDue
  64. End Sub
  65.  
  66. Public Function GetNumberOfPizzas() As Double
  67. Return numberOfPizzas
  68. End Function
  69.  
  70. Public Sub SetNumberOfPizzas(ByVal aNumberOfPizzas As Double)
  71. numberOfPizzas = aNumberOfPizzas
  72. End Sub
  73.  
  74. Public Function GetNumberOfCokes() As Double
  75. Return numberOfCokes
  76. End Function
  77.  
  78. Public Sub SetNumberOfCokes(ByVal aNumberOfCokes As Double)
  79. numberOfCokes = aNumberOfCokes
  80. End Sub
  81.  
  82. Public Function GetAmountPaid() As Double
  83. Return amountPaid
  84. End Function
  85.  
  86. Public Sub SetAmountPaid(ByVal anAmountPaid As Double)
  87. amountPaid = anAmountPaid
  88. End Sub
  89.  
  90. Public Sub SetDailySummary(ByVal aDailySummary As DailySummary)
  91. theDailySummary = aDailySummary
  92. End Sub
  93.  
  94.  
  95. End Class

DailySummary class

  1. Public Class DailySummary
  2. Inherits Order
  3.  
  4. Private orders As New ArrayList()
  5.  
  6. Private totalOfPizzas As Double
  7. Private totalOfCokes As Double
  8. Private summaryDate As Date
  9. Private totalOrderAmount As Double
  10. Private totalAmountDue As Double
  11. Private totalAmountPaid As Double
  12. Private totalChangeDue As Double
  13. Private totalSalesTax As Double
  14.  
  15. Private theOrder As Order
  16.  
  17. Public Sub New(ByVal aNumberOfPizzas As Double, ByVal aNumberOfCokes As Double, ByVal anAmountPaid As Double)
  18. MyBase.New(aNumberOfPizzas, aNumberOfCokes, anAmountPaid)
  19. SetTotalOfCokes(aNumberOfPizzas)
  20. SetTotalOfPizzas(aNumberOfCokes)
  21. SetTotalAmountPaid(anAmountPaid)
  22. SetTotalAmountDue(GetAmountDue())
  23. SetTotalChangeDue(GetChangeDue())
  24. SetTotalSalesTax(SalesTax())
  25. SetTotalOrderAmount(OrderAmount())
  26. AssignOrderToOrder(aNumberOfPizzas, aNumberOfCokes, anAmountPaid)
  27.  
  28.  
  29. End Sub
  30.  
  31. Public Overrides Function ToString() As String
  32. Return totalOfPizzas & " Pizzas @ " & FormatCurrency(PIZZA_PRICE) & ": " & (totalOfPizzas * PIZZA_PRICE) & vbNewLine & _
  33. totalOfCokes & " Cokes @ " & FormatCurrency(COKE_PRICE) & ": " & (totalOfCokes * COKE_PRICE) & vbNewLine & _
  34. " Order Amount: " & FormatCurrency(totalOrderAmount) & vbNewLine & _
  35. " Sales Tax: " & FormatCurrency(totalSalesTax) & vbNewLine & _
  36. " Amount Due: " & FormatCurrency(totalAmountDue) & vbNewLine & _
  37. " Amount Paid: " & FormatCurrency(totalAmountPaid) & vbNewLine & _
  38. " Change Due: " & FormatCurrency(totalChangeDue)
  39. End Function
  40.  
  41. Public Sub StoreOrder(ByVal aOrders As Order)
  42. orders.Add(aOrders)
  43. End Sub
  44.  
  45. 'get accessor methods
  46.  
  47. Public Function GetOrder() As ArrayList
  48. Return orders
  49. End Function
  50.  
  51. Public Function GetTotalOrderAmount() As Double
  52. Return totalOrderAmount
  53. End Function
  54.  
  55. Public Function GetTotalAmountDue() As Double
  56. Return totalAmountDue
  57. End Function
  58.  
  59. Public Function GetTotalAmountPaid() As Double
  60. Return totalAmountPaid
  61. End Function
  62.  
  63. Public Function GetTotalChangeDue() As Double
  64. Return totalChangeDue
  65. End Function
  66.  
  67. Public Function GetTotalSalesTax() As Double
  68. Return totalSalesTax
  69. End Function
  70.  
  71. Public Sub AssignOrderToOrder(ByVal aNumberOfPizzas As Double, ByVal aNumberOfCokes As Double, ByVal anAmountPaid As Double)
  72. Dim order1 As New Order(aNumberOfPizzas, aNumberOfCokes, anAmountPaid)
  73. SetOrder(order1)
  74. order1.SetDailySummary(Me)
  75. End Sub
  76.  
  77. Public Function GetTotalOfPizzas() As Double
  78. Return totalOfPizzas
  79. End Function
  80.  
  81. Public Function GetTotalOfCokes() As Double
  82. Return totalOfCokes
  83. End Function
  84. Public Function GetSummaryDate() As Date
  85. Return summaryDate
  86. End Function
  87.  
  88. 'set accessor methods
  89. Public Sub SetTotalOfPizzas(ByVal aTotalOfPizzas As Double)
  90. totalOfPizzas += aTotalOfPizzas
  91. End Sub
  92.  
  93. Public Sub SetTotalOfCokes(ByVal aTotalOfCokes As Double)
  94. totalOfCokes += aTotalOfCokes
  95. End Sub
  96. Public Sub SetSummarydate(ByVal aSummaryDate As Date)
  97. summaryDate = aSummaryDate
  98. End Sub
  99.  
  100. Public Sub SetOrder(ByVal aOrder As Order)
  101. theOrder = aOrder
  102. End Sub
  103.  
  104. Public Sub SetTotalAmountDue(ByVal aTotalAmountDue As Double)
  105. totalAmountDue += aTotalAmountDue
  106. End Sub
  107.  
  108. Public Sub SetTotalOrderAmount(ByVal aTotalOrderAmount As Double)
  109. totalOrderAmount += aTotalOrderAmount
  110. End Sub
  111.  
  112. Public Sub SetTotalAmountPaid(ByVal aTotalAmountPaid As Double)
  113. totalAmountPaid += aTotalAmountPaid
  114. End Sub
  115.  
  116. Public Sub SetTotalChangeDue(ByVal aTotalChangeDue As Double)
  117. totalChangeDue += aTotalChangeDue
  118. End Sub
  119.  
  120. Public Sub SetTotalSalesTax(ByVal aTotalSalesTax As Double)
  121. totalSalesTax += aTotalSalesTax
  122. End Sub
  123.  
  124.  
  125. End Class

Ordertester class

  1. Public Class OrderTester
  2. Inherits System.Windows.Forms.Form
  3.  
  4. 'Declare order reference variable
  5. Private aDailySummary As DailySummary
  6. Private aOrder As Order
  7.  
  8. 'Declare string variables for numberOfPizzas and numberOfCokes
  9. Private custNumOfPizzas, custNumOfCokes As Double
  10. Private custNumOfPizzas2, custNumOfCokes2 As Double
  11. Private custAmtPaid As Double
  12. Private custAmtPaid2 As Double
  13.  
  14. Private Sub btnTotal_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnTotal.Click
  15. custNumOfPizzas = txtPizza.Text
  16. custNumOfCokes = txtCoke.Text
  17. custAmtPaid = 0
  18.  
  19. Dim order1 As New Order(custNumOfPizzas, custNumOfCokes, custAmtPaid)
  20. txtTotal.Text = (FormatCurrency(order1.GetAmountDue()))
  21. End Sub
  22.  
  23. Private Sub ClearForm()
  24. txtPizza.Text = ""
  25. txtCoke.Text = ""
  26. txtTotal.Text = ""
  27. txtAmtPaid.Text = ""
  28. End Sub
  29.  
  30. 'Private Sub Order()
  31. ' Dim order1 As New Order(custNumOfPizzas, custNumOfCokes, custAmtPaid)
  32. 'End Sub
  33.  
  34. Private Sub btnClear_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClear.Click
  35. ClearForm()
  36. End Sub
  37.  
  38. Private Sub btnClose_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClose.Click
  39. Me.Close()
  40. End Sub
  41.  
  42. Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtOutput.TextChanged
  43.  
  44. End Sub
  45.  
  46. Private Sub btnViewSummary_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
  47. End Sub
  48.  
  49.  
  50.  
  51.  
  52. Private Sub btnPlcOrder_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnPlcOrder.Click
  53.  
  54. custNumOfPizzas = txtPizza.Text
  55. custNumOfCokes = txtCoke.Text
  56. custAmtPaid = txtAmtPaid.Text
  57.  
  58. Dim order1 As New Order(custNumOfPizzas, custNumOfCokes, custAmtPaid)
  59.  
  60. Dim dailySummary As New DailySummary(custNumOfPizzas, custNumOfCokes, custAmtPaid)
  61.  
  62. dailySummary.StoreOrder(order1)
  63.  
  64. txtOutput.Text = dailySummary.ToString
  65.  
  66. txtReceipt.Text = order1.ToString
  67.  
  68. ClearForm()
  69.  
  70.  
  71. End Sub
  72.  
  73.  
  74.  
  75. Private Sub btnViewAllOrders_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
  76.  
  77. End Sub
  78.  
  79. Private Sub txtReceipt_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtReceipt.TextChanged
  80.  
  81. End Sub
  82.  
  83. Private Sub TextBox3_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs)
  84.  
  85. End Sub
  86.  
  87. Private Sub TextBox1_TextChanged_1(ByVal sender As System.Object, ByVal e As System.EventArgs)
  88.  
  89. End Sub
  90. End Class
Reply With Quote Quick reply to this message  
Join Date: Mar 2006
Posts: 121
Reputation: manal is an unknown quantity at this point 
Solved Threads: 17
manal's Avatar
manal manal is offline Offline
Junior Poster

Re: HELP: Simple POS system in VB .NET

 
0
  #2
Oct 14th, 2007
what the error you got ?
"give only what u willing to receive "
Reply With Quote Quick reply to this message  
Join Date: Oct 2007
Posts: 2
Reputation: nitewolfgtr is an unknown quantity at this point 
Solved Threads: 0
nitewolfgtr nitewolfgtr is offline Offline
Newbie Poster

Re: HELP: Simple POS system in VB .NET

 
0
  #3
Oct 14th, 2007
I didn't get any errors. I just can't seem to get the arraylist to keep the history of all the individual orders so I can print a end of day summary receipt.
Reply With Quote Quick reply to this message  
Join Date: Mar 2006
Posts: 121
Reputation: manal is an unknown quantity at this point 
Solved Threads: 17
manal's Avatar
manal manal is offline Offline
Junior Poster

Re: HELP: Simple POS system in VB .NET

 
0
  #4
Oct 14th, 2007
  1. Private Sub btnPlcOrder_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnPlcOrder.Click
  2.  
  3. custNumOfPizzas = txtPizza.Text
  4. custNumOfCokes = txtCoke.Text
  5. custAmtPaid = txtAmtPaid.Text
  6.  
  7. Dim order1 As New Order(custNumOfPizzas, custNumOfCokes, custAmtPaid)
  8.  
  9. Dim dailySummary As New DailySummary(custNumOfPizzas, custNumOfCokes, custAmtPaid)
  10.  
  11. dailySummary.StoreOrder(order1)
  12.  
  13. txtOutput.Text = dailySummary.ToString
  14.  
  15. txtReceipt.Text = order1.ToString
  16.  
  17. ClearForm()
  18.  
  19.  
  20. End Sub

i am not sure if this is your peorblem , but should not you declear dailySummary outside
btnPlcOrder_Click code ??
what i understand that each time you place order a new instance of daily summary will creat , where you need only one where you will store all the orders for the day .
"give only what u willing to receive "
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC