Welcome to Dream.In.Code
Become a VB.NET Expert!

Join 150,230 VB.NET Programmers for FREE! Get instant access to thousands of VB.NET experts, tutorials, code snippets, and more! There are 2,304 people online right now. Registration is fast and FREE... Join Now!




Help with Problem (order entry system)

 
Reply to this topicStart new topic

Help with Problem (order entry system)

quakeworld2007
6 Nov, 2007 - 07:49 AM
Post #1

New D.I.C Head
*

Joined: 28 Sep, 2007
Posts: 44


My Contributions
I have this program where employees can login and buy items. I want to make it so they can buy more than one item at a time, but I do not know how. I believe that I am going to need an array to hold all of the items placed. But I do not know where to put it.

Here is my code for when the employee clicks the add button.

CODE


Private Sub btnAdd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnOrder.Click

        OrderDate = Format(Today, "MM/dd/yyyy")
        QuantityOrdered = Convert.ToInt32(Me.QanUPDOWN.Value)

        total = aProduct.GetSalePrice * QuantityOrdered
        aOrder = New Order(aItem.GetSKU, QuantityOrdered, orderDate, FormatCurrency(total), theEmployee)

        Order.Initialize()
      

        aOrder.AddNew()
      
    End Sub


User is offlineProfile CardPM
+Quote Post

Martyr2
RE: Help With Problem (order Entry System)
6 Nov, 2007 - 02:25 PM
Post #2

Programming Theoretician
Group Icon

Joined: 18 Apr, 2007
Posts: 5,660



Thanked: 313 times
Expert In: C/C++, Java, VB, VB.NET, C#, PHP, Web Development, HTML & CSS, Javascript

My Contributions
Well most likely you are going to need to put the array at the class level scope, that is outside the functions but inside the form class (under where it reads public class Form at the top. I suggest you put it there because several functions are going to need access to this list of orders. Your add function is one of them, then you might have an edit and delete and any other function that needs to sum up the order amount.

This array is going to be of your custom order type but might be of your product type, depending on your design. One thing I am not seeing that you might want to review is how you are constructing your order. Your order class should take in product classes to its add function. For example...

CODE

' Create an order
aOrder = new Order("Order for Tom Jones")

' Create some products

prod1 = new Product("Sweater",2,39.99)
prod2 = new Product("Pants",1,54.99)
prod3 = new Product("Hat",1,23.99)

' Add the products to the order
aOrder.addProduct(prod1)
aOrder.addProduct(prod2)
aOrder.addProduct(prod3)


As you can see, Tom Jones bought 2 sweaters, a pair of pants, and a hat and had it placed on his order. Now in the Orders class you are going to have an array there of products defined similar to this...

CODE

Dim OrderProducts(10) as Product


This declares an array of 10 custom products. All that is left is to create your addProduct() function which will take in a product class instance variable, check the array for the next available slot and add in the product. Your order class is going to be a "wrapper" for your products array. The order class will work on the product array doing various things like adding up the number of orders (counting the array), get the order total (loop through the array adding up their values) and add/edit/delete orders from the array.

Hopefully I have shown you the light in the darkness.

Enjoy!

"At DIC we be product / ordering class junkie ninjas!" decap.gif



User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 1/9/09 06:08AM

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter

Live VB.NET Help!

VB.NET Tutorials

Reference Sheets

VB.NET Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month