Custom Field Properties binding best practices???


Author
Message
Edhy Rijo
E
StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)
Group: StrataFrame Users
Posts: 2.4K, Visits: 23K
Hi Ben, Trent and all.
I am working on a form that will be use to capture the parameter values to generate a query for reports.  In this case we are talking about multiple parameters, at least 20 or more.  These parameters will be capture in all type of controls, like Textboxes, comboboxes, checkboxes, etc.

My questions is what would be the best way to bind those parameter controls so it will be easier to maintain and also to access their values and enforce testing rules?

Since SF binding requires a business object, I was thinking on creating a  SQL view with all the fields I would use as a parameters and then create a business object and maintain it with the BOM as normally done, but then to be able to capture any parameters value in the form, I would need to add a record to that BO and then make sure it is discarded bo.Clear() or something like that, to avoid trying to commit anything back to the database.

Is there any better approach to this?

Main goal is to make this form easier to maintain when adding more parameters as needed, and avoid having to create a whole bunch of custom field properties and manually link or bind them to the controls value.

As always, any input, suggestion is greatly appreciated.

Edhy Rijo

Larry Caylor
Larry Caylor
StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)
Group: Awaiting Activation
Posts: 592, Visits: 3.7K

Hi Edhy,

I'm using a similar approach to capture parameters for a complex search form. Only instead of a view I created a dummy table in the DDT that I map to. This allows me to bind to the fields on the form and use business rules to validate the search criteria. In the object's BeforeSave event I clear the object and cancel the save to prevent it from being saved. Works great and is easy to maintain.

-Larry


Edhy Rijo
E
StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)
Group: StrataFrame Users
Posts: 2.4K, Visits: 23K
Hi Larry,
Thanks for the information. 
I like the idea of a dummy table in the DDT specially for maintenance.

Edhy Rijo

Ivan George Borges
Ivan George Borges
Strategic Support Team Member (3.5K reputation)Strategic Support Team Member (3.5K reputation)Strategic Support Team Member (3.5K reputation)Strategic Support Team Member (3.5K reputation)Strategic Support Team Member (3.5K reputation)Strategic Support Team Member (3.5K reputation)Strategic Support Team Member (3.5K reputation)Strategic Support Team Member (3.5K reputation)Strategic Support Team Member (3.5K reputation)
Group: StrataFrame MVPs
Posts: 1.9K, Visits: 21K
Hi guys.

I also have lots of reports where I need to check for broken rules from the entered values to generate them. I have a base form for all the reports which will call a CheckForBrokenRules before it is generated and I will put all code necessary to check them into this Overridable method. I don't use any tabeless BO or anything, I just check directly to the controls values I need and then use a System.Windows.Forms.ErrorProvider to SetError to it for each broken rule I find.

Just a sample:

    Public Overrides Sub CheckForBrokenRules()
        '-- make sure Conta Bancária has been informed
        If Me.ContasBancariasLookupControl1.PrimaryKey = 0 Then
            '-- add broken rule
            _loReqFldWarning.SetError(Me.ContasBancariasLookupControl1.Controls.Item("txtCode"), RetrieveTextValue("PFNRepTText - ParamCtaBanc"))
 
            '-- set flag to show broken rules
            _RulesAreOK = False
        End If
        '-- make sure Número Cheque has been informed
        If CType(Me.txtNumCheque.Value, Decimal) = 0 Then
            '-- add broken rule
            _loReqFldWarning.SetError(Me.ContasBancariasLookupControl1.Controls.Item("txtCode"), RetrieveTextValue("PFNRepTText - ParamNumCheque"))
 
            '-- set flag to show broken rules
            _RulesAreOK = False
        End If
    End Sub



Edhy Rijo
E
StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)
Group: StrataFrame Users
Posts: 2.4K, Visits: 23K
Hi Ivan,
Thanks for the explanation and sample code.  After analyzing the situation with my colleague, we came to the conclusion on using your kind of logic, primarily because we want to be able to add new reports and have the lowest impact while delivering the report to production, using a BO with a dummy table or view would require us to update the database and have users logged out to accomplish that.

We are re-created this project from the original Visual FoxPro application and there are a gazillion filter conditions and more could be added with the new revision of the application in SF.  There are already around 70 users between 12 offices with a VPN connection working on the VFP application so we need to find the right balance to be able to release new reports or conditions with the lowest downtime possible.

Thanks again.

Edhy Rijo

Ivan George Borges
Ivan George Borges
Strategic Support Team Member (3.5K reputation)Strategic Support Team Member (3.5K reputation)Strategic Support Team Member (3.5K reputation)Strategic Support Team Member (3.5K reputation)Strategic Support Team Member (3.5K reputation)Strategic Support Team Member (3.5K reputation)Strategic Support Team Member (3.5K reputation)Strategic Support Team Member (3.5K reputation)Strategic Support Team Member (3.5K reputation)
Group: StrataFrame MVPs
Posts: 1.9K, Visits: 21K
Hi Edhy.

Glad it helped somehow.

As a bit of further information, I also save the entered values from the controls for the specific user logged in, so next time he/she come back, I automatically fill all arguments for the report from last time it was used. For this, yes, I do have a table where they will be all saved, given a Report Primary Key (all reports have also a table with information about each one of them), a CreatedBy (the user), an Argument Name and a Value.

Just some food for thought. :-)

Abraços.

Ivan
Edited 8 Years Ago by Ivan George Borges
GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search