views:

72

answers:

1

Hi... I'm creating a web form, where in there are around 12-15 Input Fields...

You can have a look at the screen here and here

The request is such that depending on the data the user selects in the Gridview and the DropDown list, the appropriate Textboxes and CheckBoxes needs to be displayed.

Some times the conditions are very direct, like when the DDL value is "ABC", get only paid amount from the user.

Sometime they are so complex like... IF DDL is "DEF" and Selected GPMS value is between 1000-2000, calculate the values of allowed, paid etc (using some formula) and the focus should be directed to Page No Field, leaving the other fields open incase user wants to edit... There are around 10-15 conditions like this.

As this was done through agile, conditions were being added as and when, and wherever it feels appropriate (DDL on change Event, GridView on selecting change event etc... etc..) After completion, now I see the code has become a big chuck, is growing unmanageably...

Now, I'm planning to clear this... From you experience, what you think is the best way to handle this. There is a possibility to add more conditions like this in future...

Please let me know, incase you need more information. I'm currently developing this app in C# .Net WindowsForms

Edit: Currently there are only three items (The Datagrid, the DDL, the OverrideAmt CheckBox) that change the way other fields behave...

Almost all of the conditions will fall between the two situations I mentioned... Mostly they belong to "Enabling/Disabling".. "Setting of Values"... and "Changing Focus" or any combination of these.

A: 

Minimal overhead


Write a single-procedure that contains all the evaluation logic.
i.e. evaluate all the individual states and show/hide the appropriate controls from within the procedure.

Now call this procedure whenever there is any change event
that requires you to re-evaluate whether to show/hide any controls.

Do NOT show/hide any controls from outside this procedure.

Any additional validation-checks in future can always be easily incorporated
by adding the additional checks inside this procedure.

To improve upon the performance of this procedure:
[1] Add a parameter (int/string) to the procedure.
[2] Pass a different value in this parameter when calling from different events of different objects.
[3] In the procedure, from on the value of the parameter, you can determine what object(& what event) has triggered this re-evaluation.

Thus You can evaluate only those conditions that could possibly depend on this particular change in this particular object. This way the re-evaluation overhead is reduced to the bare-minimum.

GoodLUCK!!
- CVS

CVS-2600Hertz
THANKS... Especially for looking at this question after such a long time... I almost thought this got buried under the new questions...Btw, What I do is more or less similar to this... I will keep this question open to get a feel of others' sugessions...
The King
All the best!! :)
CVS-2600Hertz