Home All Groups Group Topic Archive Search About

How to maintain backup of object

Author
15 Apr 2005 5:24 PM
ECathell
I have a database object. lets call it boxes. I have a winform that allows the fields of the box object to be edited. When the box is first instantiated I would like to make a copy of the box object, we can call it original_box. Now before the user moves off this particular box and instantiates a new box from a selection list I want to compare the original box to this possibly dirty version(if it a property has been changed it sets a bit called isDirty.) this will allow me to validate whether the user changed the value back to its original state. therefore not prompting for a save.

I have the text boxes databound to my object properties. If that will change your answer...

--
--Eric Cathell, MCSA

Author
15 Apr 2005 5:34 PM
ECathell
I guess I should have been a bit clearer. I know HOW to do it. I would like to know the best practices version.

do I create a copy in the winform? so that when box is instantiated, original_box is instantiated? OR do i make two classes using a base object? so I have Class Box and Class Original_Box that both inherit from BoxBase. Then when Box is instantiated, it clones itself to box_original?


--
--Eric Cathell, MCSA
  "ECathell" <ecathell@nospam.mountaire.com> wrote in message news:u4D0t$dQFHA.2132@TK2MSFTNGP14.phx.gbl...
  I have a database object. lets call it boxes. I have a winform that allows the fields of the box object to be edited. When the box is first instantiated I would like to make a copy of the box object, we can call it original_box. Now before the user moves off this particular box and instantiates a new box from a selection list I want to compare the original box to this possibly dirty version(if it a property has been changed it sets a bit called isDirty.) this will allow me to validate whether the user changed the value back to its original state. therefore not prompting for a save.

  I have the text boxes databound to my object properties. If that will change your answer...

  --
  --Eric Cathell, MCSA
Author
16 Apr 2005 12:51 AM
Dennis
I would include a method in my box class that accepts a new box and compares
it to the current instance of the box.

Show quoteHide quote
"ECathell" wrote:

> I guess I should have been a bit clearer. I know HOW to do it. I would like to know the best practices version.
>
> do I create a copy in the winform? so that when box is instantiated, original_box is instantiated? OR do i make two classes using a base object? so I have Class Box and Class Original_Box that both inherit from BoxBase. Then when Box is instantiated, it clones itself to box_original?
>
>
> --
> --Eric Cathell, MCSA
>   "ECathell" <ecathell@nospam.mountaire.com> wrote in message news:u4D0t$dQFHA.2132@TK2MSFTNGP14.phx.gbl...
>   I have a database object. lets call it boxes. I have a winform that allows the fields of the box object to be edited. When the box is first instantiated I would like to make a copy of the box object, we can call it original_box. Now before the user moves off this particular box and instantiates a new box from a selection list I want to compare the original box to this possibly dirty version(if it a property has been changed it sets a bit called isDirty.) this will allow me to validate whether the user changed the value back to its original state. therefore not prompting for a save.
>
>   I have the text boxes databound to my object properties. If that will change your answer...
>
>   --
>   --Eric Cathell, MCSA
Author
16 Apr 2005 8:58 AM
Cor Ligthert
ECathell,

As addition on the answer from Dennis

When you use the approach from system.data with its datarow, than it is in my opinion a build in feature. dr.rejectchanges sets the datarow (complete) in its original state as it was with the last acceptchanges.

I hope this gives as well an idea.

Cor