Solved

Select oldest record do some action then go to the next oldest record and do some action in vb.net

Posted on 2014-04-30
1
167 Views
Last Modified: 2014-05-01
Hi all.

I'm working on a vb.net script in Visual Studio 2010 that needs to go through a collection of records and do some action and then move on to the next until the Quantity = 0.

Each record is a "picking order" each order has a order date, product and order amount.

Picking Order----OrderDate---Product---OrderAmount
123----04/01/2014---ABC---50
456---04/03/2014---ABC---20
789---04/05/2014---ABC---60

The Quantity field is the amount we have in stock for the product. In my example, product ABC the Quantity = 60

So, I need to be able to loop through my picking orders and begin slotting the quantity I have into each picking order beginning with the oldest one.

Using my example,

(1) I start with Quantity = 60, and apply 50 to Picking Order 123 thus closing that one. And now I have Quantity = 10
(2) Then I move on to the second oldest picking order, in this case 456, and apply the remaining Quantity of 10 to it, thus making picking order 456 have an order amount of 10.
(3) If there is only 1 picking order then apply the 50 it needs and place the remaining quantity of 10 in a field called "overage", or if there only 2 picking orders and we've closed them both out and still have some "overage" then apply that "overage" to the last blanket order (in this case the second one).

The picking orders are pulled from a query to the database:

Select * From PickingOrders Where ItemNumber = "the item number I'm analyzing"

Any idea how I can do this? I was thinking a do while loop or do until loop, but need some syntax guidance.

Thank you in advance!
0
Comment
Question by:printmedia
1 Comment
 
LVL 16

Accepted Solution

by:
Kamal Khaleefa earned 500 total points
Comment Utility
hi

first make a sql query to select all the orders from data base ordered by OrderDate ascending

then take each order and process it and put a flag that it is processed

assign the quantity and update the remaining
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

This article explains how to create and use a custom WaterMark textbox class.  The custom WaterMark textbox class allows you to set the WaterMark Background Color and WaterMark text at design time.   IMAGE OF WATERMARKS STEPS Create VB …
Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now