Solved

Need help and advice with adding datagridview contents to database

Posted on 2011-02-13
7
145 Views
Last Modified: 2012-05-11
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
0
Comment
Question by:damianb123
  • 4
  • 3
7 Comments
 
LVL 83

Expert Comment

by:CodeCruiser
ID: 34883875
Not sure I understand your question but this is usually done using two tables.

Orders (OrderID, Date, CustomerName, ...)
OrderDetails(OrderDetailID, OrderID, ProductID, Quantity, Amount, ...)
0
 

Author Comment

by:damianb123
ID: 34883986
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
0
 
LVL 83

Expert Comment

by:CodeCruiser
ID: 34884016
Is it an option to split the two items into separate lines?
0
Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

 

Author Comment

by:damianb123
ID: 34884121
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....
0
 
LVL 83

Expert Comment

by:CodeCruiser
ID: 34884164
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.
0
 

Author Comment

by:damianb123
ID: 34884210
Could you possibly show me code to first update the table from the datagridview? Then we can go from there? Cheers
0
 
LVL 83

Accepted Solution

by:
CodeCruiser earned 500 total points
ID: 34884338
Are you using a datatable as a datasource to the grid?
0

Featured Post

Zoho SalesIQ

Hassle-free live chat software re-imagined for business growth. 2 users, always free.

Join & Write a Comment

Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
This video discusses moving either the default database or any database to a new volume.
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now