Click here to Skip to main content
15,302,185 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello everyone,
I am developing Sales Inventory Program using C#. I got problem to save the entire order of customer into transaction table in my database.

I click more product from product list and all of the product I click was displayed in other datagridview in which it describe for my whole order in that certain transaction.

My problem now is how can I save the entire order into transaction table in my database.

I used MySQL Database in this application. Can you help me?


1 solution

You don't. An order (not the order details) goes in a table using an OrderId as a primary key. Order details (line items of the order) go in another table using the OrderId as the foreign key.

Sorry I can't really help any further, but you haven't exactly given very much detail about the setup of your database, nor your requirements. I don't even know what you're talking about when you say "Sales Inventory". Those two terms don't really go together.
simplenick 18-Mar-11 1:12am
Actually my Project is Sales Inventory System. My problem is how can I save all ordered product of customer in transaction table in my database,since it is now temporarily stored my second datagridview. Each Table have a primary key like Prod_ID in Product table , Order_ID in Order table and Trans_ID in Transaction table.

Dave Kreskowiak 18-Mar-11 7:39am
I have no idea what your Transaction table is supposed to contain. "Sales Inventory" doesn't make any sense and your explanation is anything but.

Normally, you'd have a table with a name that's quite a bit more descriptive, like "Orders". The stuff you find at the top of an Order goes in there. The details (line items being ordered) go in another table, "OrderDetail" or something similar.

You don't "store" your order items in a DatagridView. You store them in a DataTable or some other collection, then bind your second DGV to that.

Once you have an order that is complete, you can write the order header information to the Orders table, then enumerate the order detail collection and write those items to the OrderDetail table.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900