|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
How to maintain backup of objectI 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 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 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 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
Why use a module instead of class?
An absence of IntelliSense in this situation Writing a little app to modify a file Existsing of File 2d array question... Making trial version Question about Namespaces and the Object Browser. Installing VS.NET 2005 Beta 1 transparancy in vb.net Populating WinForms DataGrid |
|||||||||||||||||||||||