Prompt to save database changes on exit

BrownFingers

Member
Joined
Nov 21, 2008
Messages
15
Programming Experience
Beginner
Hi I'm new to winforms ( I've done some .NET web apps ) and I was wondering if someone could guide me.

I have created a baseform which I will inherit all my forms from. I'd like to add in code that will check for database changes and prompt accordingly when exiting the form.

Has anyone any ideas on how best to handle this, given that it is a baseform and will have no controls on it ?

Is there a way of dynamically looping through all data controls and checking if there are pending updates?

Or does anyone have any other suggestions?
 
How would the controls know if there are pending changes or not? It's the data sources that store the data and it's they taht will know if there's pending changes.

You should declare a MustOverride method in your base class that returns a Boolean value that indicates whether there are pending changes or not. You can then call that method in your base class and prompt the user to save in the FormsClosing event handler. You then implement that method however is appropriate in each derived class.

Note that if your base class contains a MustOverride member then the class itself must be declared MustInherit.
 

Latest posts

Back
Top