Hi guys, quite an explanation here, hope someone has the patience to read it through
I'm building an application in Flex 4 that handles an ordering
system. I have a small mySql database and I've written a few services in
php to handle the database.
Basically the logic goes like this:
I have tables for customers, products, productGroups, orders, and orderContent
I have no problem with the CRUD management of the products, orders
and customers, it is the order submission that the customer will fill in
that is giving me headaches:
What I want is to display the products in dataGrids, ordered by
group, which will be populated with Flex datamanagement via the
php-services, and that per se is no problem. But I also want an extra
column in the datagrid that the user can fill in with the amount he
wishes to order of that product. This column would in theory then bind
to the db table "orderContent" via the php services.
The problem is that you would need to create a new order in the
database first that the data could bind to (orderContent is linked to an
order in the db).
I do not want to create a new order every time a user enters the page
to look at the products, rather I would like to create the order when a
button is pressed and then take everything from the datagrids on the
page and submit it into the database.
My idea has been to create a separate one-column datagrid, line it up
next to the datagrid that contains the products and in that datagrid
the user would be able to enter the amount of that product he'd like to
order.
I've created a valueObject that contains the data I would need for an order:
Code:
package valueObjects
{
public class OrderAmount
{
public var productId:int;
public var productAmount:int;
public
var productPrice:Number;
public function orderAmount()
{
}
}
}
My idea was to use a service to get all products from a certain
group, populate an ArrayCollection with the data, then transfer each
object in that ArrayCollection to an instance of the Value Object above,
add the value object to another ArrayCollection that would the be used
as a dataProvider for the one-column datagrid (I would only display
amount which would be set to zero at first, but use the other data upon
transfering it to the db)
I've tried to use the results from the automatically generated
serviceResults that retrieve the products for the datagrid and put in a
resultHandler that transfers the valueobjects, however this does not
seem to work.
Basically my question is this: Am I approaching this thing completely
wrong, is there a better solution?
Would I need to create a completely new service request to get the product id:s, and price to populate the one-column datagrid.
I'll post some code if that would help.
Thank you if you read this far.