How to set Bussinessobject read only or can not write according to backing field

How to set Bussinessobject read only or can not write according to backing field

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


simon posted on Wednesday, April 01, 2009

for example:

status of Purchase order  below:

1.Draft

2.Wait to approve

3.release

4.Complete

how to set  the object read only  in 2 or 3. 4.

If  readonlybase and bussinessobject can be tranfered to each other freely with a simple method or property will be perfect!

 

ajj3085 replied on Wednesday, April 01, 2009

You can override CanWriteProperty and have it base it's result on the state of the object.

sergeyb replied on Wednesday, April 01, 2009

Ideally, you do want to sets of objects.  A workaround would be to override CanWriteProperty, test the order status and return false when status indicates read-only state.

 

Sergey Barskiy

Principal Consultant

office: 678.405.0687 | mobile: 404.388.1899

cid:_2_0648EA840648E85C001BBCB886257279
Microsoft Worldwide Partner of the Year | Custom Development Solutions, Technical Innovation

 

From: simon [mailto:cslanet@lhotka.net]
Sent: Wednesday, April 01, 2009 8:08 AM
To: Sergey Barskiy
Subject: [CSLA .NET] How to set Bussinessobject read only or can not write according to backing field

 

for example:

status of Purchase order  below:

1.Draft

2.Wait to approve

3.release

4.Complete

how to set  the object read only  in 2 or 3. 4.

If  readonlybase and bussinessobject can be tranfered to each other freely with a simple method or property will be perfect!

 



Michael replied on Wednesday, April 01, 2009

Alternatively, you could check in the set of each property and return if necessary. That way you have full control over which properties are read only. For example, you may have an internal notes field which can be edited at any time, but the order items may not be editable from step 3 onwards. This would work best with a set of properties such as CanEditOrderItems etc which you can bind to the Enabled state of controls in your forms.

Copyright (c) Marimer LLC