Validation (newbie)

Validation (newbie)

Old forum URL: forums.lhotka.net/forums/t/1664.aspx


griff posted on Thursday, November 02, 2006

Hi

Version 1.53

I do this in the create part of my BO

Protected Overrides Sub DataPortal_Create(ByVal Criteria As Object)

'Create new object with defaults stored in the Database

BrokenRules.Assert("Mandatory Field", "Last Name must be filled.", "Last Name", (Len(mLastName) = 0))

BrokenRules.Assert("Mandatory Field", "First Name must be filled.", "First Name", (Len(mFirstName) = 0))

End Sub

On my win form in the Save button I do this:

If mMainDetails.IsSavable Then

mMainDetails.ApplyEdit()

mMainDetails = DirectCast(mMainDetails.Save, cMainDetails)

BindFields()

Cursor.Current = Cursors.Default

Else

Dim br As CSLA.BrokenRules.Rule

For Each br In mMainDetails.BrokenRulesCollection

MessageBox.Show(br.Description & vbCrLf & br.Rule, br.Property & ": Cannot Save because..")

Next

End If

1)  Is this a correct implementation?

2) The problem is only one of the rules is picked up, ie it does not loop through all the broken rules collection so if say the user completes the first name after intial error message displayed (as first and last name have not been filled) then presses save button then the record is saved and the second (last name rule is ommitted).

Any takers - I am very new to CSLA so as much help as possible is appreciated.

Does anyone have a small sample/real project that they have put together that encompasses CSLA (I know rocky has one but I'm looking for a 'live' scenario) for me (and other newbie's) to learn from. (version 1.53 and 2.1??)

Many thanks in advance for the groups help.

Richard

 

 

 

 

 

guyroch replied on Thursday, November 02, 2006

Take a look at the links provided, theey are excellent resources to get acquinted with Csla

CSLA 1.x

http://www.primos.com.au/primos/Portals/0/Tech%20articles/CSLA%20WIIFM/What%20could%20CSLA%20do%20for%20me.html

CSLA 2.x

http://www.primos.com.au/primos/Articles/CSLAversion2whatsinitforme/tabid/67/Default.aspx

http://www.onelittlevictory.com/

Hope this helps.

Copyright (c) Marimer LLC