When coding a .NET transactional form, we end up putting the same piece of code in those forms over and over - the form state code.
Every form is different, but generally we use three form states = CLEAN, POPULATED, and DIRTY. We'll use an 'Item' form for discussions sake
- Clean is for when the form is newly opened. Generally every field on the form is disabled except the main lookup field and maybe a lookup button.
- Populated is when the user has selected an item, but has not edited anything. Generally the item number field would be disabled, but the lookup button would not be, and all the form fields would be enabled
- Dirty is when the form has been edited an it needs to be saved. Both the item number field and the item lookup button are disabled, all remaining fields are enabled.
We also have code to clear every field on the form.
Last, we have code to add event handlers to each field, so that when the field is edited the form will become DIRTY.