Avoiding Duplication in Invoice No

Posted by Raj.Trivedi under ASP.NET on 9/17/2015 | Points: 10 | Views : 617 | Status : [Member] [MVP] | Replies : 1
Hello Team,

I am working on a small project where there are 2 table

Table 1 : TransactionMaster
Table 2 : TransactionDetail

I have a page where the user selects customer and product and then adds quantity, price and clicks on Add.
After clicking on Add the data is stored in data table which is dynamically created and then the data table is stored in session,
The data table which is stored in session is used as a data source to bind it to grid view.

The same the user will add multiple products. After adding all products the user will click on Save. On the save event the data table stored in session and other records stored in textbox will be saved to sql table.

My worry is that if multiple user are using the page the bill number shouldn't be duplicated and the bill number should be same in the master and detail table but duplication should not happen.

So should i insert the data first in master table or detail table and how to get the Invoice number to be same for both table for the master and detail transaction.

Thanks and regards

Regard's
Raj.Trivedi
"Sharing is Caring"
Please mark as answer if your Query is resolved



Responses

Posted by: Rajnilari2015 on: 9/20/2015 [Member] [Microsoft_MVP] [MVP] Platinum | Points: 25

Up
0
Down
My worry is that if multiple user are using the page the bill number shouldn't be duplicated and the bill number should be same in the master and detail table but duplication should not happen .

Solution : master and detail table should have a REFERENTIAL INTEGRITY Constraint implemented via Bill Number which must be a PK in Master. (or better Make the Bill Number as a composite Key [ UserID, BillNumber]). This will help you to avoid duplication.


So should i insert the data first in master table or detail table.

Answer : Master

...and how to get the Invoice number to be same for both table for the master and detail transaction

Solution By Query (Join on a common field)

Hope this helps. Let me know about your progress.

--
Thanks & Regards,
RNA Team

Raj.Trivedi, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response