Make object NOT editable based on member value?

Make object NOT editable based on member value?

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


DotNetRules posted on Sunday, May 14, 2006

Hi, I would like to make a root object not editable based on a member value.  For example if an Invoice has been completed then I would like users to be able to view the invoice but not make any edits to it.

What would be the recommended practise to achieve this?

Regards

Paul

Mark replied on Sunday, May 14, 2006

I have something very similar (Purchase Order instead of Invoice) - and I went with 2 different objects.  The "working purchase order" allowed changes to line items (qty ordered, part #, etc) and didn't necessary have all the fields of a regular Purchase Order object (PO number, current status of the various line items (partially received, backordered, etc).

Although the data is stored in the same physical tables, breaking the logic into 2 different objects was definitely the way to go.  There's a formal process that actually "converts" a working purchase order into a regular purchase order (one that has been finalized, assigned a PO#, and transmitted to the vendor).

xal replied on Monday, May 15, 2006

Here's what I do in some of my property set:

If not IsNew Then
    Throw New ApplicationException("You can't edit this field once the data has been saved. bla bla bla")
End If

Copyright (c) Marimer LLC