-1

I've a order bill whose data I've to enter in database (MS SQL) and then print the bill. This requirement is for C# windows form application. the data format of the bill is:

particulars  quantity  rate  amount

The user fills these contents in textboxes row by row. How to design a table to keep this record?

Suppose a user fills the form as:

receipt : 114
----------------------------------------------
particulars     quantity    rate    amount
particulars_1       2       5       10
particulars_2       1       10      10
particulars_3       4       7       28
particulars_4       10      10      100
----------------------------------------------
                    totol amount    148

Every bill has unique receipt number. The number of particulars in every bill is different. How to design database table to keep such kind of records?

Later on I've to retrieve all the data of the particular receipt number and present in a form. Please suggest. Thanks!

2 Answers 2

0

Unless I'm missing something fundamental, this is a very typical and basic databases 101 type scenario.

Assuming there would need to be additional information on a per receipt basis (date, time, etc) it's a simple one to many from a Receipt table containing the receipt id, etc. to a Particulars table containing the individual rows.

You also appear to have errors in your data example (10 x 10 != 10).

2
  • after the user fills the bill , then how to write insert statement for this. Since the number of rows is dynamic. Please suggest. Jul 21, 2015 at 3:17
  • I'm sorry, but it sounds to me like you simply want someone else to write the app for you. There are many architectural issues to be determined before I could even try to answer that even if I wanted to and, frankly, you sound as if you need to do a lot of learning before you can write this. I'm not going to write your app for you, the site is intended to answer specific questions, not be quick place to get others to do your work.
    – Mike
    Jul 21, 2015 at 4:10
0

Simply put, This should not be done,Use your table for storing item attributes. Do not keep the aggregate sum of rows in the table. Whenever you need to get any aggregates you can run a query to get it from the DB and show in your UI.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.