Link to home
Start Free TrialLog in
Avatar of damianb123
damianb123Flag for United Kingdom of Great Britain and Northern Ireland

asked on

Need help and advice with adding datagridview contents to database

Hi,
   I am writing a .net EPOS and Stock Control system.  basically I have the menu and the main EPOS screen completed, when someone clicks a value from the various items i.e. Chicken and Chips, the details get added to a row in a Data Grid View, which the user can click the row in the view to have all the values output to seperate text boxes to make easier to read.  If there are 5 rows in the data grid view, what would be the best way of updating my locally installed MySQL database?

I would like it so that under a transaction of say the following:

1 x Large Chips 99p
1 x Chicken and Chips 3.99
1 x Chicken Burger 1.99

Then each individual row or item can be added both to the single transaction but also each row be added seperately as this is where the stock control would come in.

Can anyone give any advice on best way forward?

Cheers
Avatar of Nasir Razzaq
Nasir Razzaq
Flag of United Kingdom of Great Britain and Northern Ireland image

Not sure I understand your question but this is usually done using two tables.

Orders (OrderID, Date, CustomerName, ...)
OrderDetails(OrderDetailID, OrderID, ProductID, Quantity, Amount, ...)
Avatar of damianb123

ASKER

I understand the need for two tables. What I need help with is:

A) getting the value from each column in the datagridview into the database I.e item name added to a database field called the same!

B) breaking down each item I.e chips and chicken into two further values in a database of chicken, and another for chips for the stock inventory.....

Thanks
Is it an option to split the two items into separate lines?
Hmmm, not as the operator sees, so when they click a button on the form, a row appears in the datagridview. I need this row to be entered as a new entry in the transaction database, and another entry be made for the item name field of new row! But I also need to be able to strip the chicken element out of chicken and chips and add separate.... If that makes sense, the last part for stick control....
That's fine for chicken and chips but there would be other similar combos right? Like burger and chips.

What you can do is add a separate table (called bundles/meals etc) which would be used to combine products. Now in the orderdetails table, you would use mealid but you can use this mealid to get to individual product items.
Could you possibly show me code to first update the table from the datagridview? Then we can go from there? Cheers
ASKER CERTIFIED SOLUTION
Avatar of Nasir Razzaq
Nasir Razzaq
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial