tags:

views:

170

answers:

8

We have a Dot net Win forms Application which has few Forms with more than 40 fields to fill.

When the User fills say 25 fields and then realizes that he needs to get some more data before he can save the information or He enter all the data but their is some Business validation error on which needs contact someone else before correcting.

In such scenarios, he would like to save the incomplete or Incorrect data to some temporary data storage and retrieve it later when he has the data to complete the save operation.

Please let me know what would be the best way to implement this?

He are few options we considered:

1) create XML blob and save on his local machine (But, user may need it from some other machine)

2) Create duplicate tables to store invalid data (But, I feel Invalid data should never be part of my database)

+1  A: 

You could put all invalid data as plain text/xml field in one database table. Presumably you never need to sort/search on the incomplete data. This might combine the benefits of both your ideas.

jjrv
+1  A: 

How do you store the data when the user sends it back for validation? Do you store it in the session? Could you just save that part of the session to your database and restore it when he/she wants to finish entry?

One other thought is to split the forms up into sub sections which get saved before proceeding. A 40-field form seems kind of excessive and may also lead to a difficult-to-use application.

J D OConal
+4  A: 

You could persist the partial form to XML and save the XML into a database table which also has the user id and the form identifier. When the user next brings up the form on the original machine or a different machine, the system would detect the partial data and prompt the user to reload/ignore/delete it. You would only need a single table for all forms & users. Separate tables for each database object would be unnecessary.

Mike Thompson
I have an application that does this. We can even store multiple drafts (we call it templates) and it can even support multiple types of screens.
jop
A: 

J D makes an excellent point. This user interface sounds like a job for a Wizard. That way they are 3 pages in by the time they realize they need more data, and you know that data is valid since you've been validating page by page.

Kevin Conner
A few problems with it as well: what if the user has non-contiguous data on hand, and wants to enter that first? what if the 40 items are closely-related and it doesn't make sense to separate them? How would the database model have to be changed to accommodate partial-valid data?
Swati
A: 

I would say go with the second option but tie the incomplete data to the session that way you gain 2 things:

1) the incomplete data will expire when the session expires 2) there will be a clear connection which data is owned by which session(user)

I don't think there's anything wrong with storing it in the database as long as you make sure it's periodically cleaned(in this case on session expiration). Good luck

Edit: If you want it to be available across session tie it to the user and expire it when it's complete.

Svet
A: 

1) the incomplete data will expire when the session expires

User wants the Incomplete data be available for his login across sessions.

Kishork
Should probably try the approach described by Mike Thompson then.
Swati
A: 

I think it belongs in a separate table. From a business point of view it is an IncompleteWidget. When saved and validated it is stored in the Widget table.

The mapping may seem like a bit of a pain, but I think in this situation it makes sense.

aaronjensen
A: 

Possibly controversial, but: store the incomplete object in the same database table you would store the completed object.

The incomplete and complete objects are of exactly the same class of entity and are merely at different stages in their lives. You can use a status field to indicate whether the object has been validated yet. This solves the problem without introducing a whole new mechanism to debug and maintain.

Matt Howells