I need help with this situation:
Table: OrderHeader
Table: OrderLines with fields: qty,price
In a listview i wanna see the list of table OrderHeader with a column total=sum(qty*price) for all lines of this order.
What is the best approach?
-Use a SQL to retrieve the value for each OrderHeader.
- Can i create a property Total in OrderLines, mark it as proxy and retrieve it with orderheaders?
- More....
-What do you think???
thanks
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Well, the best option is really up to you. However I would probably do something like the following:
1. Add a total column to both the order header and the order lines. (I'm a fan or "practical" database schemas)
2. Change the order line object so that when qty or price is updated both the line total and header totals get updated. Don't foget to handle line deletion as well.
3. Ensure that the association between orderlines and orderheaders is autosave and autoretrieve
Now when I just need an order header I can access the total via the property. If I need individual line totals I can get that via the line total field.
There is no need to use a CSummaryCriteria to calculate totals, there is no need to iterate through the lines and do a calculation and if you have to do reporting directly from the database, the order total is there at the header level.
- Richard.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
ok, is an idea. I'm thinking about it, but for curiosity and to know the two systems. How do you make it using CSummaryCriteria?
The help isn't very clearly.... ;-)
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I need help with this situation:
Table: OrderHeader
Table: OrderLines with fields: qty,price
In a listview i wanna see the list of table OrderHeader with a column total=sum(qty*price) for all lines of this order.
What is the best approach?
-Use a SQL to retrieve the value for each OrderHeader.
- Can i create a property Total in OrderLines, mark it as proxy and retrieve it with orderheaders?
- More....
-What do you think???
thanks
Well, the best option is really up to you. However I would probably do something like the following:
1. Add a total column to both the order header and the order lines. (I'm a fan or "practical" database schemas)
2. Change the order line object so that when qty or price is updated both the line total and header totals get updated. Don't foget to handle line deletion as well.
3. Ensure that the association between orderlines and orderheaders is autosave and autoretrieve
Now when I just need an order header I can access the total via the property. If I need individual line totals I can get that via the line total field.
There is no need to use a CSummaryCriteria to calculate totals, there is no need to iterate through the lines and do a calculation and if you have to do reporting directly from the database, the order total is there at the header level.
- Richard.
ok, is an idea. I'm thinking about it, but for curiosity and to know the two systems. How do you make it using CSummaryCriteria?
The help isn't very clearly.... ;-)