S
Steve Wasser
I posted this buried in another thread, so forgive me for being redundant.
Maybe someone can point me to the right method of doing this.
I'm building a web app that a user will enter a date, and will get daily
inventory from month beginning to that date. It calculates inventory for 44
different petroleum locations (terminals). All the data is stored in SQL
2000. There is one table for opening inventory for the month, each row being
a different terminal, the columns being beginning gallons for each product.
term, inventory_date, unleaded, premium, diesel, ethanol
We have daily activity, which means inventory can be depleted or added:
lifting, adjustment, delivery. Adjustment can be + or -. Like when we buy
more gas from the refinery that adds to our inventory. With me so far? Good.
We keep three tables for activity: lifting, adjustment, delivery. The
inventory activity will need to calculate against that table I mentioned
above. We have a stored procedure that pulls the activity from the three
tables and creates a recordset that looks like:
term, product_type, lifted_date, liftedUnl, liftedPrem, liftedDie,
liftedEth, deliveredUnl, deliveredPrem, deliveredDie, deliveredEth,
adjustedUnl, adjustedPrem, adjustedDie, adjustedEth
Example, if the product_type is G47, which is unleaded, only liftedUnl,
deliveredUnl and adjustedUnl will have data, the rest will be null. The next
line could have Ethanol activity, and so forth.
Since the data isn't structured the same as the table above, I have to
figure out a way of pushing the dataset into something I can use to
calculate against the opening inventory above by date, by terminal.You dizzy
yet? I need to create a report, one "page" per terminal, that shows the
beginning inventory, then any day that had activity show that activity and
subtract from the inventory, then give the total inventory remaining. Its
been suggested to use a Hashtable, or ListArray, which sounds good, but the
execution is eluding me. I have to extract each row from the stored
procedure's dataset, figure out which terminal to calculate against,
calculate it, then present it on the web page. I know it will end up being
deceptively easy, but I am having trouble visualizing how to pivot the data.
I was almost thinking of chunking the dataset into 44 different tables, then
iterating through the stored procedure dataset and storing it in a table
according to terminal, sorting by date. Have I lost you? Like, I'm pretty
new to c#, so a typical example of my type of errors are to assign a datarow
to a list array like this:
foreach (DataRow dr1 in MyTable1.Rows)
{
hashme.Insert(count, dr1);
count++;
}
count = 0;
Of course, I filled hashme with 44 system.data.datarow objects instead of
the actual data. My code is sloppy, redundant, inefficient, and someone
already suggested I refactor the code. Well, I have to write it first before
fixing it.
Maybe someone can point me to the right method of doing this.
I'm building a web app that a user will enter a date, and will get daily
inventory from month beginning to that date. It calculates inventory for 44
different petroleum locations (terminals). All the data is stored in SQL
2000. There is one table for opening inventory for the month, each row being
a different terminal, the columns being beginning gallons for each product.
term, inventory_date, unleaded, premium, diesel, ethanol
We have daily activity, which means inventory can be depleted or added:
lifting, adjustment, delivery. Adjustment can be + or -. Like when we buy
more gas from the refinery that adds to our inventory. With me so far? Good.
We keep three tables for activity: lifting, adjustment, delivery. The
inventory activity will need to calculate against that table I mentioned
above. We have a stored procedure that pulls the activity from the three
tables and creates a recordset that looks like:
term, product_type, lifted_date, liftedUnl, liftedPrem, liftedDie,
liftedEth, deliveredUnl, deliveredPrem, deliveredDie, deliveredEth,
adjustedUnl, adjustedPrem, adjustedDie, adjustedEth
Example, if the product_type is G47, which is unleaded, only liftedUnl,
deliveredUnl and adjustedUnl will have data, the rest will be null. The next
line could have Ethanol activity, and so forth.
Since the data isn't structured the same as the table above, I have to
figure out a way of pushing the dataset into something I can use to
calculate against the opening inventory above by date, by terminal.You dizzy
yet? I need to create a report, one "page" per terminal, that shows the
beginning inventory, then any day that had activity show that activity and
subtract from the inventory, then give the total inventory remaining. Its
been suggested to use a Hashtable, or ListArray, which sounds good, but the
execution is eluding me. I have to extract each row from the stored
procedure's dataset, figure out which terminal to calculate against,
calculate it, then present it on the web page. I know it will end up being
deceptively easy, but I am having trouble visualizing how to pivot the data.
I was almost thinking of chunking the dataset into 44 different tables, then
iterating through the stored procedure dataset and storing it in a table
according to terminal, sorting by date. Have I lost you? Like, I'm pretty
new to c#, so a typical example of my type of errors are to assign a datarow
to a list array like this:
foreach (DataRow dr1 in MyTable1.Rows)
{
hashme.Insert(count, dr1);
count++;
}
count = 0;
Of course, I filled hashme with 44 system.data.datarow objects instead of
the actual data. My code is sloppy, redundant, inefficient, and someone
already suggested I refactor the code. Well, I have to write it first before
fixing it.