Rattlesnake Posted April 9, 2005 Posted April 9, 2005 hi, I am creating a Purchase ORder(PO) system using ASP.net. So it is basically a Master -detail system,with the PO header and the items in the PO. I am using a Datagrid to enter the details part of the form. When a user creates a new PO , I dont want the PO to be added to the Database (Sql Server), till the user clicks on the ADD button (since the PO has to be given a specific PO Number, which is given only when the order is added.) My question is , where can I save the items that are added to the datagrid , till the user clicks on the ADD button. (What technique should I use here) Remember that , a user may later decide to modify an already added PO , so the technique shoudld work in that scenario also. Links to similar applications will be highly appreciated. Thanks Quote When you gotta go,you gotta go !!!!!!!
kahlua001 Posted April 10, 2005 Posted April 10, 2005 Store the PO and its items in a datatable you store in viewstate or session, then when the user wants to commit, you iterate thru it and insert into the db. Quote
Rattlesnake Posted April 22, 2005 Author Posted April 22, 2005 Hi, I have loaded the Detail part of the PO in a dataset and placed into a session varaiable. It works fine when a new PO is being added, since all the Detail items have to be ADDED to the Database. I face a problem when trying o modify already existing PO's. (i.e. already having some detail rows) I am unable to track the rows that are modified and those that are newly added to the PO. Is there a technique I can use for this? Thanks Quote When you gotta go,you gotta go !!!!!!!
kahlua001 Posted April 22, 2005 Posted April 22, 2005 In your datatable have a field like DetailID which is your unique key. When you update your db, if this field is null, then it is new and requires a INSERT, otherwise, it is a UPDATE Quote
HJB417 Posted April 22, 2005 Posted April 22, 2005 I hope your application has code for the situation where one po is being edited/accessed by multiple users and I'm not sure how you're implementing the creation of new pos for the user, but make sure you don't have a situation where multiple users create new pos but are being assigned the same po number, though the dataadapter's update method should throw an exception triggered by the datdabase server if the po number is an unique index. Quote
Rattlesnake Posted April 23, 2005 Author Posted April 23, 2005 Thanks kahlua001 and HJB417. I got the Update and Inserting of rows to work using your advice. Now my only problem is of deleting Detail Items. How can I delete Rows so that they donot appear in the Datagrid (which has d dataset as its datatsource), but are only deleted from the database only when the user clicks on Update. Is there a way of marking a row for deletion in a dataset so that they are not a part of the Dataset?? Thanks for your patience. I am new to ASP.net so it takes a while to understand the internal functioning of controls :) Thanks Quote When you gotta go,you gotta go !!!!!!!
kahlua001 Posted April 23, 2005 Posted April 23, 2005 To keep the data in your ds up to date, you should refill the ds and rebind to datagrid to ensure accurate data. Quote
HJB417 Posted April 23, 2005 Posted April 23, 2005 DataRow.Delete And when you invoke DataAdapter.Update, it will remove the records from the database server. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.