c# - How to deal with two successive inserts in the same form (Order-OrderItem) -
i'm simulating process of selling items customers. seller can click on button create new order. order form consists of few fields order , empty grid footer row add order items.
table order:
orderid creationdate createdby
orderitem
orderitemid orderitemquantity orderid
in case of new order, system should insert new row orders table , retrieve new id created system, items created user in new order form , insert orderitem table each reference orderid.
once seller clicks on button create new order, form pops-ups , should able add new items order right away. problem must save order first no items orderid should add items in grid.
this doesn't sound best way it, i thought of couple solutions:
1- once seller clicks button, insert order order table , id, , in same way insert items directly database once they're created. problem i'm not sure how distinguish if closed form without saving or saving know whether should delete records or not.
2- thought of creating datatable , insert items temporarily table , when seller clicks save, enter these items database. create code, don't mind if best possible solution.
does have suggestion ?
i went option 2 option 1 lead useless sql operations.
i created empty datatable , saved session. each time seller adds item, following:
1- retrieve datatable session
2- add new row data datatable
3- save datatable session
4- bind grid datatable stored in session
Comments
Post a Comment