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
170 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
ID: 40033874
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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

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…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

856 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